API Documentation¶
Radio¶
-
class
RFM69.
Radio
(freqBand, nodeID, networkID=100, **kwargs)¶ RFM69 Radio interface for the Raspberry PI.
An RFM69 module is expected to be connected to the SPI interface of the Raspberry Pi. The class is as a context manager so you can instantiate it using the ‘with’ keyword.
Parameters: - freqBand – Frequency band of radio - 315MHz, 868Mhz, 433MHz or 915MHz.
- nodeID (int) – The node ID of this device.
- networkID (int) – The network ID
Keyword Arguments: - auto_acknowledge (bool) – Automatically send acknowledgements
- isHighPower (bool) – Is this a high power radio model
- power (int) – Power level - a percentage in range 10 to 100.
- use_board_pin_numbers (bool) – Use BOARD (not BCM) pin numbers. Defaults to True.
- interruptPin (int) – Pin number of interrupt pin. This is a pin index not a GPIO number.
- resetPin (int) – Pin number of reset pin. This is a pin index not a GPIO number.
- spiBus (int) – SPI bus number.
- spiDevice (int) – SPI device number.
- promiscuousMode (bool) – Listen to all messages not just those addressed to this node ID.
- enableATC (bool) – Enable ATC mode. Defaults to False.
- encryptionKey (str) – 16 character encryption key.
- verbose (bool) – Verbose mode - Activates logging to console.
-
__init__
(freqBand, nodeID, networkID=100, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
begin_receive
()¶ Begin listening for packets
-
broadcast
(buff='')¶ Broadcast a message to network
Parameters: buff (str) – Message buffer to send
-
calibrate_radio
()¶ Calibrate the internal RC oscillator for use in wide temperature variations.
See RFM69 datasheet section [4.3.5. RC Timer Accuracy] for more information.
-
get_frequency_in_Hz
()¶ Get the radio frequency in Hertz
-
get_packet
(block=True, timeout=None)¶ Gets a single packet (thread-safe)
Parameters: - block (bool) – Block until a packet is available
- timeout (int) – Time to wait if blocking. Set to None to wait forever
Returns: The oldest packet received if available, or None if no packet is available
Return type:
-
get_packets
()¶ Get newly received packets.
Returns: Returns a list of RFM69.Packet objects. Return type: list
-
has_received_packet
()¶ Check if packet received
Returns: True if packet has been received Return type: bool
-
listen_mode_send_burst
(toAddress, buff)¶ Send a message to nodes in listen mode as a burst
Parameters: - toAddress (int) – Recipient node’s ID
- buff (str) – Message buffer to send
-
listen_mode_set_durations
(rxDuration, idleDuration)¶ Set the duty cycle for listen mode
The values used may be slightly different to accomodate what is allowed by the radio. This function returns the actual values used.
Parameters: - rxDuration (int) – number of microseconds to be in receive mode
- idleDuration (int) – number of microseconds to be sleeping
Returns: the actual (rxDuration, idleDuration) used
Return type: (int, int)
-
num_packets
()¶ Returns the number of received packets
Returns: Number of packets in the received queue Return type: int
-
read_registers
()¶ Get all register values.
Returns: Register values Return type: list
-
read_temperature
(calFactor=0)¶ Read the temperature of the radios CMOS chip.
Parameters: calFactor – Additional correction to corrects the slope, rising temp = rising val Returns: Temperature in centigrade Return type: int
-
send
(toAddress, buff='', **kwargs)¶ Send a message
Parameters: - toAddress (int) – Recipient node’s ID
- buff (str) – Message buffer to send
Keyword Arguments: - attempts (int) – Number of attempts
- wait (int) – Milliseconds to wait for acknowledgement
- require_ack (bool) – Require Acknowledgement. If Attempts > 1 this is auto set to True.
Returns: If acknowledgement received or None is no acknowledgement requested
Return type: bool
-
send_ack
(toAddress, buff=[])¶ Send an acknowledgement packet
Parameters: toAddress (int) – Recipient node’s ID
-
set_frequency
(FRF)¶ Set the radio frequency
-
set_frequency_in_Hz
(frequency_in_Hz)¶ Set the radio frequency in Hertz
Parameters: frequency_in_Hz (int) – Value between 315000000 to 915000000 Hz.
-
set_network
(network_id)¶ Set the network ID (sync)
Parameters: network_id (int) – Value between 1 and 254.
-
set_power_level
(percent)¶ Set the transmit power level
Parameters: percent (int) – Value between 0 and 100.
-
sleep
()¶ Put the radio into sleep mode
Packet¶
-
class
RFM69.
Packet
(receiver, sender, RSSI, data)¶ Object to represent received packet. Created internally and returned by radio when getPackets() is called.
Parameters: - receiver (int) – Node ID of receiver
- sender (int) – Node ID of sender
- RSSI (int) – Received Signal Strength Indicator i.e. the power present in a received radio signal
- data (list) – Raw transmitted data
-
__init__
(receiver, sender, RSSI, data)¶ Initialize self. See help(type(self)) for accurate signature.
-
data_string
¶ Returns the data as a string
-
to_dict
(dateFormat=None)¶ Returns a dictionary representation of the class data