From acae02369e966f87a2360cc089198174782c81c0 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 15 May 2024 14:08:38 +1000 Subject: [PATCH] Tweaked the wait_for_at function to handle the initial 0x00 character on the modem serial line to avoid a modem reboot caused by the previous change to this function. --- firmware/wombat/src/Utils.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/firmware/wombat/src/Utils.cpp b/firmware/wombat/src/Utils.cpp index f029998..73ed7cf 100644 --- a/firmware/wombat/src/Utils.cpp +++ b/firmware/wombat/src/Utils.cpp @@ -292,10 +292,18 @@ bool wait_for_at(void) { int i = 0; while (LTE_Serial.available() && i < (MAX_G_BUFFER-1)) { int ch = LTE_Serial.read(); + // After power up there is often a 0x00 on the serial line from the modem. + if (ch < 1) { + continue; + } + + // Between 1 and 9 inclusive means noise. if (ch < 10) { // Should only be reading CR, LF, and A-Z. - return false; + ESP_LOGI(TAG, "wait_for_at: %02x", ch); + continue; } + g_buffer[i++] = (char)(ch & 0xFF); g_buffer[i] = 0; }