From 25b438db84f4ca708250e2cd287c01a30a054fb7 Mon Sep 17 00:00:00 2001 From: DL2MF Date: Fri, 26 Apr 2019 19:21:11 +0200 Subject: [PATCH] Adding WiFi bugfix from b4sh and minor changes in RX_FSK --- RX_FSK/RX_FSK.ino | 27 +++++++++++++++------------ RX_FSK/data/config.txt | 4 ++-- RX_FSK/data/networks.txt | 4 ++-- libraries/SondeLib/Sonde.cpp | 5 +++-- libraries/SondeLib/Sonde.h | 4 ++-- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 557b8f6..37fcaec 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -11,14 +11,13 @@ #include #include -#define LORA_LED 9 - // UNCOMMENT one of the constructor lines below U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8=NULL; // initialize later after reading config file //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ OLED_SCL, /* data=*/ OLED_SDA, /* reset=*/ OLED_RST); // Unbuffered, basic graphics, software I2C //U8G2_SSD1306_128X64_NONAME_1_SW_I2C Display(U8G2_R0, /* clock=*/ OLED_SCL, /* data=*/ OLED_SDA, /* reset=*/ OLED_RST); // Page buffer, SW I2C //U8G2_SSD1306_128X64_NONAME_F_SW_I2C Display(U8G2_R0, /* clock=*/ OLED_SCL, /* data=*/ OLED_SDA, /* reset=*/ OLED_RST); // Full framebuffer, SW I2C +int LORA_LED = 9; // default POUT for LORA LED used as serial monitor int e; AsyncWebServer server(80); @@ -49,8 +48,6 @@ String processor(const String& var){ return String(); } -#define MAX_QRG 10 - const String sondeTypeSelect(int activeType) { String sts = ""; for(int i=0; i<3; i++) { @@ -137,7 +134,7 @@ const char *handleQRGPost(AsyncWebServerRequest *request) { Serial.println(request->getParam(i)->name().c_str()); } #endif - for(int i=1; i<=MAX_QRG; i++) { + for(int i=1; i<=sonde.config.maxsonde; i++) { snprintf(label, 10, "A%d", i); AsyncWebParameter *active = request->getParam(label, true); snprintf(label, 10, "F%d", i); @@ -483,7 +480,8 @@ void setup() return; } - setupConfigData(); // configuration must be read first due to OLED ports!!! + setupConfigData(); // configuration must be read first due to OLED ports!!! + LORA_LED = sonde.config.led_pout; u8x8 = new U8X8_SSD1306_128X64_NONAME_SW_I2C(/* clock=*/ sonde.config.oled_scl, /* data=*/ sonde.config.oled_sda, /* reset=*/ sonde.config.oled_rst); // Unbuffered, basic graphics, software I2C u8x8->begin(); @@ -523,7 +521,7 @@ void setup() u8x8->drawString(6, 3, buf); delay(1000); - itoa(sonde.config.led_pin, buf, 10); + itoa(sonde.config.led_pout, buf, 10); u8x8->drawString(0, 4, " LED:"); u8x8->drawString(6, 4, buf); @@ -608,6 +606,8 @@ void loopDecoder() { switch(getKeyPress()) { case KP_SHORT: sonde.nextConfig(); + sonde.updateDisplayRXConfig(); + sonde.updateDisplay(); break; case KP_DOUBLE: enterMode(ST_SCANNER); @@ -741,7 +741,7 @@ void loopWifiScan() { WiFi.disconnect(true); WiFi.mode(WIFI_STA); - const char *id, *pw; + const char *id, *pw, *wifipw; char idstr[64]="test"; if (sonde.config.wifi != 0) { @@ -761,16 +761,19 @@ void loopWifiScan() { Serial.println("-----------------------"); id=WiFi.SSID(i).c_str(); pw=fetchWifiPw(id); - if(pw) { strncpy(idstr, id, 63); } + if(pw) { + strncpy(idstr, id, 63); + wifipw = pw; + } } - if(!pw) { pw="test"; } + if(!wifipw) { wifipw="test"; } Serial.print("Connecting to: "); Serial.println(idstr); u8x8->drawString(0,6, "Conn:"); u8x8->drawString(6,6, idstr); //register event handler WiFi.onEvent(WiFiEvent); - WiFi.begin(idstr, pw); + WiFi.begin(idstr, wifipw); } while(WiFi.status() != WL_CONNECTED) { @@ -782,7 +785,7 @@ void loopWifiScan() { if(cnt==4) { WiFi.disconnect(true); // retry, for my buggy FritzBox WiFi.onEvent(WiFiEvent); - WiFi.begin(idstr, pw); + WiFi.begin(idstr, wifipw); } #endif if(cnt==15) { diff --git a/RX_FSK/data/config.txt b/RX_FSK/data/config.txt index 78ff4dd..8b34287 100644 --- a/RX_FSK/data/config.txt +++ b/RX_FSK/data/config.txt @@ -3,7 +3,7 @@ #-------------------------------# button_pin=0 # LED port -led_pin=25 +led_pout=9 # OLED Setup is depending on hardware of LoRa board # TTGO v1: SDA=4 SCL=15, RST=16 # TTGO v2: SDA=21 SCL=22, RST=16 @@ -15,7 +15,7 @@ oled_rst=16 #-------------------------------# maxsonde=20 debug=0 -wifi=0 +wifi=1 wifiap=1 #-------------------------------# # Spectrum display settings diff --git a/RX_FSK/data/networks.txt b/RX_FSK/data/networks.txt index 352a350..6e57bfa 100644 --- a/RX_FSK/data/networks.txt +++ b/RX_FSK/data/networks.txt @@ -1,4 +1,4 @@ AUTORX 12345678 -SONDERX -radiosonde \ No newline at end of file +WXSONDE +radiosonde diff --git a/libraries/SondeLib/Sonde.cpp b/libraries/SondeLib/Sonde.cpp index 75a0bd8..c652938 100644 --- a/libraries/SondeLib/Sonde.cpp +++ b/libraries/SondeLib/Sonde.cpp @@ -49,6 +49,7 @@ static uint8_t ap_tile[8]={0x00,0x04,0x22,0x92, 0x92, 0x22, 0x04, 0x00}; Sonde::Sonde() { config.button_pin = 1; + config.led_pout = 9; //config.oled_sda = 0; //config.oled_scl = 0; //config.oled_rst = 0; @@ -98,8 +99,8 @@ void Sonde::setConfig(const char *cfg) { strncpy(config.passcode, val, 9); } else if(strcmp(cfg,"button_pin")==0) { config.button_pin = atoi(val); - } else if(strcmp(cfg,"led_pin")==0) { - config.led_pin = atoi(val); + } else if(strcmp(cfg,"led_pout")==0) { + config.led_pout = atoi(val); } else if(strcmp(cfg,"oled_sda")==0) { config.oled_sda = atoi(val); } else if(strcmp(cfg,"oled_scl")==0) { diff --git a/libraries/SondeLib/Sonde.h b/libraries/SondeLib/Sonde.h index 806ea95..77e6f95 100644 --- a/libraries/SondeLib/Sonde.h +++ b/libraries/SondeLib/Sonde.h @@ -13,8 +13,8 @@ enum SondeType { STYPE_DFM06, STYPE_DFM09, STYPE_RS41 }; extern const char *sondeTypeStr[5]; typedef struct st_rdzconfig { - int button_pin; // pin number of second button (for some boards) - int led_pin; // pin number of LED + int button_pin; // PIN port number menu button (for some boards) + int led_pout; // POUT port number of LED (used as serial monitor) int oled_sda; // OLED data pin int oled_scl; // OLED clock pin int oled_rst; // OLED reset pin