MySensors Library & Examples  2.3.2-38-gaa76d26
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-2020 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
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 
69 #ifndef _RFM69_h
70 #define _RFM69_h
71 
72 #include "RFM69registers_new.h"
73 
74 #if !defined(RFM69_SPI)
75 #define RFM69_SPI hwSPI
76 #endif
77 
78 #if defined(ARDUINO_ARCH_AVR)
79 #if defined(__AVR_ATmega32U4__)
80 #define DEFAULT_RFM69_IRQ_PIN (3)
81 #else
82 #define DEFAULT_RFM69_IRQ_PIN (2)
83 #endif
84 #elif defined(ARDUINO_ARCH_ESP8266)
85 #define DEFAULT_RFM69_IRQ_PIN (5)
86 #elif defined(ARDUINO_ARCH_ESP32)
87 #define DEFAULT_RFM69_IRQ_PIN (16)
88 #define DEFAULT_RFM69_IRQ_NUM digitalPinToInterrupt(DEFAULT_RFM69_IRQ_PIN)
89 #elif defined(ARDUINO_ARCH_SAMD)
90 #define DEFAULT_RFM69_IRQ_PIN (2)
91 #elif defined(LINUX_ARCH_RASPBERRYPI)
92 #define DEFAULT_RFM69_IRQ_PIN (22)
93 #elif defined(ARDUINO_ARCH_STM32F1)
94 #define DEFAULT_RFM69_IRQ_PIN (PA3)
95 #elif defined(TEENSYDUINO)
96 #define DEFAULT_RFM69_IRQ_PIN (8)
97 #else
98 #define DEFAULT_RFM69_IRQ_PIN (2)
99 #endif
100 
101 #define DEFAULT_RFM69_CS_PIN (SS)
102 
103 // SPI settings
104 #define RFM69_SPI_DATA_ORDER MSBFIRST
105 #define RFM69_SPI_DATA_MODE SPI_MODE0
106 
107 // Additional radio settings
108 #define RFM69_SYNCVALUE1 (0x2D)
109 
110 #if (MY_RFM69HW==true)
111 // RFM69H(C)W
112 #define RFM69_VERSION_HW
113 #define RFM69_MIN_POWER_LEVEL_DBM ((rfm69_powerlevel_t)-2)
114 #if defined(MY_RFM69_MAX_POWER_LEVEL_DBM)
115 #define RFM69_MAX_POWER_LEVEL_DBM MY_RFM69_MAX_POWER_LEVEL_DBM
116 #else
117 #define RFM69_MAX_POWER_LEVEL_DBM ((rfm69_powerlevel_t)20)
118 #endif
119 #else
120 // RFM69(C)W
121 #define RFM69_MIN_POWER_LEVEL_DBM ((rfm69_powerlevel_t)-18)
122 #if defined(MY_RFM69_MAX_POWER_LEVEL_DBM)
123 #define RFM69_MAX_POWER_LEVEL_DBM MY_RFM69_MAX_POWER_LEVEL_DBM
124 #else
125 #define RFM69_MAX_POWER_LEVEL_DBM ((rfm69_powerlevel_t)13)
126 #endif
127 #endif
128 
129 #define RFM69_FIFO_SIZE (0xFFu)
130 #define RFM69_MAX_PACKET_LEN (0x40u)
131 #define RFM69_ATC_TARGET_RANGE_DBM (2u)
132 #define RFM69_PACKET_HEADER_VERSION (1u)
133 #define RFM69_MIN_PACKET_HEADER_VERSION (1u)
134 
135 #define RFM69_RETRIES (5u)
136 #define RFM69_RETRY_TIMEOUT_MS (200ul)
137 #define RFM69_MODE_READY_TIMEOUT_MS (50ul)
138 
139 #define RFM69_ACK_REQUESTED (7u)
140 #define RFM69_ACK_RECEIVED (6u)
141 #define RFM69_ACK_RSSI_REPORT (5u)
142 
143 #define RFM69_BROADCAST_ADDRESS (255u)
144 #define RFM69_TARGET_RSSI_DBM (-75)
145 #define RFM69_HIGH_POWER_DBM (18u)
146 
147 #if !defined(MY_RFM69_TX_TIMEOUT_MS)
148 #define MY_RFM69_TX_TIMEOUT_MS (2*1000ul)
149 #endif
150 
151 // CSMA settings
152 #if !defined(MY_RFM69_CSMA_LIMIT_DBM)
153 #define MY_RFM69_CSMA_LIMIT_DBM (-95)
154 #endif
155 #if !defined(MY_RFM69_CSMA_TIMEOUT_MS)
156 #define MY_RFM69_CSMA_TIMEOUT_MS (500ul)
157 #endif
158 // powerup delay
159 #define RFM69_POWERUP_DELAY_MS (100ul)
160 
161 // available frequency bands, non trivial values to avoid misconfiguration
162 #define RFM69_315MHZ (315000000ul)
163 #define RFM69_433MHZ (433920000ul)
164 #define RFM69_865MHZ (865500000ul)
165 #define RFM69_868MHZ (868000000ul)
166 #define RFM69_915MHZ (915000000ul)
167 
168 #define RFM69_COURSE_TEMP_COEF (-90)
169 #define RFM69_FXOSC (32*1000000ul)
170 #define RFM69_FSTEP (RFM69_FXOSC / 524288.0f)
171 
172 // helper macros
173 #define RFM69_getACKRequested(__value) ((bool)bitRead(__value,RFM69_ACK_REQUESTED))
174 #define RFM69_setACKRequested(__value, __flag) bitWrite(__value,RFM69_ACK_REQUESTED,__flag)
175 #define RFM69_getACKReceived(__value) ((bool)bitRead(__value,RFM69_ACK_RECEIVED))
176 #define RFM69_setACKReceived(__value, __flag) bitWrite(__value,RFM69_ACK_RECEIVED,__flag)
177 #define RFM69_setACKRSSIReport(__value, __flag) bitWrite(__value,RFM69_ACK_RSSI_REPORT,__flag)
178 #define RFM69_getACKRSSIReport(__value) ((bool)bitRead(__value,RFM69_ACK_RSSI_REPORT))
179 
180 // Register access
181 #define RFM69_READ_REGISTER (0x7Fu)
182 #define RFM69_WRITE_REGISTER (0x80u)
183 
184 // Modem configuration section
185 #define RFM69_CONFIG_FSK (RFM69_DATAMODUL_DATAMODE_PACKET | RFM69_DATAMODUL_MODULATIONTYPE_FSK | RFM69_DATAMODUL_MODULATIONSHAPING_00)
186 #define RFM69_CONFIG_GFSK (RFM69_DATAMODUL_DATAMODE_PACKET | RFM69_DATAMODUL_MODULATIONTYPE_FSK | RFM69_DATAMODUL_MODULATIONSHAPING_10)
187 #define RFM69_CONFIG_OOK (RFM69_DATAMODUL_DATAMODE_PACKET | RFM69_DATAMODUL_MODULATIONTYPE_OOK | RFM69_DATAMODUL_MODULATIONSHAPING_00)
188 
189 #define RFM69_CONFIG_NOWHITE (RFM69_PACKET1_FORMAT_VARIABLE | RFM69_PACKET1_DCFREE_OFF | RFM69_PACKET1_CRC_ON | RFM69_PACKET1_CRCAUTOCLEAR_ON | RFM69_PACKET1_ADRSFILTERING_NODEBROADCAST)
190 #define RFM69_CONFIG_WHITE (RFM69_PACKET1_FORMAT_VARIABLE | RFM69_PACKET1_DCFREE_WHITENING | RFM69_PACKET1_CRC_ON | RFM69_PACKET1_CRCAUTOCLEAR_ON | RFM69_PACKET1_ADRSFILTERING_NODEBROADCAST)
191 #define RFM69_CONFIG_MANCHESTER (RFM69_PACKET1_FORMAT_VARIABLE | RFM69_PACKET1_DCFREE_MANCHESTER | RFM69_PACKET1_CRC_ON | RFM69_PACKET1_CRCAUTOCLEAR_ON | RFM69_PACKET1_ADRSFILTERING_NODEBROADCAST)
192 
193 #define RFM69_RXBW_111_24_4 (RFM69_RXBW_DCCFREQ_111 | RFM69_RXBW_MANT_24 | RFM69_RXBW_EXP_4)
194 #define RFM69_RXBW_111_24_3 (RFM69_RXBW_DCCFREQ_111 | RFM69_RXBW_MANT_24 | RFM69_RXBW_EXP_3)
195 #define RFM69_RXBW_111_24_2 (RFM69_RXBW_DCCFREQ_111 | RFM69_RXBW_MANT_24 | RFM69_RXBW_EXP_2)
196 #define RFM69_RXBW_111_16_2 (RFM69_RXBW_DCCFREQ_111 | RFM69_RXBW_MANT_16 | RFM69_RXBW_EXP_2)
197 #define RFM69_RXBW_111_16_1 (RFM69_RXBW_DCCFREQ_111 | RFM69_RXBW_MANT_16 | RFM69_RXBW_EXP_1)
198 #define RFM69_RXBW_111_16_0 (RFM69_RXBW_DCCFREQ_111 | RFM69_RXBW_MANT_16 | RFM69_RXBW_EXP_0)
199 #define RFM69_RXBW_010_16_2 (RFM69_RXBW_DCCFREQ_010 | RFM69_RXBW_MANT_16 | RFM69_RXBW_EXP_2)
200 
201 #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
202 #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
203 #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
204 #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
205 #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
206 #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
207 #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
208 #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
209 #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
210 #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
211 
212 #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
213 #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
214 #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
215 #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
216 #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
217 #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
218 #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
219 #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
220 #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
221 #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
222 
223 #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
224 #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
225 #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
226 #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
227 #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
228 #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
229 #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
230 #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
231 #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
232 #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
233 
234 #if !defined(MY_RFM69_MODEM_CONFIGURATION)
235 #define MY_RFM69_MODEM_CONFIGURATION RFM69_FSK_BR55_5_FD50
236 #endif
237 
241 typedef enum {
250 
254 typedef uint8_t rfm69_sequenceNumber_t;
258 typedef uint8_t rfm69_RSSI_t;
262 typedef int8_t rfm69_SNR_t;
266 typedef uint8_t rfm69_controlFlags_t;
270 typedef int8_t rfm69_powerlevel_t;
271 
276 typedef struct {
277  uint8_t packetLen;
278  uint8_t recipient;
279  uint8_t version;
280  uint8_t sender;
283 } __attribute__((packed)) rfm69_header_t;
284 
288 typedef struct {
289  rfm69_sequenceNumber_t sequenceNumber;
291 } __attribute__((packed)) rfm69_ack_t;
292 
293 #define RFM69_HEADER_LEN sizeof(rfm69_header_t)
294 #define RFM69_MAX_PAYLOAD_LEN (RFM69_MAX_PACKET_LEN - RFM69_HEADER_LEN)
295 
296 
300 typedef struct {
301  union {
302  struct {
303  rfm69_header_t header;
304  union {
305  uint8_t payload[RFM69_MAX_PAYLOAD_LEN];
306  rfm69_ack_t ACK;
307  };
308  };
309  uint8_t data[RFM69_MAX_PACKET_LEN];
310  };
311  uint8_t payloadLen;
312  rfm69_RSSI_t RSSI;
313 } __attribute__((packed)) rfm69_packet_t;
314 
318 typedef struct {
319  uint8_t address;
320  rfm69_packet_t currentPacket;
323  uint8_t ATCtargetRSSI;
324  // 8 bit
326  bool dataReceived : 1;
327  bool ackReceived : 1;
328  bool ATCenabled : 1;
329  uint8_t reserved : 2;
331 
332 #define LOCAL static
333 
334 
337 LOCAL void RFM69_handler(void);
338 
342 LOCAL void RFM69_clearFIFO(void);
343 
348 LOCAL bool RFM69_channelFree(void);
349 
353 LOCAL void RFM69_interruptHandling(void);
354 
360 LOCAL bool RFM69_initialise(const uint32_t frequencyHz);
361 
366 LOCAL void RFM69_setAddress(const uint8_t addr);
367 
372 LOCAL uint8_t RFM69_getAddress(void);
373 
378 LOCAL bool RFM69_available(void);
379 
386 LOCAL uint8_t RFM69_receive(uint8_t *buf, const uint8_t maxBufSize);
387 
394 LOCAL bool RFM69_sendFrame(rfm69_packet_t *packet, const bool increaseSequenceCounter = true);
395 
405 LOCAL bool RFM69_send(const uint8_t recipient, uint8_t *data, const uint8_t len,
406  const rfm69_controlFlags_t flags, const bool increaseSequenceCounter = true);
407 
412 LOCAL void RFM69_setFrequency(const uint32_t frequencyHz);
413 
420 
426 
431 LOCAL uint8_t RFM69_getTxPowerPercent(void);
432 
437 LOCAL bool RFM69_sleep(void);
438 
443 LOCAL bool RFM69_standBy(void);
444 
448 LOCAL void RFM69_powerDown(void);
449 
453 LOCAL void RFM69_powerUp(void);
454 
461 LOCAL void RFM69_sendACK(const uint8_t recipient, const rfm69_sequenceNumber_t sequenceNumber,
462  const rfm69_RSSI_t RSSI);
463 
472 LOCAL bool RFM69_sendWithRetry(const uint8_t recipient, const void *buffer,
473  const uint8_t bufferSize,
474  const bool noACK);
475 
481 LOCAL bool RFM69_setRadioMode(const rfm69_radio_mode_t newRadioMode);
482 
486 LOCAL void RFM69_interruptHandler(void);
487 
492 LOCAL int16_t RFM69_getSendingRSSI(void);
493 
498 LOCAL int16_t RFM69_getReceivingRSSI(void);
499 
506 LOCAL bool RFM69_executeATC(const rfm69_RSSI_t currentRSSI, const rfm69_RSSI_t targetRSSI);
507 
508 // TEMP ADDED
512 LOCAL void RFM69_setConfiguration(void);
513 
518 LOCAL bool RFM69_isModeReady(void);
519 
524 LOCAL bool RFM69_sanityCheck(void);
525 
530 LOCAL void RFM69_encrypt(const char *key);
531 
536 LOCAL void RFM69_setHighPowerRegs(const bool onOff);
537 
543 LOCAL rfm69_RSSI_t RFM69_readRSSI(const bool forceTrigger = false);
544 
550 LOCAL void RFM69_ATCmode(const bool onOff, const int16_t targetRSSI = RFM69_TARGET_RSSI_DBM);
551 
557 LOCAL void RFM69_readAllRegs(void);
558 
559 #endif
560 
data
char data[MAX_PAYLOAD_SIZE+1]
Buffer for raw payload data.
Definition: MyMessage.h:653
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:321
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:245
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:246
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:332
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:277
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:254
RFM69_MAX_PAYLOAD_LEN
#define RFM69_MAX_PAYLOAD_LEN
Max payload length.
Definition: RFM69_new.h:294
RFM69_RADIO_MODE_TX
@ RFM69_RADIO_MODE_TX
TX mode.
Definition: RFM69_new.h:243
rfm69_internal_t::radioMode
rfm69_radio_mode_t radioMode
current transceiver state
Definition: RFM69_new.h:325
rfm69_internal_t::ATCtargetRSSI
uint8_t ATCtargetRSSI
ATC: target RSSI.
Definition: RFM69_new.h:323
rfm69_SNR_t
int8_t rfm69_SNR_t
SNR data type.
Definition: RFM69_new.h:262
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:244
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:279
rfm69_internal_t::dataReceived
bool dataReceived
data received
Definition: RFM69_new.h:326
RFM69_setHighPowerRegs
LOCAL void RFM69_setHighPowerRegs(const bool onOff)
RFM69_setHighPowerRegs.
__attribute__::recipient
uint8_t recipient
payload recipient
Definition: RFM69_new.h:278
__attribute__::sequenceNumber
rfm69_sequenceNumber_t sequenceNumber
packet sequence number, used for ACK
Definition: RFM69_new.h:282
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:319
RFM69_MAX_PACKET_LEN
#define RFM69_MAX_PACKET_LEN
This is the maximum number of bytes that can be carried.
Definition: RFM69_new.h:130
__attribute__::payloadLen
uint8_t payloadLen
Length of payload (excluding header)
Definition: RFM69_new.h:311
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.
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:258
rfm69_internal_t::reserved
uint8_t reserved
Reserved.
Definition: RFM69_new.h:329
RFM69_RADIO_MODE_RX
@ RFM69_RADIO_MODE_RX
RX mode.
Definition: RFM69_new.h:242
__attribute__::sender
uint8_t sender
payload sender
Definition: RFM69_new.h:280
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:281
RFM69_getReceivingRSSI
LOCAL int16_t RFM69_getReceivingRSSI(void)
RFM69_getReceivingRSSI.
__attribute__::RSSI
rfm69_RSSI_t RSSI
RSSI.
Definition: RFM69_new.h:290
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:266
RFM69_TARGET_RSSI_DBM
#define RFM69_TARGET_RSSI_DBM
RSSI target.
Definition: RFM69_new.h:144
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:303
rfm69_internal_t::ackReceived
bool ackReceived
ACK received.
Definition: RFM69_new.h:327
rfm69_internal_t
RFM69 internal variables.
Definition: RFM69_new.h:318
rfm69_internal_t::powerLevel
rfm69_powerlevel_t powerLevel
TX power level dBm.
Definition: RFM69_new.h:322
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:247
RFM69_RADIO_MODE_LISTEN
@ RFM69_RADIO_MODE_LISTEN
LISTEN mode.
Definition: RFM69_new.h:248
rfm69_powerlevel_t
int8_t rfm69_powerlevel_t
Power level in dBm.
Definition: RFM69_new.h:270
rfm69_radio_mode_t
rfm69_radio_mode_t
Radio modes.
Definition: RFM69_new.h:241
__attribute__::ACK
rfm69_ack_t ACK
Union: ACK payload (internal)
Definition: RFM69_new.h:306
rfm69_internal_t::currentPacket
rfm69_packet_t currentPacket
Buffer for current packet.
Definition: RFM69_new.h:320
rfm69_internal_t::ATCenabled
bool ATCenabled
ATC enabled.
Definition: RFM69_new.h:328
RFM69_powerDown
LOCAL void RFM69_powerDown(void)
Power down radio (HW)