Skip to content

Commit be531df

Browse files
author
brentru
committed
adding esp32 module firmware version check function into _connect
1 parent 0fb9028 commit be531df

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/AdafruitIO_AIRLIFT.h

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define SPIWIFI SPI
3333
#define ESP32_GPIO0 -1 // Not connected
3434
#endif
35+
#define NINAFWVER "1.0.0"
3536

3637
/****************************************************************************/
3738
/*!
@@ -83,7 +84,23 @@ class AdafruitIO_AIRLIFT : public AdafruitIO {
8384

8485
/********************************************************/
8586
/*!
86-
@brief Returns the network status of an AirLift module.
87+
@brief Checks the version of an ESP32 module against
88+
NINAFWVER. Raises an error if the firmware needs to be
89+
upgraded.
90+
*/
91+
/********************************************************/
92+
void firmwareCheck()
93+
{
94+
_fv = WiFi.firmwareVersion();
95+
if (_fv < NINAFWVER)
96+
{
97+
AIO_DEBUG_PRINTLN("Please upgrade the firmware on the ESP module");
98+
}
99+
}
100+
101+
/********************************************************/
102+
/*!
103+
@brief Returns the network status of an ESP32 module.
87104
@return aio_status_t
88105
*/
89106
/********************************************************/
@@ -134,6 +151,7 @@ class AdafruitIO_AIRLIFT : public AdafruitIO {
134151
protected:
135152
const char *_ssid;
136153
const char *_pass;
154+
String _fv;
137155

138156
WiFiSSLClient *_http_client;
139157
WiFiSSLClient *_mqtt_client;
@@ -146,17 +164,19 @@ class AdafruitIO_AIRLIFT : public AdafruitIO {
146164
/**************************************************************************/
147165
void _connect()
148166
{
167+
// check esp32 module version against NINAFWVER
168+
firmwareCheck();
169+
149170
// check esp32 module status
150171
if (WiFi.status() == WL_NO_MODULE)
151172
{
152-
Serial.println("No Module!!");
153-
Serial.print(WiFi.status());
173+
AIO_DEBUG_PRINTLN("No ESP32 module detected!");
174+
return;
154175
}
155176

156177
WiFi.begin(_ssid, _pass);
157178
_status = AIO_NET_DISCONNECTED;
158179
}
159180
};
160181

161-
162182
#endif // ADAFRUITIO_AIRLIFT_H

0 commit comments

Comments
 (0)