@@ -142,19 +142,19 @@ def send_bytes(self, message):
142
142
time .sleep (AD_DURATION )
143
143
self .ble .stop_advertising ()
144
144
145
- def receive (self ):
145
+ def receive (self , timeout = 1 ):
146
146
"""
147
147
Returns a message received on the channel on which the radio is
148
148
listening.
149
149
150
150
:return: A string representation of the received message, or else None.
151
151
"""
152
- msg = self .receive_full ()
152
+ msg = self .receive_full (timeout = timeout )
153
153
if msg :
154
154
return msg [0 ].decode ("utf-8" ).replace ("\x00 " , "" )
155
155
return None
156
156
157
- def receive_full (self ):
157
+ def receive_full (self , timeout = 1 ):
158
158
"""
159
159
Returns a tuple containing three values representing a message received
160
160
on the channel on which the radio is listening. If no message was
@@ -167,11 +167,14 @@ def receive_full(self):
167
167
* a microsecond timestamp: the value returned by time.monotonic() when
168
168
the message was received.
169
169
170
+ :param float timeout: The length of time (in seconds) the radio listens for a broadcast
171
+
170
172
:return: A tuple representation of the received message, or else None.
173
+
171
174
"""
172
175
try :
173
176
for entry in self .ble .start_scan (
174
- _RadioAdvertisement , minimum_rssi = - 255 , timeout = 1 , extended = True
177
+ _RadioAdvertisement , minimum_rssi = - 255 , timeout = timeout , extended = True
175
178
):
176
179
# Extract channel and unique message ID bytes.
177
180
chan , uid = struct .unpack ("<BB" , entry .msg [:2 ])
0 commit comments