Skip to content

Commit 126f430

Browse files
committed
[SD] Add debug output to adapter classes, valid return values where applicable to properly indicate its a stub class, add pico to ini
1 parent e3e6ff3 commit 126f430

File tree

3 files changed

+74
-48
lines changed

3 files changed

+74
-48
lines changed

platformio.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,15 @@ build_flags = -DUSE_TINYUSB
418418
; Once https://github.com/platformio/platformio-core > 6.1.11 these can be removed
419419
lib_ignore = WiFiNINA, WiFi101, Adafruit Zero DMA Library
420420

421+
[env:raspberrypi_pico]
422+
platform = https://github.com/maxgerhardt/platform-raspberrypi.git#develop
423+
board = rpipico
424+
platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git
425+
board_build.filesystem_size = 0.5m
426+
build_flags = -DUSE_TINYUSB
427+
; Once https://github.com/platformio/platformio-core > 6.1.11 these can be removed
428+
lib_ignore = WiFiNINA, WiFi101, Adafruit Zero DMA Library
429+
421430
[env:raspberypi_picow]
422431
extends = common:rp2040
423432

src/adapters/offline/ws_offline_pico.h

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
/*!
22
* @file ws_offline_pico.h
33
*
4-
* This is a driver for using the Raspberry Pi Pico/Pico2
5-
* without a network interface with Adafruit IO Wippersnapper.
4+
* This is a stub class for using the RP2040/RP2350 without a network interface
65
*
76
* Adafruit invests time and resources providing this open source code,
87
* please support Adafruit and open-source hardware by purchasing
98
* products from Adafruit!
109
*
11-
* Copyright (c) Brent Rubell 2024-2025 for Adafruit Industries.
10+
* Copyright (c) Brent Rubell 2025 for Adafruit Industries.
1211
*
1312
* MIT license, all text here must be included in any redistribution.
1413
*
@@ -22,8 +21,8 @@
2221
#define PICO_CONNECT_TIMEOUT_MS 20000 /*!< Connection timeout (in ms) */
2322
#define PICO_CONNECT_RETRY_DELAY_MS 200 /*!< delay time between retries. */
2423

25-
#include "Wippersnapper.h"
2624
#include "Arduino.h"
25+
#include "Wippersnapper.h"
2726

2827
extern Wippersnapper WS;
2928

