2018-10-14 13:26:23 +02:00
|
|
|
#ifndef _GLOBALS_H
|
|
|
|
#define _GLOBALS_H
|
|
|
|
|
|
|
|
// The mother of all embedded development...
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
// std::set for unified array functions
|
|
|
|
#include <set>
|
|
|
|
#include <array>
|
|
|
|
#include <algorithm>
|
|
|
|
|
2018-11-19 00:41:15 +01:00
|
|
|
// bits in payloadmask for filtering payload data
|
|
|
|
#define GPS_DATA (0x01)
|
|
|
|
#define ALARM_DATA (0x02)
|
|
|
|
#define MEMS_DATA (0x04)
|
|
|
|
#define COUNT_DATA (0x08)
|
|
|
|
#define SENSOR1_DATA (0x10)
|
|
|
|
#define SENSOR2_DATA (0x20)
|
|
|
|
#define SENSOR3_DATA (0x40)
|
2018-11-27 11:21:20 +01:00
|
|
|
#define BATT_DATA (0x80)
|
2018-11-19 00:41:15 +01:00
|
|
|
|
|
|
|
// bits in configmask for device runmode control
|
|
|
|
#define GPS_MODE (0x01)
|
|
|
|
#define ALARM_MODE (0x02)
|
|
|
|
#define BEACON_MODE (0x04)
|
|
|
|
#define UPDATE_MODE (0x08)
|
|
|
|
#define FILTER_MODE (0x10)
|
|
|
|
#define ANTENNA_MODE (0x20)
|
|
|
|
#define BLE_MODE (0x40)
|
|
|
|
#define SCREEN_MODE (0x80)
|
|
|
|
|
2018-10-14 13:26:23 +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 monitormode; // 0=disabled, 1=enabled
|
|
|
|
uint8_t runmode; // 0=normal, 1=update
|
2018-11-19 00:41:15 +01:00
|
|
|
uint8_t payloadmask; // bitswitches for payload data
|
2018-10-14 13:26:23 +02:00
|
|
|
char version[10]; // Firmware version
|
|
|
|
} configData_t;
|
|
|
|
|
|
|
|
// Struct holding payload for data send queue
|
|
|
|
typedef struct {
|
|
|
|
uint8_t MessageSize;
|
|
|
|
uint8_t MessagePort;
|
|
|
|
uint8_t Message[PAYLOAD_BUFFER_SIZE];
|
|
|
|
} MessageBuffer_t;
|
|
|
|
|
2018-11-04 19:25:11 +01:00
|
|
|
typedef struct {
|
|
|
|
uint32_t latitude;
|
|
|
|
uint32_t longitude;
|
|
|
|
uint8_t satellites;
|
|
|
|
uint16_t hdop;
|
|
|
|
uint16_t altitude;
|
|
|
|
} gpsStatus_t;
|
|
|
|
|
2018-11-14 22:11:23 +01:00
|
|
|
typedef struct {
|
2018-11-25 16:05:30 +01:00
|
|
|
float iaq; // IAQ signal
|
|
|
|
uint8_t iaq_accuracy; // accuracy of IAQ signal
|
|
|
|
float temperature; // temperature signal
|
|
|
|
float humidity; // humidity signal
|
|
|
|
float pressure; // pressure signal
|
|
|
|
float raw_temperature; // raw temperature signal
|
|
|
|
float raw_humidity; // raw humidity signal
|
|
|
|
float gas; // raw gas sensor signal
|
2018-11-14 22:11:23 +01:00
|
|
|
} bmeStatus_t;
|
|
|
|
|
2018-10-14 13:26:23 +02:00
|
|
|
// global variables
|
|
|
|
extern configData_t cfg; // current device configuration
|
|
|
|
extern char display_line6[], display_line7[]; // screen buffers
|
|
|
|
extern uint8_t volatile channel; // wifi channel rotation counter
|
|
|
|
extern uint16_t volatile macs_total, macs_wifi, macs_ble,
|
|
|
|
batt_voltage; // display values
|
|
|
|
extern std::set<uint16_t> macs; // temp storage for MACs
|
|
|
|
extern hw_timer_t *channelSwitch, *sendCycle;
|
|
|
|
|
|
|
|
extern std::array<uint64_t, 0xff>::iterator it;
|
|
|
|
extern std::array<uint64_t, 0xff> beacons;
|
|
|
|
|
|
|
|
extern TaskHandle_t irqHandlerTask, wifiSwitchTask;
|
|
|
|
|
2018-11-04 19:25:11 +01:00
|
|
|
#include "led.h"
|
|
|
|
#include "payload.h"
|
|
|
|
|
2018-10-14 13:26:23 +02:00
|
|
|
#ifdef HAS_GPS
|
2018-10-21 19:00:20 +02:00
|
|
|
#include "gpsread.h"
|
2018-10-14 13:26:23 +02:00
|
|
|
#endif
|
|
|
|
|
2018-11-14 22:11:23 +01:00
|
|
|
#ifdef HAS_BME
|
2018-11-22 23:37:53 +01:00
|
|
|
#include "bme680mems.h"
|
2018-11-14 22:11:23 +01:00
|
|
|
#endif
|
|
|
|
|
2018-10-14 13:26:23 +02:00
|
|
|
#ifdef HAS_LORA
|
|
|
|
#include "lorawan.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAS_DISPLAY
|
|
|
|
#include "display.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAS_BUTTON
|
|
|
|
#include "button.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BLECOUNTER
|
|
|
|
#include "blescan.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAS_BATTERY_PROBE
|
|
|
|
#include "battery.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAS_ANTENNA_SWITCH
|
|
|
|
#include "antenna.h"
|
|
|
|
#endif
|
|
|
|
|
2018-11-20 15:02:37 +01:00
|
|
|
#ifdef HAS_SENSORS
|
|
|
|
#include "sensor.h"
|
|
|
|
#endif
|
|
|
|
|
2018-07-17 15:15:58 +02:00
|
|
|
#endif
|