diff --git a/inc/Services/TestService.hpp b/inc/Services/TestService.hpp index 82156b23e558583afad4183acd92bdfba9f354b8..af37e9ff9ae5a409482d9cd0a0ed311b0f95fb88 100644 --- a/inc/Services/TestService.hpp +++ b/inc/Services/TestService.hpp @@ -10,8 +10,6 @@ */ class TestService : public Service { public: - - inline static const uint8_t ServiceType = 17; enum MessageType : uint8_t { @@ -30,19 +28,28 @@ public: */ void areYouAlive(Message& request); + /** + * TM[17,2] are-you-alive connection test report to show that the MCU is alive and well + */ + void areYouAliveReport(); + /** * TC[17,3] perform an on-board connection test * - * @todo Only respond if we have the correct APID */ void onBoardConnection(Message& request); + /** + * TM[17,4] on-board connection test report to show that the MCU is connected to the on-board + * @param applicationProcessId + */ + void onBoardConnectionReport(uint16_t applicationProcessId); + /** * It is responsible to call the suitable function that execute the proper subservice. The * way that the subservices are selected is for the time being based on the messageType(class * member of class Message) of the param message * - * @todo Error handling for the switch() in the implementation of this execute function */ void execute(Message& message); }; diff --git a/src/Services/TestService.cpp b/src/Services/TestService.cpp index 93c1ebeed096ba0197428622e4417985925a0a66..d85d020696acd840788e02e9f331a97cf65519ac 100644 --- a/src/Services/TestService.cpp +++ b/src/Services/TestService.cpp @@ -5,19 +5,23 @@ void TestService::areYouAlive(Message& request) { request.assertTC(TestService::ServiceType, TestService::MessageType::AreYouAliveTest); - // TM[17,2] are-you-alive connection test report - Message report = createTM(TestService::MessageType::AreYouAliveTestReport); + areYouAliveReport(); +} +void TestService::areYouAliveReport() { + Message report = createTM(TestService::MessageType::AreYouAliveTestReport); storeMessage(report); } void TestService::onBoardConnection(Message& request) { request.assertTC(TestService::ServiceType, TestService::MessageType::OnBoardConnectionTest); - // TM[17,4] on-board connection test report - Message report = createTM(TestService::MessageType::OnBoardConnectionTestReport); + uint16_t applicationProcessId = request.readUint16(); + onBoardConnectionReport(applicationProcessId); +} - report.appendUint16(request.readUint16()); - // just print it on the screen +void TestService::onBoardConnectionReport(uint16_t applicationProcessId) { + Message report = createTM(TestService::MessageType::OnBoardConnectionTestReport); + report.appendUint16(applicationProcessId); storeMessage(report); } diff --git a/test/Services/TestService.cpp b/test/Services/TestService.cpp index 3424f95a81efec51d6db6358fd1c4ad6ca49dba4..3a772b2872aa60090f89bc5478d46eae6afb9f4f 100644 --- a/test/Services/TestService.cpp +++ b/test/Services/TestService.cpp @@ -5,7 +5,7 @@ TestService& testService = Services.testService; -TEST_CASE("TM[17,1]", "[service][st17]") { +TEST_CASE("TC[17,1]", "[service][st17]") { Message receivedPacket = Message(TestService::ServiceType, TestService::MessageType::AreYouAliveTest, Message::TC, 1); MessageParser::execute(receivedPacket); REQUIRE(ServiceTests::hasOneMessage()); @@ -16,7 +16,16 @@ TEST_CASE("TM[17,1]", "[service][st17]") { REQUIRE(response.dataSize == 0); } -TEST_CASE("TM[17,3]", "[service][st17]") { +TEST_CASE("TM[17,2]", "[service][st17]") { + testService.areYouAliveReport(); + + Message response = ServiceTests::get(0); + CHECK(response.serviceType == TestService::ServiceType); + CHECK(response.messageType == TestService::MessageType::AreYouAliveTestReport); + REQUIRE(response.dataSize == 0); +} + +TEST_CASE("TC[17,3]", "[service][st17]") { Message receivedPacket = Message(TestService::ServiceType, TestService::MessageType::OnBoardConnectionTest, Message::TC, 1); receivedPacket.appendEnum16(40); MessageParser::execute(receivedPacket); @@ -28,3 +37,13 @@ TEST_CASE("TM[17,3]", "[service][st17]") { REQUIRE(response.dataSize == 2); CHECK(response.readEnum16() == 40); } + +TEST_CASE("TM[17,4]", "[service][st17]") { + testService.onBoardConnectionReport(40); + + Message response = ServiceTests::get(0); + CHECK(response.serviceType == TestService::ServiceType); + CHECK(response.messageType == TestService::MessageType::OnBoardConnectionTestReport); + REQUIRE(response.dataSize == 2); + CHECK(response.readEnum16() == 40); +}