Browse Source

Set the protocol version in PixelMessage automagically

master
Starbeamrainbowlabs 4 years ago
parent
commit
a2173bc0e3
3 changed files with 18 additions and 20 deletions
  1. +0
    -1
      PixelHub-Client/src/PixelBot.cpp
  2. +2
    -1
      PixelHub-Client/src/PixelMessage.cpp
  3. +16
    -18
      PixelHub-Client/src/PixelMessage.h

+ 0
- 1
PixelHub-Client/src/PixelBot.cpp View File

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

+ 2
- 1
PixelHub-Client/src/PixelMessage.cpp View File

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


+ 16
- 18
PixelHub-Client/src/PixelMessage.h View File

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