[client] Bugfix: Fix compiler errors in the client code, and start writing message decoding logic.
This commit is contained in:
parent
caf1a11677
commit
078d9eb75a
5 changed files with 39 additions and 21 deletions
|
@ -121,24 +121,24 @@ bool PixelBot::Connect()
|
||||||
void PixelBot::Listen()
|
void PixelBot::Listen()
|
||||||
{
|
{
|
||||||
while(true) {
|
while(true) {
|
||||||
|
if(!Tick())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PixelBot::Tick()
|
||||||
|
{
|
||||||
Serial.println("[PixelBot/Server] Entering main loop.");
|
Serial.println("[PixelBot/Server] Entering main loop.");
|
||||||
|
|
||||||
// Make sure that there's something to read
|
// Make sure that there's something to read
|
||||||
if(tcpClient.available() == 0) {
|
if(tcpClient.available() == 0) {
|
||||||
delay(10); // sleep for 10ms
|
delay(10); // sleep for 10ms
|
||||||
continue;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String nextLine = tcpClient.readStringUntil('\n');
|
String nextLine = tcpClient.readStringUntil('\n');
|
||||||
Serial.print(" > "); Serial.println(nextLine);
|
Serial.print(" > "); Serial.println(nextLine);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PixelBot::processCommand(String command)
|
|
||||||
{
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,6 @@ private:
|
||||||
// The TCP client to use as the PixelHub server transport connection.
|
// The TCP client to use as the PixelHub server transport connection.
|
||||||
WiFiClient tcpClient = WiFiClient();
|
WiFiClient tcpClient = WiFiClient();
|
||||||
|
|
||||||
bool processCommand(String command);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,17 +32,17 @@ void PixelBotController::MoveTick(int direction)
|
||||||
switch(direction) {
|
switch(direction) {
|
||||||
case STOP:
|
case STOP:
|
||||||
return;
|
return;
|
||||||
case FORWARD:
|
case FORWARDS:
|
||||||
setOutputDir(i,7-i);
|
sendTickPart(i,7-i);
|
||||||
break;
|
break;
|
||||||
case BACK:
|
case BACKWARDS:
|
||||||
setOutputDir(7-i,i);
|
sendTickPart(7-i,i);
|
||||||
break;
|
break;
|
||||||
case LEFT:
|
case LEFT:
|
||||||
setOutputDir(7-i,7-i);
|
sendTickPart(7-i,7-i);
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
setOutputDir(i,i);
|
sendTickPart(i,i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
delayMicroseconds(motorSpeed);
|
delayMicroseconds(motorSpeed);
|
||||||
|
|
1
PixelHub-Client/PixelMessaage.cpp
Normal file
1
PixelHub-Client/PixelMessaage.cpp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
17
PixelHub-Client/PixelMessage.h
Normal file
17
PixelHub-Client/PixelMessage.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct PixelMessage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PixelMessage();
|
||||||
|
~PixelMessage();
|
||||||
|
|
||||||
|
const ushort ProtocolVersion;
|
||||||
|
const ushort MessageType;
|
||||||
|
const uint MessageId;
|
||||||
|
const uint MessageLength;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Reference in a new issue