From 7f436d54dbb106d0e913a4808636371fb87a196f Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Fri, 14 May 2021 19:59:40 +1000 Subject: [PATCH] Stop crash if not enabled or in AP mode --- RX_FSK/RX_FSK.ino | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 5e7a849..4cf7688 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -2130,7 +2130,9 @@ void loopDecoder() { tncclient.write(raw, rawlen); } } - sondehub_send_data(&shclient, s, &sonde.config.sondehub); + if (sonde.config.sondehub.active) { + sondehub_send_data(&shclient, s, &sonde.config.sondehub); + } } // send to MQTT if enabled @@ -2315,6 +2317,9 @@ String translateEncryptionType(wifi_auth_mode_t encryptionType) { } } +enum t_wifi_state { WIFI_DISABLED, WIFI_SCAN, WIFI_CONNECT, WIFI_CONNECTED, WIFI_APMODE }; + +static t_wifi_state wifi_state = WIFI_DISABLED; void enableNetwork(bool enable) { if (enable) { @@ -2334,8 +2339,10 @@ void enableNetwork(bool enable) { mqttclient.init(sonde.config.mqtt.host, sonde.config.mqtt.port, sonde.config.mqtt.id, sonde.config.mqtt.username, sonde.config.mqtt.password, sonde.config.mqtt.prefix); } - //shclient.setInsecure(); // Skip verification - sondehub_station_update(&shclient, &sonde.config.sondehub); + if (sonde.config.sondehub.active && wifi_state != WIFI_APMODE) { + sondehub_station_update(&shclient, &sonde.config.sondehub); + } + connected = true; } else { MDNS.end(); @@ -2343,11 +2350,6 @@ void enableNetwork(bool enable) { } } - -enum t_wifi_state { WIFI_DISABLED, WIFI_SCAN, WIFI_CONNECT, WIFI_CONNECTED, WIFI_APMODE }; - -static t_wifi_state wifi_state = WIFI_DISABLED; - // Events used only for debug output right now void WiFiEvent(WiFiEvent_t event) {