From 0103a7efa223e22abe72dc0ce21c499af9427983 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 15 Dec 2020 02:13:59 +0100 Subject: [PATCH 01/12] remove offending `using namespace std` with `byte` conflict under c++17 --- src/ESP-sc-gway.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ESP-sc-gway.ino b/src/ESP-sc-gway.ino index 0d7c96e..ddf3597 100644 --- a/src/ESP-sc-gway.ino +++ b/src/ESP-sc-gway.ino @@ -140,7 +140,7 @@ uint8_t pdebug= P_MAIN ; // Initially only MAIN and GUI # endif //_GPS #endif //_GATEWAYNODE -using namespace std; +//using namespace std; byte currentMode = 0x81; bool sx1272 = false; // Actually we use sx1276/RFM95 uint8_t MAC_array[6]; From ecf36811654fa18e94596f0526ecea357b783f22 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 15 Dec 2020 02:20:41 +0100 Subject: [PATCH 02/12] fix "unused" or "possibly used unitialized" warns --- lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.cpp | 3 ++- lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.h | 4 ++-- lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp | 2 ++ lib/Streaming/src/Streaming.h | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.cpp b/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.cpp index f8fc226..4f0f9a0 100644 --- a/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.cpp +++ b/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.cpp @@ -388,6 +388,7 @@ void OLEDDisplay::drawStringInternal(int16_t xMove, int16_t yMove, char* text, u case TEXT_ALIGN_RIGHT: xMove -= textWidth; break; + case TEXT_ALIGN_LEFT:; } // Don't draw anything if it is not on the screen. @@ -719,7 +720,7 @@ void inline OLEDDisplay::drawInternal(int16_t xMove, int16_t yMove, int16_t widt int16_t xPos = xMove + (i / rasterHeight); int16_t yPos = ((yMove >> 3) + (i % rasterHeight)) * DISPLAY_WIDTH; - int16_t yScreenPos = yMove + yOffset; + //int16_t yScreenPos = yMove + yOffset; int16_t dataPos = xPos + yPos; if (dataPos >= 0 && dataPos < DISPLAY_BUFFER_SIZE && diff --git a/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.h b/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.h index 81537a2..a3b162e 100644 --- a/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.h +++ b/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.h @@ -247,10 +247,10 @@ class OLEDDisplay : public Print { char *logBuffer = NULL; // Send a command to the display (low level function) - virtual void sendCommand(uint8_t com) {}; + virtual void sendCommand(uint8_t com) { (void)com; }; // Connect to the display - virtual bool connect() {}; + virtual bool connect() { return false; }; // Send all the init commands void sendInitCommands(); diff --git a/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp b/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp index 3fb4326..fb7742c 100644 --- a/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp +++ b/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp @@ -277,6 +277,8 @@ void OLEDDisplayUi::drawFrame(){ x1 = 0; y1 = y - 64; break; + default: + return; } // Invert animation if direction is reversed. diff --git a/lib/Streaming/src/Streaming.h b/lib/Streaming/src/Streaming.h index 73afdf6..68c448f 100644 --- a/lib/Streaming/src/Streaming.h +++ b/lib/Streaming/src/Streaming.h @@ -100,6 +100,6 @@ inline Print &operator <<(Print &obj, const _FLOAT &arg) enum _EndLineCode { endl }; inline Print &operator <<(Print &obj, _EndLineCode arg) -{ obj.println(); return obj; } +{ (void)arg; obj.println(); return obj; } #endif From a6ed38e6c7f7a2accbeac8a1c54d538a464c7531 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 15 Dec 2020 02:26:35 +0100 Subject: [PATCH 03/12] fix warning: 'uint8_t debug' is always >=0 --- src/ESP-sc-gway.ino | 18 +++++++++--------- src/_WiFi.ino | 18 +++++++++--------- src/_loraFiles.ino | 6 +++--- src/_loraModem.ino | 6 +++--- src/_stateMachine.ino | 24 ++++++++++++------------ src/_txRx.ino | 6 +++--- src/_udpSemtech.ino | 12 ++++++------ src/_utils.ino | 8 ++++---- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/ESP-sc-gway.ino b/src/ESP-sc-gway.ino index ddf3597..f4335de 100644 --- a/src/ESP-sc-gway.ino +++ b/src/ESP-sc-gway.ino @@ -363,14 +363,14 @@ void setup() { // if (readGwayCfg(_CONFIGFILE, &gwayConfig) > 0) { // read the Gateway Config # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { mPrint("readGwayCfg:: return OK"); } # endif } else { # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { mPrint("setup:: readGwayCfg: ERROR readGwayCfg Failed"); } # endif @@ -402,7 +402,7 @@ void setup() { // Setup WiFi UDP connection. Give it some time and retry x times. '0' means try forever while (WlanConnect(0) <= 0) { # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_MAIN)) { + if ((debug>=1) && (pdebug & P_MAIN)) { mPrint("setup:: Error Wifi network connect(0)"); } # endif //_MONITOR @@ -429,7 +429,7 @@ void setup() { # endif //ESP32_ARCH # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { String response = "Host="; # if defined(ESP32_ARCH) response += String(WiFi.getHostname()); @@ -487,7 +487,7 @@ void setup() { // display results of getting hardware address // # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { String response= "Gateway ID: "; printHexDigit(MAC_array[0], response); printHexDigit(MAC_array[1], response); @@ -531,7 +531,7 @@ void setup() { time_t newTime; if (getNtpTime(&newTime)<=0) { # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { mPrint("setup:: ERROR Time not set (yet). Time="+String(newTime) ); } # endif //_MONITOR @@ -549,7 +549,7 @@ void setup() { // When we are here we succeeded in getting the time startTime = now(); // Time in seconds # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { String response= "Time set="; stringTime(now(),response); mPrint(response); @@ -670,7 +670,7 @@ void loop () // We will not read Udp in this loop cycle if not connected to Wlan if (WlanConnect(1) < 0) { # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_MAIN)) { + if ((debug>=1) && (pdebug & P_MAIN)) { mPrint("loop:: ERROR reconnect WLAN"); } # endif //_MONITOR @@ -701,7 +701,7 @@ void loop () // if (readUdp(packetSize) < 0) { # if _MONITOR>=1 - if (debug>=0) + if (debug>=1) mPrint("v readUdp ERROR, returning < 0"); # endif //_MONITOR break; diff --git a/src/_WiFi.ino b/src/_WiFi.ino index f322eff..b065d00 100644 --- a/src/_WiFi.ino +++ b/src/_WiFi.ino @@ -45,7 +45,7 @@ int WlanStatus() { // The ESP is configured to reconnect to the last router in memory. case WL_DISCONNECTED: # if _MONITOR>=1 - if ( debug>=0 ) { + if ( debug>=1 ) { mPrint("WlanStatus:: DISCONNECTED, IP=" + String(WiFi.localIP().toString())); // 6 } # endif @@ -58,7 +58,7 @@ int WlanStatus() { // When still pocessing case WL_IDLE_STATUS: # if _MONITOR>=1 - if ( debug>=0 ) { + if ( debug>=1 ) { mPrint("WlanStatus:: IDLE"); // 0 } # endif //_MONITOR @@ -68,14 +68,14 @@ int WlanStatus() { // Whene detected, the program will search for a better AP in range case WL_NO_SSID_AVAIL: # if _MONITOR>=1 - if ( debug>=0 ) + if ( debug>=1 ) mPrint("WlanStatus:: NO SSID"); // 1 # endif //_MONITOR break; case WL_CONNECT_FAILED: # if _MONITOR>=1 - if ( debug>=0 ) + if ( debug>=1 ) mPrint("WlanStatus:: Connect FAILED"); // 4 # endif //_MONITOR break; @@ -83,7 +83,7 @@ int WlanStatus() { // Never seen this code case WL_SCAN_COMPLETED: # if _MONITOR>=1 - if ( debug>=0 ) + if ( debug>=1 ) mPrint("WlanStatus:: SCAN COMPLETE"); // 2 # endif //_MONITOR break; @@ -91,7 +91,7 @@ int WlanStatus() { // Never seen this code case WL_CONNECTION_LOST: # if _MONITOR>=1 - if ( debug>=0 ) + if ( debug>=1 ) mPrint("WlanStatus:: Connection LOST"); // 5 # endif //_MONITOR break; @@ -100,14 +100,14 @@ int WlanStatus() { // before accessing WiFi functions case WL_NO_SHIELD: # if _MONITOR>=1 - if ( debug>=0 ) + if ( debug>=1 ) mPrint("WlanStatus:: WL_NO_SHIELD"); // # endif //_MONITOR break; default: # if _MONITOR>=1 - if ( debug>=0 ) { + if ( debug>=1 ) { mPrint("WlanStatus Error:: code=" + String(WiFi.status())); // 255 means ERROR } # endif //_MONITOR @@ -286,7 +286,7 @@ int WlanConnect(int maxTry) { agains++; delay(8000); // delay(agains*500); # if _MONITOR>=1 - if ( debug>=0 ) { + if ( debug>=1 ) { Serial.print("."); // Serial only } # endif //_MONITOR diff --git a/src/_loraFiles.ino b/src/_loraFiles.ino index 5209847..17d74df 100644 --- a/src/_loraFiles.ino +++ b/src/_loraFiles.ino @@ -46,7 +46,7 @@ int initMonitor(struct moniLine *monitor) void id_print (String id, String val) { #if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_MAIN)) { + if ((debug>=1) && (pdebug & P_MAIN)) { Serial.print(id); Serial.print(F("=\t")); Serial.println(val); @@ -172,7 +172,7 @@ int readConfig(const char *fn, struct espGwayConfig *c) while (f.available()) { # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_MAIN)) { + if ((debug>=1) && (pdebug & P_MAIN)) { Serial.print('.'); } # endif //_MONITOR @@ -183,7 +183,7 @@ int readConfig(const char *fn, struct espGwayConfig *c) if (tries >= 15) { f.close(); # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { mPrint("readConfig:: Formatting"); } # endif //_MONITOR diff --git a/src/_loraModem.ino b/src/_loraModem.ino index 40138e7..021a013 100644 --- a/src/_loraModem.ino +++ b/src/_loraModem.ino @@ -430,7 +430,7 @@ uint8_t receivePkt(uint8_t *payload) if (irqflags & IRQ_LORA_CRCERR_MASK) // Is CRC error? { # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_RADIO)) { + if ((debug>=1) && (pdebug & P_RADIO)) { String response=("rxPkt:: Err CRC, t="); stringTime(now(), response); mPrint(response); @@ -445,7 +445,7 @@ uint8_t receivePkt(uint8_t *payload) else if ((irqflags & IRQ_LORA_HEADER_MASK) == false) // Header not ok? { # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_RADIO)) { + if ((debug>=1) && (pdebug & P_RADIO)) { mPrint("rxPkt:: Err HEADER"); } # endif //_MONITOR @@ -484,7 +484,7 @@ uint8_t receivePkt(uint8_t *payload) if (receivedCount > PAYLOAD_LENGTH) { # if _MONITOR>=1 - if ((debug>=0) & (pdebug & P_RADIO)) { + if ((debug>=1) & (pdebug & P_RADIO)) { mPrint("rxPkt:: ERROR Payliad receivedCount="+String(receivedCount)); } # endif //_MONITOR diff --git a/src/_stateMachine.ino b/src/_stateMachine.ino index 073ece6..3d2c24d 100644 --- a/src/_stateMachine.ino +++ b/src/_stateMachine.ino @@ -133,7 +133,7 @@ void stateMachine() default: doneWait *= 1; # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_PRE)) { + if ((debug>=1) && (pdebug & P_PRE)) { mPrint("StateMachine:: PRE: DEF set"); } # endif //_MONITOR @@ -374,7 +374,7 @@ void stateMachine() // else { # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_SCAN)) { + if ((debug>=1) && (pdebug & P_SCAN)) { String response = "SCAN unknown:: "; mStat(intr, response); mPrint(response); @@ -529,7 +529,7 @@ void stateMachine() // else { # if _MONITOR>=1 - if ( debug>=0) { + if ( debug>=1) { mPrint("ERROR CAD: Unknown::" + String(intr) ); } # endif //_MONITOR @@ -565,7 +565,7 @@ void stateMachine() // if (intr & IRQ_LORA_CRCERR_MASK) { # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_RX)) { + if ((debug>=1) && (pdebug & P_RX)) { String response = "^ CRC ERROR:: "; mStat(intr, response); } @@ -612,7 +612,7 @@ void stateMachine() if((LoraUp.size = receivePkt(LoraUp.payLoad)) <= 0) { # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_RX)) { + if ((debug>=1) && (pdebug & P_RX)) { String response = "sMachine:: ERROR S-RX: size=" + String(LoraUp.size); mPrint(response); } @@ -663,7 +663,7 @@ void stateMachine() // if (receivePacket() <= 0) { // read is not successful # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_RX)) { + if ((debug>=1) && (pdebug & P_RX)) { mPrint("sMach:: ERROR receivePacket"); } # endif //_MONITOR @@ -760,7 +760,7 @@ void stateMachine() // as HEADER interrupt comes just before RXDONE else { # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_RX)) { + if ((debug>=1) && (pdebug & P_RX)) { mPrint("R S_RX:: no RXDONE, RXTOUT, HEADER:: " + String(intr)); } # endif //_MONITOR @@ -880,7 +880,7 @@ void stateMachine() if (Udp.write((unsigned char *)buff, 12) != 12) { # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { mPrint("^ readUdp:: ERROR: PULL_ACK write"); } # endif //_MONITOR @@ -895,7 +895,7 @@ void stateMachine() if (!Udp.endPacket()) { # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_TX)) { + if ((debug>=1) && (pdebug & P_TX)) { mPrint("^ readUdp:: PULL_ACK: ERROR Udp.endPacket"); } # endif //_MONITOR @@ -906,7 +906,7 @@ void stateMachine() // If a soft _event==0 interrupt and no transmission finished: else if ( intr != 0 ) { # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_TX)) { + if ((debug>=1) && (pdebug & P_TX)) { String response = "TXDONE:: ERROR unknown intr="; mStat(intr, response); mPrint(response); @@ -965,14 +965,14 @@ void stateMachine() // make sure that we pick up next interrupt default: # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_PRE)) { + if ((debug>=1) && (pdebug & P_PRE)) { mPrint("ERR state=" + String(_state)); } # endif //_MONITOR if ((gwayConfig.cad) || (gwayConfig.hop)) { # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { String response = "default:: Unknown _state "; mStat(intr, response); mPrint(response); diff --git a/src/_txRx.ino b/src/_txRx.ino index 2913b5a..30fa0ca 100644 --- a/src/_txRx.ino +++ b/src/_txRx.ino @@ -94,7 +94,7 @@ int sendPacket(uint8_t *buf, uint8_t len) auto error = deserializeJson(jsonBuffer, bufPtr); if (error) { # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_TX)) { + if ((debug>=1) && (pdebug & P_TX)) { mPrint("v sendPacket:: ERROR: Json Decode: " + String(bufPtr) ); } # endif //_MONITOR @@ -152,7 +152,7 @@ int sendPacket(uint8_t *buf, uint8_t len) } else { // There is data! # if _MONITOR>=1 - if ((debug>=0) && (pdebug & P_TX)) { + if ((debug>=1) && (pdebug & P_TX)) { mPrint("v sendPacket:: ERROR: data is NULL"); } # endif //_MONITOR @@ -225,7 +225,7 @@ int sendPacket(uint8_t *buf, uint8_t len) if (LoraDown.size != psize) { # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { mPrint("v sendPacket:: WARNING size=" + String(LoraDown.size) + ", psize=" + String(psize) ); } # endif //_MONITOR diff --git a/src/_udpSemtech.ino b/src/_udpSemtech.ino index f8d8f4a..541c8e2 100644 --- a/src/_udpSemtech.ino +++ b/src/_udpSemtech.ino @@ -63,7 +63,7 @@ bool connectUdp() } else{ # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { mPrint("Connection failed"); } # endif //_MONITOR @@ -135,7 +135,7 @@ int readUdp(int packetSize) if (remotePortNo == 123) { // NTP message arriving, not expected // This is an NTP message arriving # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { mPrint("v readUdp:: NTP msg rcvd"); } # endif //_MONITOR @@ -314,7 +314,7 @@ int readUdp(int packetSize) // as described in the specs. This function fills LoraDown struct. if (sendPacket(buff_down, packetSize) < 0) { # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { mPrint("v readUdp:: ERROR: PULL_RESP sendPacket failed"); } # endif //_MONITOR @@ -585,7 +585,7 @@ int sendUdp(IPAddress server, int port, uint8_t *msg, uint16_t length) if (!Udp.beginPacket(server, (int) port)) { # if _MONITOR>=1 - if ( debug>=0 ) { + if ( debug>=1 ) { mPrint("M sendUdp:: ERROR Udp.beginPacket"); } # endif //_MONITOR @@ -596,7 +596,7 @@ int sendUdp(IPAddress server, int port, uint8_t *msg, uint16_t length) if (Udp.write((unsigned char *)msg, length) != length) { # if _MONITOR>=1 - if ( debug>=0 ) { + if ( debug>=1 ) { mPrint("sendUdp:: ERROR Udp write"); } # endif //_MONITOR @@ -608,7 +608,7 @@ int sendUdp(IPAddress server, int port, uint8_t *msg, uint16_t length) if (!Udp.endPacket()) { # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { mPrint("sendUdp:: ERROR Udp.endPacket"); } # endif //_MONITOR diff --git a/src/_utils.ino b/src/_utils.ino index 6ff8a1f..3640162 100644 --- a/src/_utils.ino +++ b/src/_utils.ino @@ -168,7 +168,7 @@ void printIP(IPAddress ipa, const char sep, String & response) void printHex(uint32_t hexa, const char sep, String & response) { # if _MONITOR>=1 - if ((debug>=0) && (hexa==0)) { + if ((debug>=1) && (hexa==0)) { mPrint("printHex:: hexa amount to convert is 0"); } # endif @@ -252,7 +252,7 @@ int mStat(uint8_t intr, String & response) { #if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { response += "I="; @@ -461,7 +461,7 @@ int getNtpTime(time_t *t) if (!sendNtpRequest(ntpServer)) // Send the request for new time { # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { mPrint("utils:: ERROR getNtpTime: sendNtpRequest failed"); } # endif //_MONITOR @@ -481,7 +481,7 @@ int getNtpTime(time_t *t) if (Udp.read(packetBuffer, NTP_PACKET_SIZE) < NTP_PACKET_SIZE) { # if _MONITOR>=1 - if (debug>=0) { + if (debug>=1) { mPrint("getNtpTime:: ERROR packetsize too low"); } # endif //_MONITOR From ef80dd08f3b64005177797f3208f951d2f7209b1 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 15 Dec 2020 02:37:15 +0100 Subject: [PATCH 04/12] possibly use LittleFS on esp8266 (SPIFFS is deprecated and fails formatting 16MB flashes) --- src/configGway.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/configGway.h b/src/configGway.h index b69e58b..26486bc 100644 --- a/src/configGway.h +++ b/src/configGway.h @@ -33,6 +33,10 @@ // // ======================================================================================== +// esp8266 arduino core is deprecating SPIFFS +#if !defined _USE_LITTLEFS +# define _USE_LITTLEFS 0 +#endif // Define whether we should do a formatting of SPIFFS when starting the gateway // This is usually a good idea if the webserver is interrupted halfway a writing @@ -362,4 +366,9 @@ #if _REPEATER==0 # define _TTNSERVER "router.eu.thethings.network" # define _TTNPORT 1700 // Standard port for TTN -#endif \ No newline at end of file +#endif + +#if _USE_LITTLEFS==1 +#include +#define SPIFFS LittleFS +#endif From 7ed8d3a3cdfa6866c041af2cf37bcba7d079b15f Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 15 Dec 2020 02:49:36 +0100 Subject: [PATCH 05/12] fix more "unused" --- src/_loraFiles.ino | 5 ++++- src/_txRx.ino | 2 +- src/_udpSemtech.ino | 4 ++++ src/_utils.ino | 2 ++ src/_wwwServer.ino | 4 +++- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/_loraFiles.ino b/src/_loraFiles.ino index 17d74df..49ebcfd 100644 --- a/src/_loraFiles.ino +++ b/src/_loraFiles.ino @@ -494,7 +494,10 @@ int addLog(const unsigned char * line, int cnt) f.close(); // Close the file after appending to it -#endif //_STAT_LOG +#else //!_STAT_LOG + (void)line; + (void)cnt; +#endif //!_STAT_LOG gwayConfig.logFileRec++; diff --git a/src/_txRx.ino b/src/_txRx.ino index 30fa0ca..098de1f 100644 --- a/src/_txRx.ino +++ b/src/_txRx.ino @@ -115,7 +115,7 @@ int sendPacket(uint8_t *buf, uint8_t len) const char * datr = root["txpk"]["datr"]; // eg "SF7BW125" const char * codr = root["txpk"]["codr"]; // "4/5" const char * modu = root["txpk"]["modu"]; - const char * time = root["txpk"]["time"]; // Time is a string in UTC + //const char * time = root["txpk"]["time"]; // Time is a string in UTC LoraDown.modu = (char *) modu; // =="LORA" LoraDown.codr = (char *) codr; // e.g. "4/5" diff --git a/src/_udpSemtech.ino b/src/_udpSemtech.ino index 541c8e2..2dcab84 100644 --- a/src/_udpSemtech.ino +++ b/src/_udpSemtech.ino @@ -151,7 +151,9 @@ int readUdp(int packetSize) // First 4 butes are very important, rest is data // Especially the 2 token bytes should be watched. protocol= buff_down[0]; +# ifdef _PROFILER uint16_t token= buff_down[2]*256 + buff_down[1]; // LSB first [1], MSB [2] comes after +# endif //_PROFILER uint8_t ident= buff_down[3]; // uint8_t *data = (uint8_t *) ((uint8_t *)buff_down + 4); @@ -283,7 +285,9 @@ int readUdp(int packetSize) case PULL_RESP: // 0x03 DOWN if (protocol==0x01) { // If protocol version is 0x01 +# ifdef _PROFILER token = 0; // Use token 0 in that case +# endif//_PROFILER buff_down[2]=0; buff_down[1]=0; } diff --git a/src/_utils.ino b/src/_utils.ino index 3640162..dbf881a 100644 --- a/src/_utils.ino +++ b/src/_utils.ino @@ -45,6 +45,8 @@ void printInt (uint32_t i, String & response) void printRegs(struct LoraDown *LoraDown, String & response) { + (void)LoraDown; + response += "v FIFO (0x00)=0x" + String(readRegister(REG_FIFO),HEX); response += "v OPMODE (0x01)=0x" + String(readRegister(REG_OPMODE),HEX); diff --git a/src/_wwwServer.ino b/src/_wwwServer.ino index cd14989..05d7fd3 100644 --- a/src/_wwwServer.ino +++ b/src/_wwwServer.ino @@ -145,7 +145,9 @@ void wwwFile(String fn) # endif //_MONITOR -#endif //_STAT_LOG +#else //!_STAT_LOG + (void)fn; +#endif //!_STAT_LOG return; From fd1e90a15b8961cdb1ed933a8d29dd04c52db0db Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 15 Dec 2020 02:54:51 +0100 Subject: [PATCH 06/12] fix buffer oveflow --- src/ESP-sc-gway.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ESP-sc-gway.ino b/src/ESP-sc-gway.ino index f4335de..4b406a7 100644 --- a/src/ESP-sc-gway.ino +++ b/src/ESP-sc-gway.ino @@ -292,7 +292,7 @@ void setup() { char MAC_char[19]; // XXX Unbelievable MAC_char[18] = 0; - char hostname[12]; // hostname space + char hostname[32]; // hostname space initConfig(&gwayConfig); From cccb91b9f4e2813ec090536081a5c2200427aaad Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 15 Dec 2020 02:59:15 +0100 Subject: [PATCH 07/12] fix more warnings --- lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.cpp | 2 +- lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp | 2 ++ lib/aes/AES-128_V10.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.cpp b/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.cpp index 4f0f9a0..ff6f740 100644 --- a/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.cpp +++ b/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplay.cpp @@ -353,7 +353,7 @@ void OLEDDisplay::drawFastImage(int16_t xMove, int16_t yMove, int16_t width, int void OLEDDisplay::drawXbm(int16_t xMove, int16_t yMove, int16_t width, int16_t height, const char *xbm) { int16_t widthInXbm = (width + 7) / 8; - uint8_t data; + uint8_t data = 0; for(int16_t y = 0; y < height; y++) { for(int16_t x = 0; x < width; x++ ) { diff --git a/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp b/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp index fb7742c..9cd3c50 100644 --- a/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp +++ b/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp @@ -384,6 +384,8 @@ void OLEDDisplayUi::drawIndicator() { x = 0 - (8 * indicatorFadeProgress); y = 32 - frameStartPos + 2 + 12 * i; break; + default: + return; } if (posOfHighlightFrame == i) { diff --git a/lib/aes/AES-128_V10.cpp b/lib/aes/AES-128_V10.cpp index 734e013..221adad 100644 --- a/lib/aes/AES-128_V10.cpp +++ b/lib/aes/AES-128_V10.cpp @@ -77,7 +77,7 @@ static unsigned char AES_Sub_Byte(unsigned char Byte); static void AES_Shift_Rows(); static void AES_Mix_Collums(); static void AES_Calculate_Round_Key(unsigned char Round, unsigned char *Round_Key); -static void Send_State(); +//static void Send_State(); /* ***************************************************************************************** From 2c3e23ddb9bdc2fa19e51620a70fad52e790ae63 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 15 Dec 2020 03:03:48 +0100 Subject: [PATCH 08/12] fix "maybe uninitialized" --- lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp b/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp index 9cd3c50..a9f348b 100644 --- a/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp +++ b/lib/ESP8266_Oled_Driver_for_SSD1306_display/OLEDDisplayUi.cpp @@ -333,7 +333,7 @@ void OLEDDisplayUi::drawIndicator() { return; } - uint8_t posOfHighlightFrame; + uint8_t posOfHighlightFrame = 0; float indicatorFadeProgress = 0; // if the indicator needs to be slided in we want to @@ -384,8 +384,6 @@ void OLEDDisplayUi::drawIndicator() { x = 0 - (8 * indicatorFadeProgress); y = 32 - frameStartPos + 2 + 12 * i; break; - default: - return; } if (posOfHighlightFrame == i) { From fbce7d5b9179f403458a56f46295617862549b70 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 15 Dec 2020 16:12:49 +0100 Subject: [PATCH 09/12] hardware i2c pin are fixed on esp8266, they can be defaulted in last resort --- src/oLED.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/oLED.h b/src/oLED.h index b8ee697..2e0ee00 100644 --- a/src/oLED.h +++ b/src/oLED.h @@ -50,6 +50,10 @@ #define OLED_SDA 21 // GPIO21 / SDA #define OLED_RST 16 // Reset pin (Some OLED displays do not have it) +#elif defined(ARDUINO_ARCH_ESP8266) +#define OLED_SCL 5 // GPIO5 / D1 +#define OLED_SDA 4 // GPIO4 / D2 + #endif From d50032df202691d71018dc6a6a4e7412e9daa385 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Sat, 6 Feb 2021 19:23:26 +0100 Subject: [PATCH 10/12] mPrint: avoid a copy --- src/ESP-sc-gway.ino | 6 +++--- src/_utils.ino | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ESP-sc-gway.ino b/src/ESP-sc-gway.ino index 4b406a7..6a12937 100644 --- a/src/ESP-sc-gway.ino +++ b/src/ESP-sc-gway.ino @@ -238,7 +238,7 @@ int sendPacket(uint8_t *buf, uint8_t length); // _txRx.ino forward void printIP(IPAddress ipa, const char sep, String & response); // _wwwServer.ino void setupWWW(); // _wwwServer.ino forward -void mPrint(String txt); // _utils.ino +void mPrint(const String& txt); // _utils.ino int getNtpTime(time_t *t); // _utils.ino int mStat(uint8_t intr, String & response); // _utils.ino void SerialStat(uint8_t intr); // _utils.ino @@ -532,7 +532,7 @@ void setup() { if (getNtpTime(&newTime)<=0) { # if _MONITOR>=1 if (debug>=1) { - mPrint("setup:: ERROR Time not set (yet). Time="+String(newTime) ); + mPrint("setup:: ERROR Time not set (yet). Time="+String((int)newTime) ); } # endif //_MONITOR response += "."; @@ -882,7 +882,7 @@ void loop () if (getNtpTime(&newTime)<=0) { # if _MONITOR>=1 if (debug>=2) { - mPrint("loop:: WARNING Time not set (yet). Time="+String(newTime) ); + mPrint("loop:: WARNING Time not set (yet). Time="+String((int)newTime) ); } # endif //_MONITOR } diff --git a/src/_utils.ino b/src/_utils.ino index dbf881a..e6f46b5 100644 --- a/src/_utils.ino +++ b/src/_utils.ino @@ -211,7 +211,7 @@ void printHexDigit(uint8_t digit, String & response) // return: // // ---------------------------------------------------------------------------------------- -void mPrint(String txt) +void mPrint(const String& txt) { # if _DUSB>=1 From 22d2ddef156a38c5eb4c5956f20bd65cfb37c436 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Fri, 19 Feb 2021 18:54:13 +0100 Subject: [PATCH 11/12] fix use of abs() --- src/_txRx.ino | 2 +- src/configGway.h | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/_txRx.ino b/src/_txRx.ino index 098de1f..a9213fc 100644 --- a/src/_txRx.ino +++ b/src/_txRx.ino @@ -193,7 +193,7 @@ int sendPacket(uint8_t *buf, uint8_t len) uint32_t fff = (uint32_t)(root["txpk"]["freq"].as() * 1000000); - if (abs(freqs[gwayConfig.ch].dwnFreq - fff) < 100000) { + if ((freqs[gwayConfig.ch].dwnFreq - fff) < 100000) { LoraDown.freq = (uint32_t) (freqs[gwayConfig.ch].dwnFreq) & 0xFFFFFFFF ; } else { diff --git a/src/configGway.h b/src/configGway.h index 26486bc..a60c5b9 100644 --- a/src/configGway.h +++ b/src/configGway.h @@ -130,15 +130,17 @@ // continuous listen mode. // Using this function means that we HAVE to use more dio pins on the RFM95/sx1276 // device and also connect enable dio1 to detect this state. +#ifndef _CAD #define _CAD 1 - +#endif // CRCCHECK // Defines whether we should check on the CRC of RXDONE messages (see stateMachine.ino) // This should prevent us from getting a lot os stranges messgages of unknown nodes. // Note: DIO3 must be connected for this to work (Heltec and later Wemos gateways). +#ifndef _CRCCHECK #define _CRCCHECK 1 - +#endif // Definitions for the admin webserver. // _SERVER determines whether or not the admin webpage is included in the sketch. @@ -294,8 +296,9 @@ // 1: Use the nodes as a translation table for hex codes to names (in TLN) // 2: Same as 1, but is nodes NOT in the nodes list below they are NOT shown // NOTE: We probably will make this list dynamic! +#ifndef _TRUSTED_NODES #define _TRUSTED_NODES 1 - +#endif // ======================================================================== // DO NOT CHANGE BELOW THIS LINE From 3ee151d930077e8b6eb8bb9c13591ea5d38efbc8 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Fri, 19 Feb 2021 18:57:16 +0100 Subject: [PATCH 12/12] allow to use external defines for SSID/PSK --- src/configNode.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/configNode.h b/src/configNode.h index 1a6f27b..ee13fc4 100644 --- a/src/configNode.h +++ b/src/configNode.h @@ -109,8 +109,14 @@ struct wpas { // Please fill in at least ONE valid SSID and password from your own WiFI network // below. This is needed to get the gateway working // + +#ifndef STASSID +#define STASSID "yourSSID" +#define STAPSK "yourPassword" +#endif + wpas wpa[] = { - { "yourSSID", "yourPassword" }, + { STASSID, STAPSK }, { "Your2SSID", "your2Password" } };