diff --git a/ControlCore/Messages.cpp b/ControlCore/Messages.cpp new file mode 100644 index 0000000..261c01c --- /dev/null +++ b/ControlCore/Messages.cpp @@ -0,0 +1,39 @@ +#include "Messages.h" + +#pragma region IMessage + +unsigned char *IMessage::Serialize() { return nullptr; } + +bool IMessage::SendMsg(IMessage msg, unsigned char bufferSize) { + return SendMsg(msg.Serialize(), bufferSize); +} + +bool IMessage::SendMsg(unsigned char *buffer, unsigned char bufferSize) { + // SendBuffer(buffer, bufferSize); + return false; +} + +#pragma endregion + +#pragma region Investigate + +InvestigateMsg::InvestigateMsg(unsigned char thingId) { + this->networkId = 0; + this->thingId = thingId; +} + +unsigned char *InvestigateMsg::Serialize() { + unsigned char *buffer = IMessage::buffer; + buffer[0] = InvestigateMsg::id; + buffer[1] = this->networkId; + buffer[2] = this->thingId; + return buffer; +} + +bool InvestigateMsg::Send(unsigned char thingId) { + InvestigateMsg msg = InvestigateMsg(thingId); + return SendMsg(msg, InvestigateMsg::length); +} + +// Investiaget +#pragma endregion \ No newline at end of file diff --git a/ControlCore/Messages.h b/ControlCore/Messages.h new file mode 100644 index 0000000..ad298d9 --- /dev/null +++ b/ControlCore/Messages.h @@ -0,0 +1,28 @@ +namespace Passer::Control { + +class IMessage { +public: + static unsigned char buffer[256]; + + virtual unsigned char *Serialize(); + + static bool SendMsg(IMessage msg, unsigned char bufferSize); + static bool SendMsg(unsigned char *buffer, unsigned char bufferSize); +}; + +class InvestigateMsg : public IMessage { +public: + static const unsigned char id = 0x81; + static const unsigned char length = 3; + unsigned char networkId; + unsigned char thingId; + + InvestigateMsg(unsigned char thingId); + + virtual unsigned char *Serialize() override; + + static bool Send(unsigned char thingId); +}; + +} // namespace Passer::Control +using namespace Passer::Control; \ No newline at end of file