Skip to content

Commit 88fc8f9

Browse files
committed
revert reset function, changed function to use tuple instead of list, reduced lines of code and memory usage in geolocation and system_time, removed default value in the ring alert setter
1 parent f460050 commit 88fc8f9

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

adafruit_rockblock.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,8 @@ def _uart_xfer(self, cmd):
7777

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

8683
def _transfer_buffer(self):
8784
"""Copy out buffer to in buffer to simulate receiving a message."""
@@ -275,8 +272,8 @@ def ring_alert(self):
275272
return None
276273

277274
@ring_alert.setter
278-
def ring_alert(self, value=1):
279-
if value in [True, False]:
275+
def ring_alert(self, value):
276+
if value in (True, False):
280277
resp = self._uart_xfer("+SBDMTA=" + str(int(value)))
281278
if resp[-1].strip().decode() == "OK":
282279
return True
@@ -369,17 +366,12 @@ def geolocation(self):
369366

370367
# add timestamp's seconds to the iridium epoch
371368
time_now_unix = iridium_epoch_unix + int(secs_since_epoch)
372-
373-
# convert to time struct
374-
time_now = time.localtime(time_now_unix)
375-
376-
values = [
369+
return (
377370
int(temp[0]),
378371
int(temp[1]),
379372
int(temp[2]),
380-
time_now,
381-
]
382-
return tuple(values)
373+
time.localtime(time_now_unix),
374+
)
383375
return (None,) * 4
384376

385377
@property
@@ -426,9 +418,5 @@ def system_time(self):
426418

427419
# add timestamp's seconds to the iridium epoch
428420
time_now_unix = iridium_epoch_unix + int(secs_since_epoch)
429-
430-
# convert to time struct
431-
time_now = time.localtime(time_now_unix)
432-
433-
return time_now
421+
return time.localtime(time_now_unix)
434422
return None

0 commit comments

Comments
 (0)