API Documentation¶
Radio¶
-
class
RFM69.
Radio
(freqBand, nodeID, networkID=100, **kwargs)¶ -
__init__
(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.
- 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.
- encryptionKey (str) – 16 character encryption key.
- verbose (bool) – Verbose mode - Activates logging to console.
-
begin_receive
()¶ Begin listening for packets
-
broadcast
(buff='')¶ Broadcast a message to network i.e. sends to node 255 with no ACK request.
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_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
-
listenModeSendBurst
(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
-
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 acknowledgemet packet
Parameters: toAddress (int) – Recipient node’s ID
-
set_frequency
(FRF)¶ Set the radio frequency
-
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.
-
to_dict
(dateFormat=None)¶ Returns a dictionary representation of the class data