| 13 | char text[512]; // command size |
| 14 | }; |
| 15 | bool parseSerialCommand(const String &command, bool waitForResponse) { |
| 16 | if (!cmdQueue || !rspQueue) { |
| 17 | Serial.println("Command or response queue not initialized"); |
| 18 | return false; |
| 19 | } |
| 20 | CmdPacket packet; |
| 21 | memset(&packet, 0, sizeof(packet)); |
| 22 | strncpy(packet.text, command.c_str(), sizeof(packet.text) - 1); |
| 23 | |
| 24 | // Enqueue the command packet for processing |
| 25 | if (xQueueSend(cmdQueue, &packet, 0) != pdTRUE) { |
| 26 | Serial.println("Failed to send command to queue"); |
| 27 | return false; |
| 28 | } |
| 29 | if (!waitForResponse) { return true; } |
| 30 | // Wait for the response |
| 31 | bool result; |
| 32 | if (xQueueReceive(rspQueue, &result, pdMS_TO_TICKS(20))) { return result; } |
| 33 | Serial.println("Failed to receive command response"); |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | void handleSerialCommands(SerialCli &serialCli) { |
| 38 | CmdPacket packet; |
no test coverage detected