self.start_listening(channel)
message = []
while True:
radio_status = self.get_register_bits('status')
self._debug("radio_status={}".format(radio_status))
if radio_status['packet_flag'] == 0:
if wait:
time.sleep(wait_time)
continue
else:
return None
if radio_status['crc_error'] == 1:
# Handle invalid packet ?
self.start_listening(channel)
continue
# Data is available, read it from the FIFO register
# The first result will include the length
# XXX *IF* length encoding is enabled ?
fifo_data = self.get_register('fifo')
message_length = fifo_data >> 8
if message_length == 0:
self.start_listening(channel)
continue
# Keep track of the total message length to truncate it
final_message_length = message_length
message += [fifo_data & 0xff]
message_length -= 1