diff --git a/mission/devices/GPSHandler.cpp b/mission/devices/GPSHandler.cpp index e53ce347..2264a833 100644 --- a/mission/devices/GPSHandler.cpp +++ b/mission/devices/GPSHandler.cpp @@ -8,11 +8,24 @@ GPSHandler::GPSHandler(object_id_t objectId, object_id_t deviceCommunication, GPSHandler::~GPSHandler() {} void GPSHandler::doStartUp() { + if(internalState == InternalStates::NONE) { + commandExecuted = false; + internalState = InternalStates::WAIT_FIRST_MESSAGE; + } + if(internalState == InternalStates::WAIT_FIRST_MESSAGE) { + if(commandExecuted) { + internalState = InternalStates::IDLE; + setMode(MODE_ON); + commandExecuted = false; + } + } } void GPSHandler::doShutDown() { - + internalState = InternalStates::NONE; + commandExecuted = false; + setMode(MODE_OFF); } ReturnValue_t GPSHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { diff --git a/mission/devices/GPSHandler.h b/mission/devices/GPSHandler.h index 06362dd6..7ee400e2 100644 --- a/mission/devices/GPSHandler.h +++ b/mission/devices/GPSHandler.h @@ -16,6 +16,13 @@ public: virtual ~GPSHandler(); protected: + enum class InternalStates { + NONE, + WAIT_FIRST_MESSAGE, + IDLE + }; + InternalStates internalState = InternalStates::NONE; + bool commandExecuted = false; /* DeviceHandlerBase overrides */ ReturnValue_t buildTransitionDeviceCommand(