timmbogner / Farm-Data-Relay-System

A system that uses ESP-NOW, LoRa, and other protocols to transport sensor data in remote areas without relying on WiFi.
MIT License
507 stars 114 forks source link

Implementation of GLOBALS is not correct / wrong values used in the constructor #33

Closed Gulpman closed 2 years ago

Gulpman commented 2 years ago

I just tested the universal_beta_sensor and universal_gateway in the dev branch. I found out that the way the band and sf are choosen is not implemented correctly.

As for the sensor: First of all the includes are not in the correct order: Actually it is:

#include "fdrs_sensor.h"
#include "sensor_setup.h"

It must be:

#include "sensor_setup.h"
#include "fdrs_sensor.h"

as in "fdrs_sensors.h the existance of GLOBALS is checked which is done within sensors_setup.h.

At this point only FDRS_BAND and FDRS_FS should be used. In the constructor of the Universal_Sensor_beta the defines BAND and FS are used, where FDRS_BAND and FDRS_FS should be used. So the constructor is: FDRSLoRa FDRS(GTWY_MAC,READING_ID,MISO,MOSI,SCK,SS,RST,DIO0,BAND,SF); but should be: FDRSLoRa FDRS(GTWY_MAC,READING_ID,MISO,MOSI,SCK,SS,RST,DIO0,FDRS_BAND,FDRS_SF);

This way you can either correctly choose the band and sf within the universal_sensor.ino via

#define BAND 866E6
#define SF 7

or within the fdrs_globals.h via

#define GLOBAL_BAND 866E6 //LoRa Frequency Band
#define GLOBAL_SF 7  //LoRa Spreading Factor

I try to check this in as a pull request but I'm still struggling with git/github a little bit. :) So just to be sure, someone else can fix this just in case.

Best Sascha