- Notifications
You must be signed in to change notification settings - Fork37
License
NotificationsYou must be signed in to change notification settings
arduino-libraries/Arduino_ConnectionHandler
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Library for handling and managing network connections by providing keep-alive functionality and automatic reconnection in case of connection-loss. It supports the following boards:
- WiFi:
MKR 1000
,MKR WiFi 1010
,Nano 33 IoT
,Portenta H7
,Nano RP2040 Connect
,Nicla Vision
,OPTA WiFi
,GIGA R1 WiFi
,Portenta C33
,UNO R4 WiFi
,Nano ESP32
,ESP8266
,ESP32
- GSM:
MKR GSM 1400
- 5G:
MKR NB 1500
- LoRa:
MKR WAN 1300/1310
- Ethernet:
Portenta H7
+Vision Shield Ethernet
,Max Carrier
,Breakout
,Portenta Machine Control
,OPTA WiFi
,OPTA RS485
,OPTA Lite
,Portenta C33
+Vision Shield Ethernet
- Notecard:Provides Cellular/LoRa/Satellite/Wi-Fi to any modern board/architecture
#include<Arduino_ConnectionHandler.h>/* ...*/#if defined(BOARD_HAS_NOTECARD)NotecardConnectionHandlerconMan("com.domain.you:product");#elif defined(BOARD_HAS_ETHERNET)EthernetConnectionHandler conMan;#elif defined(BOARD_HAS_WIFI)WiFiConnectionHandlerconMan("SECRET_WIFI_SSID","SECRET_WIFI_PASS");#elif defined(BOARD_HAS_GSM)GSMConnectionHandlerconMan("SECRET_PIN","SECRET_APN","SECRET_GSM_LOGIN","SECRET_GSM_PASS");#elif defined(BOARD_HAS_NB)NBConnectionHandlerconMan("SECRET_PIN","SECRET_APN","SECRET_GSM_LOGIN","SECRET_GSM_PASS");#elif defined(BOARD_HAS_LORA)LoRaConnectionHandlerconMan("SECRET_APP_EUI","SECRET_APP_KEY");#endif/* ...*/voidsetup() { Serial.begin(9600);while(!Serial) { }setDebugMessageLevel(DBG_INFO); conMan.addCallback(NetworkConnectionEvent::CONNECTED, onNetworkConnect); conMan.addCallback(NetworkConnectionEvent::DISCONNECTED, onNetworkDisconnect); conMan.addCallback(NetworkConnectionEvent::ERROR, onNetworkError);}voidloop() {/* The following code keeps on running connection workflows on our * ConnectionHandler object, hence allowing reconnection in case of failure * and notification of connect/disconnect event if enabled (see * addConnectCallback/addDisconnectCallback) NOTE: any use of delay() within * the loop or methods called from it will delay the execution of .check(), * which might not guarantee the correct functioning of the ConnectionHandler * object.*/ conMan.check();}/* ...*/voidonNetworkConnect() { Serial.println(">>>> CONNECTED to network");}voidonNetworkDisconnect() { Serial.println(">>>> DISCONNECTED from network");}voidonNetworkError() { Serial.println(">>>> ERROR");}
About
No description, website, or topics provided.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.