diff --git a/inc/Services/EventActionService.hpp b/inc/Services/EventActionService.hpp index 5f19cbb88f336a1a1952da097c2b276b37e4fee4..c551afedc61d227d661732b99d422422560c5061 100644 --- a/inc/Services/EventActionService.hpp +++ b/inc/Services/EventActionService.hpp @@ -15,7 +15,8 @@ * initialization or rather the lack of it. Pay attention especially in parts of the code that I * use strings <3 . * - * @todo: Do something with the applicationID. + + * @todo: check if executeAction should accept applicationID too * @todo: check if eventActionFunctionStatus should be private or not * @todo: check if eventAction array of definitions should be private or not * @todo: check size of eventActionDefinitionArray diff --git a/src/MessageParser.cpp b/src/MessageParser.cpp index 84f31620fdbd8275fcd15e52cb0bbb8c26e2a83b..9bf0b1d81d0b93f3be114a708644ccb27139e82a 100644 --- a/src/MessageParser.cpp +++ b/src/MessageParser.cpp @@ -78,8 +78,8 @@ void MessageParser::parseTC(uint8_t *data, uint16_t length, Message &message) { Message MessageParser::parseRequestTC(String<64> data) { Message message; - uint8_t *dataInt = (unsigned char *) data.data(); + uint8_t* dataInt = reinterpret_cast<uint8_t *>(data.data()); message.packetType = Message::TC; - parseTC(dataInt, 256, message); // Should length here be 256? + parseTC(dataInt, 256, message); // maybe instead of 256 shoule there be a variable? return message; } diff --git a/src/Services/EventActionService.cpp b/src/Services/EventActionService.cpp index 3f819c74e601540815458defebbafb9fd0c1bac5..c29401784fbb8ada3a5719788c98c634b2e247e0 100644 --- a/src/Services/EventActionService.cpp +++ b/src/Services/EventActionService.cpp @@ -170,6 +170,7 @@ void EventActionService::disableEventActionFunction(Message message) { } // Should I use the name execute here instead of executeAction? +// Should I use applicationID too? void EventActionService::executeAction(uint16_t eventID) { // Custom function if (eventActionFunctionStatus == enabledFunction) { @@ -177,15 +178,11 @@ void EventActionService::executeAction(uint16_t eventID) { while (i < 256) { if (eventActionDefinitionArray[i].empty == 0) { if (eventActionDefinitionArray[i].eventDefinitionID == eventID) { - break; - } + MessageParser messageParser; + Message message = messageParser.parseRequestTC(eventActionDefinitionArray[i].request); + messageParser.execute(message); } } i++; } - if (i != 256) { // If i == 256 that means that no matching eventId was found - MessageParser messageParser; - Message message = messageParser.parseRequestTC(eventActionDefinitionArray[i].request); - messageParser.execute(message); - } } } diff --git a/test/Services/EventActionService.cpp b/test/Services/EventActionService.cpp index a57f2f59ca92adad6d9323327468018d315a2e71..1fac8d654db51b4ae6f55f5b24d5abc8c0a9d8c4 100644 --- a/test/Services/EventActionService.cpp +++ b/test/Services/EventActionService.cpp @@ -170,9 +170,19 @@ TEST_CASE("Event-action status report TM[19,7]", "[service][st09]") { } TEST_CASE("Enable event-action function TC[19,8]", "[service][st09]") { - + EventActionService eventActionService; + Message message(19, 8, Message::TC, 0); + eventActionService.enableEventActionFunction(message); + CHECK(eventActionService.eventActionFunctionStatus == EventActionService::enabledFunction); } TEST_CASE("Disable event-action function TC[19,1]", "[service][st09]") { - + EventActionService eventActionService; + Message message(19, 9, Message::TC, 0); + eventActionService.disableEventActionFunction(message); + CHECK(eventActionService.eventActionFunctionStatus == EventActionService::disabledFunction); } + +TEST_CASE("Execute a TC request", "[service][st09]"){ + +} \ No newline at end of file