Skip to content

Commit c2b3d30

Browse files
committed
Add GPRS::status() API to retrieve the current GPRS status
1 parent ae6889d commit c2b3d30

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/GPRS.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,13 @@ int GPRS::ping(IPAddress ip, uint8_t ttl)
358358
return ping(host, ttl);
359359
}
360360

361+
GSM3_NetworkStatus_t GPRS::status()
362+
{
363+
MODEM.poll();
364+
365+
return _status;
366+
}
367+
361368
void GPRS::handleUrc(const String& urc)
362369
{
363370
if (urc.startsWith("+UUPINGER: ")) {
@@ -380,5 +387,12 @@ void GPRS::handleUrc(const String& urc)
380387
_pingResult = GPRS_PING_ERROR;
381388
}
382389
}
390+
} else if (urc.startsWith("+UUPSDD: ")) {
391+
int profileId = urc.charAt(urc.length() - 1) - '0';
392+
393+
if (profileId == 0) {
394+
// disconnected
395+
_status = IDLE;
396+
}
383397
}
384398
}

src/GPRS.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class GPRS : public ModemUrcHandler {
8888
int ping(const String& hostname, uint8_t ttl = 128);
8989
int ping(IPAddress ip, uint8_t ttl = 128);
9090

91+
GSM3_NetworkStatus_t status();
92+
9193
void handleUrc(const String& urc);
9294

9395
private:

0 commit comments

Comments
 (0)