Merge pull request #570 from cyberman54/development
update branch sds011 to dev
This commit is contained in:
23 files changed
+623
-501
No files matched your search
@@ -3,15 +3,37 @@
|
||||
|
||||
#include "cyclic.h"
|
||||
#include "qrcode.h"
|
||||
#define DISPLAY_PAGES (7) // number of paxcounter display pages
|
||||
|
||||
// settings for oled display library
|
||||
#define USE_BACKBUFFER 1
|
||||
#define MY_OLED OLED_128x64
|
||||
#define OLED_ADDR -1
|
||||
#define OLED_INVERT 0
|
||||
#define USE_HW_I2C 1
|
||||
|
||||
#ifndef DISPLAY_FLIP
|
||||
#define DISPLAY_FLIP 0
|
||||
#endif
|
||||
|
||||
// settings for qr code generator
|
||||
#define QR_VERSION 3 // 29 x 29px
|
||||
#define QR_SCALEFACTOR 2 // 29 -> 58x < 64px
|
||||
|
||||
// settings for curve plotter
|
||||
#define DISPLAY_WIDTH 128 // Width in pixels of OLED-display, must be 32X
|
||||
#define DISPLAY_HEIGHT 64 // Height in pixels of OLED-display, must be 64X
|
||||
|
||||
extern uint8_t DisplayIsOn, displaybuf[];
|
||||
|
||||
void setup_display(int contrast = 0);
|
||||
void refreshTheDisplay(bool nextPage = false);
|
||||
void init_display(bool verbose = false);
|
||||
void shutdown_display(void);
|
||||
void draw_page(time_t t, bool nextpage);
|
||||
void dp_printf(uint16_t x, uint16_t y, uint8_t font, uint8_t inv,
|
||||
const char *format, ...);
|
||||
void dp_dump(uint8_t *pBuffer);
|
||||
void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message);
|
||||
void oledfillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
||||
uint8_t bRender);
|
||||
|
||||
@@ -132,7 +132,6 @@ extern SemaphoreHandle_t I2Caccess;
|
||||
extern TaskHandle_t irqHandlerTask, ClockTask;
|
||||
extern TimerHandle_t WifiChanTimer;
|
||||
extern Timezone myTZ;
|
||||
extern time_t userUTCTime;
|
||||
extern RTC_DATA_ATTR runmode_t RTC_runmode;
|
||||
|
||||
// application includes
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ int gps_config();
|
||||
bool gps_hasfix();
|
||||
void gps_storelocation(gpsStatus_t *gps_store);
|
||||
void gps_loop(void *pvParameters);
|
||||
time_t fetch_gpsTime(uint16_t *msec);
|
||||
time_t fetch_gpsTime(void);
|
||||
time_t get_gpstime(uint16_t *msec);
|
||||
time_t get_gpstime(void);
|
||||
|
||||
#endif
|
||||
+42
-20
@@ -5,9 +5,6 @@
|
||||
#include "rcommand.h"
|
||||
#include "timekeeper.h"
|
||||
#include <driver/rtc_io.h>
|
||||
#if (TIME_SYNC_LORASERVER)
|
||||
#include "timesync.h"
|
||||
#endif
|
||||
|
||||
// LMIC-Arduino LoRaWAN Stack
|
||||
#include <lmic.h>
|
||||
@@ -23,13 +20,6 @@
|
||||
|
||||
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(bool do_join);
|
||||
void lora_setupForNetwork(bool preJoin);
|
||||
void lmictask(void *pvParameters);
|
||||
@@ -39,24 +29,56 @@ void get_hard_deveui(uint8_t *pdeveui);
|
||||
void os_getDevKey(u1_t *buf);
|
||||
void os_getArtEui(u1_t *buf);
|
||||
void os_getDevEui(u1_t *buf);
|
||||
void showLoraKeys(void);
|
||||
void lora_send(void *pvParameters);
|
||||
void lora_enqueuedata(MessageBuffer_t *message);
|
||||
void lora_queuereset(void);
|
||||
void IRAM_ATTR myEventCallback(void *pUserData, ev_t ev);
|
||||
void IRAM_ATTR myRxCallback(void *pUserData, uint8_t port,
|
||||
const uint8_t *pMsg, size_t nMsg);
|
||||
void IRAM_ATTR myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg,
|
||||
size_t nMsg);
|
||||
void IRAM_ATTR myTxCallback(void *pUserData, int fSuccess);
|
||||
void mac_decode(const uint8_t cmd[], const uint8_t cmdlen, const mac_t table[],
|
||||
const uint8_t tablesize);
|
||||
//u1_t os_getBattLevel(void);
|
||||
const char *getSfName(rps_t rps);
|
||||
const char *getBwName(rps_t rps);
|
||||
const char *getCrName(rps_t rps);
|
||||
// u1_t os_getBattLevel(void);
|
||||
|
||||
#if (TIME_SYNC_LORAWAN)
|
||||
void user_request_network_time_callback(void *pVoidUserUTCTime,
|
||||
int flagSuccess);
|
||||
#endif
|
||||
#if (VERBOSE)
|
||||
|
||||
// a table for storage of LORAWAN MAC commands
|
||||
typedef struct {
|
||||
const uint8_t cid;
|
||||
const char cmdname[20];
|
||||
const uint8_t params;
|
||||
} mac_t;
|
||||
|
||||
// table of LORAWAN MAC messages sent by the network to the device
|
||||
// format: CDI, Command (max 19 chars), #parameters (bytes)
|
||||
// source: LoRaWAN 1.1 Specification (October 11, 2017)
|
||||
static const mac_t MACdn_table[] = {
|
||||
{0x01, "ResetConf", 1}, {0x02, "LinkCheckAns", 2},
|
||||
{0x03, "LinkADRReq", 4}, {0x04, "DutyCycleReq", 1},
|
||||
{0x05, "RXParamSetupReq", 4}, {0x06, "DevStatusReq", 0},
|
||||
{0x07, "NewChannelReq", 5}, {0x08, "RxTimingSetupReq", 1},
|
||||
{0x09, "TxParamSetupReq", 1}, {0x0A, "DlChannelReq", 4},
|
||||
{0x0B, "RekeyConf", 1}, {0x0C, "ADRParamSetupReq", 1},
|
||||
{0x0D, "DeviceTimeAns", 5}, {0x0E, "ForceRejoinReq", 2},
|
||||
{0x0F, "RejoinParamSetupReq", 1}};
|
||||
|
||||
static const uint8_t MACdn_tSize = sizeof(MACdn_table) / sizeof(MACdn_table[0]);
|
||||
|
||||
// table of LORAWAN MAC messages sent by the device to the network
|
||||
static const mac_t MACup_table[] = {
|
||||
{0x01, "ResetInd", 1}, {0x02, "LinkCheckReq", 0},
|
||||
{0x03, "LinkADRAns", 1}, {0x04, "DutyCycleAns", 0},
|
||||
{0x05, "RXParamSetupAns", 1}, {0x06, "DevStatusAns", 2},
|
||||
{0x07, "NewChannelAns", 1}, {0x08, "RxTimingSetupAns", 0},
|
||||
{0x09, "TxParamSetupAns", 0}, {0x0A, "DlChannelAns", 1},
|
||||
{0x0B, "RekeyInd", 1}, {0x0C, "ADRParamSetupAns", 0},
|
||||
{0x0D, "DeviceTimeReq", 0}, {0x0F, "RejoinParamSetupAns", 1}};
|
||||
|
||||
static const uint8_t MACup_tSize = sizeof(MACup_table) / sizeof(MACup_table[0]);
|
||||
|
||||
void mac_decode(const uint8_t cmd[], const uint8_t cmdlen, bool is_down);
|
||||
void showLoraKeys(void);
|
||||
#endif // VERBOSE
|
||||
|
||||
#endif
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "rtctime.h"
|
||||
#include "TimeLib.h"
|
||||
#include "irqhandler.h"
|
||||
#include "timesync.h"
|
||||
|
||||
#if (HAS_GPS)
|
||||
#include "gpsread.h"
|
||||
@@ -31,7 +32,5 @@ void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec, timesource_t mytimesou
|
||||
time_t compiledUTC(void);
|
||||
TickType_t tx_Ticks(uint32_t framesize, unsigned long baud, uint32_t config,
|
||||
int8_t rxPin, int8_t txPins);
|
||||
time_t TimeSyncAns(uint8_t seqNo, uint64_t unixTime);
|
||||
void TimeSyncReq(uint8_t seqNo);
|
||||
|
||||
#endif // _timekeeper_H
|
||||
+17
-11
@@ -1,22 +1,28 @@
|
||||
#ifndef _TIMESYNC_H
|
||||
#define _TIMESYNC_H
|
||||
|
||||
#include <chrono>
|
||||
#include "globals.h"
|
||||
#include "irqhandler.h"
|
||||
#include "timekeeper.h"
|
||||
|
||||
//#define TIME_SYNC_TRIGGER 100 // threshold for time sync [milliseconds]
|
||||
#define TIME_SYNC_FRAME_LENGTH 0x07 // timeserver answer frame length [bytes]
|
||||
#define TIME_SYNC_FIXUP 4 // calibration to fixup processing time [milliseconds]
|
||||
#define TIMEREQUEST_MAX_SEQNO 0xf0 // threshold for wrap around seqno
|
||||
#define TIME_SYNC_FRAME_LENGTH 6 // timeserver answer frame length [bytes]
|
||||
#define TIME_SYNC_FIXUP 16 // compensation for processing time [milliseconds]
|
||||
#define TIME_SYNC_MAX_SEQNO 0xfe // threshold for wrap around time_sync_seqNo
|
||||
#define TIME_SYNC_END_FLAG (TIME_SYNC_MAX_SEQNO + 1) // end of handshake marker
|
||||
#define GPS_UTC_DIFF 315964800 // seconds diff between gps and utc epoch
|
||||
|
||||
enum timesync_t {
|
||||
timesync_tx,
|
||||
timesync_rx,
|
||||
gwtime_sec,
|
||||
gwtime_msec,
|
||||
no_of_timestamps
|
||||
};
|
||||
|
||||
void timesync_init(void);
|
||||
void send_timesync_req(void);
|
||||
|
||||
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 timesync_request(void);
|
||||
void timesync_store(uint32_t timestamp, timesync_t timestamp_type);
|
||||
void IRAM_ATTR timesync_processReq(void *taskparameter);
|
||||
void IRAM_ATTR timesync_serverAnswer(void *pUserData, int flag);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user