Browse Source

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

master
Starbeamrainbowlabs 3 years ago
parent
commit
461396d231
3 changed files with 12 additions and 4 deletions
  1. +10
    -2
      PixelHub-Client/src/PixelBot.cpp
  2. +1
    -1
      PixelHub-Client/src/PixelBotController.h
  3. +1
    -1
      PixelHub-Client/src/PixelMessage.h

+ 10
- 2
PixelHub-Client/src/PixelBot.cpp View File

@ -135,9 +135,17 @@ bool PixelBot::Tick()
delay(10); // sleep for 10ms
return true;
}
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;
}

+ 1
- 1
PixelHub-Client/src/PixelBotController.h View File

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


+ 1
- 1
PixelHub-Client/src/PixelMessage.h View File

@ -26,7 +26,7 @@ public:
static const unsigned int TYPE_COMMANDFAILED = 14;
static const unsigned int TYPE_INFOREQUEST = 20;
static const unsigned int TYPE_INFORESPONSE = 21;
// The protocol version associated with this message.
unsigned short ProtocolVersion = 1;
unsigned short MessageType = 1;