need to rework how commands are received and the main system state
This commit is contained in:
+20
-5
@@ -77,7 +77,7 @@ void setup() {
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
// Initialize the debug serial object
|
// Initialize the debug serial object
|
||||||
Logger::Initialize(UART1_RX, UART1_TX);
|
Logger::Initialize(UART1_RX, UART1_TX, 115200);
|
||||||
|
|
||||||
LOG_INFO(F("=== ESP32 SimRacing DashDisplay ===\r\n"));
|
LOG_INFO(F("=== ESP32 SimRacing DashDisplay ===\r\n"));
|
||||||
LOG_INFO(F("* Initiating display\r\n"));
|
LOG_INFO(F("* Initiating display\r\n"));
|
||||||
@@ -90,13 +90,16 @@ void setup() {
|
|||||||
mainWindow->drawBox();
|
mainWindow->drawBox();
|
||||||
|
|
||||||
delay(500);
|
delay(500);
|
||||||
LOG_INFO(F("* Ready for loop"));
|
LOG_INFO(F("* Ready for loop\r\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// I have to organize this better, but for now it will do
|
||||||
const uint16_t PayloadMax = 2056;
|
const uint16_t PayloadMax = 2056;
|
||||||
uint8_t payload[PayloadMax] = {0};
|
uint8_t payload[PayloadMax] = {0};
|
||||||
char lineBuffer[64]; // Enough for "XX XX XX XX XX XX XX XX "
|
char lineBuffer[64]; // Enough for "XX XX XX XX XX XX XX XX "
|
||||||
//
|
//
|
||||||
|
bool connected = false;
|
||||||
|
|
||||||
void print_memory_stats() {
|
void print_memory_stats() {
|
||||||
multi_heap_info_t info;
|
multi_heap_info_t info;
|
||||||
|
|
||||||
@@ -135,12 +138,23 @@ void loop(void) {
|
|||||||
|
|
||||||
// print_memory_stats();
|
// print_memory_stats();
|
||||||
|
|
||||||
switch(cmd) {
|
// If its not connected the only command we can receive is the CmdRequestID
|
||||||
case CmdRequestID:
|
if (!connected) {
|
||||||
|
if (cmd != CmdRequestID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle the ID request, it should connect us. TODO: Improve this
|
||||||
IdentificationPacket papers;
|
IdentificationPacket papers;
|
||||||
initIdentificationPacket(&papers, ESLABS_DEVICE_NAME, ESLABS_DEVICE_ID);
|
initIdentificationPacket(&papers, ESLABS_DEVICE_NAME, ESLABS_DEVICE_ID);
|
||||||
WalkieTalkie::SendData(&papers);
|
WalkieTalkie::SendData(&papers);
|
||||||
break;
|
|
||||||
|
LOG_INFO(F("Connection request came in"));
|
||||||
|
|
||||||
|
connected = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
switch(cmd) {
|
||||||
case CmdCreateWindow: {
|
case CmdCreateWindow: {
|
||||||
int8_t newWindowID = Window::Create(payload, &mainScreen);
|
int8_t newWindowID = Window::Create(payload, &mainScreen);
|
||||||
if (newWindowID < 0) {
|
if (newWindowID < 0) {
|
||||||
@@ -235,3 +249,4 @@ void loop(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user