User Tools

Site Tools


projects:crazyradio:python_lib

This is an old revision of the document!


Python Crazyradio Library

The python crazyradio lib can be found in the Crazyradio git repos https://github.com/bitcraze/crazyradio-firmware/blob/master/lib/crazyradio.py. It is a single file that implements the low level Crazyradio dongle functionalities.

Theory of operation

The Crazyradio is configured in PTX mode which means that it will start all comunication. If a device in PRX mode is on the same address, channel and datarate, the device will send back an ack packet that may contains data.

   Crazyradio    Device
      _             _
      |             |
      |  Packet     |
      |------------>|
      |        Ack  |
      |<------------|
      |             |

Ths is an example on how to use the lib:

import crazyradio
 
cr = crazyradio.Crazyradio()
cr.set_channel(90)
cr.set_data_rate(cr.DR_2MPS)
 
res = cr.send_packet([0xff, ])
print res.ack                   # At true if an ack has been received
print res.data                  # The ack payload data

API

Crazyradio

Fields

None

Methods

__init__(self. device=None, devid=0)
Name _ _init_ _ (Constructor)
Parameters (USBDevice) device, (int) devid
Returns None
Description Initialize the Crazyradio object. If device is not specified, a list of available Crazyradio is made and devId selects the Crazyradio used (by default the first one)
close(self)
Name close
Parameters None
Returns None
Description Close the USB device. Should be called before closing the program.
set_channel(self, channel)
Name set_channel
Parameters (int) channel
Returns None
Description Set the Crazyradio channel. Channel must be between 0 and 125. Channels are spaced by 1MHz starting at 2400MHz and ending at 2525MHz.
set_channel(self, channel)
Name set_channel
Parameters (int) channel
Returns None
Description Set the Crazyradio channel. Channel must be between 0 and 125. Channels are spaced by 1MHz starting at 2400MHz and ending at 2525MHz.
set_address(self, address)
Name set_address
Parameters (list of int) address
Returns None
Description Set the Crazyradio address. The address is 5 bytes long. It should be a list of 5 bytes values.
set_data_rate(self, datarate)
Name set_datarate
Parameters (int) datarate
Returns None
Description Set the Crazyradio datarate. Datarate is one of DR_250KPS, DR_1MPS or DR_2MPS

_radio_ack

Fields

Methods

projects/crazyradio/python_lib.1438854363.txt.gz · Last modified: 2015-08-06 11:46 by arnaud