kopia lustrzana https://github.com/jgromes/RadioLib
RF69 - Fixed address filtering
rodzic
3fba66e9cf
commit
76d2b5ebf4
|
@ -82,9 +82,9 @@ uint8_t RF69::begin(float freq, float br, float rxBw, float freqDev, int8_t powe
|
|||
return(ERR_NONE);
|
||||
}
|
||||
|
||||
uint8_t RF69::transmit(uint8_t* data, size_t len) {
|
||||
uint8_t RF69::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||
// check packet length
|
||||
if(len >= 256) {
|
||||
if(len > 64) {
|
||||
return(ERR_PACKET_TOO_LONG);
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,12 @@ uint8_t RF69::transmit(uint8_t* data, size_t len) {
|
|||
// set packet length
|
||||
_mod->SPIwriteRegister(RF69_REG_FIFO, len);
|
||||
|
||||
// check address filtering
|
||||
uint8_t filter = _mod->SPIgetRegValue(RF69_REG_PACKET_CONFIG_1, 2, 1);
|
||||
if((filter == RF69_ADDRESS_FILTERING_NODE) || (filter == RF69_ADDRESS_FILTERING_NODE_BROADCAST)) {
|
||||
_mod->SPIwriteRegister(RF69_REG_FIFO, addr);
|
||||
}
|
||||
|
||||
// write packet to FIFO
|
||||
_mod->SPIwriteRegisterBurst(RF69_REG_FIFO, data, len);
|
||||
|
||||
|
@ -117,11 +123,11 @@ uint8_t RF69::transmit(uint8_t* data, size_t len) {
|
|||
return(ERR_NONE);
|
||||
}
|
||||
|
||||
uint8_t RF69::transmit(const char* str) {
|
||||
return(RF69::transmit((uint8_t*)str, strlen(str)));
|
||||
uint8_t RF69::transmit(const char* str, uint8_t addr) {
|
||||
return(RF69::transmit((uint8_t*)str, strlen(str), addr));
|
||||
}
|
||||
|
||||
uint8_t RF69::transmit(String& str) {
|
||||
uint8_t RF69::transmit(String& str, uint8_t addr) {
|
||||
return(RF69::transmit(str.c_str()));
|
||||
}
|
||||
|
||||
|
@ -151,6 +157,12 @@ uint8_t RF69::receive(uint8_t* data, size_t len) {
|
|||
// get packet length
|
||||
size_t length = _mod->SPIreadRegister(RF69_REG_FIFO);
|
||||
|
||||
// check address filtering
|
||||
uint8_t filter = _mod->SPIgetRegValue(RF69_REG_PACKET_CONFIG_1, 2, 1);
|
||||
if((filter == RF69_ADDRESS_FILTERING_NODE) || (filter == RF69_ADDRESS_FILTERING_NODE_BROADCAST)) {
|
||||
_mod->SPIreadRegister(RF69_REG_FIFO);
|
||||
}
|
||||
|
||||
// read packet data
|
||||
if(len == 0) {
|
||||
// argument len equal to zero indicates String call, which means dynamically allocated data array
|
||||
|
|
|
@ -329,7 +329,6 @@
|
|||
#define RF69_SYNC_ON 0b10000000 // 7 7 sync word detection on (default)
|
||||
#define RF69_FIFO_FILL_CONDITION_SYNC 0b00000000 // 6 6 FIFO fill condition: on SyncAddress interrupt (default)
|
||||
#define RF69_FIFO_FILL_CONDITION 0b01000000 // 6 6 as long as the bit is set
|
||||
//#define RF69_SYNC_SIZE 0b00011000 // 5 3 size of sync word: SyncSize + 1 bytes
|
||||
#define RF69_SYNC_SIZE 0b00001000 // 5 3 size of sync word: SyncSize + 1 bytes
|
||||
#define RF69_SYNC_TOL 0b00000000 // 2 0 number of tolerated errors in sync word
|
||||
|
||||
|
@ -420,9 +419,9 @@ class RF69 {
|
|||
|
||||
// basic methods
|
||||
uint8_t begin(float freq = 434.0, float br = 48.0, float rxBw = 125.0, float freqDev = 50.0, int8_t power = 13);
|
||||
uint8_t transmit(uint8_t* data, size_t len);
|
||||
uint8_t transmit(const char* str);
|
||||
uint8_t transmit(String& str);
|
||||
uint8_t transmit(uint8_t* data, size_t len, uint8_t addr = 0);
|
||||
uint8_t transmit(const char* str, uint8_t addr = 0);
|
||||
uint8_t transmit(String& str, uint8_t addr = 0);
|
||||
uint8_t receive(uint8_t* data, size_t len);
|
||||
uint8_t receive(String& str, size_t len = 0);
|
||||
uint8_t sleep();
|
||||
|
|
Ładowanie…
Reference in New Issue