@@ -41,8 +40,7 @@ class ws_offline_pico : public Wippersnapper {
4140
*/
4241
/**************************************************************************/
4342
ws_offline_pico() : Wippersnapper() {
44-
_ssid = 0;
45-
_pass = 0;
43+
// do-nothing
4644
}
4745

4846
/**************************************************************************/
@@ -51,7 +49,7 @@ class ws_offline_pico : public Wippersnapper {
5149
*/
5250
/**************************************************************************/
5351
~ws_offline_pico() {
54-
// Do nothing
52+
// do-nothing - this class has no resources to release
5553
}
5654

5755
/********************************************************/
@@ -64,7 +62,8 @@ class ws_offline_pico : public Wippersnapper {
6462
*/
6563
/********************************************************/
6664
void set_ssid_pass(const char *ssid, const char *ssidPassword) {
67-
// Do nothing
65+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: set_ssid_pass is not supported "
66+
"in this implementation!");
6867
}
6968

7069
/**********************************************************/
@@ -73,7 +72,8 @@ class ws_offline_pico : public Wippersnapper {
7372
*/
7473
/**********************************************************/
7574
void set_ssid_pass() {
76-
// Do nothing
75+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: set_ssid_pass is not supported "
76+
"in this implementation!");
7777
}
7878

7979
/***********************************************************/
@@ -83,6 +83,8 @@ class ws_offline_pico : public Wippersnapper {
8383
*/
8484
/***********************************************************/
8585
bool check_valid_ssid() {
86+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: check_valid_ssid is not "
87+
"supported in this implementation!");
8688
return false;
8789
}
8890

@@ -93,7 +95,8 @@ class ws_offline_pico : public Wippersnapper {
9395
*/
9496
/********************************************************/
9597
void getMacAddr() {
96-
// Do nothing
98+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: getMacAddr() is not supported "
99+
"in this implementation!");
97100
}
98101

99102
/********************************************************/
@@ -102,7 +105,11 @@ class ws_offline_pico : public Wippersnapper {
102105
@return int32_t RSSI value
103106
*/
104107
/********************************************************/
105-
int32_t getRSSI() { return 0; }
108+
int32_t getRSSI() {
109+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: getRSSI() is not supported in "
110+
"this implementation!");
111+
return -9999; // return an invalid value
112+
}
106113

107114
/********************************************************/
108115
/*!
@@ -112,7 +119,8 @@ class ws_offline_pico : public Wippersnapper {
112119
*/
113120
/********************************************************/
114121
void setupMQTTClient(const char *clientID) {
115-
// Do nothing
122+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: setupMQTTClient() is not "
123+
"supported in this implementation!");
116124
}
117125

118126
/********************************************************/
@@ -122,7 +130,10 @@ class ws_offline_pico : public Wippersnapper {
122130
*/
123131
/********************************************************/
124132
ws_status_t networkStatus() {
125-
return WS_NET_DISCONNECTED;
133+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: networkStatus() is not "
134+
"supported in this implementation!");
135+
return WS_NET_DISCONNECTED; // this value is valid, we are not connected to
136+
// a network
126137
}
127138

128139
/*******************************************************************/
@@ -131,28 +142,27 @@ class ws_offline_pico : public Wippersnapper {
131142
@return Pico
132143
*/
133144
/*******************************************************************/
134-
const char *connectionType() { return "Pico-NoNet"; }
145+
const char *connectionType() { return "ws-offline-pico"; }
135146

136147
protected:
137-
const char *_ssid; ///< WiFi SSID
138-
const char *_pass; ///< WiFi password
139-
140148
/**************************************************************************/
141149
/*!
142-
@brief Establishes a connection with the wireless network.
150+
@brief Establishes a connection with a wireless network.
143151
*/
144152
/**************************************************************************/
145153
void _connect() {
146-
// Do nothing
154+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: _connect() is not supported in "
155+
"this implementation!");
147156
}
148157

149158
/**************************************************************************/
150159
/*!
151-
@brief Disconnects from the wireless network.
160+
@brief Disconnects from a wireless network.
152161
*/
153162
/**************************************************************************/
154163
void _disconnect() {
155-
// Do nothing
164+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: _connect() is not supported in "
165+
"this implementation!");
156166
}
157167
};
158168

src/adapters/offline/ws_offline_pico_v2.h

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
/*!
22
* @file ws_offline_pico_v2.h
33
*
4-
* This is a driver for using the Raspberry Pi Pi Pico/Pico2
5-
* without a network interface with Adafruit IO Wippersnapper.
4+
* This is a stub class for using the RP2040/RP2350 without a network interface
65
*
76
* Adafruit invests time and resources providing this open source code,
87
* please support Adafruit and open-source hardware by purchasing
98
* products from Adafruit!
109
*
11-
* Copyright (c) Brent Rubell 2024-2025 for Adafruit Industries.
10+
* Copyright (c) Brent Rubell 2025 for Adafruit Industries.
1211
*
1312
* MIT license, all text here must be included in any redistribution.
1413
*
@@ -22,8 +21,8 @@
2221
#define PICO_CONNECT_TIMEOUT_MS 20000 /*!< Connection timeout (in ms) */
2322
#define PICO_CONNECT_RETRY_DELAY_MS 200 /*!< delay time between retries. */
2423

25-
#include "Wippersnapper_V2.h"
2624
#include "Arduino.h"
25+
#include "Wippersnapper_V2.h"
2726

2827
extern Wippersnapper_V2 WsV2;
2928

