Skip to content

Commit 6907402

Browse files
another pass
1 parent 0284d37 commit 6907402

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

adafruit_rockblock.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525
2626
"""
2727
try:
28-
from typing import Tuple, List, Union, Optional
28+
from typing import Tuple, Union, Optional
2929
from board import UART
3030
from serial import Serial
31-
from time import time_struct
3231
except ImportError:
3332
pass
3433

@@ -48,7 +47,7 @@ def __init__(self, uart: Union[UART, Serial], baudrate: int = 19200) -> None:
4847
self._buf_out = None
4948
self.reset()
5049

51-
def _uart_xfer(self, cmd: str) -> Tuple[List[bytes]]:
50+
def _uart_xfer(self, cmd: str) -> Tuple[bytes, ...]:
5251
"""Send AT command and return response as tuple of lines read."""
5352
self._uart.reset_input_buffer()
5453
self._uart.write(str.encode("AT" + cmd + "\r"))
@@ -74,7 +73,7 @@ def _transfer_buffer(self) -> None:
7473
self._uart_xfer("+SBDTC")
7574

7675
@property
77-
def data_out(self) -> None:
76+
def data_out(self) -> Optional[bytes]:
7877
"""The binary data in the outbound buffer."""
7978
return self._buf_out
8079

@@ -126,7 +125,7 @@ def text_out(self, text: str) -> None:
126125
self.data_out = str.encode(text)
127126

128127
@property
129-
def data_in(self) -> Optional[List[bytes]]:
128+
def data_in(self) -> Optional[bytes]:
130129
"""The binary data in the inbound buffer."""
131130
data = None
132131
if self.status[2] == 1:
@@ -157,10 +156,10 @@ def text_in(self) -> Optional[str]:
157156
return text
158157

159158
@text_in.setter
160-
def text_in(self, text: str) -> None:
159+
def text_in(self, text: bytes) -> None:
161160
self.data_in = text
162161

163-
def satellite_transfer(self, location: str = None) -> Tuple[Optional[str], ...]:
162+
def satellite_transfer(self, location: str = None) -> Tuple[Optional[int], ...]:
164163
"""Initiate a Short Burst Data transfer with satellites."""
165164
status = (None,) * 6
166165
if location:
@@ -176,7 +175,7 @@ def satellite_transfer(self, location: str = None) -> Tuple[Optional[str], ...]:
176175
return tuple(status)
177176

178177
@property
179-
def status(self) -> Tuple[Optional[str], ...]:
178+
def status(self) -> Tuple[Optional[int], ...]:
180179
"""Return tuple of Short Burst Data status."""
181180
resp = self._uart_xfer("+SBDSX")
182181
if resp[-1].strip().decode() == "OK":
@@ -205,7 +204,7 @@ def serial_number(self) -> Optional[str]:
205204
return None
206205

207206
@property
208-
def signal_quality(self) -> int:
207+
def signal_quality(self) -> Optional[int]:
209208
"""Signal Quality also known as the Received Signal Strength Indicator (RSSI).
210209
211210
Values returned are 0 to 5, where 0 is no signal (0 bars) and 5 is strong signal (5 bars).
@@ -302,7 +301,7 @@ def ring_indication(self) -> Tuple[Optional[str], ...]:
302301
@property
303302
def geolocation(
304303
self,
305-
) -> Union[Tuple[int, int, int, time_struct], Tuple[None, None, None, None]]:
304+
) -> Union[Tuple[int, int, int, time.struct_time], Tuple[None, None, None, None]]:
306305
"""Most recent geolocation of the modem as measured by the Iridium constellation
307306
including a timestamp of when geolocation measurement was made.
308307
@@ -321,20 +320,20 @@ def geolocation(
321320
This geolocation coordinate system is known as ECEF (acronym earth-centered, earth-fixed),
322321
also known as ECR (initialism for earth-centered rotational)
323322
324-
<timestamp> is a time_struct
323+
<timestamp> is a time.struct_time
325324
The timestamp is assigned by the modem when the geolocation grid code received from
326325
the network is stored to the modem's internal memory.
327326
328327
The timestamp used by the modem is Iridium system time, which is a running count of
329328
90 millisecond intervals, since Sunday May 11, 2014, at 14:23:55 UTC (the most recent
330329
Iridium epoch).
331330
The timestamp returned by the modem is a 32-bit integer displayed in hexadecimal form.
332-
We convert the modem's timestamp and return it as a time_struct.
331+
We convert the modem's timestamp and return it as a time.struct_time.
333332
334333
The system time value is always expressed in UTC time.
335334
336335
Returns a tuple:
337-
(int, int, int, time_struct)
336+
(int, int, int, time.struct_time)
338337
"""
339338
resp = self._uart_xfer("-MSGEO")
340339
if resp[-1].strip().decode() == "OK":
@@ -366,7 +365,7 @@ def geolocation(
366365
return (None,) * 4
367366

368367
@property
369-
def system_time(self) -> Optional[time_struct]:
368+
def system_time(self) -> Optional[time.struct_time]:
370369
"""Current date and time as given by the Iridium network.
371370
372371
The system time is available and valid only after the ISU has registered with
@@ -379,12 +378,12 @@ def system_time(self) -> Optional[time_struct]:
379378
90 millisecond intervals, since Sunday May 11, 2014, at 14:23:55 UTC (the most recent
380379
Iridium epoch).
381380
The timestamp returned by the modem is a 32-bit integer displayed in hexadecimal form.
382-
We convert the modem's timestamp and return it as a time_struct.
381+
We convert the modem's timestamp and return it as a time.struct_time.
383382
384383
The system time value is always expressed in UTC time.
385384
386385
Returns:
387-
time_struct
386+
time.struct_time
388387
"""
389388
resp = self._uart_xfer("-MSSTM")
390389
if resp[-1].strip().decode() == "OK":

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
# SPDX-License-Identifier: Unlicense
44

55
Adafruit-Blinka
6+
board
7+
serial

0 commit comments

Comments
 (0)