|
|
|
@ -130,42 +130,69 @@ enum {
|
|
|
|
|
#else
|
|
|
|
|
// ASSERT("NO MQTT password defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
|
|
|
|
|
#endif //MQTT_PASS
|
|
|
|
|
|
|
|
|
|
#if defined (MQTT_AUTH) || defined (GLOBAL_MQTT_AUTH)
|
|
|
|
|
#define FDRS_MQTT_AUTH
|
|
|
|
|
#endif //MQTT_AUTH
|
|
|
|
|
|
|
|
|
|
#endif //USE_WIFI
|
|
|
|
|
|
|
|
|
|
#ifdef USE_LORA
|
|
|
|
|
|
|
|
|
|
// select LoRa band configuration
|
|
|
|
|
#if defined(LORA_BAND)
|
|
|
|
|
#define FDRS_BAND LORA_BAND
|
|
|
|
|
#elif defined (GLOBAL_LORA_BAND)
|
|
|
|
|
#define FDRS_BAND GLOBAL_LORA_BAND
|
|
|
|
|
#else
|
|
|
|
|
// ASSERT("NO LORA-BAND defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
|
|
|
|
|
#endif //LORA_BAND
|
|
|
|
|
#if defined(LORA_FREQUENCY)
|
|
|
|
|
#define FDRS_LORA_FREQUENCY LORA_FREQUENCY
|
|
|
|
|
#else
|
|
|
|
|
#define FDRS_LORA_FREQUENCY GLOBAL_LORA_FREQUENCY
|
|
|
|
|
#endif //LORA_FREQUENCY
|
|
|
|
|
|
|
|
|
|
// select LoRa SF configuration
|
|
|
|
|
#if defined(LORA_SF)
|
|
|
|
|
#define FDRS_SF LORA_SF
|
|
|
|
|
#elif defined (GLOBAL_LORA_SF)
|
|
|
|
|
#define FDRS_SF GLOBAL_LORA_SF
|
|
|
|
|
#else
|
|
|
|
|
// ASSERT("NO LORA-SF defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
|
|
|
|
|
#define FDRS_LORA_SF LORA_SF
|
|
|
|
|
#else
|
|
|
|
|
#define FDRS_LORA_SF GLOBAL_LORA_SF
|
|
|
|
|
#endif //LORA_SF
|
|
|
|
|
|
|
|
|
|
// select LoRa TXPWR configuration
|
|
|
|
|
// select LoRa ACK Timeout configuration
|
|
|
|
|
#if defined(LORA_ACK_TIMEOUT)
|
|
|
|
|
#define FDRS_ACK_TIMEOUT LORA_ACK_TIMEOUT
|
|
|
|
|
#else
|
|
|
|
|
#define FDRS_ACK_TIMEOUT GLOBAL_ACK_TIMEOUT
|
|
|
|
|
#endif //LORA_ACK_TIMEOUT
|
|
|
|
|
|
|
|
|
|
// select LoRa Retry configuration
|
|
|
|
|
#if defined(LORA_RETRIES)
|
|
|
|
|
#define FDRS_LORA_RETRIES LORA_RETRIES
|
|
|
|
|
#else
|
|
|
|
|
#define FDRS_LORA_RETRIES GLOBAL_LORA_RETRIES
|
|
|
|
|
#endif //LORA_RETRIES
|
|
|
|
|
|
|
|
|
|
// select LoRa Tx Power configuration
|
|
|
|
|
#if defined(LORA_TXPWR)
|
|
|
|
|
#define FDRS_TXPWR LORA_TXPWR
|
|
|
|
|
#elif defined (GLOBAL_LORA_TXPWR)
|
|
|
|
|
#define FDRS_TXPWR GLOBAL_LORA_TXPWR
|
|
|
|
|
#else
|
|
|
|
|
// ASSERT("NO LORA-TXPWR defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
|
|
|
|
|
#define FDRS_LORA_TXPWR LORA_TXPWR
|
|
|
|
|
#else
|
|
|
|
|
#define FDRS_LORA_TXPWR GLOBAL_LORA_TXPWR
|
|
|
|
|
#endif //LORA_TXPWR
|
|
|
|
|
|
|
|
|
|
// select LoRa BANDWIDTH configuration
|
|
|
|
|
#if defined(LORA_BANDWIDTH)
|
|
|
|
|
#define FDRS_LORA_BANDWIDTH LORA_BANDWIDTH
|
|
|
|
|
#else
|
|
|
|
|
#define FDRS_LORA_BANDWIDTH GLOBAL_LORA_BANDWIDTH
|
|
|
|
|
#endif //LORA_BANDWIDTH
|
|
|
|
|
|
|
|
|
|
// select LoRa Coding Rate configuration
|
|
|
|
|
#if defined(LORA_CR)
|
|
|
|
|
#define FDRS_LORA_CR LORA_CR
|
|
|
|
|
#else
|
|
|
|
|
#define FDRS_LORA_CR GLOBAL_LORA_CR
|
|
|
|
|
#endif //LORA_CR
|
|
|
|
|
|
|
|
|
|
// select LoRa SyncWord configuration
|
|
|
|
|
#if defined(LORA_SYNCWORD)
|
|
|
|
|
#define FDRS_LORA_SYNCWORD LORA_SYNCWORD
|
|
|
|
|
#else
|
|
|
|
|
#define FDRS_LORA_SYNCWORD GLOBAL_LORA_SYNCWORD
|
|
|
|
|
#endif //LORA_SYNCWORD
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif //USE_LORA
|
|
|
|
|
|
|
|
|
|
#define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE // Should only be changed if implementing multiple FDRS systems.
|
|
|
|
@ -207,15 +234,6 @@ uint8_t ESPNOW1[] = {MAC_PREFIX, ESPNOW_NEIGHBOR_1};
|
|
|
|
|
uint8_t ESPNOW2[] = {MAC_PREFIX, ESPNOW_NEIGHBOR_2};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef USE_LORA
|
|
|
|
|
uint16_t LoRa1 = ((mac_prefix[4] << 8) | LORA_NEIGHBOR_1); // Use 2 bytes for LoRa addressing instead of previous 3 bytes
|
|
|
|
|
uint16_t LoRa2 = ((mac_prefix[4] << 8) | LORA_NEIGHBOR_2);
|
|
|
|
|
uint16_t loraGwAddress = ((selfAddress[4] << 8) | selfAddress[5]); // last 2 bytes of gateway address
|
|
|
|
|
uint16_t loraBroadcast = 0xFFFF;
|
|
|
|
|
unsigned long receivedLoRaMsg = 0; // Number of total LoRa packets destined for us and of valid size
|
|
|
|
|
unsigned long ackOkLoRaMsg = 0; // Number of total LoRa packets with valid CRC
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined (USE_SD_LOG) || defined (USE_FS_LOG)
|
|
|
|
|
char logBuffer[512];
|
|
|
|
|
uint16_t logBufferPos = 0; // datatype depends on size of sdBuffer
|
|
|
|
|