4444__version__ = "0.0.0-auto.0"
4545__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FONA.git"
4646
47- # pylint: disable=bad-whitespace
4847FONA_DEFAULT_TIMEOUT_MS = 500 # TODO: Check this against arduino...
4948
5049# Commands
6766# FONA preferred SMS storage
6867FONA_SMS_STORAGE_SIM = b'"SM"' # Storage on the SIM
6968FONA_SMS_STORAGE_INTERNAL = b'"ME"' # Internal storage on the FONA
70- # pylint: enable=bad-whitespace
7169
7270
7371# pylint: disable=too-many-instance-attributes, too-many-public-methods
@@ -177,12 +175,14 @@ def reset(self):
177175 @property
178176 # pylint: disable=too-many-return-statements
179177 def version (self ):
180- """Returns FONA Version."""
178+ """The version of the FONA module. Can be FONA_800_L,
179+ FONA_800_H, FONA_808_V1, FONA_808_V2, FONA_3G_A, FONA3G_E.
180+ """
181181 return self ._fona_type
182182
183183 @property
184184 def iemi (self ):
185- """Returns FONA module 's IEMI number."""
185+ """FONA Module 's IEMI (International Mobile Equipment Identity) number."""
186186 if self ._debug :
187187 print ("FONA IEMI" )
188188 self ._uart .reset_input_buffer ()
@@ -194,18 +194,18 @@ def iemi(self):
194194
195195 @property
196196 def local_ip (self ):
197- """Returns the local IP Address, False if not set."""
197+ """Module's local IP address, None if not set."""
198198 self ._uart_write (b"AT+CIFSR\r \n " )
199199 self ._read_line ()
200200 try :
201201 ip_addr = self .pretty_ip (self ._buf )
202202 except ValueError :
203- return False
203+ return None
204204 return ip_addr
205205
206206 @property
207207 def iccid (self ):
208- """Returns SIM Card's ICCID number as a string ."""
208+ """SIM Card's unique ICCID (Integrated Circuit Card Identifier) ."""
209209 if self ._debug :
210210 print ("ICCID" )
211211 self ._uart_write (b"AT+CCID\r \n " )
@@ -215,7 +215,7 @@ def iccid(self):
215215
216216 @property
217217 def gprs (self ):
218- """Returns module's GPRS state ."""
218+ """GPRS (General Packet Radio Services) power status ."""
219219 if not self ._send_parse_reply (b"AT+CGATT?" , b"+CGATT: " , ":" ):
220220 return False
221221 if not self ._buf :
@@ -311,7 +311,7 @@ def set_gprs(self, apn=None, enable=True):
311311
312312 @property
313313 def network_status (self ):
314- """Returns cellular network status """
314+ """The status of the cellular network. """
315315 self ._read_line ()
316316 if self ._debug :
317317 print ("Network status" )
@@ -324,7 +324,9 @@ def network_status(self):
324324
325325 @property
326326 def rssi (self ):
327- """Returns cellular network's Received Signal Strength Indicator (RSSI)."""
327+ """The received signal strength indicator for the cellular network
328+ we are connected to.
329+ """
328330 if self ._debug :
329331 print ("RSSI" )
330332 if not self ._send_parse_reply (b"AT+CSQ" , b"+CSQ: " ):
@@ -347,7 +349,7 @@ def rssi(self):
347349
348350 @property
349351 def gps (self ):
350- """Returns the GPS fix ."""
352+ """Module's GPS status ."""
351353 if self ._debug :
352354 print ("GPS Fix" )
353355 if self ._fona_type == FONA_808_V2 :
@@ -370,10 +372,6 @@ def gps(self):
370372
371373 @gps .setter
372374 def gps (self , gps_on = False ):
373- """Sets GPS module power, parses returned buffer.
374- :param bool gps_on: Enables the GPS module, disabled by default.
375-
376- """
377375 if not (
378376 self ._fona_type == FONA_3G_A
379377 or self ._fona_type == FONA_3G_E
@@ -422,14 +420,13 @@ def unpretty_ip(self, ip): # pylint: disable=no-self-use, invalid-name
422420
423421 @property
424422 def enable_sms_notification (self ):
425- """Returns status of new SMS message notifications"""
423+ """Checks if SMS notifications are enabled. """
426424 if not self ._send_parse_reply (b"AT+CNMI?\r \n " , b"+CNMI:" , idx = 1 ):
427425 return False
428426 return self ._buf
429427
430428 @enable_sms_notification .setter
431429 def enable_sms_notification (self , enable = True ):
432- """Enables or disables new SMS message notifications."""
433430 if enable :
434431 if not self ._send_check_reply (b"AT+CNMI=2,1\r \n " , reply = REPLY_OK ):
435432 return False
@@ -442,8 +439,7 @@ def receive_sms(self):
442439 """Checks for a message notification from the FONA module,
443440 replies back with the a tuple containing (sender, message).
444441 NOTE: This method needs to be polled consistently due to the lack
445- of hw-based interrupts in CircuitPython. Adding time.sleep delays
446- may cause missed messages if using the RI pin instead of UART.
442+ of hw-based interrupts in CircuitPython.
447443
448444 """
449445 if self ._ri is not None : # poll the RI pin
@@ -501,12 +497,12 @@ def send_sms(self, phone_number, message):
501497 return True
502498
503499 def num_sms (self , sim_storage = True ):
504- """Returns the number of SMS messages stored in memory, False if none stored .
500+ """Returns the number of SMS messages stored in memory.
505501 :param bool sim_storage: SMS storage on the SIM, otherwise internal storage on FONA chip.
506502
507503 """
508504 if not self ._send_check_reply (b"AT+CMGF=1" , reply = REPLY_OK ):
509- return False
505+ raise RuntimeError ( "Operating mode not supported by FONA module." )
510506
511507 if sim_storage : # ask how many SMS are stored
512508 if self ._send_parse_reply (b"AT+CPMS?" , FONA_SMS_STORAGE_SIM + b"," , idx = 1 ):
@@ -524,10 +520,10 @@ def num_sms(self, sim_storage=True):
524520 self ._read_line () # eat OK
525521 if self ._send_parse_reply (b"AT+CPMS?" , b'"SM_P",' , idx = 1 ):
526522 return self ._buf
527- return False
523+ return 0
528524
529525 def delete_sms (self , sms_slot ):
530- """Deletes a SMS message in the provided SMS slot.
526+ """Deletes a SMS message from a storage (internal or sim) slot
531527 :param int sms_slot: SMS SIM or FONA memory slot number.
532528
533529 """
@@ -597,7 +593,6 @@ def read_sms(self, sms_slot):
597593
598594 def get_host_by_name (self , hostname ):
599595 """Converts a hostname to a packed 4-byte IP address.
600- Returns a 4 bytearray.
601596 :param str hostname: Destination server.
602597
603598 """
@@ -618,9 +613,7 @@ def get_host_by_name(self, hostname):
618613 return self ._buf
619614
620615 def get_socket (self ):
621- """Returns an avaliable socket (INITIAL or CLOSED state).
622-
623- """
616+ """Obtains a socket, if available."""
624617 if self ._debug :
625618 print ("*** Get socket" )
626619
@@ -643,7 +636,7 @@ def get_socket(self):
643636 return allocated_socket
644637
645638 def remote_ip (self , sock_num ):
646- """Returns the IP address of the host who sent the current incoming packet .
639+ """Returns the IP address of the remote server .
647640 :param int sock_num: Desired socket.
648641
649642 """
@@ -658,7 +651,7 @@ def remote_ip(self, sock_num):
658651 return self ._buf
659652
660653 def socket_status (self , sock_num ):
661- """Returns if socket is connected.
654+ """Returns the socket connection status, False if not connected.
662655 :param int sock_num: Desired socket number.
663656
664657 """
@@ -688,7 +681,7 @@ def socket_status(self, sock_num):
688681 return True
689682
690683 def socket_available (self , sock_num ):
691- """Returns the amount of bytes to be read from the socket.
684+ """Returns the amount of bytes available to be read from the socket.
692685 :param int sock_num: Desired socket to return bytes available from.
693686
694687 """
0 commit comments