diff --git a/src/Wippersnapper.cpp b/src/Wippersnapper.cpp index 67ad018c7..731f8b7b6 100644 --- a/src/Wippersnapper.cpp +++ b/src/Wippersnapper.cpp @@ -185,10 +185,12 @@ void Wippersnapper::getMacAddr() { /****************************************************************************/ /*! @brief Gets the network's RSSI. + @return int32_t RSSI value */ /****************************************************************************/ -void Wippersnapper::getRSSI() { +int32_t Wippersnapper::getRSSI() { WS_DEBUG_PRINTLN("ERROR: Please define a network interface!"); + return 0; } /****************************************************************************/ @@ -2401,7 +2403,7 @@ void Wippersnapper::runNetFSM() { WS_LED_STATUS_WIFI_CONNECTING); } WS_DEBUG_PRINT("SSID found! RSSI: "); - WS_DEBUG_PRINTLN(WS._RSSI); + WS_DEBUG_PRINTLN(WS.getRSSI()); // Attempt to connect to wireless network maxAttempts = 5; while (maxAttempts > 0) { @@ -2567,9 +2569,8 @@ void Wippersnapper::pingBroker() { runNetFSM(); } _prv_ping = millis(); - getRSSI(); // update RSSI WS_DEBUG_PRINT("WiFi RSSI: "); - WS_DEBUG_PRINTLN(WS._RSSI); + WS_DEBUG_PRINTLN(WS.getRSSI()); } // blink status LED every STATUS_LED_KAT_BLINK_TIME millis if (millis() > (_prvKATBlink + STATUS_LED_KAT_BLINK_TIME)) { diff --git a/src/Wippersnapper.h b/src/Wippersnapper.h index a837f5935..975f24dee 100644 --- a/src/Wippersnapper.h +++ b/src/Wippersnapper.h @@ -270,7 +270,7 @@ class Wippersnapper { void disconnect(); virtual void getMacAddr(); - virtual void getRSSI(); + virtual int32_t getRSSI(); virtual void setupMQTTClient(const char *clientID); virtual ws_status_t networkStatus(); @@ -362,7 +362,6 @@ class Wippersnapper { ws_uart *_uartComponent; ///< Instance of UART class // TODO: does this really need to be global? - int32_t _RSSI = 0; ///< RSSI value of the network connection uint8_t _macAddr[6]; /*!< Unique network iface identifier */ char sUID[13]; /*!< Unique network iface identifier */ const char *_boardId; /*!< Adafruit IO+ board string */ diff --git a/src/network_interfaces/Wippersnapper_AIRLIFT.h b/src/network_interfaces/Wippersnapper_AIRLIFT.h index 544ab80d3..b3beb2c9c 100644 --- a/src/network_interfaces/Wippersnapper_AIRLIFT.h +++ b/src/network_interfaces/Wippersnapper_AIRLIFT.h @@ -120,7 +120,6 @@ class Wippersnapper_AIRLIFT : public Wippersnapper { // Was the network within secrets.json found? for (int i = 0; i < n; ++i) { if (strcmp(_ssid, WiFi.SSID(i)) == 0) { - WS._RSSI = WiFi.RSSI(i); return true; } } @@ -225,12 +224,10 @@ class Wippersnapper_AIRLIFT : public Wippersnapper { /********************************************************/ /*! @brief Gets the current network RSSI value + @return int32_t RSSI value */ /********************************************************/ - void getRSSI() { - // test if this fails when disconnected or returns something sensible - WS._RSSI = WiFi.RSSI(); - } + int32_t getRSSI() { return WiFi.RSSI(); } /********************************************************/ /*! diff --git a/src/network_interfaces/Wippersnapper_ESP32.h b/src/network_interfaces/Wippersnapper_ESP32.h index cf1b1c780..2f4f2b4cb 100644 --- a/src/network_interfaces/Wippersnapper_ESP32.h +++ b/src/network_interfaces/Wippersnapper_ESP32.h @@ -110,7 +110,6 @@ class Wippersnapper_ESP32 : public Wippersnapper { // Was the network within secrets.json found? for (int i = 0; i < n; ++i) { if (strcmp(_ssid, WiFi.SSID(i).c_str()) == 0) { - WS._RSSI = WiFi.RSSI(i); return true; } } @@ -143,12 +142,10 @@ class Wippersnapper_ESP32 : public Wippersnapper { /********************************************************/ /*! @brief Gets the current network RSSI value + @return int32_t RSSI value */ /********************************************************/ - void getRSSI() { - // test if this fails when disconnected or returns something sensible - WS._RSSI = WiFi.RSSI(); - } + int32_t getRSSI() { return WiFi.RSSI(); } /********************************************************/ /*! diff --git a/src/network_interfaces/Wippersnapper_ESP8266.h b/src/network_interfaces/Wippersnapper_ESP8266.h index 51f5df861..5e48a9b33 100644 --- a/src/network_interfaces/Wippersnapper_ESP8266.h +++ b/src/network_interfaces/Wippersnapper_ESP8266.h @@ -133,7 +133,6 @@ class Wippersnapper_ESP8266 : public Wippersnapper { // Was the network within secrets.json found? for (int i = 0; i < n; ++i) { if (strcmp(_ssid, WiFi.SSID(i).c_str()) == 0) { - WS._RSSI = WiFi.RSSI(i); return true; } } @@ -166,12 +165,10 @@ class Wippersnapper_ESP8266 : public Wippersnapper { /********************************************************/ /*! @brief Gets the current network RSSI value + @return int32_t RSSI value */ /********************************************************/ - void getRSSI() { - // test if this fails when disconnected or returns something sensible - WS._RSSI = WiFi.RSSI(); - } + int32_t getRSSI() { return WiFi.RSSI(); } /*******************************************************************/ /*! diff --git a/src/network_interfaces/Wippersnapper_WIFININA.h b/src/network_interfaces/Wippersnapper_WIFININA.h index ea301cf4f..33d43e8e4 100644 --- a/src/network_interfaces/Wippersnapper_WIFININA.h +++ b/src/network_interfaces/Wippersnapper_WIFININA.h @@ -131,7 +131,6 @@ class Wippersnapper_WIFININA : public Wippersnapper { // Was the network within secrets.json found? for (int i = 0; i < n; ++i) { if (strcmp(_ssid, WiFi.SSID(i)) == 0) { - WS._RSSI = WiFi.RSSI(i); return true; } } @@ -190,12 +189,10 @@ class Wippersnapper_WIFININA : public Wippersnapper { /********************************************************/ /*! @brief Gets the current network RSSI value + @return int32_t RSSI value */ /********************************************************/ - void getRSSI() { - // test if this fails when disconnected or returns something sensible - WS._RSSI = WiFi.RSSI(); - } + int32_t getRSSI() { return WiFi.RSSI(); } /********************************************************/ /*! diff --git a/src/network_interfaces/ws_networking_pico.h b/src/network_interfaces/ws_networking_pico.h index 13c23581a..efd513051 100644 --- a/src/network_interfaces/ws_networking_pico.h +++ b/src/network_interfaces/ws_networking_pico.h @@ -109,7 +109,6 @@ class ws_networking_pico : public Wippersnapper { // Was the network within secrets.json found? for (int i = 0; i < n; ++i) { if (strcmp(_ssid, WiFi.SSID(i)) == 0) { - WS._RSSI = WiFi.RSSI(i); return true; } } @@ -142,12 +141,10 @@ class ws_networking_pico : public Wippersnapper { /********************************************************/ /*! @brief Gets the current network RSSI value + @return int32_t RSSI value */ /********************************************************/ - void getRSSI() { - // test if this fails when disconnected or returns something sensible - WS._RSSI = WiFi.RSSI(); - } + int32_t getRSSI() { return WiFi.RSSI(); } /********************************************************/ /*!