MySensors Library & Examples  2.3.2-62-ge298769
RFM69_new.h
Go to the documentation of this file.
1 /*
2  * The MySensors Arduino library handles the wireless radio link and protocol
3  * between your home built sensors/actuators and HA controller of choice.
4  * The sensors forms a self healing radio network with optional repeaters. Each
5  * repeater and gateway builds a routing tables in EEPROM which keeps track of the
6  * network topology allowing messages to be routed to nodes.
7  *
8  * Created by Henrik Ekblad <[email protected]>
9  * Copyright (C) 2013-2022 Sensnology AB
10  * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
11  *
12  * Documentation: http://www.mysensors.org
13  * Support Forum: http://forum.mysensors.org
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * version 2 as published by the Free Software Foundation.
18  *
19  * RFM69 driver refactored for MySensors
20  *
21  * Based on :
22  * - LowPowerLab RFM69 Lib Copyright Felix Rusu (2014), [email protected]
23  * - Automatic Transmit Power Control class derived from RFM69 library.
24  * Discussion and details in this forum post: https://lowpowerlab.com/forum/index.php/topic,688.0.html
25  * Copyright Thomas Studwell (2014,2015)
26  * - MySensors generic radio driver implementation Copyright (C) 2017, 2018 Olivier Mauti <[email protected]>
27  *
28  * Changes by : @tekka, @scalz, @marceloagno, @docbender
29  *
30  * Definitions for Semtech SX1231/H radios:
31  * https://www.semtech.com/uploads/documents/sx1231.pdf
32  * https://www.semtech.com/uploads/documents/sx1231h.pdf
33  */
34 
35 
74 #ifndef _RFM69_h
75 #define _RFM69_h
76 
77 #include "RFM69registers_new.h"
78 
79 #if !defined(RFM69_SPI)
80 #define RFM69_SPI hwSPI
81 #endif
82 
83 #if defined(ARDUINO_ARCH_AVR)
84 #if defined(__AVR_ATmega32U4__)
85 #define DEFAULT_RFM69_IRQ_PIN (3)
86 #else
87 #define DEFAULT_RFM69_IRQ_PIN (2)
88 #endif
89 #elif defined(ARDUINO_ARCH_ESP8266)
90 #define DEFAULT_RFM69_IRQ_PIN (5)
91 #elif defined(ARDUINO_ARCH_ESP32)
92 #define DEFAULT_RFM69_IRQ_PIN (16)
93 #define DEFAULT_RFM69_IRQ_NUM digitalPinToInterrupt(DEFAULT_RFM69_IRQ_PIN)
94 #elif defined(ARDUINO_ARCH_SAMD)
95 #define DEFAULT_RFM69_IRQ_PIN (2)
96 #elif defined(LINUX_ARCH_RASPBERRYPI)
97 #define DEFAULT_RFM69_IRQ_PIN (22)
98 #elif defined(ARDUINO_ARCH_STM32F1)
99 #define DEFAULT_RFM69_IRQ_PIN (PA3)
100 #elif defined(TEENSYDUINO)
101 #define DEFAULT_RFM69_IRQ_PIN (8)
102 #else
103 #define DEFAULT_RFM69_IRQ_PIN (2)
104 #endif
105 
106 #define DEFAULT_RFM69_CS_PIN (SS)
107 
108 // SPI settings
109 #define RFM69_SPI_DATA_ORDER MSBFIRST
110 #define RFM69_SPI_DATA_MODE SPI_MODE0
111 
112 // Additional radio settings
113 #define RFM69_SYNCVALUE1 (0x2D)
114 
115 #if (MY_RFM69HW==true)
116 // RFM69H(C)W
117 #define RFM69_VERSION_HW
118 #define RFM69_MIN_POWER_LEVEL_DBM ((rfm69_powerlevel_t)-2)
119 #if defined(MY_RFM69_MAX_POWER_LEVEL_DBM)
120 #define RFM69_MAX_POWER_LEVEL_DBM MY_RFM69_MAX_POWER_LEVEL_DBM
121 #else
122 #define RFM69_MAX_POWER_LEVEL_DBM ((rfm69_powerlevel_t)20)
123 #endif
124 #else
125 // RFM69(C)W
126 #define RFM69_MIN_POWER_LEVEL_DBM ((rfm69_powerlevel_t)-18)
127 #if defined(MY_RFM69_MAX_POWER_LEVEL_DBM)
128 #define RFM69_MAX_POWER_LEVEL_DBM MY_RFM69_MAX_POWER_LEVEL_DBM
129 #else
130 #define RFM69_MAX_POWER_LEVEL_DBM ((rfm69_powerlevel_t)13)
131 #endif
132 #endif
133 
134 #define RFM69_FIFO_SIZE (0xFFu)
135 #define RFM69_MAX_PACKET_LEN static_cast<size_t>(0x40u)
136 #define RFM69_ATC_TARGET_RANGE_DBM (2u)
137 #define RFM69_PACKET_HEADER_VERSION (1u)
138 #define RFM69_MIN_PACKET_HEADER_VERSION (1u)
139 
140 #define RFM69_RETRIES (5u)
141 #define RFM69_RETRY_TIMEOUT_MS (200ul)
142 #define RFM69_MODE_READY_TIMEOUT_MS (50ul)
143 
144 #define RFM69_ACK_REQUESTED (7u)
145 #define RFM69_ACK_RECEIVED (6u)
146 #define RFM69_ACK_RSSI_REPORT (5u)
147 
148 #define RFM69_BROADCAST_ADDRESS (255u)
149 #define RFM69_TARGET_RSSI_DBM (-75)
150 #define RFM69_HIGH_POWER_DBM (18u)
151 
152 #if !defined(MY_RFM69_TX_TIMEOUT_MS)
153 #define MY_RFM69_TX_TIMEOUT_MS (2*1000ul)
154 #endif
155 
156 // CSMA settings
157 #if !defined(MY_RFM69_CSMA_LIMIT_DBM)
158 #define MY_RFM69_CSMA_LIMIT_DBM (-95)
159 #endif
160 #if !defined(MY_RFM69_CSMA_TIMEOUT_MS)
161 #define MY_RFM69_CSMA_TIMEOUT_MS (500ul)
162 #endif
163 // powerup delay
164 #define RFM69_POWERUP_DELAY_MS (100ul)
165 
166 // available frequency bands, non trivial values to avoid misconfiguration
167 #define RFM69_315MHZ (315000000ul)
168 #define RFM69_433MHZ (433920000ul)
169 #define RFM69_865MHZ (865500000ul)
170 #define RFM69_868MHZ (868000000ul)
171 #define RFM69_915MHZ (915000000ul)
172 
173 #define RFM69_COURSE_TEMP_COEF (-90)
174 #define RFM69_FXOSC (32*1000000ul)
175 #define RFM69_FSTEP (RFM69_FXOSC / 524288.0f)
176 
177 // helper macros
178 #define RFM69_getACKRequested(__value) ((bool)bitRead(__value,RFM69_ACK_REQUESTED))
179 #define RFM69_setACKRequested(__value, __flag) bitWrite(__value,RFM69_ACK_REQUESTED,__flag)
180 #define RFM69_getACKReceived(__value) ((bool)bitRead(__value,RFM69_ACK_RECEIVED))
181 #define RFM69_setACKReceived(__value, __flag) bitWrite(__value,RFM69_ACK_RECEIVED,__flag)
182 #define RFM69_setACKRSSIReport(__value, __flag) bitWrite(__value,RFM69_ACK_RSSI_REPORT,__flag)
183 #define RFM69_getACKRSSIReport(__value) ((bool)bitRead(__value,RFM69_ACK_RSSI_REPORT))
184 
185 // Register access
186 #define RFM69_READ_REGISTER (0x7Fu)
187 #define RFM69_WRITE_REGISTER (0x80u)
188 
189 // Modem configuration section
190 #define RFM69_CONFIG_FSK (RFM69_DATAMODUL_DATAMODE_PACKET | RFM69_DATAMODUL_MODULATIONTYPE_FSK | RFM69_DATAMODUL_MODULATIONSHAPING_00)
191 #define RFM69_CONFIG_GFSK (RFM69_DATAMODUL_DATAMODE_PACKET | RFM69_DATAMODUL_MODULATIONTYPE_FSK | RFM69_DATAMODUL_MODULATIONSHAPING_10)
192 #define RFM69_CONFIG_OOK (RFM69_DATAMODUL_DATAMODE_PACKET | RFM69_DATAMODUL_MODULATIONTYPE_OOK | RFM69_DATAMODUL_MODULATIONSHAPING_00)
193 
194 #define RFM69_CONFIG_NOWHITE (RFM69_PACKET1_FORMAT_VARIABLE | RFM69_PACKET1_DCFREE_OFF | RFM69_PACKET1_CRC_ON | RFM69_PACKET1_CRCAUTOCLEAR_ON | RFM69_PACKET1_ADRSFILTERING_NODEBROADCAST)
195 #define RFM69_CONFIG_WHITE (RFM69_PACKET1_FORMAT_VARIABLE | RFM69_PACKET1_DCFREE_WHITENING | RFM69_PACKET1_CRC_ON | RFM69_PACKET1_CRCAUTOCLEAR_ON | RFM69_PACKET1_ADRSFILTERING_NODEBROADCAST)
196 #define RFM69_CONFIG_MANCHESTER (RFM69_PACKET1_FORMAT_VARIABLE | RFM69_PACKET1_DCFREE_MANCHESTER | RFM69_PACKET1_CRC_ON | RFM69_PACKET1_CRCAUTOCLEAR_ON | RFM69_PACKET1_ADRSFILTERING_NODEBROADCAST)
197 
198 #define RFM69_RXBW_111_24_4 (RFM69_RXBW_DCCFREQ_111 | RFM69_RXBW_MANT_24 | RFM69_RXBW_EXP_4)
199 #define RFM69_RXBW_111_24_3 (RFM69_RXBW_DCCFREQ_111 | RFM69_RXBW_MANT_24 | RFM69_RXBW_EXP_3)
200 #define RFM69_RXBW_111_24_2 (RFM69_RXBW_DCCFREQ_111 | RFM69_RXBW_MANT_24 | RFM69_RXBW_EXP_2)
201 #define RFM69_RXBW_111_16_2 (RFM69_RXBW_DCCFREQ_111 | RFM69_RXBW_MANT_16 | RFM69_RXBW_EXP_2)
202 #define RFM69_RXBW_111_16_1 (RFM69_RXBW_DCCFREQ_111 | RFM69_RXBW_MANT_16 | RFM69_RXBW_EXP_1)
203 #define RFM69_RXBW_111_16_0 (RFM69_RXBW_DCCFREQ_111 | RFM69_RXBW_MANT_16 | RFM69_RXBW_EXP_0)
204 #define RFM69_RXBW_010_16_2 (RFM69_RXBW_DCCFREQ_010 | RFM69_RXBW_MANT_16 | RFM69_RXBW_EXP_2)
205 
206 #define RFM69_FSK_BR2_FD5 RFM69_CONFIG_FSK, RFM69_BITRATEMSB_2000, RFM69_BITRATELSB_2000, RFM69_FDEVMSB_5000, RFM69_FDEVLSB_5000, RFM69_RXBW_111_24_4, RFM69_CONFIG_WHITE
207 #define RFM69_FSK_BR2_4_FD4_8 RFM69_CONFIG_FSK, RFM69_BITRATEMSB_2400, RFM69_BITRATELSB_2400, RFM69_FDEVMSB_4800, RFM69_FDEVLSB_4800, RFM69_RXBW_111_24_4, RFM69_CONFIG_WHITE
208 #define RFM69_FSK_BR4_8_FD9_6 RFM69_CONFIG_FSK, RFM69_BITRATEMSB_4800, RFM69_BITRATELSB_4800, RFM69_FDEVMSB_9600, RFM69_FDEVLSB_9600, RFM69_RXBW_111_24_4, RFM69_CONFIG_WHITE
209 #define RFM69_FSK_BR9_6_FD19_2 RFM69_CONFIG_FSK, RFM69_BITRATEMSB_9600, RFM69_BITRATELSB_9600, RFM69_FDEVMSB_19200, RFM69_FDEVLSB_19200, RFM69_RXBW_111_24_4, RFM69_CONFIG_WHITE
210 #define RFM69_FSK_BR19_2_FD38_4 RFM69_CONFIG_FSK, RFM69_BITRATEMSB_19200, RFM69_BITRATELSB_19200, RFM69_FDEVMSB_38400, RFM69_FDEVLSB_38400, RFM69_RXBW_111_24_3, RFM69_CONFIG_WHITE
211 #define RFM69_FSK_BR38_4_FD76_8 RFM69_CONFIG_FSK, RFM69_BITRATEMSB_38400, RFM69_BITRATELSB_38400, RFM69_FDEVMSB_76800, RFM69_FDEVLSB_76800, RFM69_RXBW_111_24_2, RFM69_CONFIG_WHITE
212 #define RFM69_FSK_BR55_5_FD50 RFM69_CONFIG_FSK, RFM69_BITRATEMSB_55555, RFM69_BITRATELSB_55555, RFM69_FDEVMSB_50000, RFM69_FDEVLSB_50000, RFM69_RXBW_111_16_2, RFM69_CONFIG_WHITE
213 #define RFM69_FSK_BR57_6_FD120 RFM69_CONFIG_FSK, RFM69_BITRATEMSB_57600, RFM69_BITRATELSB_57600, RFM69_FDEVMSB_120000, RFM69_FDEVLSB_120000, RFM69_RXBW_111_16_1, RFM69_CONFIG_WHITE
214 #define RFM69_FSK_BR125_FD125 RFM69_CONFIG_FSK, RFM69_BITRATEMSB_125000, RFM69_BITRATELSB_125000, RFM69_FDEVMSB_125000, RFM69_FDEVLSB_125000, RFM69_RXBW_010_16_2, RFM69_CONFIG_WHITE
215 #define RFM69_FSK_BR250_FD250 RFM69_CONFIG_FSK, RFM69_BITRATEMSB_250000, RFM69_BITRATELSB_250000, RFM69_FDEVMSB_250000, RFM69_FDEVLSB_250000, RFM69_RXBW_111_16_0, RFM69_CONFIG_WHITE
216 
217 #define RFM69_GFSK_BR2_FD5 RFM69_CONFIG_GFSK, RFM69_BITRATEMSB_2000, RFM69_BITRATELSB_2000, RFM69_FDEVMSB_5000, RFM69_FDEVLSB_5000, RFM69_RXBW_111_24_4, RFM69_CONFIG_WHITE
218 #define RFM69_GFSK_BR2_4_FD4_8 RFM69_CONFIG_GFSK, RFM69_BITRATEMSB_2400, RFM69_BITRATELSB_2400, RFM69_FDEVMSB_4800, RFM69_FDEVLSB_4800, RFM69_RXBW_111_24_4, RFM69_CONFIG_WHITE
219 #define RFM69_GFSK_BR4_8_FD9_6 RFM69_CONFIG_GFSK, RFM69_BITRATEMSB_4800, RFM69_BITRATELSB_4800, RFM69_FDEVMSB_9600, RFM69_FDEVLSB_9600, RFM69_RXBW_111_24_4, RFM69_CONFIG_WHITE
220 #define RFM69_GFSK_BR9_6_FD19_2 RFM69_CONFIG_GFSK, RFM69_BITRATEMSB_9600, RFM69_BITRATELSB_9600, RFM69_FDEVMSB_19200, RFM69_FDEVLSB_19200, RFM69_RXBW_111_24_4, RFM69_CONFIG_WHITE
221 #define RFM69_GFSK_BR19_2_FD38_4 RFM69_CONFIG_GFSK, RFM69_BITRATEMSB_19200, RFM69_BITRATELSB_19200, RFM69_FDEVMSB_38400, RFM69_FDEVLSB_38400, RFM69_RXBW_111_24_3, RFM69_CONFIG_WHITE
222 #define RFM69_GFSK_BR38_4_FD76_8 RFM69_CONFIG_GFSK, RFM69_BITRATEMSB_38400, RFM69_BITRATELSB_38400, RFM69_FDEVMSB_76800, RFM69_FDEVLSB_76800, RFM69_RXBW_111_24_2, RFM69_CONFIG_WHITE
223 #define RFM69_GFSK_BR55_5_FD50 RFM69_CONFIG_GFSK, RFM69_BITRATEMSB_55555, RFM69_BITRATELSB_55555, RFM69_FDEVMSB_50000, RFM69_FDEVLSB_50000, RFM69_RXBW_111_16_2, RFM69_CONFIG_WHITE
224 #define RFM69_GFSK_BR57_6_FD120 RFM69_CONFIG_GFSK, RFM69_BITRATEMSB_57600, RFM69_BITRATELSB_57600, RFM69_FDEVMSB_120000, RFM69_FDEVLSB_120000, RFM69_RXBW_111_16_1, RFM69_CONFIG_WHITE
225 #define RFM69_GFSK_BR125_FD125 RFM69_CONFIG_GFSK, RFM69_BITRATEMSB_125000, RFM69_BITRATELSB_125000, RFM69_FDEVMSB_125000, RFM69_FDEVLSB_125000, RFM69_RXBW_010_16_2, RFM69_CONFIG_WHITE
226 #define RFM69_GFSK_BR250_FD250 RFM69_CONFIG_GFSK, RFM69_BITRATEMSB_250000, RFM69_BITRATELSB_250000, RFM69_FDEVMSB_250000, RFM69_FDEVLSB_250000, RFM69_RXBW_111_16_0, RFM69_CONFIG_WHITE
227 
228 #define RFM69_OOK_BR2_FD5 RFM69_CONFIG_OOK, RFM69_BITRATEMSB_2000, RFM69_BITRATELSB_2000, RFM69_FDEVMSB_5000, RFM69_FDEVLSB_5000, RFM69_RXBW_111_24_4, RFM69_CONFIG_WHITE
229 #define RFM69_OOK_BR2_4_FD4_8 RFM69_CONFIG_OOK, RFM69_BITRATEMSB_2400, RFM69_BITRATELSB_2400, RFM69_FDEVMSB_4800, RFM69_FDEVLSB_4800, RFM69_RXBW_111_24_4, RFM69_CONFIG_WHITE
230 #define RFM69_OOK_BR4_8_FD9_6 RFM69_CONFIG_OOK, RFM69_BITRATEMSB_4800, RFM69_BITRATELSB_4800, RFM69_FDEVMSB_9600, RFM69_FDEVLSB_9600, RFM69_RXBW_111_24_4, RFM69_CONFIG_WHITE
231 #define RFM69_OOK_BR9_6_FD19_2 RFM69_CONFIG_OOK, RFM69_BITRATEMSB_9600, RFM69_BITRATELSB_9600, RFM69_FDEVMSB_19200, RFM69_FDEVLSB_19200, RFM69_RXBW_111_24_4, RFM69_CONFIG_WHITE
232 #define RFM69_OOK_BR19_2_FD38_4 RFM69_CONFIG_OOK, RFM69_BITRATEMSB_19200, RFM69_BITRATELSB_19200, RFM69_FDEVMSB_38400, RFM69_FDEVLSB_38400, RFM69_RXBW_111_24_3, RFM69_CONFIG_WHITE
233 #define RFM69_OOK_BR38_4_FD76_8 RFM69_CONFIG_OOK, RFM69_BITRATEMSB_38400, RFM69_BITRATELSB_38400, RFM69_FDEVMSB_76800, RFM69_FDEVLSB_76800, RFM69_RXBW_111_24_2, RFM69_CONFIG_WHITE
234 #define RFM69_OOK_BR55_5_FD50 RFM69_CONFIG_OOK, RFM69_BITRATEMSB_55555, RFM69_BITRATELSB_55555, RFM69_FDEVMSB_50000, RFM69_FDEVLSB_50000, RFM69_RXBW_111_16_2, RFM69_CONFIG_WHITE
235 #define RFM69_OOK_BR57_6_FD120 RFM69_CONFIG_OOK, RFM69_BITRATEMSB_57600, RFM69_BITRATELSB_57600, RFM69_FDEVMSB_120000, RFM69_FDEVLSB_120000, RFM69_RXBW_111_16_1, RFM69_CONFIG_WHITE
236 #define RFM69_OOK_BR125_FD125 RFM69_CONFIG_OOK, RFM69_BITRATEMSB_125000, RFM69_BITRATELSB_125000, RFM69_FDEVMSB_125000, RFM69_FDEVLSB_125000, RFM69_RXBW_010_16_2, RFM69_CONFIG_WHITE
237 #define RFM69_OOK_BR250_FD250 RFM69_CONFIG_OOK, RFM69_BITRATEMSB_250000, RFM69_BITRATELSB_250000, RFM69_FDEVMSB_250000, RFM69_FDEVLSB_250000, RFM69_RXBW_111_16_0, RFM69_CONFIG_WHITE
238 
239 #if !defined(MY_RFM69_MODEM_CONFIGURATION)
240 #define MY_RFM69_MODEM_CONFIGURATION RFM69_FSK_BR55_5_FD50
241 #endif
242 
246 typedef enum {
255 
259 typedef uint8_t rfm69_sequenceNumber_t;
263 typedef uint8_t rfm69_RSSI_t;
267 typedef int8_t rfm69_SNR_t;
271 typedef uint8_t rfm69_controlFlags_t;
275 typedef int8_t rfm69_powerlevel_t;
276 
281 typedef struct {
282  uint8_t packetLen;
283  uint8_t recipient;
284  uint8_t version;
285  uint8_t sender;
288 } __attribute__((packed)) rfm69_header_t;
289 
293 typedef struct {
294  rfm69_sequenceNumber_t sequenceNumber;
296 } __attribute__((packed)) rfm69_ack_t;
297 
298 #define RFM69_HEADER_LEN sizeof(rfm69_header_t)
299 #define RFM69_MAX_PAYLOAD_LEN (RFM69_MAX_PACKET_LEN - RFM69_HEADER_LEN)
300 
301 
305 typedef struct {
306  union {
307  struct {
308  rfm69_header_t header;
309  union {
310  uint8_t payload[RFM69_MAX_PAYLOAD_LEN];
311  rfm69_ack_t ACK;
312  };
313  };
314  uint8_t data[RFM69_MAX_PACKET_LEN];
315  };
316  uint8_t payloadLen;
317  rfm69_RSSI_t RSSI;
318 } __attribute__((packed)) rfm69_packet_t;
319 
323 typedef struct {
324  uint8_t address;
325  rfm69_packet_t currentPacket;
328  uint8_t ATCtargetRSSI;
329  // 8 bit
331  bool dataReceived : 1;
332  bool ackReceived : 1;
333  bool ATCenabled : 1;
334  uint8_t reserved : 2;
336 
337 #define LOCAL static
338 
339 
342 LOCAL void RFM69_handler(void);
343 
347 LOCAL void RFM69_clearFIFO(void);
348 
353 LOCAL bool RFM69_channelFree(void);
354 
358 LOCAL void RFM69_interruptHandling(void);
359 
365 LOCAL bool RFM69_initialise(const uint32_t frequencyHz);
366 
371 LOCAL void RFM69_setAddress(const uint8_t addr);
372 
377 LOCAL uint8_t RFM69_getAddress(void);
378 
383 LOCAL bool RFM69_available(void);
384 
391 LOCAL uint8_t RFM69_receive(uint8_t *buf, const uint8_t maxBufSize);
392 
399 LOCAL bool RFM69_sendFrame(rfm69_packet_t *packet, const bool increaseSequenceCounter = true);
400 
410 LOCAL bool RFM69_send(const uint8_t recipient, uint8_t *data, const uint8_t len,
411  const rfm69_controlFlags_t flags, const bool increaseSequenceCounter = true);
412 
417 LOCAL void RFM69_setFrequency(const uint32_t frequencyHz);
418 
425 
431 
436 LOCAL uint8_t RFM69_getTxPowerPercent(void);
437 
442 LOCAL bool RFM69_sleep(void);
443 
448 LOCAL bool RFM69_standBy(void);
449 
453 LOCAL void RFM69_powerDown(void);
454 
458 LOCAL void RFM69_powerUp(void);
459 
466 LOCAL void RFM69_sendACK(const uint8_t recipient, const rfm69_sequenceNumber_t sequenceNumber,
467  const rfm69_RSSI_t RSSI);
468 
477 LOCAL bool RFM69_sendWithRetry(const uint8_t recipient, const void *buffer,
478  const uint8_t bufferSize,
479  const bool noACK);
480 
486 LOCAL bool RFM69_setRadioMode(const rfm69_radio_mode_t newRadioMode);
487 
491 LOCAL void RFM69_interruptHandler(void);
492 
497 LOCAL int16_t RFM69_getSendingRSSI(void);
498 
503 LOCAL int16_t RFM69_getReceivingRSSI(void);
504 
511 LOCAL bool RFM69_executeATC(const rfm69_RSSI_t currentRSSI, const rfm69_RSSI_t targetRSSI);
512 
513 // TEMP ADDED
517 LOCAL void RFM69_setConfiguration(void);
518 
523 LOCAL bool RFM69_isModeReady(void);
524 
529 LOCAL bool RFM69_sanityCheck(void);
530 
535 LOCAL void RFM69_encrypt(const char *key);
536 
541 LOCAL void RFM69_setHighPowerRegs(const bool onOff);
542 
548 LOCAL rfm69_RSSI_t RFM69_readRSSI(const bool forceTrigger = false);
549 
555 LOCAL void RFM69_ATCmode(const bool onOff, const int16_t targetRSSI = RFM69_TARGET_RSSI_DBM);
556 
562 LOCAL void RFM69_readAllRegs(void);
563 
564 #endif
565 
data
char data[MAX_PAYLOAD_SIZE+1]
Buffer for raw payload data.
Definition: MyMessage.h:654
RFM69_setTxPowerLevel
LOCAL bool RFM69_setTxPowerLevel(rfm69_powerlevel_t newPowerLevel)
Sets the transmitter power output level, and configures the transmitter pin.
rfm69_internal_t::txSequenceNumber
rfm69_sequenceNumber_t txSequenceNumber
RFM69_txSequenceNumber.
Definition: RFM69_new.h:326
RFM69_sleep
LOCAL bool RFM69_sleep(void)
Sets the radio into low-power sleep mode.
RFM69_RADIO_MODE_SLEEP
@ RFM69_RADIO_MODE_SLEEP
SLEEP mode.
Definition: RFM69_new.h:250
RFM69_readAllRegs
LOCAL void RFM69_readAllRegs(void)
RFM69_readAllRegs Read and display all RFM69 register contents.
RFM69_RADIO_MODE_STDBY
@ RFM69_RADIO_MODE_STDBY
STDBY mode.
Definition: RFM69_new.h:251
RFM69_getTxPowerPercent
LOCAL uint8_t RFM69_getTxPowerPercent(void)
Reports the transmitter power output level in percents.
RFM69_getSendingRSSI
LOCAL int16_t RFM69_getSendingRSSI(void)
RFM69_getSendingRSSI.
LOCAL
#define LOCAL
static
Definition: RFM69_new.h:337
RFM69_available
LOCAL bool RFM69_available(void)
Tests whether a new message is available.
RFM69_ATCmode
LOCAL void RFM69_ATCmode(const bool onOff, const int16_t targetRSSI=RFM69_TARGET_RSSI_DBM)
RFM69_ATCmode.
__attribute__::packetLen
uint8_t packetLen
packet length
Definition: RFM69_new.h:282
RFM69_sendACK
LOCAL void RFM69_sendACK(const uint8_t recipient, const rfm69_sequenceNumber_t sequenceNumber, const rfm69_RSSI_t RSSI)
RFM69_sendACK.
RFM69_standBy
LOCAL bool RFM69_standBy(void)
Sets the radio to standby mode.
RFM69_encrypt
LOCAL void RFM69_encrypt(const char *key)
RFM69_encrypt Set encryption mode.
RFM69_sanityCheck
LOCAL bool RFM69_sanityCheck(void)
RFM69_sanityCheck detect HW defect, configuration errors or interrupted SPI line.
rfm69_sequenceNumber_t
uint8_t rfm69_sequenceNumber_t
Sequence number data type.
Definition: RFM69_new.h:259
RFM69_MAX_PAYLOAD_LEN
#define RFM69_MAX_PAYLOAD_LEN
Max payload length.
Definition: RFM69_new.h:299
RFM69_RADIO_MODE_TX
@ RFM69_RADIO_MODE_TX
TX mode.
Definition: RFM69_new.h:248
rfm69_internal_t::radioMode
rfm69_radio_mode_t radioMode
current transceiver state
Definition: RFM69_new.h:330
rfm69_internal_t::ATCtargetRSSI
uint8_t ATCtargetRSSI
ATC: target RSSI.
Definition: RFM69_new.h:328
rfm69_SNR_t
int8_t rfm69_SNR_t
SNR data type.
Definition: RFM69_new.h:267
__attribute__::sequenceNumber
rfm69_sequenceNumber_t sequenceNumber
packet sequence number, used for ACK
Definition: RFM69_new.h:287
RFM69_setAddress
LOCAL void RFM69_setAddress(const uint8_t addr)
Set the driver/node address.
RFM69_RADIO_MODE_CAD
@ RFM69_RADIO_MODE_CAD
CAD mode.
Definition: RFM69_new.h:249
RFM69_setFrequency
LOCAL void RFM69_setFrequency(const uint32_t frequencyHz)
Sets the transmitter and receiver center frequency.
__attribute__::version
uint8_t version
header version (20180128tk: >=3.0.0 fused with controlFlags)
Definition: RFM69_new.h:284
rfm69_internal_t::dataReceived
bool dataReceived
data received
Definition: RFM69_new.h:331
RFM69_setHighPowerRegs
LOCAL void RFM69_setHighPowerRegs(const bool onOff)
RFM69_setHighPowerRegs.
__attribute__::recipient
uint8_t recipient
payload recipient
Definition: RFM69_new.h:283
RFM69_setConfiguration
LOCAL void RFM69_setConfiguration(void)
RFM69_setConfiguration Set general radio register configuration TODO temp use setmodemregisters.
rfm69_internal_t::address
uint8_t address
Node address.
Definition: RFM69_new.h:324
RFM69_MAX_PACKET_LEN
#define RFM69_MAX_PACKET_LEN
This is the maximum number of bytes that can be carried.
Definition: RFM69_new.h:135
__attribute__::payloadLen
uint8_t payloadLen
Length of payload (excluding header)
Definition: RFM69_new.h:316
RFM69_sendFrame
LOCAL bool RFM69_sendFrame(rfm69_packet_t *packet, const bool increaseSequenceCounter=true)
RFM69_sendFrame.
__attribute__
struct @4::@5 __attribute__
Doxygen will complain without this comment.
Definition: DigitalPin.h:65
RFM69_clearFIFO
LOCAL void RFM69_clearFIFO(void)
Clear flags and FIFO.
RFM69_interruptHandler
LOCAL void RFM69_interruptHandler(void)
Low level interrupt handler.
__attribute__::RSSI
rfm69_RSSI_t RSSI
RSSI.
Definition: RFM69_new.h:295
RFM69_getAddress
LOCAL uint8_t RFM69_getAddress(void)
Get driver/node address.
rfm69_RSSI_t
uint8_t rfm69_RSSI_t
RSSI data type.
Definition: RFM69_new.h:263
rfm69_internal_t::reserved
uint8_t reserved
Reserved.
Definition: RFM69_new.h:334
RFM69_RADIO_MODE_RX
@ RFM69_RADIO_MODE_RX
RX mode.
Definition: RFM69_new.h:247
__attribute__::sender
uint8_t sender
payload sender
Definition: RFM69_new.h:285
RFM69_sendWithRetry
LOCAL bool RFM69_sendWithRetry(const uint8_t recipient, const void *buffer, const uint8_t bufferSize, const bool noACK)
RFM69_sendWithRetry.
RFM69_powerUp
LOCAL void RFM69_powerUp(void)
Power up radio (HW)
RFM69_readRSSI
LOCAL rfm69_RSSI_t RFM69_readRSSI(const bool forceTrigger=false)
RFM69_readRSSI.
__attribute__::controlFlags
rfm69_controlFlags_t controlFlags
control flags, used for ACK
Definition: RFM69_new.h:286
RFM69_getReceivingRSSI
LOCAL int16_t RFM69_getReceivingRSSI(void)
RFM69_getReceivingRSSI.
RFM69_handler
LOCAL void RFM69_handler(void)
RFM69_handler.
RFM69_channelFree
LOCAL bool RFM69_channelFree(void)
Check for channel activity.
RFM69_initialise
LOCAL bool RFM69_initialise(const uint32_t frequencyHz)
Initialise the driver transport hardware and software.
rfm69_controlFlags_t
uint8_t rfm69_controlFlags_t
Control flag data type.
Definition: RFM69_new.h:271
RFM69_TARGET_RSSI_DBM
#define RFM69_TARGET_RSSI_DBM
RSSI target.
Definition: RFM69_new.h:149
RFM69_getTxPowerLevel
LOCAL rfm69_powerlevel_t RFM69_getTxPowerLevel(void)
Reports the transmitter power output level in dBm.
RFM69_setRadioMode
LOCAL bool RFM69_setRadioMode(const rfm69_radio_mode_t newRadioMode)
RFM69_setRadioMode.
RFM69_isModeReady
LOCAL bool RFM69_isModeReady(void)
RFM69_isModeReady.
__attribute__::header
rfm69_header_t header
Packet header.
Definition: RFM69_new.h:308
rfm69_internal_t::ackReceived
bool ackReceived
ACK received.
Definition: RFM69_new.h:332
rfm69_internal_t
RFM69 internal variables.
Definition: RFM69_new.h:323
rfm69_internal_t::powerLevel
rfm69_powerlevel_t powerLevel
TX power level dBm.
Definition: RFM69_new.h:327
RFM69_executeATC
LOCAL bool RFM69_executeATC(const rfm69_RSSI_t currentRSSI, const rfm69_RSSI_t targetRSSI)
RFM69_executeATC.
RFM69_send
LOCAL bool RFM69_send(const uint8_t recipient, uint8_t *data, const uint8_t len, const rfm69_controlFlags_t flags, const bool increaseSequenceCounter=true)
RFM69_send.
RFM69_interruptHandling
LOCAL void RFM69_interruptHandling(void)
RFM69_interruptHandling.
RFM69_receive
LOCAL uint8_t RFM69_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.
RFM69_RADIO_MODE_SYNTH
@ RFM69_RADIO_MODE_SYNTH
SYNTH mode.
Definition: RFM69_new.h:252
RFM69_RADIO_MODE_LISTEN
@ RFM69_RADIO_MODE_LISTEN
LISTEN mode.
Definition: RFM69_new.h:253
rfm69_powerlevel_t
int8_t rfm69_powerlevel_t
Power level in dBm.
Definition: RFM69_new.h:275
rfm69_radio_mode_t
rfm69_radio_mode_t
Radio modes.
Definition: RFM69_new.h:246
__attribute__::ACK
rfm69_ack_t ACK
Union: ACK payload (internal)
Definition: RFM69_new.h:311
rfm69_internal_t::currentPacket
rfm69_packet_t currentPacket
Buffer for current packet.
Definition: RFM69_new.h:325
rfm69_internal_t::ATCenabled
bool ATCenabled
ATC enabled.
Definition: RFM69_new.h:333
RFM69_powerDown
LOCAL void RFM69_powerDown(void)
Power down radio (HW)