need to rework how commands are received and the main system state

This commit is contained in:
2026-09-21 17:46:04 +01:00
parent 3437ea473e
commit cceafe027c
+20 -5
View File
@@ -77,7 +77,7 @@ void setup() {
Serial.begin(115200);
// 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("* Initiating display\r\n"));
@@ -90,13 +90,16 @@ void setup() {
mainWindow->drawBox();
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;
uint8_t payload[PayloadMax] = {0};
char lineBuffer[64]; // Enough for "XX XX XX XX XX XX XX XX "
//
bool connected = false;
void print_memory_stats() {
multi_heap_info_t info;
@@ -135,12 +138,23 @@ void loop(void) {
// print_memory_stats();
switch(cmd) {
case CmdRequestID:
// If its not connected the only command we can receive is the CmdRequestID
if (!connected) {
if (cmd != CmdRequestID) {
return;
}
// Handle the ID request, it should connect us. TODO: Improve this
IdentificationPacket papers;
initIdentificationPacket(&papers, ESLABS_DEVICE_NAME, ESLABS_DEVICE_ID);
WalkieTalkie::SendData(&papers);
break;
LOG_INFO(F("Connection request came in"));
connected = true;
} else {
switch(cmd) {
case CmdCreateWindow: {
int8_t newWindowID = Window::Create(payload, &mainScreen);
if (newWindowID < 0) {
@@ -234,4 +248,5 @@ void loop(void) {
break;
}
}
}
}