Set the protocol version in PixelMessage automagically

This commit is contained in:
Starbeamrainbowlabs 2017-03-02 19:05:06 +00:00
parent ad1bcba459
commit a2173bc0e3
3 changed files with 18 additions and 20 deletions

View file

@ -141,4 +141,3 @@ bool PixelBot::Tick()
return true; return true;
} }

View file

@ -1,10 +1,11 @@
#include "PixelMessage.h" #include "PixelMessage.h"
#include "PixelBot.h"
#include <Arduino.h> #include <Arduino.h>
PixelMessage::PixelMessage() PixelMessage::PixelMessage()
{ {
ProtocolVersion = PixelBot::PROTOCOL_VERSION;
} }
PixelMessage::PixelMessage(byte* rawMessage) : PixelMessage() PixelMessage::PixelMessage(byte* rawMessage) : PixelMessage()
{ {

View file

@ -1,28 +1,26 @@
#pragma once
#include <Arduino.h> #include <Arduino.h>
struct PixelMessage struct PixelMessage
{ {
public: public:
PixelMessage(); PixelMessage();
PixelMessage(byte* rawMessage); PixelMessage(byte* rawMessage);
~PixelMessage(); ~PixelMessage();
/// <summary> /// <summary>
/// The length of the message header, in bytes. /// The length of the message header, in bytes.
/// The message header contains things like the protocol version, the payload length, and the message type. /// The message header contains things like the protocol version, the payload length, and the message type.
/// </summary> /// </summary>
static const unsigned int MESSAGE_HEADER_LENGTH = 12; static const unsigned int MESSAGE_HEADER_LENGTH = 12;
// The protocol version associated with this message. // The protocol version associated with this message.
unsigned short ProtocolVersion = 1; unsigned short ProtocolVersion = 1;
unsigned short MessageType = 1; unsigned short MessageType = 1;
unsigned int MessageId = 0; unsigned int MessageId = 0;
unsigned int MessageLength = 0; unsigned int MessageLength = 0;
//const byte* Payload; //const byte* Payload;
private: private: