Browse Source

[client] Bugfix: Fix compiler errors in the client code, and start writing message decoding logic.

master
Starbeamrainbowlabs 4 years ago
parent
commit
078d9eb75a
  1. 28
      PixelHub-Client/PixelBot.cpp
  2. 2
      PixelHub-Client/PixelBot.h
  3. 12
      PixelHub-Client/PixelBotController.cpp
  4. 1
      PixelHub-Client/PixelMessaage.cpp
  5. 17
      PixelHub-Client/PixelMessage.h

28
PixelHub-Client/PixelBot.cpp

@ -121,24 +121,24 @@ bool PixelBot::Connect()
void PixelBot::Listen()
{
while(true) {
Serial.println("[PixelBot/Server] Entering main loop.");
// Make sure that there's something to read
if(tcpClient.available() == 0) {
delay(10); // sleep for 10ms
continue;
}
String nextLine = tcpClient.readStringUntil('\n');
Serial.print(" > "); Serial.println(nextLine);
if(!Tick())
break;
}
}
bool PixelBot::processCommand(String command)
bool PixelBot::Tick()
{
Serial.println("[PixelBot/Server] Entering main loop.");
return false;
// Make sure that there's something to read
if(tcpClient.available() == 0) {
delay(10); // sleep for 10ms
return true;
}
String nextLine = tcpClient.readStringUntil('\n');
Serial.print(" > "); Serial.println(nextLine);
return true;
}

2
PixelHub-Client/PixelBot.h

@ -85,6 +85,6 @@ private:
// The TCP client to use as the PixelHub server transport connection.
WiFiClient tcpClient = WiFiClient();
bool processCommand(String command);
};

12
PixelHub-Client/PixelBotController.cpp

@ -32,17 +32,17 @@ void PixelBotController::MoveTick(int direction)
switch(direction) {
case STOP:
return;
case FORWARD:
setOutputDir(i,7-i);
case FORWARDS:
sendTickPart(i,7-i);
break;
case BACK:
setOutputDir(7-i,i);
case BACKWARDS:
sendTickPart(7-i,i);
break;
case LEFT:
setOutputDir(7-i,7-i);
sendTickPart(7-i,7-i);
break;
case RIGHT:
setOutputDir(i,i);
sendTickPart(i,i);
break;
}
delayMicroseconds(motorSpeed);

1
PixelHub-Client/PixelMessaage.cpp

@ -0,0 +1 @@

17
PixelHub-Client/PixelMessage.h

@ -0,0 +1,17 @@
#pragma once
struct PixelMessage
{
public:
PixelMessage();
~PixelMessage();
const ushort ProtocolVersion;
const ushort MessageType;
const uint MessageId;
const uint MessageLength;
private:
}