Merge branch 'development' of https://github.com/cyberman54/ESP32-Paxcounter into development
This commit is contained in:
commit
014e6cd4a5
53 files changed
+1239
-547
No files matched your search
+11
-12
@@ -42,12 +42,16 @@
|
||||
#define SCREEN_MODE (0x80)
|
||||
|
||||
// I2C bus access control
|
||||
#define I2C_MUTEX_LOCK() (xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(10)) == pdTRUE)
|
||||
#define I2C_MUTEX_LOCK() \
|
||||
(xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(10)) == pdTRUE)
|
||||
#define I2C_MUTEX_UNLOCK() (xSemaphoreGive(I2Caccess))
|
||||
|
||||
enum sendprio_t { prio_low, prio_normal, prio_high };
|
||||
enum timesource_t { _gps, _rtc, _lora, _unsynced };
|
||||
|
||||
// Struct holding devices's runtime configuration
|
||||
typedef struct {
|
||||
uint8_t lorasf; // 7-12, lora spreadfactor
|
||||
uint8_t loradr; // 0-15, lora datarate
|
||||
uint8_t txpower; // 2-15, lora tx power
|
||||
uint8_t adrmode; // 0=disabled, 1=enabled
|
||||
uint8_t screensaver; // 0=disabled, 1=enabled
|
||||
@@ -73,6 +77,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
uint8_t MessageSize;
|
||||
uint8_t MessagePort;
|
||||
sendprio_t MessagePrio;
|
||||
uint8_t Message[PAYLOAD_BUFFER_SIZE];
|
||||
} MessageBuffer_t;
|
||||
|
||||
@@ -95,16 +100,13 @@ typedef struct {
|
||||
float gas; // raw gas sensor signal
|
||||
} bmeStatus_t;
|
||||
|
||||
enum sendprio_t { prio_low, prio_normal, prio_high };
|
||||
enum timesource_t { _gps, _rtc, _lora, _unsynced };
|
||||
|
||||
extern std::set<uint16_t, std::less<uint16_t>, Mallocator<uint16_t>> macs;
|
||||
extern std::array<uint64_t, 0xff>::iterator it;
|
||||
extern std::array<uint64_t, 0xff> beacons;
|
||||
|
||||
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 configData_t cfg; // current device configuration
|
||||
extern char lmic_event_msg[]; // display buffer
|
||||
extern uint8_t volatile channel; // wifi channel rotation counter
|
||||
extern uint16_t volatile macs_total, macs_wifi, macs_ble,
|
||||
batt_voltage; // display values
|
||||
extern bool volatile TimePulseTick; // 1sec pps flag set by GPS or RTC
|
||||
@@ -120,6 +122,7 @@ extern time_t userUTCTime;
|
||||
#include "led.h"
|
||||
#include "payload.h"
|
||||
#include "blescan.h"
|
||||
#include "power.h"
|
||||
|
||||
#if (HAS_GPS)
|
||||
#include "gpsread.h"
|
||||
@@ -141,10 +144,6 @@ extern time_t userUTCTime;
|
||||
#include "button.h"
|
||||
#endif
|
||||
|
||||
#ifdef BAT_MEASURE_ADC
|
||||
#include "battery.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAS_ANTENNA_SWITCH
|
||||
#include "antenna.h"
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef _I2CSCAN_H
|
||||
#define _I2CSCAN_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define SSD1306_PRIMARY_ADDRESS (0x3D)
|
||||
#define SSD1306_SECONDARY_ADDRESS (0x3C)
|
||||
#define BME_PRIMARY_ADDRESS (0x77)
|
||||
#define BME_SECONDARY_ADDRESS (0x76)
|
||||
#define AXP192_PRIMARY_ADDRESS (0x34)
|
||||
#define MCP_24AA02E64_PRIMARY_ADDRESS (0x50)
|
||||
#define QUECTEL_GPS_PRIMARY_ADDRESS (0x10)
|
||||
|
||||
int i2c_scan(void);
|
||||
|
||||
#endif
|
||||
@@ -10,12 +10,14 @@
|
||||
#define UNMASK_IRQ 0x040
|
||||
#define BME_IRQ 0x080
|
||||
#define MATRIX_DISPLAY_IRQ 0x100
|
||||
#define PMU_IRQ 0x200
|
||||
|
||||
#include "globals.h"
|
||||
#include "cyclic.h"
|
||||
#include "senddata.h"
|
||||
#include "timekeeper.h"
|
||||
#include "bmesensor.h"
|
||||
#include "power.h"
|
||||
|
||||
void irqHandler(void *pvParameters);
|
||||
void mask_user_IRQ();
|
||||
@@ -33,5 +35,9 @@ void IRAM_ATTR MatrixDisplayIRQ();
|
||||
void IRAM_ATTR ButtonIRQ();
|
||||
#endif
|
||||
|
||||
#ifdef HAS_PMU
|
||||
void IRAM_ATTR PMUIRQ();
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -13,5 +13,6 @@ void refreshTheMatrixDisplay(bool nextPage = false);
|
||||
void DrawNumber(String strNum, uint8_t iDotPos = 0);
|
||||
uint8_t GetCharFromFont(char cChar);
|
||||
uint8_t GetCharWidth(char cChar);
|
||||
void ScrollLeft(uint8_t *buf, const uint16_t cols, const uint16_t rows);
|
||||
|
||||
#endif
|
||||
+21
-5
@@ -4,7 +4,7 @@
|
||||
#include "globals.h"
|
||||
#include "rcommand.h"
|
||||
#include "timekeeper.h"
|
||||
#if(TIME_SYNC_LORASERVER)
|
||||
#if (TIME_SYNC_LORASERVER)
|
||||
#include "timesync.h"
|
||||
#endif
|
||||
|
||||
@@ -21,7 +21,14 @@
|
||||
#endif
|
||||
|
||||
extern QueueHandle_t LoraSendQueue;
|
||||
extern TaskHandle_t lmicTask;
|
||||
extern TaskHandle_t lmicTask, lorasendTask;
|
||||
|
||||
// table of LORAWAN MAC commands
|
||||
typedef struct {
|
||||
const uint8_t opcode;
|
||||
const char cmdname[20];
|
||||
const uint8_t params;
|
||||
} mac_t;
|
||||
|
||||
esp_err_t lora_stack_init();
|
||||
void lmictask(void *pvParameters);
|
||||
@@ -33,10 +40,19 @@ void os_getDevKey(u1_t *buf);
|
||||
void os_getArtEui(u1_t *buf);
|
||||
void os_getDevEui(u1_t *buf);
|
||||
void showLoraKeys(void);
|
||||
void switch_lora(uint8_t sf, uint8_t tx);
|
||||
void lora_send(osjob_t *job);
|
||||
void lora_enqueuedata(MessageBuffer_t *message, sendprio_t prio);
|
||||
void lora_send(void *pvParameters);
|
||||
void lora_enqueuedata(MessageBuffer_t *message);
|
||||
void lora_queuereset(void);
|
||||
void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg,
|
||||
size_t nMsg);
|
||||
void myTxCallback(void *pUserData, int fSuccess);
|
||||
void mac_decode(const uint8_t cmd[], const uint8_t cmdlen, const mac_t table[],
|
||||
const uint8_t tablesize);
|
||||
uint8_t getBattLevel(void);
|
||||
const char *getSfName(rps_t rps);
|
||||
const char *getBwName(rps_t rps);
|
||||
const char *getCrName(rps_t rps);
|
||||
|
||||
#if (TIME_SYNC_LORAWAN)
|
||||
void user_request_network_time_callback(void *pVoidUserUTCTime,
|
||||
int flagSuccess);
|
||||
|
||||
+5
-3
@@ -1,12 +1,14 @@
|
||||
#ifndef _MAIN_H
|
||||
#define _MAIN_H
|
||||
|
||||
#include <esp_spi_flash.h> // needed for reading ESP32 chip attributes
|
||||
#include <esp_event_loop.h> // needed for Wifi event handler
|
||||
#include <esp_spi_flash.h> // needed for reading ESP32 chip attributes
|
||||
#include <esp_event_loop.h> // needed for Wifi event handler
|
||||
#include <esp32-hal-timer.h> // needed for timers
|
||||
#include <esp_coexist.h> // needed for showing coex sw version
|
||||
#include <esp_coexist.h> // needed for showing coex sw version
|
||||
|
||||
#include "globals.h"
|
||||
#include "power.h"
|
||||
#include "i2cscan.h"
|
||||
#include "blescan.h"
|
||||
#include "wifiscan.h"
|
||||
#include "configmanager.h"
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#ifdef USE_OTA
|
||||
|
||||
#include "globals.h"
|
||||
#include "battery.h"
|
||||
#include <Update.h>
|
||||
#include <WiFi.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#ifndef _BATTERY_H
|
||||
#define _BATTERY_H
|
||||
#ifndef _POWER_H
|
||||
#define _POWER_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <driver/adc.h>
|
||||
#include <esp_adc_cal.h>
|
||||
#include "i2cscan.h"
|
||||
|
||||
#define DEFAULT_VREF 1100 // tbd: use adc2_vref_to_gpio() for better estimate
|
||||
#define NO_OF_SAMPLES 64 // we do some multisampling to get better values
|
||||
@@ -11,4 +13,12 @@ uint16_t read_voltage(void);
|
||||
void calibrate_voltage(void);
|
||||
bool batt_sufficient(void);
|
||||
|
||||
#endif
|
||||
#ifdef HAS_PMU
|
||||
#include <axp20x.h>
|
||||
void power_event_IRQ(void);
|
||||
void AXP192_power(bool on);
|
||||
void AXP192_init(void);
|
||||
void AXP192_showstatus(void);
|
||||
#endif // HAS_PMU
|
||||
|
||||
#endif
|
||||
+2
-2
@@ -19,11 +19,11 @@
|
||||
typedef struct {
|
||||
const uint8_t opcode;
|
||||
void (*func)(uint8_t []);
|
||||
uint8_t params;
|
||||
const uint8_t params;
|
||||
const bool store;
|
||||
} cmd_t;
|
||||
|
||||
void rcommand(uint8_t cmd[], uint8_t cmdlength);
|
||||
void rcommand(const uint8_t cmd[], const uint8_t cmdlength);
|
||||
void do_reset();
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
extern Ticker sendcycler;
|
||||
|
||||
void SendPayload(uint8_t port, sendprio_t prio);
|
||||
void sendCounter(void);
|
||||
void sendData(void);
|
||||
void checkSendQueues(void);
|
||||
void flushQueues();
|
||||
void sendcycle(void);
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ licenses. Refer to LICENSE.txt file in repository for more details.
|
||||
|
||||
esp_err_t spi_init();
|
||||
|
||||
void spi_enqueuedata(MessageBuffer_t *message, sendprio_t prio);
|
||||
void spi_enqueuedata(MessageBuffer_t *message);
|
||||
void spi_queuereset();
|
||||
|
||||
#endif // _SPISLAVE_H
|
||||
@@ -27,6 +27,7 @@ void timeSync(void);
|
||||
uint8_t timepulse_init(void);
|
||||
time_t timeIsValid(time_t const t);
|
||||
void calibrateTime(void);
|
||||
void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec, timesource_t mytimesource);
|
||||
time_t compiledUTC(void);
|
||||
TickType_t tx_Ticks(uint32_t framesize, unsigned long baud, uint32_t config,
|
||||
int8_t rxPin, int8_t txPins);
|
||||
|
||||
+2
-3
@@ -12,9 +12,8 @@
|
||||
|
||||
void timesync_init(void);
|
||||
void send_timesync_req(void);
|
||||
int recv_timesync_ans(uint8_t buf[], uint8_t buf_len);
|
||||
int recv_timesync_ans(const uint8_t buf[], uint8_t buf_len);
|
||||
void process_timesync_req(void *taskparameter);
|
||||
void store_time_sync_req(uint32_t t_millisec);
|
||||
void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec, timesource_t timesource);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
Reference in new issue
Block a user