ESP32-PaxCounter/src/globals.h

92 lines
2.5 KiB
C
Raw Normal View History

2018-07-17 15:15:58 +02:00
#ifndef _GLOBALS_H
#define _GLOBALS_H
2018-03-18 19:45:17 +01:00
// The mother of all embedded development...
#include <Arduino.h>
2018-07-17 11:53:43 +02:00
// needed for ESP_LOGx on arduino framework
#include <esp32-hal-log.h>
// attn: increment version after modifications to configData_t truct!
#define PROGVERSION "1.3.91" // use max 10 chars here!
#define PROGNAME "PAXCNT"
2018-03-18 19:45:17 +01:00
// std::set for unified array functions
2018-06-10 21:03:16 +02:00
#include <set>
#include <array>
#include <algorithm>
2018-03-18 19:45:17 +01:00
2018-07-17 11:53:43 +02:00
// Struct holding devices's runtime configuration
typedef struct {
uint8_t lorasf; // 7-12, lora spreadfactor
uint8_t txpower; // 2-15, lora tx power
uint8_t adrmode; // 0=disabled, 1=enabled
uint8_t screensaver; // 0=disabled, 1=enabled
uint8_t screenon; // 0=disabled, 1=enabled
uint8_t countermode; // 0=cyclic unconfirmed, 1=cumulative, 2=cyclic confirmed
int16_t rssilimit; // threshold for rssilimiter, negative value!
uint8_t sendcycle; // payload send cycle [seconds/2]
uint8_t wifichancycle; // wifi channel switch cycle [seconds/100]
uint8_t blescantime; // BLE scan cycle duration [seconds]
uint8_t blescan; // 0=disabled, 1=enabled
uint8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4)
uint8_t vendorfilter; // 0=disabled, 1=enabled
uint8_t rgblum; // RGB Led luminosity (0..100%)
uint8_t gpsmode; // 0=disabled, 1=enabled
char version[10]; // Firmware version
} configData_t;
2018-06-08 22:41:37 +02:00
2018-03-21 17:34:11 +01:00
extern configData_t cfg;
2018-07-14 20:07:33 +02:00
extern char display_line6[], display_line7[];
extern int countermode, screensaver, adrmode, lorasf, txpower, rlim;
2018-07-15 14:28:05 +02:00
extern uint8_t channel, DisplayState;
2018-04-19 10:55:59 +02:00
extern uint16_t macs_total, macs_wifi, macs_ble; // MAC counters
2018-04-28 14:09:27 +02:00
extern std::set<uint16_t> macs;
2018-07-14 23:38:43 +02:00
extern hw_timer_t *channelSwitch, *sendCycle;
2018-07-15 14:28:05 +02:00
extern portMUX_TYPE timerMux;
2018-07-17 15:15:58 +02:00
#ifdef HAS_GPS
#include "gps.h"
#endif
2018-07-17 11:53:43 +02:00
#ifdef HAS_LORA
#include "lorawan.h"
#endif
#ifdef HAS_DISPLAY
#include "display.h"
#endif
#ifdef BLECOUNTER
#include "blescan.h"
#endif
#ifdef HAS_BATTERY_PROBE
#include "battery.h"
#endif
#ifdef HAS_ANTENNA_SWITCH
#include "antenna.h"
#endif
// class for preparing payload data
#include "payload.h"
2018-06-16 19:50:36 +02:00
// payload encoder
2018-06-17 01:15:02 +02:00
#if PAYLOAD_ENCODER == 1
extern TTNplain payload;
2018-06-17 01:15:02 +02:00
#elif PAYLOAD_ENCODER == 2
2018-06-17 22:41:32 +02:00
extern TTNpacked payload;
2018-06-17 01:15:02 +02:00
#elif PAYLOAD_ENCODER == 3
extern CayenneLPP payload;
2018-06-16 19:50:36 +02:00
#else
#error "No valid payload converter defined"
2018-07-17 11:53:43 +02:00
#endif
void reset_counters(void);
void blink_LED(uint16_t set_color, uint16_t set_blinkduration);
void led_loop(void);
2018-07-17 15:15:58 +02:00
uint64_t uptime();
#endif