Skip to content

Commit 4beb004

Browse files
author
brentru
committed
only reset PDP
1 parent 07c1aad commit 4beb004

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

adafruit_fona/adafruit_fona.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ def _init_fona(self):
162162
while self._uart.in_waiting:
163163
if self._send_check_reply(CMD_AT, reply=REPLY_OK):
164164
break
165-
166-
#while self._uart.in_waiting:
167165
if self._send_check_reply(CMD_AT, reply=REPLY_AT):
168166
break
169167
time.sleep(0.5)
@@ -254,7 +252,7 @@ def gprs(self, gprs_on=True):
254252
if attempts == 0:
255253
raise RuntimeError("Unable to establish PDP context.")
256254
if self._debug:
257-
print("* Not registered with network, retrying, ", attempts)
255+
print("* Unable to bringup network, retrying, ", attempts)
258256
self._set_gprs(False)
259257
attempts -= 1
260258
time.sleep(5)
@@ -277,8 +275,8 @@ def _set_gprs(self, gprs_on=True):
277275
return False
278276
if self._debug:
279277
print("* Not registered with network, retrying, ", attempts)
280-
time.sleep(5)
281278
attempts -= 1
279+
time.sleep(5)
282280

283281
# enable multi connection mode (3,1)
284282
if not self._send_check_reply(b"AT+CIPMUX=1", reply=REPLY_OK):
@@ -346,22 +344,12 @@ def _set_gprs(self, gprs_on=True):
346344
return False
347345

348346
else:
349-
# reset pdp state
347+
# reset PDP state
350348
if not self._send_check_reply(
351349
b"AT+CIPSHUT", reply=b"SHUT OK", timeout=20000
352350
):
353351
return False
354352

355-
# close bearer
356-
if not self._send_check_reply(
357-
b"AT+SAPBR=0,1", reply=REPLY_OK, timeout=10000
358-
):
359-
return False
360-
361-
# detach from gprs service
362-
if not self._send_check_reply(b"AT+CGATT=0", reply=REPLY_OK, timeout=10000):
363-
return False
364-
365353
return True
366354

367355
@property
@@ -887,8 +875,6 @@ def _send_check_reply(
887875

888876
# validate response
889877
if not self._buf == reply:
890-
print("buf: ", self._buf, end="")
891-
print(" reply: ", reply)
892878
return False
893879

894880
return True

0 commit comments

Comments
 (0)