|
MySensors Library & Examples
2.3.2-62-ge298769
|
Go to the documentation of this file.
82 #include "RFM95registers.h"
84 #if !defined(RFM95_SPI)
85 #define RFM95_SPI hwSPI
89 #if defined(ARDUINO_ARCH_AVR)
90 #if defined(__AVR_ATmega32U4__)
91 #define DEFAULT_RFM95_IRQ_PIN (3)
93 #define DEFAULT_RFM95_IRQ_PIN (2)
95 #elif defined(ARDUINO_ARCH_ESP8266)
96 #define DEFAULT_RFM95_IRQ_PIN (5)
97 #elif defined(ARDUINO_ARCH_ESP32)
98 #define DEFAULT_RFM95_IRQ_PIN (16)
99 #define DEFAULT_RFM95_IRQ_NUM digitalPinToInterrupt(DEFAULT_RFM95_IRQ_PIN)
100 #elif defined(ARDUINO_ARCH_SAMD)
101 #define DEFAULT_RFM95_IRQ_PIN (2)
102 #elif defined(LINUX_ARCH_RASPBERRYPI)
103 #define DEFAULT_RFM95_IRQ_PIN (22)
104 #elif defined(ARDUINO_ARCH_STM32F1)
105 #define DEFAULT_RFM95_IRQ_PIN (PA3)
106 #elif defined(TEENSYDUINO)
107 #define DEFAULT_RFM95_IRQ_PIN (8)
109 #define DEFAULT_RFM95_IRQ_PIN (2)
112 #define DEFAULT_RFM95_CS_PIN (SS)
115 #define RFM95_SPI_DATA_ORDER MSBFIRST
116 #define RFM95_SPI_DATA_MODE SPI_MODE0
119 #define RFM95_BW125CR45SF128 RFM95_BW_125KHZ | RFM95_CODING_RATE_4_5, RFM95_SPREADING_FACTOR_128CPS | RFM95_RX_PAYLOAD_CRC_ON, RFM95_AGC_AUTO_ON
120 #define RFM95_BW500CR45SF128 RFM95_BW_500KHZ | RFM95_CODING_RATE_4_5, RFM95_SPREADING_FACTOR_128CPS | RFM95_RX_PAYLOAD_CRC_ON, RFM95_AGC_AUTO_ON
121 #define RFM95_BW31_25CR48SF512 RFM95_BW_31_25KHZ | RFM95_CODING_RATE_4_8, RFM95_SPREADING_FACTOR_512CPS | RFM95_RX_PAYLOAD_CRC_ON, RFM95_AGC_AUTO_ON
122 #define RFM95_BW125CR48SF4096 RFM95_BW_125KHZ | RFM95_CODING_RATE_4_8, RFM95_SPREADING_FACTOR_4096CPS | RFM95_RX_PAYLOAD_CRC_ON, RFM95_AGC_AUTO_ON | RFM95_LOW_DATA_RATE_OPTIMIZE
124 #if !defined(RFM95_RETRY_TIMEOUT_MS)
130 #define RFM95_RETRY_TIMEOUT_MS (500ul)
133 #if !defined(MY_RFM95_TX_TIMEOUT_MS)
134 #define MY_RFM95_TX_TIMEOUT_MS (5*1000ul)
138 #define RFM95_169MHZ (169000000ul)
139 #define RFM95_315MHZ (315000000ul)
140 #define RFM95_434MHZ (433920000ul)
141 #define RFM95_868MHZ (868100000ul)
142 #define RFM95_915MHZ (915000000ul)
144 #define RFM95_RETRIES (5u)
145 #define RFM95_FIFO_SIZE (0xFFu)
146 #define RFM95_RX_FIFO_ADDR (0x00u)
147 #define RFM95_TX_FIFO_ADDR (0x80u)
148 #define RFM95_MAX_PACKET_LEN (0x40u)
149 #define RFM95_PREAMBLE_LENGTH (8u)
150 #define RFM95_CAD_TIMEOUT_MS (2*1000ul)
151 #define RFM95_POWERUP_DELAY_MS (100u)
153 #define RFM95_PACKET_HEADER_VERSION (1u)
154 #define RFM95_MIN_PACKET_HEADER_VERSION (1u)
155 #define RFM95_BIT_ACK_REQUESTED (7u)
156 #define RFM95_BIT_ACK_RECEIVED (6u)
157 #define RFM95_BIT_ACK_RSSI_REPORT (5u)
159 #define RFM95_BROADCAST_ADDRESS (255u)
160 #define RFM95_ATC_TARGET_RANGE_DBM (2u)
161 #define RFM95_RSSI_OFFSET (137u)
162 #define RFM95_TARGET_RSSI (-70)
163 #define RFM95_PROMISCUOUS (false)
165 #define RFM95_FXOSC (32*1000000ul)
166 #define RFM95_FSTEP (RFM95_FXOSC / 524288.0f)
169 #define RFM95_getACKRequested(__value) ((bool)bitRead(__value, RFM95_BIT_ACK_REQUESTED))
170 #define RFM95_setACKRequested(__value, __flag) bitWrite(__value, RFM95_BIT_ACK_REQUESTED,__flag)
171 #define RFM95_getACKReceived(__value) ((bool)bitRead(__value, RFM95_BIT_ACK_RECEIVED))
172 #define RFM95_setACKReceived(__value, __flag) bitWrite(__value, RFM95_BIT_ACK_RECEIVED,__flag)
173 #define RFM95_setACKRSSIReport(__value, __flag) bitWrite(__value, RFM95_BIT_ACK_RSSI_REPORT,__flag)
174 #define RFM95_getACKRSSIReport(__value) ((bool)bitRead(__value, RFM95_BIT_ACK_RSSI_REPORT))
175 #define RFM95_internalToSNR(__value) ((int8_t)(__value / 4))
177 #define RFM95_MIN_POWER_LEVEL_DBM ((rfm95_powerLevel_t)5u)
178 #if defined(MY_RFM95_MAX_POWER_LEVEL_DBM)
179 #define RFM95_MAX_POWER_LEVEL_DBM MY_RFM95_MAX_POWER_LEVEL_DBM
181 #define RFM95_MAX_POWER_LEVEL_DBM ((rfm95_powerLevel_t)23u)
244 #define RFM95_HEADER_LEN sizeof(rfm95_header_t)
245 #define RFM95_MAX_PAYLOAD_LEN (RFM95_MAX_PACKET_LEN - RFM95_HEADER_LEN)
409 const uint8_t bufferSize,
const bool noACK);
RFM95 modem config registers.
RFM95 internal variables.
char data[MAX_PAYLOAD_SIZE+1]
Buffer for raw payload data.
int8_t rfm95_SNR_t
SNR data type.
@ RFM95_RADIO_MODE_TX
TX mode.
bool ackReceived
ACK received.
LOCAL bool RFM95_send(const uint8_t recipient, uint8_t *data, const uint8_t len, const rfm95_controlFlags_t flags, const bool increaseSequenceCounter=true)
RFM95_send.
uint8_t rfm95_controlFlags_t
Control flag data type.
LOCAL bool RFM95_sanityCheck(void)
RFM95_sanityCheck.
LOCAL bool RFM95_setTxPowerPercent(const uint8_t newPowerPercent)
Sets the transmitter power output percent.
LOCAL int16_t RFM95_getSendingSNR(void)
RFM95_getSendingSNR.
bool ATCenabled
ATC enabled.
rfm95_radioMode_t radioMode
current transceiver state
LOCAL void RFM95_powerDown(void)
Powerdown radio, if RFM95_POWER_PIN defined.
LOCAL bool RFM95_executeATC(const rfm95_RSSI_t currentRSSI, const rfm95_RSSI_t targetRSSI)
RFM_executeATC.
LOCAL void RFM95_setAddress(const uint8_t addr)
Set the driver/node address.
rfm95_packet_t currentPacket
Buffer for current packet.
LOCAL bool RFM95_waitCAD(void)
Wait until no channel activity detected.
uint8_t rfm95_RSSI_t
RSSI data type.
uint16_t rfm95_sequenceNumber_t
Sequence number data type.
LOCAL bool RFM95_standBy(void)
Sets the radio into standby mode.
LOCAL bool RFM95_setTxPowerLevel(rfm95_powerLevel_t newPowerLevel)
Sets the transmitter power output level, and configures the transmitter pin.
LOCAL bool RFM95_sleep(void)
Sets the radio into low-power sleep mode.
LOCAL void RFM95_interruptHandler(void)
Low level interrupt handler.
LOCAL void RFM95_setModemRegisters(const rfm95_modemConfig_t *config)
Sets all the registers required to configure the data modem in the RF95/96/97/98, including the bandw...
#define RFM95_TARGET_RSSI
RSSI target.
rfm95_ack_t ACK
Union: ACK.
LOCAL void RFM95_enableTCXO(void)
Enable TCXO mode Call this immediately after init(), to force your radio to use an external frequency...
rfm95_sequenceNumber_t sequenceNumber
Packet sequence number, used for ACK.
LOCAL void RFM95_setPreambleLength(const uint16_t preambleLength)
RFM95_setPreambleLength.
rfm95_RSSI_t ATCtargetRSSI
ATC: target RSSI.
uint8_t reg_26
Value for register REG_26_MODEM_CONFIG3.
LOCAL uint8_t RFM95_getAddress(void)
Get driver/node address.
struct @4::@5 __attribute__
Doxygen will complain without this comment.
@ RFM95_RADIO_MODE_CAD
CAD mode.
#define RFM95_MAX_PAYLOAD_LEN
Max payload length.
LOCAL void RFM95_ATCmode(const bool OnOff, const int16_t targetRSSI=RFM95_TARGET_RSSI)
RFM95_ATCmode.
@ RFM95_RADIO_MODE_RX
RX mode.
LOCAL void RFM95_setFrequency(const uint32_t frequencyHz)
Sets the transmitter and receiver centre frequency.
LOCAL int16_t RFM95_getReceivingSNR(void)
RFM95_getReceivingSNR.
rfm95_header_t header
LoRa header.
int8_t rfm95_powerLevel_t
Power level in dBm.
LOCAL void RFM95_interruptHandling(void)
Packet engine.
LOCAL int16_t RFM95_getReceivingRSSI(void)
RFM95_getSendingRSSI.
uint8_t sender
8 bit - Id of sender node (origin)
LOCAL void RFM95_sendACK(const uint8_t recipient, const rfm95_sequenceNumber_t sequenceNumber, const rfm95_RSSI_t RSSI, const rfm95_SNR_t SNR)
RFM95_sendACK.
rfm95_sequenceNumber_t txSequenceNumber
RFM95_txSequenceNumber.
bool dataReceived
Data received.
LOCAL bool RFM95_initialise(const uint32_t frequencyHz)
Initialise the driver transport hardware and software.
LOCAL uint8_t RFM95_getTxPowerLevel(void)
Get transmitter power level.
uint8_t reg_1e
Value for register REG_1E_MODEM_CONFIG2.
@ RFM95_RADIO_MODE_STDBY
STDBY mode.
LOCAL void RFM95_handler(void)
RFM95_handler.
rfm95_powerLevel_t powerLevel
TX power level dBm.
LOCAL bool RFM95_available(void)
Tests whether a new message is available.
uint8_t reg_1d
Value for register REG_1D_MODEM_CONFIG1.
LOCAL bool RFM95_sendWithRetry(const uint8_t recipient, const void *buffer, const uint8_t bufferSize, const bool noACK)
RFM95_sendWithRetry.
LOCAL int16_t RFM95_getSendingRSSI(void)
RFM95_getSendingRSSI.
#define RFM95_MAX_PACKET_LEN
This is the maximum number of bytes that can be carried by the LORA.
LOCAL uint8_t RFM95_getTxPowerPercent(void)
Get transmitter power level.
rfm95_controlFlags_t controlFlags
Control flags, used for ACK.
LOCAL void RFM95_powerUp(void)
Powerup radio, if RFM95_POWER_PIN defined.
LOCAL uint8_t RFM95_receive(uint8_t *buf, const uint8_t maxBufSize)
If a valid message is received, copy it to buf and return length. 0 byte messages are permitted.
LOCAL bool RFM95_sendFrame(rfm95_packet_t *packet, const bool increaseSequenceCounter=true)
RFM95_sendFrame.
uint8_t address
Node address.
bool channelActive
RFM95_cad.
rfm95_radioMode_t
Radio modes.
LOCAL bool RFM95_setRadioMode(const rfm95_radioMode_t newRadioMode)
RFM95_setRadioMode.
@ RFM95_RADIO_MODE_SLEEP
SLEEP mode.