diff --git a/App.cpp b/App.cpp index 971be29..7e1fabc 100644 --- a/App.cpp +++ b/App.cpp @@ -1,11 +1,11 @@ -#include "AccelerometerSampleService.h" +#include "MovesenseExerciseService.h" #include "movesense.h" MOVESENSE_APPLICATION_STACKSIZE(1024) MOVESENSE_PROVIDERS_BEGIN(1) -MOVESENSE_PROVIDER_DEF(AccelerometerSampleService) +MOVESENSE_PROVIDER_DEF(MovesenseExerciseService) MOVESENSE_PROVIDERS_END(1) @@ -34,7 +34,7 @@ DEBUGSERVICE_BUFFER_SIZE(6, 120); // 6 lines, 120 characters total DEBUG_EEPROM_MEMORY_AREA(false, 0, 0) LOGBOOK_MEMORY_AREA(0, 384 * 1024); -APPINFO_NAME("Sample Accelerometer"); +APPINFO_NAME("Movesense Exercise"); APPINFO_VERSION("1.1.0"); APPINFO_COMPANY("Movesense"); diff --git a/AccelerometerSampleService.cpp b/MovesenseExerciseService.cpp similarity index 74% rename from AccelerometerSampleService.cpp rename to MovesenseExerciseService.cpp index f4c0fc4..c3f9a2a 100644 --- a/AccelerometerSampleService.cpp +++ b/MovesenseExerciseService.cpp @@ -1,4 +1,4 @@ -#include "AccelerometerSampleService.h" +#include "MovesenseExerciseService.h" #include "app-resources/resources.h" #include "common/core/debug.h" #include "meas_acc/resources.h" @@ -7,16 +7,16 @@ #include #include -const char* const AccelerometerSampleService::LAUNCHABLE_NAME = "SampleA"; +const char* const MovesenseExerciseService::LAUNCHABLE_NAME = "SampleA"; #define SAMPLE_RATE 13 static const whiteboard::ExecutionContextId sExecutionContextId = - WB_RES::LOCAL::SAMPLE_ACCELEROMETER_DATA::EXECUTION_CONTEXT; + WB_RES::LOCAL::EXERCISE_SUMVECTOR_DENES::EXECUTION_CONTEXT; static const whiteboard::LocalResourceId sProviderResources[] = { - WB_RES::LOCAL::SAMPLE_ACCELEROMETER_DATA::LID, + WB_RES::LOCAL::EXERCISE_SUMVECTOR_DENES::LID, }; -AccelerometerSampleService::AccelerometerSampleService() +MovesenseExerciseService::MovesenseExerciseService() : ResourceClient(WBDEBUG_NAME(__FUNCTION__), sExecutionContextId), ResourceProvider(WBDEBUG_NAME(__FUNCTION__), sExecutionContextId), LaunchableModule(LAUNCHABLE_NAME, sExecutionContextId), @@ -24,11 +24,11 @@ AccelerometerSampleService::AccelerometerSampleService() { } -AccelerometerSampleService::~AccelerometerSampleService() +MovesenseExerciseService::~MovesenseExerciseService() { } -bool AccelerometerSampleService::initModule() +bool MovesenseExerciseService::initModule() { if (registerProviderResources(sProviderResources) != whiteboard::HTTP_CODE_OK) { @@ -39,34 +39,34 @@ bool AccelerometerSampleService::initModule() return true; } -void AccelerometerSampleService::deinitModule() +void MovesenseExerciseService::deinitModule() { unregisterProviderResources(sProviderResources); mModuleState = WB_RES::ModuleStateValues::UNINITIALIZED; } /** @see whiteboard::ILaunchableModule::startModule */ -bool AccelerometerSampleService::startModule() +bool MovesenseExerciseService::startModule() { mModuleState = WB_RES::ModuleStateValues::STARTED; return true; } -void AccelerometerSampleService::onUnsubscribeResult(whiteboard::RequestId requestId, +void MovesenseExerciseService::onUnsubscribeResult(whiteboard::RequestId requestId, whiteboard::ResourceId resourceId, whiteboard::Result resultCode, const whiteboard::Value& rResultData) { - DEBUGLOG("AccelerometerSampleService::onUnsubscribeResult() called."); + DEBUGLOG("MovesenseExerciseService::onUnsubscribeResult() called."); } -void AccelerometerSampleService::onSubscribeResult(whiteboard::RequestId requestId, +void MovesenseExerciseService::onSubscribeResult(whiteboard::RequestId requestId, whiteboard::ResourceId resourceId, whiteboard::Result resultCode, const whiteboard::Value& rResultData) { - DEBUGLOG("AccelerometerSampleService::onSubscribeResult() called. resourceId: %u, result: %d", resourceId.localResourceId, (uint32_t)resultCode); + DEBUGLOG("MovesenseExerciseService::onSubscribeResult() called. resourceId: %u, result: %d", resourceId.localResourceId, (uint32_t)resultCode); whiteboard::Request relatedIncomingRequest; bool relatedRequestFound = mOngoingRequests.get(requestId, relatedIncomingRequest); @@ -77,14 +77,14 @@ void AccelerometerSampleService::onSubscribeResult(whiteboard::RequestId request } } -whiteboard::Result AccelerometerSampleService::startRunning(whiteboard::RequestId& remoteRequestId) +whiteboard::Result MovesenseExerciseService::startRunning(whiteboard::RequestId& remoteRequestId) { if (isRunning) { return whiteboard::HTTP_CODE_OK; } - DEBUGLOG("AccelerometerSampleService::startRunning()"); + DEBUGLOG("MovesenseExerciseService::startRunning()"); // Reset max acceleration members mMaxAccelerationSq = FLT_MIN; @@ -108,20 +108,20 @@ whiteboard::Result AccelerometerSampleService::startRunning(whiteboard::RequestI return whiteboard::HTTP_CODE_OK; } -whiteboard::Result AccelerometerSampleService::stopRunning() +whiteboard::Result MovesenseExerciseService::stopRunning() { if (!isRunning) { return whiteboard::HTTP_CODE_OK; } - if (isResourceSubscribed(WB_RES::LOCAL::SAMPLE_ACCELEROMETER_DATA::ID) == wb::HTTP_CODE_OK) + if (isResourceSubscribed(WB_RES::LOCAL::EXERCISE_SUMVECTOR_DENES::ID) == wb::HTTP_CODE_OK) { - DEBUGLOG("AccelerometerSampleService::stopRunning() skipping. Subscribers still exist."); + DEBUGLOG("MovesenseExerciseService::stopRunning() skipping. Subscribers still exist."); return whiteboard::HTTP_CODE_OK; } - DEBUGLOG("AccelerometerSampleService::stopRunning()"); + DEBUGLOG("MovesenseExerciseService::stopRunning()"); // Unsubscribe the LinearAcceleration resource, when unsubscribe is done, we get callback wb::Result result = asyncUnsubscribe(mMeasAccResourceId, NULL); @@ -136,7 +136,7 @@ whiteboard::Result AccelerometerSampleService::stopRunning() } // This callback is called when the resource we have subscribed notifies us -void AccelerometerSampleService::onNotify(whiteboard::ResourceId resourceId, const whiteboard::Value& value, +void MovesenseExerciseService::onNotify(whiteboard::ResourceId resourceId, const whiteboard::Value& value, const whiteboard::ParameterList& parameters) { DEBUGLOG("onNotify() called."); @@ -185,7 +185,7 @@ void AccelerometerSampleService::onNotify(whiteboard::ResourceId resourceId, con mMaxAccelerationSq = FLT_MIN; // and update our WB resource. This causes notification to be fired to our subscribers - updateResource(WB_RES::LOCAL::SAMPLE_ACCELEROMETER_DATA(), + updateResource(WB_RES::LOCAL::EXERCISE_SUMVECTOR_DENES(), ResponseOptions::Empty, sampleDataValue); } } @@ -193,12 +193,12 @@ void AccelerometerSampleService::onNotify(whiteboard::ResourceId resourceId, con } } -void AccelerometerSampleService::onSubscribe(const whiteboard::Request& request, +void MovesenseExerciseService::onSubscribe(const whiteboard::Request& request, const whiteboard::ParameterList& parameters) { switch (request.getResourceConstId()) { - case WB_RES::LOCAL::SAMPLE_ACCELEROMETER_DATA::ID: + case WB_RES::LOCAL::EXERCISE_SUMVECTOR_DENES::ID: { // Someone subscribed to our service. Start collecting data and notifying when our service changes state (every 10 seconds) whiteboard::RequestId remoteRequestId; @@ -223,12 +223,12 @@ void AccelerometerSampleService::onSubscribe(const whiteboard::Request& request, } } -void AccelerometerSampleService::onUnsubscribe(const whiteboard::Request& request, +void MovesenseExerciseService::onUnsubscribe(const whiteboard::Request& request, const whiteboard::ParameterList& parameters) { switch (request.getResourceConstId()) { - case WB_RES::LOCAL::SAMPLE_ACCELEROMETER_DATA::ID: + case WB_RES::LOCAL::EXERCISE_SUMVECTOR_DENES::ID: stopRunning(); returnResult(request, wb::HTTP_CODE_OK); break; @@ -239,14 +239,14 @@ void AccelerometerSampleService::onUnsubscribe(const whiteboard::Request& reques } } -void AccelerometerSampleService::onRemoteWhiteboardDisconnected(whiteboard::WhiteboardId whiteboardId) +void MovesenseExerciseService::onRemoteWhiteboardDisconnected(whiteboard::WhiteboardId whiteboardId) { - DEBUGLOG("AccelerometerSampleService::onRemoteWhiteboardDisconnected()"); + DEBUGLOG("MovesenseExerciseService::onRemoteWhiteboardDisconnected()"); stopRunning(); } -void AccelerometerSampleService::onClientUnavailable(whiteboard::ClientId clientId) +void MovesenseExerciseService::onClientUnavailable(whiteboard::ClientId clientId) { - DEBUGLOG("AccelerometerSampleService::onClientUnavailable()"); + DEBUGLOG("MovesenseExerciseService::onClientUnavailable()"); stopRunning(); -} \ No newline at end of file +} diff --git a/AccelerometerSampleService.h b/MovesenseExerciseService.h similarity index 93% rename from AccelerometerSampleService.h rename to MovesenseExerciseService.h index f8f264e..5fb75ed 100644 --- a/AccelerometerSampleService.h +++ b/MovesenseExerciseService.h @@ -7,16 +7,16 @@ #include "wb-resources/resources.h" -class AccelerometerSampleService FINAL : private whiteboard::ResourceClient, - private whiteboard::ResourceProvider, - public whiteboard::LaunchableModule +class MovesenseExerciseService FINAL : private whiteboard::ResourceClient, + private whiteboard::ResourceProvider, + public whiteboard::LaunchableModule { public: /** Name of this class. Used in StartupProvider list. */ static const char* const LAUNCHABLE_NAME; - AccelerometerSampleService(); - ~AccelerometerSampleService(); + MovesenseExerciseService(); + ~MovesenseExerciseService(); private: /** @see whiteboard::ILaunchableModule::initModule */ diff --git a/app_root.yaml b/app_root.yaml index da3cfcc..e826647 100644 --- a/app_root.yaml +++ b/app_root.yaml @@ -21,6 +21,6 @@ executionContexts: apis: - AccelerometerSample.*: + MovesenseExercise.*: apiId: 100 defaultExecutionContext: meas diff --git a/wbresources/AccelerometerSample.yaml b/wbresources/MovesenseExercise.yaml similarity index 91% rename from wbresources/AccelerometerSample.yaml rename to wbresources/MovesenseExercise.yaml index f4177bf..48d8d6b 100644 --- a/wbresources/AccelerometerSample.yaml +++ b/wbresources/MovesenseExercise.yaml @@ -5,9 +5,9 @@ swagger: '2.0' # Document metadata info: version: "0.0.0" - title: Movesense Accelerometer sample app API + title: Movesense Exercise app API description: | - This file defines API for Movesense Accelerometer Sample service + This file defines API for Movesense Exercise service See http://movesense.com for more information. termsOfService: http://suunto.com/wbapi/terms/ @@ -17,7 +17,7 @@ info: # Paths paths: - /Sample/Accelerometer/Data/Subscription: + /Exercise/Sumvector/Denes/Subscription: post: description: | Subscribe to periodic Data values.