42 lines
1.2 KiB
C++

#pragma once
#include "IMessage.h"
#include "Thing.h"
namespace RoboidControl {
/// @brief A message containing binary data for custom communication
class BinaryMsg : public IMessage {
public:
/// @brief The message ID
static const unsigned char id = 0xB1;
/// @brief The length of the message in bytes, excluding the binary data
/// For the total size of the message this.bytes.Length should be added to this value.
static const unsigned length = 4;
/// @brief The network ID of the thing
unsigned char networkId;
/// @brief The ID of the thing
unsigned char thingId;
/// @brief The thing for which the binary data is communicated
Thing* thing;
unsigned char dataLength;
/// @brief The binary data which is communicated
char* data = nullptr;
/// @brief Create a BinaryMsg
/// @param networkId The network ID of the thing
/// @param thing The thing for which binary data is sent
BinaryMsg(unsigned char networkId, Thing* thing);
/// @copydoc RoboidControl::IMessage::IMessage(char*)
BinaryMsg(char* buffer);
/// @brief Destructor for the message
virtual ~BinaryMsg();
/// @copydoc RoboidControl::IMessage::Serialize
virtual unsigned char Serialize(char* buffer) override;
};
} // namespace RoboidControl