Skip to content

Commit b1799e6

Browse files
committed
feat: NotecardConnectionManager
1 parent d05d54c commit b1799e6

7 files changed

+1146
-9
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode/

examples/ConnectionHandlerDemo/ConnectionHandlerDemo.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131

3232
#include <Arduino_ConnectionHandler.h>
3333

34-
#if defined(BOARD_HAS_ETHERNET)
34+
#if defined(USE_NOTECARD)
35+
NotecardConnectionHandler conMan(SECRET_NOTEHUB_PROJECT);
36+
#elif defined(BOARD_HAS_ETHERNET)
3537
EthernetConnectionHandler conMan(SECRET_IP, SECRET_DNS, SECRET_GATEWAY, SECRET_NETMASK);
3638
#elif defined(BOARD_HAS_WIFI)
3739
WiFiConnectionHandler conMan(SECRET_SSID, SECRET_PASS);

examples/ConnectionHandlerDemo/arduino_secrets.h

+2
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ const char SECRET_IP[] = "IP ADDRESS";
1717
const char SECRET_DNS[] = "DNS ADDRESS";
1818
const char SECRET_GATEWAY[] = "GATEWAY ADDRESS";
1919
const char SECRET_NETMASK[] = "NETWORK MASK";
20+
21+
const char SECRET_NOTEHUB_PROJECT[] = "PROJECT UID";

library.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name=Arduino_ConnectionHandler
22
version=0.9.0
33
author=Ubi de Feo, Cristian Maglie, Andrea Catozzi, Alexander Entinger et al.
44
maintainer=Arduino <[email protected]>
5-
sentence=Arduino Library for network connection management (WiFi, GSM, NB, [Ethernet])
5+
sentence=Arduino Library for network connection management (WiFi, GSM, NB, [Ethernet], Notecard)
66
paragraph=Originally part of ArduinoIoTCloud
77
category=Communication
88
url=https://github.com/arduino-libraries/Arduino_ConnectionHandler
99
architectures=samd,esp32,esp8266,mbed,megaavr,mbed_nano,mbed_portenta,mbed_nicla,mbed_opta,mbed_giga,renesas_portenta,renesas_uno,mbed_edge
10-
depends=Arduino_DebugUtils, WiFi101, WiFiNINA, MKRGSM, MKRNB, MKRWAN
10+
depends=Arduino_DebugUtils, Blues Wireless Notecard (>=1.6.0), WiFi101, WiFiNINA, MKRGSM, MKRNB, MKRWAN

src/Arduino_ConnectionHandler.h

+16-6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
#include <Arduino.h>
3030

31+
#ifndef USE_NOTECARD
32+
3133
#ifdef ARDUINO_SAMD_MKR1000
3234
#include <WiFi101.h>
3335
#include <WiFiUdp.h>
@@ -179,6 +181,8 @@
179181
#define NETWORK_HARDWARE_ERROR
180182
#endif
181183

184+
#endif // USE_NOTECARD
185+
182186
/******************************************************************************
183187
TYPEDEFS
184188
******************************************************************************/
@@ -206,7 +210,8 @@ enum class NetworkAdapter {
206210
GSM,
207211
LORA,
208212
CATM1,
209-
CELL
213+
CELL,
214+
NOTECARD
210215
};
211216

212217
typedef void (*OnNetworkEventCallback)();
@@ -239,11 +244,13 @@ class ConnectionHandler {
239244

240245
ConnectionHandler(bool const keep_alive, NetworkAdapter interface);
241246

242-
243247
NetworkConnectionState check();
244248

245249
#if !defined(BOARD_HAS_LORA)
246250
virtual unsigned long getTime() = 0;
251+
#endif
252+
253+
#if !defined(BOARD_HAS_LORA) && !defined(USE_NOTECARD)
247254
virtual Client &getClient() = 0;
248255
virtual UDP &getUDP() = 0;
249256
#else
@@ -279,16 +286,19 @@ class ConnectionHandler {
279286
virtual NetworkConnectionState update_handleDisconnecting() = 0;
280287
virtual NetworkConnectionState update_handleDisconnected () = 0;
281288

282-
283289
private:
284290

285291
unsigned long _lastConnectionTickTime;
286292
NetworkConnectionState _current_net_connection_state;
287-
OnNetworkEventCallback _on_connect_event_callback = NULL,
288-
_on_disconnect_event_callback = NULL,
289-
_on_error_event_callback = NULL;
293+
OnNetworkEventCallback _on_connect_event_callback = NULL,
294+
_on_disconnect_event_callback = NULL,
295+
_on_error_event_callback = NULL;
290296
};
291297

298+
#if defined(USE_NOTECARD)
299+
#include "Arduino_NotecardConnectionHandler.h"
300+
#endif
301+
292302
#if defined(BOARD_HAS_WIFI)
293303
#include "Arduino_WiFiConnectionHandler.h"
294304
#elif defined(BOARD_HAS_GSM)

0 commit comments

Comments
 (0)