commit
e2d0cb6ca1
21
README.md
21
README.md
@ -311,7 +311,7 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
|
||||
|
||||
Example for EU868:
|
||||
|
||||
DataRate Radio Bit/s
|
||||
DataRate Configuration Bit/s
|
||||
0 LoRa: SF12 / 125 kHz 250
|
||||
1 LoRa: SF11 / 125 kHz 440
|
||||
2 LoRa: SF10 / 125 kHz 980
|
||||
@ -320,20 +320,33 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
|
||||
5 LoRa: SF7 / 125 kHz 5470
|
||||
6* LoRa: SF7 / 250 kHz 11000
|
||||
7* FSK: 50 kbps 50000
|
||||
8 .. 14 reserved for future use (RFU)
|
||||
15 ignored (device keeps current setting)
|
||||
|
||||
*) not supported by TheThingsNetwork
|
||||
|
||||
0x06 set LoRa TXpower
|
||||
|
||||
0 ... 15 [default: 14]
|
||||
0 ... 15 [default: 7]
|
||||
|
||||
TXPower Configuration
|
||||
0 Max EIRP (usually +16dB)
|
||||
1 -2dB
|
||||
2 -4dB
|
||||
3 -6dB
|
||||
4 -8dB
|
||||
5 -10dB
|
||||
6 -12dB
|
||||
7 -14dB
|
||||
8 .. 14 reserved for future use (RFU)
|
||||
15 ignored (device keeps current setting)
|
||||
|
||||
0x07 set LoRa Adaptive Data Rate mode
|
||||
|
||||
0 = ADR off
|
||||
1 = ADR on [default]
|
||||
|
||||
Note: set ADR to off, if device is moving, set to on, if not.
|
||||
If ADR is set to on, SF value is shown inverted on display.
|
||||
If ADR is set to off, SF value is shown inverted on display.
|
||||
|
||||
0x08 do nothing
|
||||
|
||||
|
@ -42,7 +42,8 @@
|
||||
#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 };
|
||||
@ -103,9 +104,9 @@ 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
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
; ---> SELECT THE TARGET PLATFORM HERE! <---
|
||||
[board]
|
||||
halfile = generic.h
|
||||
;halfile = generic.h
|
||||
;halfile = ebox.h
|
||||
;halfile = eboxtube.h
|
||||
;halfile = ecopower.h
|
||||
@ -18,7 +18,7 @@ halfile = generic.h
|
||||
;halfile = ttgov21old.h
|
||||
;halfile = ttgov21new.h
|
||||
;halfile = ttgofox.h
|
||||
;halfile = ttgobeam.h
|
||||
halfile = ttgobeam.h
|
||||
;halfile = ttgobeam10.h
|
||||
;halfile = fipy.h
|
||||
;halfile = lopy.h
|
||||
@ -46,7 +46,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I
|
||||
release_version = 1.8.3
|
||||
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
|
||||
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
|
||||
debug_level = 3
|
||||
debug_level = 4
|
||||
extra_scripts = pre:build.py
|
||||
otakeyfile = ota.conf
|
||||
lorakeyfile = loraconf.h
|
||||
|
@ -10,15 +10,17 @@ Display-Mask (128 x 64 pixel):
|
||||
0|PAX:aabbccddee
|
||||
1|PAX:aabbccddee
|
||||
2|B:a.bcV Sats:ab
|
||||
3|BLTH:abcde SF:ab
|
||||
3|BLTH:abcde SFab
|
||||
4|WIFI:abcde ch:ab
|
||||
5|RLIM:abcd abcdKB
|
||||
6|xxxxxxxxxxxxxxxx
|
||||
6|20:27:00* 27.Feb
|
||||
7|yyyyyyyyyyyyyyab
|
||||
|
||||
line 6: x = Text for LORA status OR time/date
|
||||
line 7: y = Text for LMIC status; ab = payload queue
|
||||
line 6: * = char {L|G|R|?} indicates time source,
|
||||
inverse = clock controller is active,
|
||||
pulsed = pps input signal is active
|
||||
|
||||
line 7: y = LMIC event message; ab = payload queue length
|
||||
|
||||
*/
|
||||
|
||||
@ -203,10 +205,10 @@ void draw_page(time_t t, uint8_t page) {
|
||||
|
||||
#if (HAS_LORA)
|
||||
u8x8.setCursor(11, 3);
|
||||
if (cfg.adrmode) // if ADR=on then display SF value inverse
|
||||
if (!cfg.adrmode) // if ADR=off then display SF value inverse
|
||||
u8x8.setInverseFont(1);
|
||||
u8x8.printf("%5s", getSfName(updr2rps(LMIC.datarate)));
|
||||
if (cfg.adrmode) // switch off inverse if it was turned on
|
||||
u8x8.printf("%4s", getSfName(updr2rps(LMIC.datarate)));
|
||||
if (!cfg.adrmode) // switch off inverse if it was turned on
|
||||
u8x8.setInverseFont(0);
|
||||
#endif // HAS_LORA
|
||||
|
||||
@ -239,17 +241,13 @@ void draw_page(time_t t, uint8_t page) {
|
||||
#endif // HAS_DCF77 || HAS_IF482
|
||||
if (timeSource != _unsynced)
|
||||
u8x8.printf(" %2d.%3s", day(t), printmonth[month(t)]);
|
||||
#else // update LoRa status display
|
||||
#if (HAS_LORA)
|
||||
u8x8.printf("%-16s", display_line6);
|
||||
#endif
|
||||
|
||||
#endif // TIME_SYNC_INTERVAL
|
||||
|
||||
#if (HAS_LORA)
|
||||
// line 7: update LMiC event display
|
||||
u8x8.setCursor(0, 7);
|
||||
u8x8.printf("%-14s", display_line7);
|
||||
u8x8.printf("%-14s", lmic_event_msg);
|
||||
|
||||
// update LoRa send queue display
|
||||
msgWaiting = uxQueueMessagesWaiting(LoraSendQueue);
|
||||
@ -259,7 +257,6 @@ void draw_page(time_t t, uint8_t page) {
|
||||
u8x8.printf("%-2s", msgWaiting == SEND_QUEUE_SIZE ? "<>" : buff);
|
||||
} else
|
||||
u8x8.printf(" ");
|
||||
|
||||
#endif // HAS_LORA
|
||||
|
||||
break; // page0
|
||||
|
@ -231,7 +231,6 @@ void onEvent(ev_t ev) {
|
||||
|
||||
case EV_JOINED:
|
||||
strcpy_P(buff, PSTR("JOINED"));
|
||||
sprintf(display_line6, " "); // clear previous lmic status
|
||||
// set data rate adaptation according to saved setting
|
||||
LMIC_setAdrMode(cfg.adrmode);
|
||||
// set data rate and transmit power to defaults only if we have no ADR
|
||||
@ -258,16 +257,7 @@ void onEvent(ev_t ev) {
|
||||
break;
|
||||
|
||||
case EV_TXCOMPLETE:
|
||||
|
||||
#if (TIME_SYNC_LORASERVER)
|
||||
// if last packet sent was a timesync request, store TX timestamp
|
||||
if (LMIC.pendTxPort == TIMEPORT)
|
||||
store_time_sync_req(osticks2ms(LMIC.txend)); // milliseconds
|
||||
#endif
|
||||
|
||||
strcpy_P(buff, (LMIC.txrxFlags & TXRX_ACK) ? PSTR("RECEIVED ACK")
|
||||
: PSTR("TX COMPLETE"));
|
||||
sprintf(display_line6, " "); // clear previous lmic status
|
||||
strcpy_P(buff, PSTR("TX COMPLETE"));
|
||||
break;
|
||||
|
||||
case EV_LOST_TSYNC:
|
||||
@ -321,7 +311,7 @@ void onEvent(ev_t ev) {
|
||||
// Log & Display if asked
|
||||
if (*buff) {
|
||||
ESP_LOGI(TAG, "%s", buff);
|
||||
sprintf(display_line7, buff);
|
||||
sprintf(lmic_event_msg, buff);
|
||||
}
|
||||
}
|
||||
|
||||
@ -585,7 +575,12 @@ void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg,
|
||||
|
||||
// transmit complete message handler
|
||||
void myTxCallback(void *pUserData, int fSuccess) {
|
||||
/* currently no code here */
|
||||
|
||||
#if (TIME_SYNC_LORASERVER)
|
||||
// if last packet sent was a timesync request, store TX timestamp
|
||||
if (LMIC.pendTxPort == TIMEPORT)
|
||||
store_time_sync_req(osticks2ms(LMIC.txend)); // milliseconds
|
||||
#endif
|
||||
}
|
||||
|
||||
// decode LORAWAN MAC message
|
||||
@ -651,12 +646,12 @@ uint8_t getBattLevel() {
|
||||
|
||||
const char *getSfName(rps_t rps) {
|
||||
const char *const t[] = {"FSK", "SF7", "SF8", "SF9",
|
||||
"SF10", "SF11", "SF12", "SFrfu"};
|
||||
"SF10", "SF11", "SF12", "SF?"};
|
||||
return t[getSf(rps)];
|
||||
}
|
||||
|
||||
const char *getBwName(rps_t rps) {
|
||||
const char *const t[] = {"BW125", "BW250", "BW500", "BWrfu"};
|
||||
const char *const t[] = {"BW125", "BW250", "BW500", "BW?"};
|
||||
return t[getBw(rps)];
|
||||
}
|
||||
|
||||
|
@ -76,9 +76,9 @@ triggers pps 1 sec impulse
|
||||
// Basic Config
|
||||
#include "main.h"
|
||||
|
||||
configData_t cfg; // struct holds current device configuration
|
||||
char display_line6[16], display_line7[16]; // display buffers
|
||||
uint8_t volatile channel = 0; // channel rotation counter
|
||||
configData_t cfg; // struct holds current device configuration
|
||||
char lmic_event_msg[16]; // display buffer for LMIC event message
|
||||
uint8_t volatile channel = 0; // channel rotation counter
|
||||
uint16_t volatile macs_total = 0, macs_wifi = 0, macs_ble = 0,
|
||||
batt_voltage = 0; // globals for display
|
||||
|
||||
|
@ -41,7 +41,7 @@ inline String getHeaderValue(String header, String headerName) {
|
||||
void start_ota_update() {
|
||||
|
||||
// check battery status if we can before doing ota
|
||||
if (!batt_sufficient()) {
|
||||
if (!batt_sufficient()) {
|
||||
ESP_LOGE(TAG, "Battery voltage %dmV too low for OTA", batt_voltage);
|
||||
return;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@
|
||||
#define RETRANSMIT_RCMD 5 // [seconds] wait time before retransmitting rcommand results
|
||||
#define PAYLOAD_BUFFER_SIZE 51 // maximum size of payload block per transmit
|
||||
#define LORADRDEFAULT 5 // 0 .. 15, LoRaWAN datarate, according to regional LoRaWAN specs [default = 5]
|
||||
#define LORATXPOWDEFAULT 14 // 0 .. 15, LoRaWAN TX power
|
||||
#define LORATXPOWDEFAULT 7 // 0 .. 15, LoRaWAN TX power [default = 7]
|
||||
#define MAXLORARETRY 500 // maximum count of TX retries if LoRa busy
|
||||
#define SEND_QUEUE_SIZE 10 // maximum number of messages in payload send queue [1 = no queue]
|
||||
|
||||
@ -75,7 +75,7 @@
|
||||
#define TIME_SYNC_INTERVAL_RETRY 10 // retry time sync after lost sync each .. minutes [default = 10], 0 means off
|
||||
#define TIME_SYNC_COMPILEDATE 0 // set to 1 to use compile date to initialize RTC after power outage [default = 0]
|
||||
#define TIME_SYNC_LORAWAN 0 // set to 1 to use LORA network as time source, 0 means off [default = 0]
|
||||
#define TIME_SYNC_LORASERVER 0 // set to 1 to use LORA timeserver as time source, 0 means off [default = 0]
|
||||
#define TIME_SYNC_LORASERVER 1 // set to 1 to use LORA timeserver as time source, 0 means off [default = 0]
|
||||
|
||||
// settings for syncing time with timeserver applications
|
||||
#define TIME_SYNC_SAMPLES 1 // number of time requests for averaging
|
||||
|
@ -19,32 +19,25 @@ void do_reset() {
|
||||
void set_reset(uint8_t val[]) {
|
||||
switch (val[0]) {
|
||||
case 0: // restart device
|
||||
sprintf(display_line6, "Reset pending");
|
||||
do_reset();
|
||||
break;
|
||||
case 1: // reset MAC counter
|
||||
ESP_LOGI(TAG, "Remote command: reset MAC counter");
|
||||
reset_counters(); // clear macs
|
||||
get_salt(); // get new salt
|
||||
sprintf(display_line6, "Reset counter");
|
||||
break;
|
||||
case 2: // reset device to factory settings
|
||||
ESP_LOGI(TAG, "Remote command: reset device to factory settings");
|
||||
sprintf(display_line6, "Factory reset");
|
||||
eraseConfig();
|
||||
break;
|
||||
case 3: // reset send queues
|
||||
ESP_LOGI(TAG, "Remote command: flush send queue");
|
||||
sprintf(display_line6, "Queue reset");
|
||||
flushQueues();
|
||||
break;
|
||||
case 9: // reset and ask for software update via Wifi OTA
|
||||
ESP_LOGI(TAG, "Remote command: software update via Wifi");
|
||||
#if (USE_OTA)
|
||||
sprintf(display_line6, "Software update");
|
||||
cfg.runmode = 1;
|
||||
#else
|
||||
sprintf(display_line6, "Software update not implemented");
|
||||
#endif // USE_OTA
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user