Skip to content

Instantly share code, notes, and snippets.

@ataffanel
Created April 4, 2016 12:12
Show Gist options
  • Save ataffanel/87669a6a3781990edc8d4a8f5ee5d3ad to your computer and use it in GitHub Desktop.
Save ataffanel/87669a6a3781990edc8d4a8f5ee5d3ad to your computer and use it in GitHub Desktop.
Example reading RSSI measurement from Crazyflie 2.0
# cflib can be installed via 'pip install cflib'
import cflib.drivers.crazyradio as crazyradio
cradio = crazyradio.Crazyradio()
# Connection parameter for the CF2
cradio.set_data_rate(cradio.DR_2MPS)
cradio.set_channel(110)
for _ in range(10000):
pk = cradio.send_packet((0xff, ))
# Filter for NULL packet that includes a RSSI measurement
# -> Null packet have a header of 0xF3, with a mask of 0xF3
# -> RSSI NULL packets have 1 after the header, and the RSSI after
if pk.ack and len(pk.data) > 2 and \
pk.data[0] & 0xf3 == 0xf3 and pk.data[1] == 0x01:
print("RSSI: -{}dBm".format(pk.data[2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment