Skip to content

Commit 7f34ca3

Browse files
committed
Bring SAMD Airlift in-line for v2
1 parent bc5a005 commit 7f34ca3

File tree

5 files changed

+27
-29
lines changed

5 files changed

+27
-29
lines changed
File renamed without changes.

examples/Wippersnapper_demo/.picow_rp2040_tinyusb.test.skip

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/Wippersnapper_V2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
while (millis() - start < timeout) { \
6363
delay(10); \
6464
yield(); \
65-
feedWDT(); \
65+
WsV2.feedWDTV2(); \
6666
if (millis() < start) { \
6767
start = millis(); \
6868
} \

src/adapters/wifi/ws_wifi_airlift.h

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* please support Adafruit and open-source hardware by purchasing
1212
* products from Adafruit!
1313
*
14-
* Copyright (c) Brent Rubell 2020-2021 for Adafruit Industries.
14+
* Copyright (c) Brent Rubell 2020-2025 for Adafruit Industries.
1515
*
1616
* MIT license, all text here must be included in any redistribution.
1717
*
@@ -25,30 +25,30 @@
2525
#include "Arduino.h"
2626
#include "SPI.h"
2727
#include "WiFiNINA.h"
28-
#include "Wippersnapper.h"
28+
#include "Wippersnapper_V2.h"
29+
#include "../../helpers/ws_helper_macros.h"
2930

30-
#define NINAFWVER \
31-
"1.7.7" /*!< min. nina-fw version compatible with this library. */
31+
#define NINAFWVER "2.0.0-rc.0+adafruit" /*!< min. nina-fw version compatible with this library. */
3232
#define AIRLIFT_CONNECT_TIMEOUT_MS 20000 /*!< Connection timeout (in ms) */
3333
#define AIRLIFT_CONNECT_RETRY_DELAY_MS 200 /*!< delay time between retries. */
3434

3535
#define SPIWIFI SPI /*!< Instance of SPI interface used by an AirLift. */
3636

37-
extern Wippersnapper WS; ///< Global Wippersnapper instance
37+
extern Wippersnapper_V2 WsV2; ///< Wippersnapper client instance
3838
/****************************************************************************/
3939
/*!
4040
@brief Class for using the AirLift Co-Processor network iface.
4141
*/
4242
/****************************************************************************/
43-
class ws_wifi_airlift : public Wippersnapper {
43+
class ws_wifi_airlift : public Wippersnapper_V2 {
4444

4545
public:
4646
/**************************************************************************/
4747
/*!
4848
@brief Initializes the Adafruit IO class for AirLift devices.
4949
*/
5050
/**************************************************************************/
51-
ws_wifi_airlift() : Wippersnapper() {
51+
ws_wifi_airlift() : Wippersnapper_V2() {
5252
_ssPin = SPIWIFI_SS; // 10;
5353
_ackPin = SPIWIFI_ACK; // 7;
5454
_rstPin = SPIWIFI_RESET; // 5; // should be 7 on PyPortals
@@ -72,8 +72,8 @@ class ws_wifi_airlift : public Wippersnapper {
7272
*/
7373
/**************************************************************************/
7474
~ws_wifi_airlift() {
75-
if (_mqtt)
76-
delete _mqtt;
75+
if (_mqttV2)
76+
delete _mqttV2;
7777
}
7878

7979
/**********************************************************/
@@ -97,8 +97,8 @@ class ws_wifi_airlift : public Wippersnapper {
9797
*/
9898
/**********************************************************/
9999
void set_ssid_pass() {
100-
_ssid = WS._config.network.ssid;
101-
_pass = WS._config.network.pass;
100+
_ssid = WsV2._configV2.network.ssid;
101+
_pass = WsV2._configV2.network.pass;
102102
}
103103

104104
/***********************************************************/
@@ -231,7 +231,7 @@ class ws_wifi_airlift : public Wippersnapper {
231231
void getMacAddr() {
232232
uint8_t mac[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
233233
WiFi.macAddress(mac);
234-
memcpy(WS._macAddr, mac, sizeof(mac));
234+
memcpy(WsV2._macAddrV2, mac, sizeof(mac));
235235
}
236236

237237
/********************************************************/
@@ -250,9 +250,9 @@ class ws_wifi_airlift : public Wippersnapper {
250250
*/
251251
/********************************************************/
252252
void setupMQTTClient(const char *clientID) {
253-
WS._mqtt = new Adafruit_MQTT_Client(
254-
_mqtt_client, WS._config.aio_url, WS._config.io_port, clientID,
255-
WS._config.aio_user, WS._config.aio_key);
253+
WsV2._mqttV2 = new Adafruit_MQTT_Client(
254+
_mqtt_client, WsV2._configV2.aio_url, WsV2._configV2.io_port, clientID,
255+
WsV2._configV2.aio_user, WsV2._configV2.aio_key);
256256
}
257257

258258
/********************************************************/
@@ -300,7 +300,7 @@ class ws_wifi_airlift : public Wippersnapper {
300300
/**************************************************************************/
301301
void _connect() {
302302
if (strlen(_ssid) == 0) {
303-
_status = WS_SSID_INVALID; // possibly unneccesary as already checking
303+
_statusV2 = WS_SSID_INVALID; // possibly unneccesary as already checking
304304
// elsewhere
305305
} else {
306306
// disconnect from possible previous connection
@@ -310,16 +310,16 @@ class ws_wifi_airlift : public Wippersnapper {
310310
_wifi->end();
311311
delay(100);
312312
_wifi->begin();
313-
feedWDT();
313+
WsV2.feedWDTV2();
314314
// reset the esp32 if possible
315315
resetAirLift();
316-
feedWDT();
316+
WsV2.feedWDTV2();
317317

318318
WS_DEBUG_PRINT("ESP32 booted, version: ");
319319
WS_PRINTER.flush();
320320
WS_DEBUG_PRINTLN(WiFi.firmwareVersion());
321321
WS_PRINTER.flush();
322-
feedWDT();
322+
WsV2.feedWDTV2();
323323

324324
// validate co-processor's firmware version
325325
if (!firmwareCheck()) {
@@ -330,26 +330,25 @@ class ws_wifi_airlift : public Wippersnapper {
330330
WS_DEBUG_PRINT("Connecting to ");
331331
WS_DEBUG_PRINTLN(_ssid);
332332
WS_PRINTER.flush();
333-
feedWDT();
333+
WsV2.feedWDTV2();
334334
WiFi.begin(_ssid, _pass);
335-
_status = WS_NET_DISCONNECTED;
335+
_statusV2 = WS_NET_DISCONNECTED;
336336

337337
// Use the macro to retry the status check until connected / timed out
338338
int lastResult = -1;
339339
RETRY_FUNCTION_UNTIL_TIMEOUT(
340340
[]() -> int { return WiFi.status(); }, // Function call each cycle
341-
int, // return type
342341
lastResult, // return variable
343342
[](int status) { return status == WL_CONNECTED; }, // check
344343
AIRLIFT_CONNECT_TIMEOUT_MS, // timeout interval (ms)
345344
AIRLIFT_CONNECT_RETRY_DELAY_MS); // interval between retries
346345

347346
if (lastResult == WL_CONNECTED) {
348-
_status = WS_NET_CONNECTED;
347+
_statusV2 = WS_NET_CONNECTED;
349348
// wait 2seconds for connection to stabilize
350349
WS_DELAY_WITH_WDT(2000);
351350
} else {
352-
_status = WS_NET_DISCONNECTED; // maybe connect failed instead?
351+
_statusV2 = WS_NET_DISCONNECTED; // maybe connect failed instead?
353352
}
354353
}
355354
}

src/helpers/ws_helper_macros.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
while (millis() - start < timeout) { \
2626
delay(10); \
2727
yield(); \
28-
feedWDT(); \
28+
WsV2.feedWDTV2(); \
2929
if (millis() < start) { \
3030
start = millis(); /* if rollover */ \
3131
} \
@@ -51,12 +51,12 @@
5151
The arguments to pass to the function.
5252
*/
5353
/**************************************************************************/
54-
#define RETRY_FUNCTION_UNTIL_TIMEOUT(func, result_type, result_var, condition, \
54+
#define RETRY_FUNCTION_UNTIL_TIMEOUT(func, result_var, condition, \
5555
timeout, interval, ...) \
5656
{ \
5757
unsigned long startTime = millis(); \
5858
while (millis() - startTime < timeout) { \
59-
result_type result_var = func(__VA_ARGS__); \
59+
result_var = func(__VA_ARGS__); \
6060
if (condition(result_var)) { \
6161
break; \
6262
} \

0 commit comments

Comments
 (0)