@@ -79,7 +79,7 @@ class FONA:
79
79
:param bool debug: Enable debugging output.
80
80
81
81
"""
82
-
82
+
83
83
# Connection modes
84
84
TCP_MODE = const (0 )
85
85
UDP_MODE = const (1 )
@@ -290,7 +290,9 @@ def _set_gprs(self, gprs_on=True):
290
290
return False
291
291
292
292
# disconnect all sockets
293
- if not self ._send_check_reply (b"AT+CIPSHUT" , reply = b"SHUT OK" , timeout = 20000 ):
293
+ if not self ._send_check_reply (
294
+ b"AT+CIPSHUT" , reply = b"SHUT OK" , timeout = 20000
295
+ ):
294
296
return False
295
297
296
298
if not self ._send_check_reply (b"AT+CGATT=1" , reply = REPLY_OK , timeout = 10000 ):
@@ -338,7 +340,9 @@ def _set_gprs(self, gprs_on=True):
338
340
return False
339
341
340
342
# Open GPRS context
341
- if not self ._send_check_reply (b"AT+SAPBR=1,1" , reply = REPLY_OK , timeout = 1850 ):
343
+ if not self ._send_check_reply (
344
+ b"AT+SAPBR=1,1" , reply = REPLY_OK , timeout = 1850
345
+ ):
342
346
return False
343
347
344
348
# Bring up wireless connection
@@ -514,7 +518,9 @@ def get_host_by_name(self, hostname):
514
518
515
519
if self ._debug :
516
520
print ("\t ---> AT+CDNSGIP=" , hostname )
517
- if not self ._send_check_reply (b'AT+CDNSGIP="' + hostname + b'"\r \n ' , reply = REPLY_OK ):
521
+ if not self ._send_check_reply (
522
+ b'AT+CDNSGIP="' + hostname + b'"\r \n ' , reply = REPLY_OK
523
+ ):
518
524
return False
519
525
520
526
# attempt to parse a response
@@ -536,14 +542,14 @@ def get_socket(self):
536
542
print ("*** Allocating Socket" )
537
543
538
544
self ._uart .write (b"AT+CIPSTATUS\r \n " )
539
- self ._read_line (100 ) # OK
540
- self ._read_line (100 ) # table header
545
+ self ._read_line (100 ) # OK
546
+ self ._read_line (100 ) # table header
541
547
542
548
for sock in range (0 , FONA_MAX_SOCKETS ):
543
549
# parse and check for INITIAL client state
544
550
self ._read_line (100 )
545
- self ._parse_reply (b'C:' , idx = 5 )
546
- if self ._buf .strip ('\ " ' ) == "INITIAL" or self ._buf .strip ('\ " ' ) == "CLOSED" :
551
+ self ._parse_reply (b"C:" , idx = 5 )
552
+ if self ._buf .strip ('"' ) == "INITIAL" or self ._buf .strip ('"' ) == "CLOSED" :
547
553
break
548
554
# read out the rest of the responses
549
555
for _ in range (sock , FONA_MAX_SOCKETS ):
@@ -688,7 +694,7 @@ def socket_close(self, sock_num, quick_close=1):
688
694
sockets for the FONA module."
689
695
self ._read_line ()
690
696
691
- self ._uart .write (b"AT+CIPCLOSE=" + str (sock_num ).encode () + b"," )
697
+ self ._uart .write (b"AT+CIPCLOSE=" + str (sock_num ).encode () + b"," )
692
698
self ._uart .write (str (sock_num ).encode () + b"\r \n " )
693
699
self ._read_line ()
694
700
if not self ._parse_reply (b"CLOSE OK" , idx = 0 ):
0 commit comments