@@ -150,8 +150,6 @@ def _init_fona(self):
150150 # determine if SIM800H
151151 self .uart_write (b"AT+GMM\r \n " )
152152 self ._read_line (multiline = True )
153- if self ._debug :
154- print ("\t <---" , self ._buf )
155153
156154 if self ._buf .find (b"SIM800H" ) != - 1 :
157155 self ._fona_type = FONA_800_H
@@ -287,8 +285,6 @@ def set_gprs(self, apn=None, enable=True):
287285 )
288286
289287 # send AT+CSTT,"apn","user","pass"
290- if self ._debug :
291- print ("setting APN..." )
292288 self ._uart .reset_input_buffer ()
293289
294290 self .uart_write (b'AT+CSTT="' + apn_name )
@@ -481,8 +477,6 @@ def get_host_by_name(self, hostname):
481477 while not self ._parse_reply (b"+CDNSGIP:" , idx = 2 ):
482478 self ._read_line ()
483479
484- if self ._debug :
485- print ("\t <--- " , self ._buf )
486480 return self ._buf
487481
488482 def pretty_ip (self , ip ): # pylint: disable=no-self-use, invalid-name
@@ -519,7 +513,7 @@ def get_socket(self):
519513 for _ in range (allocated_socket , FONA_MAX_SOCKETS ):
520514 self ._read_line (100 )
521515 if self ._debug :
522- print ("Allocated socket #%d" % allocated_socket )
516+ print ("Allocated socket #%d" % allocated_socket )
523517 return allocated_socket
524518
525519 def remote_ip (self , sock_num ):
@@ -535,8 +529,6 @@ def remote_ip(self, sock_num):
535529 self ._read_line (100 )
536530
537531 self ._parse_reply (b"+CIPSTATUS:" , idx = 3 )
538- if self ._debug :
539- print ("\t <--- " , self ._buf )
540532 return self ._buf
541533
542534 def socket_status (self , sock_num ):
@@ -553,8 +545,6 @@ def socket_status(self, sock_num):
553545
554546 # eat the 'STATE: ' message
555547 self ._read_line ()
556- if self ._debug :
557- print ("\t <--- " , self ._buf )
558548
559549 # read "C: <n>" for each active connection
560550 for state in range (0 , sock_num + 1 ):
@@ -718,19 +708,13 @@ def socket_write(self, sock_num, buffer):
718708 self .uart_write (b"\r \n " )
719709 self ._read_line ()
720710
721- if self ._debug :
722- print ("\t <--- " , self ._buf )
723-
724711 if self ._buf [0 ] != 62 :
725712 # promoting mark ('>') not found
726713 return False
727714
728715 self .uart_write (buffer + b"\r \n " )
729716 self ._read_line (3000 )
730717
731- if self ._debug :
732- print ("\t <--- " , self ._buf )
733-
734718 if "SEND OK" not in self ._buf .decode ():
735719 return False
736720
@@ -744,15 +728,10 @@ def uart_write(self, buffer):
744728 :param bytes buffer: Buffer of bytes to send to the bus.
745729
746730 """
747- #out_buffer_str = ", ".join([hex(i) for i in buffer])
748731 if self ._debug :
749732 print ("\t UARTWRITE ::" , buffer .decode ())
750733 self ._uart .write (buffer )
751734
752- def uart_read (self ):
753- # TODO!
754- pass
755-
756735 def _send_parse_reply (self , send_data , reply_data , divider = "," , idx = 0 ):
757736 """Sends data to FONA module, parses reply data returned.
758737 :param bytes send_data: Data to send to the module.
@@ -782,9 +761,6 @@ def _get_reply(
782761 self .uart_write (prefix + suffix + b"\r \n " )
783762
784763 line = self ._read_line (timeout )
785-
786- if self ._debug :
787- print ("\t <--- " , self ._buf )
788764 return line
789765
790766 def _parse_reply (self , reply , divider = "," , idx = 0 ):
@@ -813,7 +789,8 @@ def _parse_reply(self, reply, divider=",", idx=0):
813789 return True
814790
815791 def _read_line (self , timeout = FONA_DEFAULT_TIMEOUT_MS , multiline = False ):
816- """Reads one or multiple lines into the buffer.
792+ """Reads one or multiple lines into the buffer. Optionally prints the buffer
793+ after reading.
817794 :param int timeout: Time to wait for UART serial to reply, in seconds.
818795 :param bool multiline: Read multiple lines.
819796
@@ -848,6 +825,9 @@ def _read_line(self, timeout=FONA_DEFAULT_TIMEOUT_MS, multiline=False):
848825 timeout -= 1
849826 time .sleep (0.001 )
850827
828+ if self ._debug :
829+ print ("\t UARTREAD ::" , self ._buf .decode ())
830+
851831 return reply_idx
852832
853833 def _send_check_reply (
@@ -909,9 +889,6 @@ def _get_reply_quoted(self, prefix, suffix, timeout):
909889 self .uart_write (suffix + b'"\r \n ' )
910890
911891 line = self ._read_line (timeout )
912- if self ._debug :
913- print ("\t <--- " , self ._buf )
914-
915892 return line
916893
917894 def _expect_reply (self , reply , timeout = 10000 ):
@@ -920,8 +897,6 @@ def _expect_reply(self, reply, timeout=10000):
920897
921898 """
922899 self ._read_line (timeout )
923- if self ._debug :
924- print ("\t <--- " , self ._buf )
925900 if reply not in self ._buf :
926901 return False
927902 return True
0 commit comments