File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -51,9 +51,40 @@ UDP & CellularConnectionHandler::getUDP()
5151 PROTECTED MEMBER FUNCTIONS
5252 ******************************************************************************/
5353
54+ #if defined(ARDUINO_OPTA) && defined(BOARD_HAS_CELLULAR)
55+ CellularExpansion ce;
56+ static void beginOptaCellular () {
57+ static bool first_call = true ;
58+
59+ if (first_call) {
60+ first_call = false ;
61+ OptaController.registerCustomExpansion (CellularExpansion::getProduct (),
62+ CellularExpansion::makeExpansion,
63+ CellularExpansion::startUp);
64+ OptaController.begin ();
65+ delay (500 );
66+ for (int i = 0 ; i < OptaController.getExpansionNum (); i++) {
67+ ce = OptaController.getExpansion (i);
68+ if (ce) {
69+ ce.ctrlModem (true );
70+ delay (100 );
71+ break ;
72+ }
73+ }
74+ }
75+ else {
76+ OptaController.update ();
77+ }
78+ }
79+ #endif
80+
5481NetworkConnectionState CellularConnectionHandler::update_handleInit ()
5582{
83+ #if defined(ARDUINO_OPTA) && defined(BOARD_HAS_CELLULAR)
84+ beginOptaCellular ();
85+ #else
5686 _cellular.begin ();
87+ #endif
5788 _cellular.setDebugStream (Serial);
5889 if (String (_pin).length () > 0 && !_cellular.unlockSIM (_pin)) {
5990 Debug.print (DBG_ERROR, F (" SIM not present or wrong PIN" ));
Original file line number Diff line number Diff line change 2020
2121#if defined(ARDUINO_PORTENTA_C33) || defined(ARDUINO_PORTENTA_H7_M7)
2222#include < Arduino_Cellular.h>
23+ #elif defined(ARDUINO_OPTA)
24+ #include < Arduino_OptaCellular.h>
2325#endif
2426
2527#ifndef BOARD_HAS_CELLULAR
@@ -57,8 +59,12 @@ class CellularConnectionHandler : public ConnectionHandler
5759 const char * _apn;
5860 const char * _login;
5961 const char * _pass;
60-
62+
63+ #if defined(ARDUINO_OPTA)
64+ ArduinoCellular &_cellular = CellularExpansion::getCellular();
65+ #else
6166 ArduinoCellular _cellular;
67+ #endif
6268 TinyGsmClient _gsm_client = _cellular.getNetworkClient();
6369};
6470
Original file line number Diff line number Diff line change 8181#if defined(ARDUINO_OPTA )
8282 #define BOARD_HAS_WIFI
8383 #define BOARD_HAS_ETHERNET
84+ #define BOARD_HAS_CELLULAR
8485 #define NETWORK_HARDWARE_ERROR WL_NO_SHIELD
8586 #define NETWORK_IDLE_STATUS WL_IDLE_STATUS
8687 #define NETWORK_CONNECTED WL_CONNECTED
You can’t perform that action at this time.
0 commit comments