Skip to content

Commit 1cecbf2

Browse files
committed
Introducing Arduino Opta Cellular as possible connection source for Arduino Opta
1 parent 3885f18 commit 1cecbf2

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/CellularConnectionHandler.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,40 @@ UDP & CellularConnectionHandler::getUDP()
5454
PROTECTED MEMBER FUNCTIONS
5555
******************************************************************************/
5656

57+
#if defined(ARDUINO_OPTA) && defined(BOARD_HAS_CELLULAR)
58+
CellularExpansion ce;
59+
static void beginOptaCellular() {
60+
static bool first_call = true;
61+
62+
if(first_call) {
63+
first_call = false;
64+
OptaController.registerCustomExpansion(CellularExpansion::getProduct(),
65+
CellularExpansion::makeExpansion,
66+
CellularExpansion::startUp);
67+
OptaController.begin();
68+
delay(500);
69+
for (int i = 0; i < OptaController.getExpansionNum(); i++) {
70+
ce = OptaController.getExpansion(i);
71+
if(ce) {
72+
ce.ctrlModem(true);
73+
delay(100);
74+
break;
75+
}
76+
}
77+
}
78+
else {
79+
OptaController.update();
80+
}
81+
}
82+
#endif
83+
5784
NetworkConnectionState CellularConnectionHandler::update_handleInit()
5885
{
86+
#if defined(ARDUINO_OPTA) && defined(BOARD_HAS_CELLULAR)
87+
beginOptaCellular();
88+
#else
5989
_cellular.begin();
90+
#endif
6091
_cellular.setDebugStream(Serial);
6192
if (strlen(_settings.cell.pin) > 0 && !_cellular.unlockSIM(_settings.cell.pin)) {
6293
DEBUG_ERROR(F("SIM not present or wrong PIN"));

src/ConnectionHandlerDefinitions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#if defined(ARDUINO_OPTA)
7575
#define BOARD_HAS_WIFI
7676
#define BOARD_HAS_ETHERNET
77+
#define BOARD_HAS_CELLULAR
7778
#define NETWORK_HARDWARE_ERROR WL_NO_SHIELD
7879
#define NETWORK_IDLE_STATUS WL_IDLE_STATUS
7980
#define NETWORK_CONNECTED WL_CONNECTED

0 commit comments

Comments
 (0)