[client] Start working on hooking the message receiving code up to the PixelMessage class, but there are problems :-(

This commit is contained in:
Starbeamrainbowlabs 2017-05-18 19:58:13 +01:00
parent e0bc536891
commit 461396d231
3 changed files with 12 additions and 4 deletions

View File

@ -135,9 +135,17 @@ bool PixelBot::Tick()
delay(10); // sleep for 10ms delay(10); // sleep for 10ms
return true; return true;
} }
String nextLine = tcpClient.readStringUntil('\n'); String nextLine = tcpClient.readStringUntil('\n');
Serial.print(" > "); Serial.println(nextLine); char* messageBuffer = new char[nextLine.length()];
nextLine.toCharArray(messageBuffer, nextLine.length());
int MessageType = *(static_cast<unsigned short*>(static_cast<void*>(messageBuffer + 2)));
Serial.print("Got message: Length: "); Serial.print(nextLine.length());
Serial.print(", Message Type: "); Serial.println(MessageType);
Serial.print(" > "); Serial.println(messageBuffer);
return true; return true;
} }

View File

@ -16,7 +16,7 @@ public:
static const int RIGHT = 4; static const int RIGHT = 4;
void MoveDistance(int direction, int ticks); void MoveDistance(int direction, int ticks);
void MoveTick(int direction); void MoveTick(int direction);
unsigned long GetTicksTravelled(); unsigned long GetTicksTravelled();

View File

@ -26,7 +26,7 @@ public:
static const unsigned int TYPE_COMMANDFAILED = 14; static const unsigned int TYPE_COMMANDFAILED = 14;
static const unsigned int TYPE_INFOREQUEST = 20; static const unsigned int TYPE_INFOREQUEST = 20;
static const unsigned int TYPE_INFORESPONSE = 21; static const unsigned int TYPE_INFORESPONSE = 21;
// 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;