Skip to content

Commit 017c826

Browse files
author
Marcus Peterson
committed
attachment status
One problem with the MKRNB is that sometimes when the sim card inside of the MKRNB has the status of attached, which essentially means that the sim card will be attached to the MCU, this can cause connections issues, so if you accidentally attached it, you can now easily check the status
1 parent eabf10b commit 017c826

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/GPRS.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,37 @@ int GPRS::ready()
162162
return ready;
163163
}
164164

165+
//Check to see if the sim card that is inside the MKRNB is attached or detached to a LTE-M provideer
166+
NB_NetworkStatus_t GPRS::checkAttachmentStatus()
167+
{
168+
MODEM.setResponseDataStorage(&_response);
169+
MODEM.send("AT+CGATT?");
170+
_state = GPRS_STATE_WAIT_CHECK_ATTACHED_RESPONSE;
171+
172+
int ready = 0;
173+
174+
while (ready == 0) {
175+
ready = MODEM.ready();
176+
177+
if (ready > 1) {
178+
_state = GPRS_STATE_IDLE;
179+
_status = NB_ERROR;
180+
break;
181+
}
182+
183+
delay(500);
184+
}
185+
186+
if (_response.indexOf("1,1") >= 0) {
187+
_state = GPRS_STATE_IDLE;
188+
return GPRS_READY;
189+
} else {
190+
_state = GPRS_STATE_IDLE;
191+
return IDLE;
192+
}
193+
}
194+
195+
165196
IPAddress GPRS::getIPAddress()
166197
{
167198
String response;

src/GPRS.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class GPRS {
6363
*/
6464
NB_NetworkStatus_t detachGPRS(bool synchronous = true);
6565

66+
NB_NetworkStatus_t checkAttachmentStatus();
67+
6668
/** Get actual assigned IP address in IPAddress format
6769
@return IP address in IPAddress format
6870
*/

0 commit comments

Comments
 (0)