@@ -41,8 +40,7 @@ class ws_offline_pico_v2 : public Wippersnapper_V2 {
4140
*/
4241
/**************************************************************************/
4342
ws_offline_pico_v2() : Wippersnapper_V2() {
44-
45-
// No-op
43+
// Do-nothing
4644
}
4745

4846
/**************************************************************************/
@@ -51,7 +49,7 @@ class ws_offline_pico_v2 : public Wippersnapper_V2 {
5149
*/
5250
/**************************************************************************/
5351
~ws_offline_pico_v2() {
54-
// No-op
52+
// Do-nothing - this class has no resources to release
5553
}
5654

5755
/********************************************************/
@@ -64,8 +62,8 @@ class ws_offline_pico_v2 : public Wippersnapper_V2 {
6462
*/
6563
/********************************************************/
6664
void set_ssid_pass(const char *ssid, const char *ssidPassword) {
67-
// No-op
68-
WS_DEBUG_PRINTLN("Code should not get here!");
65+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: set_ssid_pass() is not "
66+
"supported in this implementation!");
6967
}
7068

7169
/**********************************************************/
@@ -74,7 +72,8 @@ class ws_offline_pico_v2 : public Wippersnapper_V2 {
7472
*/
7573
/**********************************************************/
7674
void set_ssid_pass() {
77-
WS_DEBUG_PRINTLN("Code should not get here!");
75+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: set_ssid_pass() is not "
76+
"supported in this implementation!");
7877
}
7978

8079
/***********************************************************/
@@ -84,8 +83,9 @@ class ws_offline_pico_v2 : public Wippersnapper_V2 {
8483
*/
8584
/***********************************************************/
8685
bool check_valid_ssid() {
87-
WS_DEBUG_PRINTLN("Code should not get here!");
88-
return false;
86+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: check_valid_ssid() is not "
87+
"supported in this implementation!");
88+
return false; // return an invalid value
8989
}
9090

9191
/********************************************************/
@@ -95,7 +95,8 @@ class ws_offline_pico_v2 : public Wippersnapper_V2 {
9595
*/
9696
/********************************************************/
9797
void getMacAddr() {
98-
WS_DEBUG_PRINTLN("Code should not get here!");
98+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: getMacAddr() is not supported "
99+
"in this implementation!");
99100
}
100101

101102
/********************************************************/
@@ -104,9 +105,11 @@ class ws_offline_pico_v2 : public Wippersnapper_V2 {
104105
@return int32_t RSSI value
105106
*/
106107
/********************************************************/
107-
int32_t getRSSI() {
108-
WS_DEBUG_PRINTLN("Code should not get here!");
109-
return 0; }
108+
int32_t getRSSI() {
109+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: getRSSI() is not supported in "
110+
"this implementation!");
111+
return -9999; // return an invalid value
112+
}
110113

111114
/********************************************************/
112115
/*!
@@ -116,8 +119,8 @@ class ws_offline_pico_v2 : public Wippersnapper_V2 {
116119
*/
117120
/********************************************************/
118121
void setupMQTTClient(const char *clientID) {
119-
// No-op
120-
WS_DEBUG_PRINTLN("Code should not get here!");
122+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: setupMQTTClient() is not "
123+
"supported in this implementation!");
121124
}
122125

123126
/********************************************************/
@@ -127,8 +130,10 @@ class ws_offline_pico_v2 : public Wippersnapper_V2 {
127130
*/
128131
/********************************************************/
129132
ws_status_t networkStatus() {
130-
WS_DEBUG_PRINTLN("Code should not get here!");
131-
return WS_NET_DISCONNECTED;
133+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: networkStatus() is not "
134+
"supported in this implementation!");
135+
return WS_NET_DISCONNECTED; // this value is valid, we are not connected to
136+
// a network
132137
}
133138

134139
/*******************************************************************/
@@ -137,9 +142,11 @@ class ws_offline_pico_v2 : public Wippersnapper_V2 {
137142
@return Pico
138143
*/
139144
/*******************************************************************/
140-
const char *connectionType() {
141-
WS_DEBUG_PRINTLN("Code should not get here!");
142-
return "Pico-Nonet-v2"; }
145+
const char *connectionType() {
146+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: connectionType() is not "
147+
"supported in this implementation!");
148+
return "ws-offline-pico";
149+
}
143150

144151
protected:
145152
/**************************************************************************/
@@ -148,8 +155,8 @@ class ws_offline_pico_v2 : public Wippersnapper_V2 {
148155
*/
149156
/**************************************************************************/
150157
void _connect() {
151-
// No-op
152-
WS_DEBUG_PRINTLN("Code should not get here!");
158+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: _connect() is not supported in "
159+
"this implementation!");
153160
}
154161

155162
/**************************************************************************/
@@ -158,8 +165,8 @@ class ws_offline_pico_v2 : public Wippersnapper_V2 {
158165
*/
159166
/**************************************************************************/
160167
void _disconnect() {
161-
// No-op
162-
WS_DEBUG_PRINTLN("Code should not get here!");
168+
WS_DEBUG_PRINTLN("[ws_offline_pico] Error: _disconnect() is not supported "
169+
"in this implementation!");
163170
}
164171
};
165172

0 commit comments

Comments
 (0)