25
25
26
26
"""
27
27
try :
28
- from typing import Tuple , List , Union , Optional
28
+ from typing import Tuple , Union , Optional
29
29
from board import UART
30
30
from serial import Serial
31
- from time import time_struct
32
31
except ImportError :
33
32
pass
34
33
@@ -48,7 +47,7 @@ def __init__(self, uart: Union[UART, Serial], baudrate: int = 19200) -> None:
48
47
self ._buf_out = None
49
48
self .reset ()
50
49
51
- def _uart_xfer (self , cmd : str ) -> Tuple [List [ bytes ] ]:
50
+ def _uart_xfer (self , cmd : str ) -> Tuple [bytes , ... ]:
52
51
"""Send AT command and return response as tuple of lines read."""
53
52
self ._uart .reset_input_buffer ()
54
53
self ._uart .write (str .encode ("AT" + cmd + "\r " ))
@@ -74,7 +73,7 @@ def _transfer_buffer(self) -> None:
74
73
self ._uart_xfer ("+SBDTC" )
75
74
76
75
@property
77
- def data_out (self ) -> None :
76
+ def data_out (self ) -> Optional [ bytes ] :
78
77
"""The binary data in the outbound buffer."""
79
78
return self ._buf_out
80
79
@@ -126,7 +125,7 @@ def text_out(self, text: str) -> None:
126
125
self .data_out = str .encode (text )
127
126
128
127
@property
129
- def data_in (self ) -> Optional [List [ bytes ] ]:
128
+ def data_in (self ) -> Optional [bytes ]:
130
129
"""The binary data in the inbound buffer."""
131
130
data = None
132
131
if self .status [2 ] == 1 :
@@ -157,10 +156,10 @@ def text_in(self) -> Optional[str]:
157
156
return text
158
157
159
158
@text_in .setter
160
- def text_in (self , text : str ) -> None :
159
+ def text_in (self , text : bytes ) -> None :
161
160
self .data_in = text
162
161
163
- def satellite_transfer (self , location : str = None ) -> Tuple [Optional [str ], ...]:
162
+ def satellite_transfer (self , location : str = None ) -> Tuple [Optional [int ], ...]:
164
163
"""Initiate a Short Burst Data transfer with satellites."""
165
164
status = (None ,) * 6
166
165
if location :
@@ -176,7 +175,7 @@ def satellite_transfer(self, location: str = None) -> Tuple[Optional[str], ...]:
176
175
return tuple (status )
177
176
178
177
@property
179
- def status (self ) -> Tuple [Optional [str ], ...]:
178
+ def status (self ) -> Tuple [Optional [int ], ...]:
180
179
"""Return tuple of Short Burst Data status."""
181
180
resp = self ._uart_xfer ("+SBDSX" )
182
181
if resp [- 1 ].strip ().decode () == "OK" :
@@ -205,7 +204,7 @@ def serial_number(self) -> Optional[str]:
205
204
return None
206
205
207
206
@property
208
- def signal_quality (self ) -> int :
207
+ def signal_quality (self ) -> Optional [ int ] :
209
208
"""Signal Quality also known as the Received Signal Strength Indicator (RSSI).
210
209
211
210
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], ...]:
302
301
@property
303
302
def geolocation (
304
303
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 ]]:
306
305
"""Most recent geolocation of the modem as measured by the Iridium constellation
307
306
including a timestamp of when geolocation measurement was made.
308
307
@@ -321,20 +320,20 @@ def geolocation(
321
320
This geolocation coordinate system is known as ECEF (acronym earth-centered, earth-fixed),
322
321
also known as ECR (initialism for earth-centered rotational)
323
322
324
- <timestamp> is a time_struct
323
+ <timestamp> is a time.struct_time
325
324
The timestamp is assigned by the modem when the geolocation grid code received from
326
325
the network is stored to the modem's internal memory.
327
326
328
327
The timestamp used by the modem is Iridium system time, which is a running count of
329
328
90 millisecond intervals, since Sunday May 11, 2014, at 14:23:55 UTC (the most recent
330
329
Iridium epoch).
331
330
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 .
333
332
334
333
The system time value is always expressed in UTC time.
335
334
336
335
Returns a tuple:
337
- (int, int, int, time_struct )
336
+ (int, int, int, time.struct_time )
338
337
"""
339
338
resp = self ._uart_xfer ("-MSGEO" )
340
339
if resp [- 1 ].strip ().decode () == "OK" :
@@ -366,7 +365,7 @@ def geolocation(
366
365
return (None ,) * 4
367
366
368
367
@property
369
- def system_time (self ) -> Optional [time_struct ]:
368
+ def system_time (self ) -> Optional [time . struct_time ]:
370
369
"""Current date and time as given by the Iridium network.
371
370
372
371
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]:
379
378
90 millisecond intervals, since Sunday May 11, 2014, at 14:23:55 UTC (the most recent
380
379
Iridium epoch).
381
380
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 .
383
382
384
383
The system time value is always expressed in UTC time.
385
384
386
385
Returns:
387
- time_struct
386
+ time.struct_time
388
387
"""
389
388
resp = self ._uart_xfer ("-MSSTM" )
390
389
if resp [- 1 ].strip ().decode () == "OK" :
0 commit comments