if data['id'] == 'tx_status': print(data['deliver_status'].encode('hex')) elif data['id'] == 'rx': print(data['rf_data']) else: print('Unimplemented frame type') # Create XBee library API object, which spawns a new thread zb = ZigBee(ser, callback=message_received) sendsched = BlockingScheduler() sendsched.start() # every 30 seconds send a house query packet to the XBee network sendsched.add_interval_job(sendQueryPacket, seconds=30) # Do other stuff in the main thread while True: try: time.sleep(0.1) if packets.qsize() > 0: # got a packet from recv thread # See, the receive thread gets them # puts them on a queue and here is # where I pick them off to use newPacket = packets.get_nowait() # now go dismantle the packet # and use it. handlePacket(newPacket) except KeyboardInterrupt: