Added LoRa Stress test example
parent
0c5129461c
commit
745aedcec7
@ -0,0 +1,161 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// LoRa Stress Tester or "Spammer"
|
||||
//
|
||||
//
|
||||
|
||||
#include "fdrs_node_config.h"
|
||||
#include <fdrs_node.h>
|
||||
|
||||
#define PING_TIME_DELAY 300
|
||||
#define REQ_TIME_DELAY 300
|
||||
#define LOAD_TIME_DELAY 1000
|
||||
#define CYCLES 15
|
||||
unsigned long lastruntime = 0;
|
||||
int test = 0;
|
||||
unsigned long lastCycle = 0;
|
||||
|
||||
void setup() {
|
||||
beginFDRS();
|
||||
}
|
||||
void loop() {
|
||||
loopFDRS();
|
||||
|
||||
switch (test) {
|
||||
case 0:
|
||||
DBG("Sending pings in quick succession.");
|
||||
delay(4000);
|
||||
for(int i=1; i < CYCLES + 1; i) {
|
||||
if(TDIFF(lastruntime,PING_TIME_DELAY)) {
|
||||
lastruntime = millis();
|
||||
Serial.println();
|
||||
DBG("--- Test #" + String(i) + " ---");
|
||||
Serial.println();
|
||||
pingFDRS(1000);
|
||||
i++;
|
||||
}
|
||||
loopFDRS();
|
||||
}
|
||||
while(millis()-lastruntime < 1000) {
|
||||
loopFDRS();
|
||||
}
|
||||
test++;
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
DBG("Sending time requests in quick succession.");
|
||||
delay(4000);
|
||||
for(int i=1; i < CYCLES + 1; i) {
|
||||
if(TDIFF(lastruntime,REQ_TIME_DELAY)) {
|
||||
lastruntime = millis();
|
||||
Serial.println();
|
||||
DBG("--- Test #" + String(i) + " ---");
|
||||
Serial.println();
|
||||
reqTimeFDRS();
|
||||
i++;
|
||||
}
|
||||
loopFDRS();
|
||||
}
|
||||
while(millis()-lastruntime < 1000) {
|
||||
loopFDRS();
|
||||
}
|
||||
test++;
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
DBG("No ACK - data cycles in quick succession.");
|
||||
ack = false;
|
||||
delay(4000);
|
||||
for(int i=1; i < CYCLES + 1; i) {
|
||||
if(TDIFF(lastruntime,LOAD_TIME_DELAY)) {
|
||||
lastruntime = millis();
|
||||
Serial.println();
|
||||
DBG("--- Test #" + String(i) + " ---");
|
||||
Serial.println();
|
||||
for(int j=0; j < i; j++) {
|
||||
loadFDRS(READING_ID + j, STATUS_T);
|
||||
}
|
||||
if(sendFDRS()){
|
||||
DBG("Big Success!");
|
||||
} else {
|
||||
DBG("Nope, not so much.");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
loopFDRS();
|
||||
}
|
||||
while(millis()-lastruntime < 1000) {
|
||||
loopFDRS();
|
||||
}
|
||||
test++;
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
DBG("ACK - data cycles in quick succession.");
|
||||
ack = true;
|
||||
delay(4000);
|
||||
for(int i=1; i < CYCLES + 1; i) {
|
||||
if(TDIFF(lastruntime,LOAD_TIME_DELAY)) {
|
||||
lastruntime = millis();
|
||||
Serial.println();
|
||||
DBG("--- Test #" + String(i) + " ---");
|
||||
Serial.println();
|
||||
for(int j=0; j < i; j++) {
|
||||
loadFDRS(READING_ID + j, STATUS_T);
|
||||
}
|
||||
if(sendFDRS()){
|
||||
DBG("Big Success!");
|
||||
} else {
|
||||
DBG("Nope, not so much.");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
loopFDRS();
|
||||
}
|
||||
while(millis()-lastruntime < 1000) {
|
||||
loopFDRS();
|
||||
}
|
||||
test++;
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
DBG("Combination of commands in quick succession.");
|
||||
delay(4000);
|
||||
for(int i=1; i < CYCLES + 1; i) {
|
||||
if(TDIFF(lastruntime,5000)) {
|
||||
lastruntime = millis();
|
||||
Serial.println();
|
||||
DBG("--- Test #" + String(i) + " ---");
|
||||
Serial.println();
|
||||
pingFDRS(1000);
|
||||
reqTimeFDRS();
|
||||
subscribeFDRS(READING_ID);
|
||||
i++;
|
||||
}
|
||||
loopFDRS();
|
||||
}
|
||||
while(millis()-lastruntime < 2000) {
|
||||
loopFDRS();
|
||||
}
|
||||
test++;
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
break;
|
||||
|
||||
default:
|
||||
DBG("DONE! Starting over again soon.");
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
delay(4000);
|
||||
test = 0;
|
||||
break;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
#include <fdrs_globals.h>
|
||||
|
||||
#define READING_ID 5 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
// #define USE_ESPNOW
|
||||
#define USE_LORA
|
||||
//#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
//
|
||||
// I2C - OLED or RTC
|
||||
#define I2C_SDA 5
|
||||
#define I2C_SCL 6
|
||||
|
||||
// OLED -- Displays console debugging messages on an SSD1306 I²C OLED
|
||||
// #define USE_OLED
|
||||
#define OLED_HEADER "FDRS"
|
||||
#define OLED_PAGE_SECS 30
|
||||
#define OLED_RST -1
|
||||
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276 //Tested on SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
#define LORA_BUSY 33
|
||||
//#define USE_SX126X
|
||||
|
||||
//#define CUSTOM_SPI
|
||||
#define LORA_SPI_SCK 5
|
||||
#define LORA_SPI_MISO 19
|
||||
#define LORA_SPI_MOSI 27
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
||||
|
||||
// Time settings
|
||||
#define USDST
|
||||
// #define EUDST
|
||||
#define STD_OFFSET (-6) // Local standard time offset in hours from UTC - if unsure, check https://time.is
|
||||
#define DST_OFFSET (STD_OFFSET + 1) // Local savings time offset in hours from UTC - if unsure, check https://time.is
|
||||
#define TIME_PRINTTIME 15 // Time, in minutes, between printing local time to debug
|
Loading…
Reference in New Issue