From 5ee6d1f84a7863805dc45d58ee5b984705bc308e Mon Sep 17 00:00:00 2001 From: gabryelreyes Date: Mon, 20 Nov 2023 13:59:07 +0100 Subject: [PATCH] Sent data using a void pointer. Structs defined in SerialMuxChannels can be sent without recasting --- examples/cpp/main.cpp | 3 +-- src/SerialMuxProtServer.hpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/cpp/main.cpp b/examples/cpp/main.cpp index 5d39c31..b38b521 100644 --- a/examples/cpp/main.cpp +++ b/examples/cpp/main.cpp @@ -135,8 +135,7 @@ void gCounterChannelCallback(const uint8_t* payload, const uint8_t payloadSize, { Timestamp timestampData; timestampData.timestamp = millis(); - gSmpServer.sendData(gSerialMuxProtChannelIdTimestamp, reinterpret_cast(×tampData), - sizeof(timestampData)); + gSmpServer.sendData(gSerialMuxProtChannelIdTimestamp, ×tampData, sizeof(timestampData)); } } } \ No newline at end of file diff --git a/src/SerialMuxProtServer.hpp b/src/SerialMuxProtServer.hpp index 567d8ae..4281e15 100644 --- a/src/SerialMuxProtServer.hpp +++ b/src/SerialMuxProtServer.hpp @@ -123,7 +123,7 @@ class SerialMuxProtServer * @param[in] payloadSize Amount of bytes to send. * @returns If payload succesfully sent, returns true. Otherwise, false. */ - bool sendData(uint8_t channelNumber, const uint8_t* payload, uint8_t payloadSize) const + bool sendData(uint8_t channelNumber, const void* payload, uint8_t payloadSize) const { bool isSent = false; @@ -577,7 +577,7 @@ class SerialMuxProtServer * @param[in] payloadSize Amount of bytes to send. * @returns If payload succesfully sent, returns true. Otherwise, false. */ - bool send(uint8_t channelNumber, const uint8_t* payload, uint8_t payloadSize) const + bool send(uint8_t channelNumber, const void* payload, uint8_t payloadSize) const { bool frameSent = false; uint8_t channelDLC = getTxChannelDLC(channelNumber);