312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
-
-
-
|
result = self._spi.xfer([reg, high, low], self._spi.max_speed_hz, delay)
if reg & 0x80 == 0x80:
self._debug(" regRead[%02X] = %s" % ((reg & 0x7f), result))
else:
self._debug("regWrite[%02X:0x%02X%02X] = %s" % (reg, high, low, result))
#if reg & 0x80 != 0x80:
# time.sleep(delay / 1000.0)
return result
def put_register(self, reg, value):
high = (value >> 8) & 0xff
low = value & 0xff
return self._put_register_high_low(reg, high, low)
|
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
|
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
|
-
+
+
-
+
|
# XXX: Untested
while True:
radio_status = self.get_register_bits('status')
self._debug("radio_status={}".format(radio_status))
if radio_status['packet_flag'] == 1:
break
time.sleep(0.1)
time.sleep(0.001)
return True
def multi_transmit(self, message, channels, retries = 3, delay = 0.1):
for channel in channels:
for i in range(retries):
if not self.transmit(message, channel):
return False
if delay != 0:
time.sleep(delay / retries)
time.sleep(delay / retries)
return True
def start_listening(self, channel):
# Initialize the receiver
self.stop_listening()
# Go into listening mode
|