Skip to content

Commit c6bad87

Browse files
committed
Correct GSM::isAccessAlive() implementation
1 parent 2354655 commit c6bad87

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/GSM.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,18 @@ GSM3_NetworkStatus_t GSM::begin(const char* pin, bool restart, bool synchronous)
7676

7777
int GSM::isAccessAlive()
7878
{
79-
return (MODEM.noop() == 1 ? 1 : 0);
79+
String response;
80+
81+
MODEM.send("AT+CREG?");
82+
if (MODEM.waitForResponse(100, &response) == 1) {
83+
int status = response.charAt(response.length() - 1) - '0';
84+
85+
if (status == 1 || status == 5 || status == 8) {
86+
return 1;
87+
}
88+
}
89+
90+
return 0;
8091
}
8192

8293
bool GSM::shutdown()

0 commit comments

Comments
 (0)