diff --git a/Bootload/COM.bat b/Bootload/COM.bat index b815e4d..ddad37e 100644 --- a/Bootload/COM.bat +++ b/Bootload/COM.bat @@ -1,5 +1,5 @@ REM Firmware -esptool.exe --chip esp32 --port COM5 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 boot_app0.bin 0x1000 bootloader_qio_80m.bin 0x10000 ..\releases\AfterburnerV3.1.9.bin 0x8000 Afterburner.partitions.bin +esptool.exe --chip esp32 --port COM5 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 boot_app0.bin 0x1000 bootloader_qio_80m.bin 0x10000 AfterburnerV3.1.9.bin 0x8000 Afterburner.partitions.bin REM SPIFFS esptool.exe --chip esp32 --port COM5 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_size detect 0x3d0000 spiffs.bin diff --git a/platformio.ini b/platformio.ini index 3f725c6..b244765 100644 --- a/platformio.ini +++ b/platformio.ini @@ -25,7 +25,7 @@ upload_protocol = esptool extra_scripts = post:add_CRC.py ; replace shitty Arduino millis with a linear time version build_flags = - -Wl,--wrap,millis + -Wl,--wrap,millis debug_tool = esp-prog ;upload_protocol = esp-prog -debug_init_break = +debug_init_break = \ No newline at end of file diff --git a/src/Afterburner.cpp b/src/Afterburner.cpp index d12d0c1..a28f995 100644 --- a/src/Afterburner.cpp +++ b/src/Afterburner.cpp @@ -126,8 +126,8 @@ const int FirmwareRevision = 31; const int FirmwareSubRevision = 9; -const int FirmwareMinorRevision = 0; -const char* FirmwareDate = "14 Jan 2020"; +const int FirmwareMinorRevision = 1; +const char* FirmwareDate = "15 Jan 2020"; #ifdef ESP32 @@ -1370,15 +1370,15 @@ void checkDebugCommands() static String pw1; static String pw2; - // check for test commands received from PC Over USB - if(DebugPort.available()) { + // check for test commands received over Debug serial port or telnet + char rxVal; + if(DebugPort.getch(rxVal)) { + #ifdef PROTOCOL_INVESTIGATION - static int mode = 0; + static int mode = 0;6 static int val = 0; #endif - char rxVal = DebugPort.read(); - if(bTestBTModule) { bTestBTModule = Bluetooth.test(rxVal); return; @@ -2030,3 +2030,5 @@ CTempSense& getTempSensor() { return TempSensor; } + + diff --git a/src/Utility/ABTelnetSpy.cpp b/src/Utility/ABTelnetSpy.cpp index 9ab2a9c..fe3c5fd 100644 --- a/src/Utility/ABTelnetSpy.cpp +++ b/src/Utility/ABTelnetSpy.cpp @@ -24,6 +24,8 @@ ABTelnetSpy::ABTelnetSpy() : TelnetSpy() { _enabled = true; + _CRtimeout = 0; + _pending = 0; } size_t @@ -40,4 +42,47 @@ ABTelnetSpy::enable(bool state) _enabled = state; } +// typical problem we have with terminal software that may or may not send CR/LF +// when a user hits ENTER. +// This method will inject a LF if none was received within a period of time +bool +ABTelnetSpy::getch(char& rxVal) +{ + if(_CRtimeout) { + // have received a CR, now in wait interval for a LF + long diff = millis() - _CRtimeout; + if(available()) { + // a character is sitting in the debug input + // grab it and check if it is a LF, if so do not retain and return a faked LF + // otherwise retain for next pass, and return a faked LF now + _pending = read(); // read pending character + if(_pending == '\n') { // if it's a LF, a normal CR/LF occured + _pending = 0; // cancel retention + } + diff = 1; // force timeout to happen now + } + if(diff > 0) { + // timed out waiting for a LF, inject one now + _CRtimeout = 0; // reset timeout + rxVal = '\n'; // force a LF response + return true; // rxVal is valid + } + return false; // no character ready + } + + // dispose of any character that may have been received during CR/LF timeout + if(_pending) { + rxVal = _pending; + _pending = 0; + return true; + } + if(available()) { + rxVal = read(); // read incoming character + if(rxVal == '\r') { // if it's a CR, start the timeout + _CRtimeout = (millis() + _LFPERIOD) | 1; // ensure always non zero + } + return true; // rxVal is valid + } + return false; // no character ready +} diff --git a/src/Utility/ABTelnetSpy.h b/src/Utility/ABTelnetSpy.h index 1eb5320..1abb562 100644 --- a/src/Utility/ABTelnetSpy.h +++ b/src/Utility/ABTelnetSpy.h @@ -30,9 +30,19 @@ public: ABTelnetSpy(); size_t write(uint8_t) override; void enable(bool); + /// getch(): + // typical problem we have with terminal software that may or may not send CR/LF + // when a user hits ENTER. + // This getch method will inject a LF if none was received within a period of time + bool getch(char& rxVal); protected: bool _enabled; + unsigned long _CRtimeout; + char _pending; + const int _LFPERIOD = 100; }; + + #endif // __ABTELNETSPY_H__ diff --git a/src/Utility/MQTTsetup.cpp b/src/Utility/MQTTsetup.cpp index 9972c0c..e9c6d2f 100644 --- a/src/Utility/MQTTsetup.cpp +++ b/src/Utility/MQTTsetup.cpp @@ -96,8 +96,8 @@ CMQTTsetup::HandleMQTTsetup(char rxVal) switch(_mode) { case 1: DebugPort.printf("Enter MQTT broker's IP address (%s)", _MQTTsetup.host); break; case 2: DebugPort.printf("Enter MQTT broker's port (%d)", _MQTTsetup.port); break; - case 3: DebugPort.printf("Enter MQTT broker's username (%s)", _MQTTsetup.username); break; - case 4: DebugPort.printf("Enter MQTT broker's password (%s)", _MQTTsetup.password); break; + case 3: DebugPort.printf("Enter MQTT broker's username (currently '%s', CTRL-X to erase)", _MQTTsetup.username); break; + case 4: DebugPort.printf("Enter MQTT broker's password (currently '%s', CTRL-X to erase)", _MQTTsetup.password); break; case 5: DebugPort.printf("Enter root topic name (%s)", _MQTTsetup.topicPrefix); break; case 6: DebugPort.printf("Enter QoS level (%d)", _MQTTsetup.qos); break; case 7: DebugPort.printf("Enable MQTT? (Y)es / (N)o (%s)", _MQTTsetup.enabled ? "YES" : "NO"); break; @@ -181,14 +181,18 @@ CMQTTsetup::getMQTTstring(char rxVal, int maxidx, char* pTargetString) { if(rxVal < ' ') { if(_idx == 0) strcpy(_buffer, pTargetString); - if(rxVal == '\r') + if(rxVal == ('x' & 0x1f)) { // CTRL-X - erase string, return done + memset(pTargetString, 0, maxidx+1); + return true; + } + if(rxVal == '\r') // ignore CR return false; - if(rxVal == '\n') { + if(rxVal == '\n') { // accept buffered string upon LF, return done strncpy(pTargetString, _buffer, maxidx); pTargetString[maxidx] = 0; return true; } - if(rxVal == 0x1b) { + if(rxVal == 0x1b) { // abort, no change upon ESC, return done return true; } }