Skip to content

Commit f8cbc85

Browse files
committed
make revisions to docstrings, property names, return types, typos
1 parent a51d021 commit f8cbc85

File tree

1 file changed

+79
-36
lines changed

1 file changed

+79
-36
lines changed

adafruit_rockblock.py

Lines changed: 79 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ def _uart_xfer(self, cmd):
7777

7878
def reset(self):
7979
"""Perform a software reset."""
80-
if self._uart_xfer("&F0") is None: # factory defaults
80+
if self._uart_xfer("&F0")[0] is None: # factory defaults
8181
return False
82-
if self._uart_xfer("&K0") is None: # flow control off
82+
if self._uart_xfer("&K0")[0] is None: # flow control off
8383
return False
8484
return True
8585

@@ -89,7 +89,7 @@ def _transfer_buffer(self):
8989

9090
@property
9191
def data_out(self):
92-
"The binary data in the outbound buffer."
92+
"""The binary data in the outbound buffer."""
9393
return self._buf_out
9494

9595
@data_out.setter
@@ -208,30 +208,43 @@ def model(self):
208208

209209
@property
210210
def serial_number(self):
211-
"""Return modem imei/serial."""
211+
"""Modem's serial number, also known as the modem's IMEI.
212+
213+
Returns
214+
string
215+
"""
212216
resp = self._uart_xfer("+CGSN")
213217
if resp[-1].strip().decode() == "OK":
214218
return resp[1].strip().decode()
215219
return None
216220

217221
@property
218-
def rssi(self):
219-
"""Return Received Signal Strength Indicator (RSSI)
220-
values returned are 0 to 5, where 0 is no signal (0 bars) and 5 is strong signal (5 bars).
221-
Important note: signal strength may not be fully accurate, so
222-
waiting for high signal strength prior to sending a message isn't always recommended.
222+
def signal_quality(self):
223+
"""Signal Quality also known as the Received Signal Strength Indicator (RSSI).
224+
225+
Values returned are 0 to 5, where 0 is no signal (0 bars) and 5 is strong signal (5 bars).
226+
227+
Important note: signal strength may not be fully accurate, so waiting for
228+
high signal strength prior to sending a message isn't always recommended.
223229
For details see https://docs.rockblock.rock7.com/docs/checking-the-signal-strength
230+
231+
Returns:
232+
int
224233
"""
225234
resp = self._uart_xfer("+CSQ")
226235
if resp[-1].strip().decode() == "OK":
227-
return resp[1].strip().decode().split(":")[1]
236+
return int(resp[1].strip().decode().split(":")[1])
228237
return None
229238

230239
@property
231240
def revision(self):
232-
"""Return the modem components' firmware versions.
241+
"""Modem's internal component firmware revisions.
242+
233243
For example: Call Processor Version, Modem DSP Version, DBB Version (ASIC),
234244
RFA VersionSRFA2), NVM Version, Hardware Version, BOOT Version
245+
246+
Returns a tuple:
247+
(string, string, string, string, string, string, string)
235248
"""
236249
resp = self._uart_xfer("+CGMR")
237250
if resp[-1].strip().decode() == "OK":
@@ -240,38 +253,47 @@ def revision(self):
240253
line = resp[x]
241254
if line != b"\r\n":
242255
lines.append(line.decode().strip())
243-
return lines
244-
return None
256+
return tuple(lines)
257+
return (None,) * 7
245258

246259
@property
247260
def ring_alert(self):
248-
"""Retrieve setting for SBD Ring Alerts."""
261+
"""The current ring indication mode.
262+
263+
False means Ring Alerts are disabled, and True means Ring Alerts are enabled.
264+
265+
When SBD ring indication is enabled, the ISU asserts the RI line and issues
266+
the unsolicited result code SBDRING when an SBD ring alert is received.
267+
(Note: the network can only send ring alerts to the ISU after it has registered).
268+
269+
Returns:
270+
bool
271+
"""
249272
resp = self._uart_xfer("+SBDMTA?")
250273
if resp[-1].strip().decode() == "OK":
251274
return bool(int(resp[1].strip().decode().split(":")[1]))
252275
return None
253276

254277
@ring_alert.setter
255278
def ring_alert(self, value=1):
256-
"""Enable or disable ring alert feature."""
257279
if value in [True, False]:
258280
resp = self._uart_xfer("+SBDMTA=" + str(int(value)))
259281
if resp[-1].strip().decode() == "OK":
260282
return True
261283
raise RuntimeError("Error setting Ring Alert.")
262284
raise ValueError(
263-
"Use 0 or False to disable Ring Alert or use 0 or True to enable Ring Alert."
285+
"Use 0 or False to disable Ring Alert or use 1 or True to enable Ring Alert."
264286
)
265287

266288
@property
267289
def ring_indication(self):
268-
"""
269-
Query the ring indication status, returning the reason for the most recent assertion
270-
of the Ring Indicate signal.
290+
"""The ring indication status.
291+
292+
Returns the reason for the most recent assertion of the Ring Indicate signal.
271293
272294
The response contains separate indications for telephony and SBD ring indications.
273295
The response is in the form:
274-
[<tel_ri>,<sbd_ri>]
296+
(<tel_ri>,<sbd_ri>)
275297
276298
<tel_ri> indicates the telephony ring indication status:
277299
0 No telephony ring alert received.
@@ -282,21 +304,24 @@ def ring_indication(self):
282304
<sbd_ri> indicates the SBD ring indication status:
283305
0 No SBD ring alert received.
284306
1 SBD ring alert received.
307+
308+
Returns a tuple:
309+
(string, string)
285310
"""
286311
resp = self._uart_xfer("+CRIS")
287312
if resp[-1].strip().decode() == "OK":
288-
return resp[1].strip().decode().split(":")[1].split(",")
289-
return None
313+
return tuple(resp[1].strip().decode().split(":")[1].split(","))
314+
return (None,) * 2
290315

291316
@property
292317
def geolocation(self):
293-
"""
294-
Return the geolocation of the modem as measured by the Iridium constellation
295-
and the current time based on the Iridium network timestamp.
318+
"""Most recent geolocation of the modem as measured by the Iridium constellation
319+
including a timestamp of when geolocation measurement was made.
320+
296321
The response is in the form:
297-
[<x>,<y>,<z>,<timestamp>]
322+
(<x>, <y>, <z>, <timestamp>)
298323
299-
<x>,<y>,<z> is a geolocation grid code from an earth centered Cartesian coordinate system,
324+
<x>, <y>, <z> is a geolocation grid code from an earth centered Cartesian coordinate system,
300325
using dimensions, x, y, and z, to specify location. The coordinate system is aligned
301326
such that the z-axis is aligned with the north and south poles, leaving the x-axis
302327
and y-axis to lie in the plane containing the equator. The axes are aligned such that
@@ -311,10 +336,17 @@ def geolocation(self):
311336
<timestamp> is a time_struct
312337
The timestamp is assigned by the modem when the geolocation grid code received from
313338
the network is stored to the modem's internal memory.
339+
314340
The timestamp used by the modem is Iridium system time, which is a running count of
315-
90 millisecond intervals, since Sunday May 11, 2014, at 14:23:55 UTC.
341+
90 millisecond intervals, since Sunday May 11, 2014, at 14:23:55 UTC (the most recent
342+
Iridium epoch).
316343
The timestamp returned by the modem is a 32-bit integer displayed in hexadecimal form.
317344
We convert the modem's timestamp and return it as a time_struct.
345+
346+
The system time value is always expressed in UTC time.
347+
348+
Returns a tuple:
349+
(int, int, int, time_struct)
318350
"""
319351
resp = self._uart_xfer("-MSGEO")
320352
if resp[-1].strip().decode() == "OK":
@@ -347,18 +379,29 @@ def geolocation(self):
347379
int(temp[2]),
348380
time_now,
349381
]
350-
return values
351-
return None
382+
return tuple(values)
383+
return (None,) * 4
352384

353385
@property
354-
def timestamp(self):
355-
"""
356-
Return the current date and time as given by the Iridium network
357-
The timestamp is assigned by the modem when the geolocation grid code received from
358-
the network is stored to the modem's internal memory.
386+
def system_time(self):
387+
"""Current date and time as given by the Iridium network.
388+
389+
The system time is available and valid only after the ISU has registered with
390+
the network and has received the Iridium system time from the network.
391+
Once the time is received, the ISU uses its internal clock to increment the counter.
392+
In addition, at least every 8 hours, or on location update or other event that
393+
requires re-registration, the ISU will obtain a new system time from the network.
394+
359395
The timestamp used by the modem is Iridium system time, which is a running count of
360-
90 millisecond intervals, since Sunday May 11, 2014, at 14:23:55 UTC.
396+
90 millisecond intervals, since Sunday May 11, 2014, at 14:23:55 UTC (the most recent
397+
Iridium epoch).
398+
The timestamp returned by the modem is a 32-bit integer displayed in hexadecimal form.
361399
We convert the modem's timestamp and return it as a time_struct.
400+
401+
The system time value is always expressed in UTC time.
402+
403+
Returns:
404+
time_struct
362405
"""
363406
resp = self._uart_xfer("-MSSTM")
364407
if resp[-1].strip().decode() == "OK":

0 commit comments

Comments
 (0)