Skip to content

Commit

Permalink
fix promiscuous() examples to spyMode()
Browse files Browse the repository at this point in the history
  • Loading branch information
LowPowerLab committed May 22, 2020
1 parent d3c706c commit f28c65f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 32 deletions.
27 changes: 9 additions & 18 deletions Examples/Gateway/Gateway.ino
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
// **********************************************************************************
//
// !!!! ATTENTION: !!!!
//
// This is just a simple receiving sketch that will work with most examples
// in the RFM69 library.
//
// If you're looking for the Gateway sketch to use with your RaspberryPi,
// as part of the PiGateway software interface (lowpowerlab.com/gateway),
// this is the wrong sketch.
//
// Use this sketch instead: PiGateway:
// this is the wrong sketch. Use this sketch instead: PiGateway:
// https://github.com/LowPowerLab/RFM69/blob/master/Examples/PiGateway/PiGateway.ino
// **********************************************************************************

// Sample RFM69 receiver/gateway sketch, with ACK and optional encryption, and Automatic Transmission Control
// Passes through any wireless received messages to the serial port & responds to ACKs
// It also looks for an onboard FLASH chip, if present
Expand Down Expand Up @@ -42,12 +37,11 @@
#include <RFM69.h> //get it here: https://www.github.com/lowpowerlab/rfm69
#include <RFM69_ATC.h> //get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPIFlash.h> //get it here: https://www.github.com/lowpowerlab/spiflash
#include <SPI.h> //included with Arduino IDE install (www.arduino.cc)

//*********************************************************************************************
//************ IMPORTANT SETTINGS - YOU MUST CHANGE/CONFIGURE TO FIT YOUR HARDWARE *************
//*********************************************************************************************
#define NODEID 1 //unique for each node on same network
#define NODEID 1 //should always be 1 for a Gateway
#define NETWORKID 100 //the same on all nodes that talk to each other
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
//#define FREQUENCY RF69_433MHZ
Expand All @@ -72,7 +66,7 @@
#endif

SPIFlash flash(SS_FLASHMEM, 0xEF30); //EF30 for 4mbit Windbond chip (W25X40CL)
bool promiscuousMode = false; //set to 'true' to sniff all packets on the same network
bool spy = false; //set to 'true' to sniff all packets on the same network

void setup() {
Serial.begin(SERIAL_BAUD);
Expand All @@ -82,8 +76,8 @@ void setup() {
radio.setHighPower(); //must include this only for RFM69HW/HCW!
#endif
radio.encrypt(ENCRYPTKEY);
radio.promiscuous(promiscuousMode);
//radio.setFrequency(919000000); //set frequency to some custom frequency
radio.spyMode(spy);
//radio.setFrequency(916000000); //set frequency to some custom frequency
char buff[50];
sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
Serial.println(buff);
Expand Down Expand Up @@ -129,9 +123,9 @@ void loop() {
radio.encrypt(null);
if (input == 'p')
{
promiscuousMode = !promiscuousMode;
radio.promiscuous(promiscuousMode);
Serial.print("Promiscuous mode ");Serial.println(promiscuousMode ? "on" : "off");
spy = !spy;
radio.spyMode(spy);
Serial.print("SpyMode mode ");Serial.println(spy ? "on" : "off");
}

if (input == 'd') //d=dump flash area
Expand Down Expand Up @@ -177,10 +171,7 @@ void loop() {
Serial.print(++packetCount);
Serial.print(']');
Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
if (promiscuousMode)
{
Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");
}
if (spy) Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");
for (byte i = 0; i < radio.DATALEN; i++)
Serial.print((char)radio.DATA[i]);
Serial.print(" [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
Expand Down
8 changes: 3 additions & 5 deletions Examples/OLEDMote/OLEDMote.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

RFM69 radio;
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI SSD1306 OLED 128x64
bool promiscuousMode = true; //set to 'true' to sniff all packets on the same network
bool spy = true; //set to 'true' to sniff all packets on the same network

void setup() {
Serial.begin(SERIAL_BAUD);
Expand All @@ -64,7 +64,7 @@ void setup() {
radio.setHighPower(); //must include this only for RFM69HW/HCW!
#endif
radio.encrypt(ENCRYPTKEY);
radio.promiscuous(promiscuousMode);
radio.spyMode(spy);
char buff[50];
sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
Serial.println(buff);
Expand Down Expand Up @@ -146,9 +146,7 @@ void loop() {
if (radio.receiveDone())
{
Serial.print('[');Serial.print(radio.SENDERID);Serial.print("] ");
if (promiscuousMode)
Serial.print("to [");Serial.print(radio.TARGETID);Serial.print("] ");

if (spy) Serial.print("to [");Serial.print(radio.TARGETID);Serial.print("] ");
Serial.print((char*)radio.DATA);
Serial.print(" [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
Serial.println();
Expand Down
15 changes: 6 additions & 9 deletions Examples/Struct_receive/Struct_receive.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#endif

SPIFlash flash(SS_FLASHMEM, 0xEF30); //EF40 for 16mbit windbond chip
bool promiscuousMode = false; //set to 'true' to sniff all packets on the same network
bool spy = false; //set to 'true' to sniff all packets on the same network

typedef struct {
int nodeId; //store this nodeId
Expand All @@ -72,7 +72,7 @@ void setup() {
radio.setHighPower(); //must include this only for RFM69HW/HCW!
#endif
radio.encrypt(ENCRYPTKEY);
radio.promiscuous(promiscuousMode);
radio.spyMode(spy);
char buff[50];
sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
Serial.println(buff);
Expand All @@ -96,9 +96,9 @@ void loop() {
radio.encrypt(null);
if (input == 'p')
{
promiscuousMode = !promiscuousMode;
radio.promiscuous(promiscuousMode);
Serial.print("Promiscuous mode ");Serial.println(promiscuousMode ? "on" : "off");
spy = !spy;
radio.spyMode(spy);
Serial.print("Spy mode ");Serial.println(spy ? "on" : "off");
}

if (input == 'd') //d=dump flash area
Expand Down Expand Up @@ -132,10 +132,7 @@ void loop() {
{
Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
Serial.print(" [RX_RSSI:");Serial.print(radio.readRSSI());Serial.print("]");
if (promiscuousMode)
{
Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");
}
if (spy) Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");

if (radio.DATALEN != sizeof(Payload))
Serial.print("Invalid payload received, not matching Payload struct!");
Expand Down

0 comments on commit f28c65f

Please sign in to comment.