Replace promiscuous() with spyMode()

This commit is contained in:
Felix Rusu 2020-01-21 12:52:45 -05:00
parent f2e0a1a705
commit fbc65dedcf
3 changed files with 16 additions and 10 deletions

View File

@ -43,7 +43,7 @@ RFM69::RFM69(uint8_t slaveSelectPin, uint8_t interruptPin, bool isRFM69HW)
_slaveSelectPin = slaveSelectPin; _slaveSelectPin = slaveSelectPin;
_interruptPin = interruptPin; _interruptPin = interruptPin;
_mode = RF69_MODE_STANDBY; _mode = RF69_MODE_STANDBY;
_promiscuousMode = false; _spyMode = false;
_powerLevel = 31; _powerLevel = 31;
_isRFM69HW = isRFM69HW; _isRFM69HW = isRFM69HW;
#if defined(RF69_LISTENMODE_ENABLE) #if defined(RF69_LISTENMODE_ENABLE)
@ -349,7 +349,7 @@ void RFM69::interruptHandler() {
TARGETID |= (uint16_t(CTLbyte) & 0x0C) << 6; //10 bit address (most significant 2 bits stored in bits(2,3) of CTL byte TARGETID |= (uint16_t(CTLbyte) & 0x0C) << 6; //10 bit address (most significant 2 bits stored in bits(2,3) of CTL byte
SENDERID |= (uint16_t(CTLbyte) & 0x03) << 8; //10 bit address (most sifnigicant 2 bits stored in bits(0,1) of CTL byte SENDERID |= (uint16_t(CTLbyte) & 0x03) << 8; //10 bit address (most sifnigicant 2 bits stored in bits(0,1) of CTL byte
if(!(_promiscuousMode || TARGETID == _address || TARGETID == RF69_BROADCAST_ADDR) // match this node's address, or broadcast address or anything in promiscuous mode if(!(_spyMode || TARGETID == _address || TARGETID == RF69_BROADCAST_ADDR) // match this node's address, or broadcast address or anything in spy mode
|| PAYLOADLEN < 3) // address situation could receive packets that are malformed and don't fit this libraries extra fields || PAYLOADLEN < 3) // address situation could receive packets that are malformed and don't fit this libraries extra fields
{ {
PAYLOADLEN = 0; PAYLOADLEN = 0;
@ -501,13 +501,18 @@ void RFM69::unselect() {
#endif #endif
} }
// true = disable filtering to capture all frames on network // true = disable ID filtering to capture all packets on network, regardless of TARGETID
// false = enable node/broadcast filtering to capture only frames sent to this/broadcast address // false (default) = enable node/broadcast ID filtering to capture only frames sent to this/broadcast address
void RFM69::promiscuous(bool onOff) { void RFM69::spyMode(bool onOff) {
_promiscuousMode = onOff; _spyMode = onOff;
//writeReg(REG_PACKETCONFIG1, (readReg(REG_PACKETCONFIG1) & 0xF9) | (onOff ? RF_PACKET1_ADRSFILTERING_OFF : RF_PACKET1_ADRSFILTERING_NODEBROADCAST)); //writeReg(REG_PACKETCONFIG1, (readReg(REG_PACKETCONFIG1) & 0xF9) | (onOff ? RF_PACKET1_ADRSFILTERING_OFF : RF_PACKET1_ADRSFILTERING_NODEBROADCAST));
} }
void RFM69::promiscuous(bool onOff) {
Serial.println("\nRFM69::promiscuous(bool): DEPRECATED, use spyMode(bool) instead!\n");
spyMode(onOff);
}
// for RFM69HW only: you must call setHighPower(true) after initialize() or else transmission won't work // for RFM69HW only: you must call setHighPower(true) after initialize() or else transmission won't work
void RFM69::setHighPower(bool onOff) { void RFM69::setHighPower(bool onOff) {
_isRFM69HW = onOff; _isRFM69HW = onOff;
@ -979,7 +984,7 @@ void RFM69::listenModeInterruptHandler(void)
PAYLOADLEN = SPI.transfer(0); PAYLOADLEN = SPI.transfer(0);
PAYLOADLEN = PAYLOADLEN > 64 ? 64 : PAYLOADLEN; // precaution PAYLOADLEN = PAYLOADLEN > 64 ? 64 : PAYLOADLEN; // precaution
TARGETID = SPI.transfer(0); TARGETID = SPI.transfer(0);
if(!(_promiscuousMode || TARGETID == _address || TARGETID == RF69_BROADCAST_ADDR) // match this node's address, or broadcast address or anything in promiscuous mode if(!(_spyMode || TARGETID == _address || TARGETID == RF69_BROADCAST_ADDR) // match this node's address, or broadcast address or anything in spy mode
|| PAYLOADLEN < 3) // address situation could receive packets that are malformed and don't fit this library's extra fields || PAYLOADLEN < 3) // address situation could receive packets that are malformed and don't fit this library's extra fields
{ {
listenModeReset(); listenModeReset();

View File

@ -204,7 +204,8 @@ class RFM69 {
void encrypt(const char* key); void encrypt(const char* key);
void setCS(uint8_t newSPISlaveSelect); void setCS(uint8_t newSPISlaveSelect);
int16_t readRSSI(bool forceTrigger=false); // *current* signal strength indicator; e.g. < -90dBm says the frequency channel is free + ready to transmit int16_t readRSSI(bool forceTrigger=false); // *current* signal strength indicator; e.g. < -90dBm says the frequency channel is free + ready to transmit
void promiscuous(bool onOff=true); void spyMode(bool onOff=true);
void promiscuous(bool onOff=true); //deprecated, replaced with spyMode()
virtual void setHighPower(bool onOFF=true); // has to be called after initialize() for RFM69HW virtual void setHighPower(bool onOFF=true); // has to be called after initialize() for RFM69HW
virtual void setPowerLevel(uint8_t level); // reduce/increase transmit power level virtual void setPowerLevel(uint8_t level); // reduce/increase transmit power level
void sleep(); void sleep();
@ -228,7 +229,7 @@ class RFM69 {
uint8_t _interruptPin; uint8_t _interruptPin;
uint8_t _interruptNum; uint8_t _interruptNum;
uint16_t _address; uint16_t _address;
bool _promiscuousMode; bool _spyMode;
uint8_t _powerLevel; uint8_t _powerLevel;
bool _isRFM69HW; bool _isRFM69HW;
#if defined (SPCR) && defined (SPSR) #if defined (SPCR) && defined (SPSR)

View File

@ -30,7 +30,7 @@ getFrequency KEYWORD2
encrypt KEYWORD2 encrypt KEYWORD2
setCS KEYWORD2 setCS KEYWORD2
readRSSI KEYWORD2 readRSSI KEYWORD2
promiscuous KEYWORD2 spyMode KEYWORD2
setHighPower KEYWORD2 setHighPower KEYWORD2
sleep KEYWORD2 sleep KEYWORD2
readReg KEYWORD2 readReg KEYWORD2