lmic event msg display optimizations
This commit is contained in:
parent
b2300d0c23
commit
7e5d053ec5
@ -41,6 +41,9 @@
|
|||||||
#define BLE_MODE (0x40)
|
#define BLE_MODE (0x40)
|
||||||
#define SCREEN_MODE (0x80)
|
#define SCREEN_MODE (0x80)
|
||||||
|
|
||||||
|
// length of display buffer for lmic event messages
|
||||||
|
#define LMIC_EVENTMSG_LEN 17
|
||||||
|
|
||||||
// I2C bus access control
|
// I2C bus access control
|
||||||
#define I2C_MUTEX_LOCK() \
|
#define I2C_MUTEX_LOCK() \
|
||||||
(xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(10)) == pdTRUE)
|
(xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(10)) == pdTRUE)
|
||||||
@ -104,9 +107,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>::iterator it;
|
||||||
extern std::array<uint64_t, 0xff> beacons;
|
extern std::array<uint64_t, 0xff> beacons;
|
||||||
|
|
||||||
extern configData_t cfg; // current device configuration
|
extern configData_t cfg; // current device configuration
|
||||||
extern char lmic_event_msg[]; // display buffer
|
extern char lmic_event_msg[LMIC_EVENTMSG_LEN]; // display buffer
|
||||||
extern uint8_t volatile channel; // wifi channel rotation counter
|
extern uint8_t volatile channel; // wifi channel rotation counter
|
||||||
extern uint16_t volatile macs_total, macs_wifi, macs_ble,
|
extern uint16_t volatile macs_total, macs_wifi, macs_ble,
|
||||||
batt_voltage; // display values
|
batt_voltage; // display values
|
||||||
extern bool volatile TimePulseTick; // 1sec pps flag set by GPS or RTC
|
extern bool volatile TimePulseTick; // 1sec pps flag set by GPS or RTC
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern QueueHandle_t LoraSendQueue;
|
|
||||||
extern TaskHandle_t lmicTask, lorasendTask;
|
extern TaskHandle_t lmicTask, lorasendTask;
|
||||||
|
|
||||||
// table of LORAWAN MAC commands
|
// table of LORAWAN MAC commands
|
||||||
|
@ -179,7 +179,7 @@ void saveConfig() {
|
|||||||
|
|
||||||
// set and save cfg.version
|
// set and save cfg.version
|
||||||
void migrateVersion() {
|
void migrateVersion() {
|
||||||
sprintf(cfg.version, "%s", PROGVERSION);
|
snprintf(cfg.version, 10, "%s", PROGVERSION);
|
||||||
ESP_LOGI(TAG, "version set to %s", cfg.version);
|
ESP_LOGI(TAG, "version set to %s", cfg.version);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,15 @@ Display-Mask (128 x 64 pixel):
|
|||||||
4|WIFI:abcde BLTH:abcde SMALL
|
4|WIFI:abcde BLTH:abcde SMALL
|
||||||
5|RLIM:abcd Mem:abcdKB SMALL
|
5|RLIM:abcd Mem:abcdKB SMALL
|
||||||
6|27.Feb 2019 20:27:00* SMALL
|
6|27.Feb 2019 20:27:00* SMALL
|
||||||
7|yyyyyyyyyyyyyyyy SFab SMALL
|
7|yyyyyyyyyyyyy xx SFab SMALL
|
||||||
|
|
||||||
* = char {L|G|R|?} indicates time source,
|
* = char {L|G|R|?} indicates time source,
|
||||||
inverse = clock controller is active,
|
inverse = clock controller is active,
|
||||||
pulsed = pps input signal is active
|
pulsed = pps input signal is active
|
||||||
|
|
||||||
y = LMIC event message; ab = payload queue length
|
y = LMIC event message
|
||||||
|
xx = payload sendqueue length
|
||||||
|
ab = LMIC spread factor
|
||||||
|
|
||||||
FONT_SMALL: 6x8px = 21 chars / line
|
FONT_SMALL: 6x8px = 21 chars / line
|
||||||
FONT_NORMAL: 8x8px = 16 chars / line
|
FONT_NORMAL: 8x8px = 16 chars / line
|
||||||
@ -108,7 +110,7 @@ void init_display(uint8_t verbose) {
|
|||||||
uint8_t buf[8];
|
uint8_t buf[8];
|
||||||
char deveui[17];
|
char deveui[17];
|
||||||
os_getDevEui((u1_t *)buf);
|
os_getDevEui((u1_t *)buf);
|
||||||
sprintf(deveui, "%016llX", *((uint64_t *)&buf));
|
snprintf(deveui, 17, "%016llX", *((uint64_t *)&buf));
|
||||||
|
|
||||||
// display DEVEUI as QR code on the left
|
// display DEVEUI as QR code on the left
|
||||||
oledSetContrast(30);
|
oledSetContrast(30);
|
||||||
@ -175,7 +177,6 @@ void refreshTheDisplay(bool nextPage) {
|
|||||||
void draw_page(time_t t, uint8_t page) {
|
void draw_page(time_t t, uint8_t page) {
|
||||||
|
|
||||||
char timeState;
|
char timeState;
|
||||||
uint8_t msgWaiting;
|
|
||||||
#if (HAS_GPS)
|
#if (HAS_GPS)
|
||||||
static bool wasnofix = true;
|
static bool wasnofix = true;
|
||||||
#endif
|
#endif
|
||||||
@ -248,19 +249,11 @@ void draw_page(time_t t, uint8_t page) {
|
|||||||
|
|
||||||
// line 7: LORA network status
|
// line 7: LORA network status
|
||||||
#if (HAS_LORA)
|
#if (HAS_LORA)
|
||||||
// LMiC event display, display inverse if sendqueue not empty
|
// LMiC event display
|
||||||
msgWaiting = uxQueueMessagesWaiting(LoraSendQueue);
|
dp_printf(0, 7, FONT_SMALL, 0, "%-16s", lmic_event_msg);
|
||||||
if (msgWaiting)
|
|
||||||
dp_printf(0, 7, FONT_SMALL, 1, "%-16s", lmic_event_msg);
|
|
||||||
else
|
|
||||||
dp_printf(0, 7, FONT_SMALL, 0, "%-16s", lmic_event_msg);
|
|
||||||
// LORA datarate, display inverse if ADR disabled
|
// LORA datarate, display inverse if ADR disabled
|
||||||
if (cfg.adrmode)
|
dp_printf(104, 7, FONT_SMALL, !cfg.adrmode, "%-4s",
|
||||||
dp_printf(100, 7, FONT_SMALL, 0, "%-4s",
|
getSfName(updr2rps(LMIC.datarate)));
|
||||||
getSfName(updr2rps(LMIC.datarate)));
|
|
||||||
else
|
|
||||||
dp_printf(100, 7, FONT_SMALL, 1, "%-4s",
|
|
||||||
getSfName(updr2rps(LMIC.datarate)));
|
|
||||||
#endif // HAS_LORA
|
#endif // HAS_LORA
|
||||||
|
|
||||||
break; // page0
|
break; // page0
|
||||||
|
@ -346,8 +346,14 @@ void lora_enqueuedata(MessageBuffer_t *message) {
|
|||||||
ret = xQueueSendToBack(LoraSendQueue, (void *)message, (TickType_t)0);
|
ret = xQueueSendToBack(LoraSendQueue, (void *)message, (TickType_t)0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ret != pdTRUE)
|
if (ret != pdTRUE) {
|
||||||
|
snprintf(lmic_event_msg + 14, LMIC_EVENTMSG_LEN - 14, "<>");
|
||||||
ESP_LOGW(TAG, "LORA sendqueue is full");
|
ESP_LOGW(TAG, "LORA sendqueue is full");
|
||||||
|
} else {
|
||||||
|
// add Lora send queue length to display
|
||||||
|
snprintf(lmic_event_msg + 14, LMIC_EVENTMSG_LEN - 14, "%2u",
|
||||||
|
uxQueueMessagesWaiting(LoraSendQueue));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lora_queuereset(void) { xQueueReset(LoraSendQueue); }
|
void lora_queuereset(void) { xQueueReset(LoraSendQueue); }
|
||||||
@ -438,12 +444,15 @@ void myEventCallback(void *pUserData, ev_t ev) {
|
|||||||
|
|
||||||
// using message descriptors from LMIC library
|
// using message descriptors from LMIC library
|
||||||
static const char *const evNames[] = {LMIC_EVENT_NAME_TABLE__INIT};
|
static const char *const evNames[] = {LMIC_EVENT_NAME_TABLE__INIT};
|
||||||
|
// get current length of lora send queue
|
||||||
|
uint8_t const msgWaiting = uxQueueMessagesWaiting(LoraSendQueue);
|
||||||
|
|
||||||
// get current event message
|
// get current event message
|
||||||
if (ev < sizeof(evNames) / sizeof(evNames[0]))
|
if (ev < sizeof(evNames) / sizeof(evNames[0]))
|
||||||
sprintf(lmic_event_msg, "%s", evNames[ev] + 3); // +3 to strip "EV_"
|
snprintf(lmic_event_msg, LMIC_EVENTMSG_LEN, "%-16s",
|
||||||
|
evNames[ev] + 3); // +3 to strip "EV_"
|
||||||
else
|
else
|
||||||
sprintf(lmic_event_msg, "LMIC event %d", ev);
|
snprintf(lmic_event_msg, LMIC_EVENTMSG_LEN, "LMIC event %-04u ", ev);
|
||||||
|
|
||||||
// process current event message
|
// process current event message
|
||||||
switch (ev) {
|
switch (ev) {
|
||||||
@ -459,12 +468,16 @@ void myEventCallback(void *pUserData, ev_t ev) {
|
|||||||
|
|
||||||
case EV_JOIN_TXCOMPLETE:
|
case EV_JOIN_TXCOMPLETE:
|
||||||
// replace descriptor from library with more descriptive term
|
// replace descriptor from library with more descriptive term
|
||||||
lmic_event_msg = "JOIN_WAIT";
|
snprintf(lmic_event_msg, LMIC_EVENTMSG_LEN, "%-16s", "JOIN_WAIT");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// print event
|
// print event
|
||||||
ESP_LOGD(TAG, "%s", lmic_event_msg);
|
ESP_LOGD(TAG, "%s", lmic_event_msg);
|
||||||
|
|
||||||
|
// add Lora send queue length to display
|
||||||
|
if (msgWaiting)
|
||||||
|
snprintf(lmic_event_msg + 14, LMIC_EVENTMSG_LEN - 14, "%2u", msgWaiting);
|
||||||
}
|
}
|
||||||
|
|
||||||
// receive message handler
|
// receive message handler
|
||||||
|
@ -30,7 +30,7 @@ void printKey(const char *name, const uint8_t *key, uint8_t len, bool lsb) {
|
|||||||
char keystring[len + 1] = "", keybyte[3];
|
char keystring[len + 1] = "", keybyte[3];
|
||||||
for (uint8_t i = 0; i < len; i++) {
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
p = lsb ? key + len - i - 1 : key + i;
|
p = lsb ? key + len - i - 1 : key + i;
|
||||||
sprintf(keybyte, "%02X", *p);
|
snprintf(keybyte, 3, "%02X", *p);
|
||||||
strncat(keystring, keybyte, 2);
|
strncat(keystring, keybyte, 2);
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "%s: %s", name, keystring);
|
ESP_LOGI(TAG, "%s: %s", name, keystring);
|
||||||
|
@ -76,9 +76,9 @@ triggers pps 1 sec impulse
|
|||||||
// Basic Config
|
// Basic Config
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
configData_t cfg; // struct holds current device configuration
|
configData_t cfg; // struct holds current device configuration
|
||||||
char lmic_event_msg[16]; // display buffer for LMIC event message
|
char lmic_event_msg[LMIC_EVENTMSG_LEN]; // display buffer for LMIC event message
|
||||||
uint8_t volatile channel = 0; // channel rotation counter
|
uint8_t volatile channel = 0; // channel rotation counter
|
||||||
uint16_t volatile macs_total = 0, macs_wifi = 0, macs_ble = 0,
|
uint16_t volatile macs_total = 0, macs_wifi = 0, macs_ble = 0,
|
||||||
batt_voltage = 0; // globals for display
|
batt_voltage = 0; // globals for display
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user