fix promiscuous() examples to spyMode()
This commit is contained in:
parent
d3c706cc9a
commit
f28c65f0de
|
|
@ -1,18 +1,13 @@
|
||||||
// **********************************************************************************
|
// **********************************************************************************
|
||||||
//
|
|
||||||
// !!!! ATTENTION: !!!!
|
// !!!! ATTENTION: !!!!
|
||||||
//
|
|
||||||
// This is just a simple receiving sketch that will work with most examples
|
// This is just a simple receiving sketch that will work with most examples
|
||||||
// in the RFM69 library.
|
// in the RFM69 library.
|
||||||
//
|
//
|
||||||
// If you're looking for the Gateway sketch to use with your RaspberryPi,
|
// If you're looking for the Gateway sketch to use with your RaspberryPi,
|
||||||
// as part of the PiGateway software interface (lowpowerlab.com/gateway),
|
// as part of the PiGateway software interface (lowpowerlab.com/gateway),
|
||||||
// this is the wrong sketch.
|
// this is the wrong sketch. Use this sketch instead: PiGateway:
|
||||||
//
|
|
||||||
// Use this sketch instead: PiGateway:
|
|
||||||
// https://github.com/LowPowerLab/RFM69/blob/master/Examples/PiGateway/PiGateway.ino
|
// 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
|
// 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
|
// Passes through any wireless received messages to the serial port & responds to ACKs
|
||||||
// It also looks for an onboard FLASH chip, if present
|
// It also looks for an onboard FLASH chip, if present
|
||||||
|
|
@ -42,12 +37,11 @@
|
||||||
#include <RFM69.h> //get it here: https://www.github.com/lowpowerlab/rfm69
|
#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 <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 <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 *************
|
//************ 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
|
#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):
|
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
|
||||||
//#define FREQUENCY RF69_433MHZ
|
//#define FREQUENCY RF69_433MHZ
|
||||||
|
|
@ -72,7 +66,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SPIFlash flash(SS_FLASHMEM, 0xEF30); //EF30 for 4mbit Windbond chip (W25X40CL)
|
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() {
|
void setup() {
|
||||||
Serial.begin(SERIAL_BAUD);
|
Serial.begin(SERIAL_BAUD);
|
||||||
|
|
@ -82,8 +76,8 @@ void setup() {
|
||||||
radio.setHighPower(); //must include this only for RFM69HW/HCW!
|
radio.setHighPower(); //must include this only for RFM69HW/HCW!
|
||||||
#endif
|
#endif
|
||||||
radio.encrypt(ENCRYPTKEY);
|
radio.encrypt(ENCRYPTKEY);
|
||||||
radio.promiscuous(promiscuousMode);
|
radio.spyMode(spy);
|
||||||
//radio.setFrequency(919000000); //set frequency to some custom frequency
|
//radio.setFrequency(916000000); //set frequency to some custom frequency
|
||||||
char buff[50];
|
char buff[50];
|
||||||
sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
|
sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
|
||||||
Serial.println(buff);
|
Serial.println(buff);
|
||||||
|
|
@ -129,9 +123,9 @@ void loop() {
|
||||||
radio.encrypt(null);
|
radio.encrypt(null);
|
||||||
if (input == 'p')
|
if (input == 'p')
|
||||||
{
|
{
|
||||||
promiscuousMode = !promiscuousMode;
|
spy = !spy;
|
||||||
radio.promiscuous(promiscuousMode);
|
radio.spyMode(spy);
|
||||||
Serial.print("Promiscuous mode ");Serial.println(promiscuousMode ? "on" : "off");
|
Serial.print("SpyMode mode ");Serial.println(spy ? "on" : "off");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input == 'd') //d=dump flash area
|
if (input == 'd') //d=dump flash area
|
||||||
|
|
@ -177,10 +171,7 @@ void loop() {
|
||||||
Serial.print(++packetCount);
|
Serial.print(++packetCount);
|
||||||
Serial.print(']');
|
Serial.print(']');
|
||||||
Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
|
Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
|
||||||
if (promiscuousMode)
|
if (spy) Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");
|
||||||
{
|
|
||||||
Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");
|
|
||||||
}
|
|
||||||
for (byte i = 0; i < radio.DATALEN; i++)
|
for (byte i = 0; i < radio.DATALEN; i++)
|
||||||
Serial.print((char)radio.DATA[i]);
|
Serial.print((char)radio.DATA[i]);
|
||||||
Serial.print(" [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
|
Serial.print(" [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
|
|
||||||
RFM69 radio;
|
RFM69 radio;
|
||||||
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI SSD1306 OLED 128x64
|
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() {
|
void setup() {
|
||||||
Serial.begin(SERIAL_BAUD);
|
Serial.begin(SERIAL_BAUD);
|
||||||
|
|
@ -64,7 +64,7 @@ void setup() {
|
||||||
radio.setHighPower(); //must include this only for RFM69HW/HCW!
|
radio.setHighPower(); //must include this only for RFM69HW/HCW!
|
||||||
#endif
|
#endif
|
||||||
radio.encrypt(ENCRYPTKEY);
|
radio.encrypt(ENCRYPTKEY);
|
||||||
radio.promiscuous(promiscuousMode);
|
radio.spyMode(spy);
|
||||||
char buff[50];
|
char buff[50];
|
||||||
sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
|
sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
|
||||||
Serial.println(buff);
|
Serial.println(buff);
|
||||||
|
|
@ -146,9 +146,7 @@ void loop() {
|
||||||
if (radio.receiveDone())
|
if (radio.receiveDone())
|
||||||
{
|
{
|
||||||
Serial.print('[');Serial.print(radio.SENDERID);Serial.print("] ");
|
Serial.print('[');Serial.print(radio.SENDERID);Serial.print("] ");
|
||||||
if (promiscuousMode)
|
if (spy) Serial.print("to [");Serial.print(radio.TARGETID);Serial.print("] ");
|
||||||
Serial.print("to [");Serial.print(radio.TARGETID);Serial.print("] ");
|
|
||||||
|
|
||||||
Serial.print((char*)radio.DATA);
|
Serial.print((char*)radio.DATA);
|
||||||
Serial.print(" [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
|
Serial.print(" [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SPIFlash flash(SS_FLASHMEM, 0xEF30); //EF40 for 16mbit windbond chip
|
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 {
|
typedef struct {
|
||||||
int nodeId; //store this nodeId
|
int nodeId; //store this nodeId
|
||||||
|
|
@ -72,7 +72,7 @@ void setup() {
|
||||||
radio.setHighPower(); //must include this only for RFM69HW/HCW!
|
radio.setHighPower(); //must include this only for RFM69HW/HCW!
|
||||||
#endif
|
#endif
|
||||||
radio.encrypt(ENCRYPTKEY);
|
radio.encrypt(ENCRYPTKEY);
|
||||||
radio.promiscuous(promiscuousMode);
|
radio.spyMode(spy);
|
||||||
char buff[50];
|
char buff[50];
|
||||||
sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
|
sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
|
||||||
Serial.println(buff);
|
Serial.println(buff);
|
||||||
|
|
@ -96,9 +96,9 @@ void loop() {
|
||||||
radio.encrypt(null);
|
radio.encrypt(null);
|
||||||
if (input == 'p')
|
if (input == 'p')
|
||||||
{
|
{
|
||||||
promiscuousMode = !promiscuousMode;
|
spy = !spy;
|
||||||
radio.promiscuous(promiscuousMode);
|
radio.spyMode(spy);
|
||||||
Serial.print("Promiscuous mode ");Serial.println(promiscuousMode ? "on" : "off");
|
Serial.print("Spy mode ");Serial.println(spy ? "on" : "off");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input == 'd') //d=dump flash area
|
if (input == 'd') //d=dump flash area
|
||||||
|
|
@ -132,10 +132,7 @@ void loop() {
|
||||||
{
|
{
|
||||||
Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
|
Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
|
||||||
Serial.print(" [RX_RSSI:");Serial.print(radio.readRSSI());Serial.print("]");
|
Serial.print(" [RX_RSSI:");Serial.print(radio.readRSSI());Serial.print("]");
|
||||||
if (promiscuousMode)
|
if (spy) Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");
|
||||||
{
|
|
||||||
Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (radio.DATALEN != sizeof(Payload))
|
if (radio.DATALEN != sizeof(Payload))
|
||||||
Serial.print("Invalid payload received, not matching Payload struct!");
|
Serial.print("Invalid payload received, not matching Payload struct!");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue