Package: cc1101-python
cc1101-pythonThis project provides an interface to theCC1101 Linux Driverto allow receiving and transmitting packets from Python.Setuppip3 install cc1101-pythonCommand Linepython3 -m cc1101 {tx,rx,config,reset}configRetreive the current configuration from the driver.rxandtxprint the human-readable configuration options.rx_rawandtx_rawprint the register values of the CC1101 for the current RX and TX configs.dev_rawprints the current register values of the hardware.resetClear the RX and TX configs and reset the radio hardware.tx/rxTransmits or receives packets.Common OptionsdeviceThe path to a/dev/cc1101.x.xinterface provided by the driver.frequencyThe frequency to receive/transmit on. Valid values are 300-348, 387-464 and 779-928 MHz.modulationThe modulation scheme to use. Valid values are OOK, FSK_2, FSK_4, GFSK, MSK.baud_rateThe data rate in kBaud to receive/transmit packets. Valid values are within the range 0.6-500 and depend on modulation:ModulationBaud RateOOK / GFSK0.6 - 2502FSK0.6 - 5004FSK0.6 - 300MSK26 - 500--sync_wordThe Sync Word to use, specified as a two or four byte hexadecimal value (e.g0f0f). If four bytes are used, the upper and lower two bytes must be the same (e.g0f0f0f0f)In RX, the device searches for the specified sync word to begin reception. Set0x00to disable the sync word.In TX, the sync word is preprended to each packet.--deviationWhen using an FSK modulation, sets the deviation in kHz either side of the provided frequency to use for modulation.rxOptionspacket_lengthThe number of bytes the radio will receive once RX is triggered, either via sync word or carrier sense threshold.--bandwidthSets the receive bandwidth in kHz. Valid values are58,67,81,101,116,135,162,203,232,270,325,406,464,541,650,812--carrier-senseSets the carrier sense threshold in dB required to begin RX. Carrier sense can be set to a relative or an absolute value. When a sync word is provided, RX only begins when the carrier sense is above the threshold and the sync word has been received.Not specifying a value disables carrier sense.Relative values are+6,+10and+14. These cause the radio to begin RX when the Received Signal Strength Indicator (RSSI) suddenly increases by this value. This is the easiest mode to use for basic RX.Absolute values are-7to7dB. These values cause the radio to begin RX when the RSSI exceeds the absolute value specified by--magn-target+/- the carrier-sense value. Using absolute carrier sense will likely require adjusting the--magn-target,--max-lna-gainand--max-dvga-gainexperimentally until the required RSSI range is reached.--out-format rssican be used to help find this. See Section 17.4 of theCC1101 Datasheetfor examples.--magn-targetSets the target channel filter amplitude in dB. Valid values are:24, 27, 30, 33, 36, 38, 40, 42--max-lna-gainDecreases the maximum LNA gain by approximately the specified amount in dB.Valid values are:0, 3, 6, 7, 9, 12, 15, 17--max-dvga-gainDecreases the maximum DVGA gain by approximately the specified amount in dB.Valid values are:0, 6, 12, 18--blockHold the device handle open while receiving. This prevents another process from using or reconfiguring the device, but prevents multiplexing of RX/TX on a single device between two processes.--out-formatSet the output format.infoprints the packet received count, Received Signal Strength Indictator (RSSI) and the hexadecimal representation of each packet as it is received.hexprints the packet as hexadecimal.binoutputs the raw packet bytes to stdout. This is useful for piping into other tools.rssicontinually outputs the current value of RSSI.txOptionsfrequencyFrequency to transmit on. In TX mode, frequencies are by default restricted to 315/433/868/915 MHz +/- 1MHz, which allows specifying TX Power as one of the dBm values listed inTI DN013. This checking can be disabled by using the--rawflag.tx_powerThe power in dBm to use for transmission. Values must match one of the values in the appropriate frequency table ofTI DN013.packetA sequence of bytes in hexadecimal form to transmit using the CC1101.--rawIn--rawmode,tx_poweris provided as a single byte in hexadecimal, which will be directly set in the CC1101'sPATABLE. Any valid frequency value can be used.RX Examplepython3 -m cc1101 rx /dev/cc1101.0.0 433 OOK 1 64TX Examplepython3 -m cc1101 tx /dev/cc1101.0.0 433 OOK 1 1.4 0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0fPython LibraryThese examples show how to integrate the CC1101 into Python programs.Receivefromtimeimportsleepfrombinasciiimporthexlifyfromcc1101.configimportRXConfig,Modulationfromcc1101importCC1101rx_config=RXConfig.new(frequency=434,modulation=Modulation.OOK,baud_rate=1,sync_word=0x0000,packet_length=64)radio=CC1101("/dev/cc1101.0.0",rx_config,blocking=True)whileTrue:packets=radio.receive()forpacketinpackets:print(f"Received -{hexlify(packet)}")sleep(0.1)Transmitfrombinasciiimportunhexlifyfromcc1101.configimportTXConfig,Modulationfromcc1101importCC1101tx_config=TXConfig.new(frequency=434,modulation=Modulation.OOK,baud_rate=1,tx_power=0.1)radio=CC1101("/dev/cc1101.0.0")radio.transmit(tx_config,unhexlify("0f0f0f0f0f0f0f0f0f0f0f"))