centralize display writes (part 3)
This commit is contained in:
parent
3efd3890f3
commit
4bc888d78d
@ -44,6 +44,7 @@ extern configData_t cfg;
|
|||||||
extern uint8_t mydata[];
|
extern uint8_t mydata[];
|
||||||
extern uint64_t uptimecounter;
|
extern uint64_t uptimecounter;
|
||||||
extern osjob_t sendjob;
|
extern osjob_t sendjob;
|
||||||
|
extern char display_lora[], display_lmic[];
|
||||||
extern int countermode, screensaver, adrmode, lorasf, txpower, rlim;
|
extern int countermode, screensaver, adrmode, lorasf, txpower, rlim;
|
||||||
extern bool joinstate;
|
extern bool joinstate;
|
||||||
extern std::set<uint16_t> wifis;
|
extern std::set<uint16_t> wifis;
|
||||||
|
@ -135,15 +135,14 @@ void do_send(osjob_t* j){
|
|||||||
//mydata[5] = data & 0xff;
|
//mydata[5] = data & 0xff;
|
||||||
|
|
||||||
// Check if there is not a current TX/RX job running
|
// Check if there is not a current TX/RX job running
|
||||||
u8x8.clearLine(7);
|
|
||||||
if (LMIC.opmode & OP_TXRXPEND) {
|
if (LMIC.opmode & OP_TXRXPEND) {
|
||||||
ESP_LOGI(TAG, "OP_TXRXPEND, not sending");
|
ESP_LOGI(TAG, "OP_TXRXPEND, not sending");
|
||||||
u8x8.drawString(0, 7, "LORA BUSY");
|
sprintf(display_lmic, "LORA BUSY");
|
||||||
} else {
|
} else {
|
||||||
// Prepare upstream data transmission at the next possible time.
|
// Prepare upstream data transmission at the next possible time.
|
||||||
LMIC_setTxData2(1, mydata, sizeof(mydata), (cfg.countermode & 0x02));
|
LMIC_setTxData2(1, mydata, sizeof(mydata), (cfg.countermode & 0x02));
|
||||||
ESP_LOGI(TAG, "Packet queued");
|
ESP_LOGI(TAG, "Packet queued");
|
||||||
u8x8.drawString(0, 7, "PACKET QUEUED");
|
sprintf(display_lmic, "PACKET QUEUED");
|
||||||
}
|
}
|
||||||
// Next TX is scheduled after TX_COMPLETE event.
|
// Next TX is scheduled after TX_COMPLETE event.
|
||||||
}
|
}
|
||||||
@ -168,7 +167,7 @@ void onEvent (ev_t ev) {
|
|||||||
|
|
||||||
case EV_JOINED:
|
case EV_JOINED:
|
||||||
strcpy_P(buff, PSTR("JOINED"));
|
strcpy_P(buff, PSTR("JOINED"));
|
||||||
u8x8.clearLine(6); // erase "Join Wait" message from display, see main.cpp
|
sprintf(display_lora, " "); // erase "Join Wait" message from display
|
||||||
// Disable link check validation (automatically enabled
|
// Disable link check validation (automatically enabled
|
||||||
// during join, but not supported by TTN at this time).
|
// during join, but not supported by TTN at this time).
|
||||||
LMIC_setLinkCheckMode(0);
|
LMIC_setLinkCheckMode(0);
|
||||||
@ -182,23 +181,21 @@ void onEvent (ev_t ev) {
|
|||||||
break;
|
break;
|
||||||
case EV_TXCOMPLETE:
|
case EV_TXCOMPLETE:
|
||||||
ESP_LOGI(TAG, "EV_TXCOMPLETE (includes waiting for RX windows)");
|
ESP_LOGI(TAG, "EV_TXCOMPLETE (includes waiting for RX windows)");
|
||||||
u8x8.clearLine(7);
|
|
||||||
if (LMIC.txrxFlags & TXRX_ACK) {
|
if (LMIC.txrxFlags & TXRX_ACK) {
|
||||||
ESP_LOGI(TAG, "Received ack");
|
ESP_LOGI(TAG, "Received ack");
|
||||||
u8x8.drawString(0, 7, "RECEIVED ACK");
|
sprintf(display_lmic, "RECEIVED ACK");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
u8x8.drawString(0, 7, "TX COMPLETE");
|
sprintf(display_lmic, "TX COMPLETE");
|
||||||
}
|
}
|
||||||
if (LMIC.dataLen) {
|
if (LMIC.dataLen) {
|
||||||
ESP_LOGI(TAG, "Received %d bytes of payload", LMIC.dataLen);
|
ESP_LOGI(TAG, "Received %d bytes of payload", LMIC.dataLen);
|
||||||
u8x8.clearLine(6);
|
sprintf(display_lora, "Rcvd %d bytes", LMIC.dataLen);
|
||||||
u8x8.setCursor(0, 6);
|
|
||||||
u8x8.printf("Rcvd %d bytes", LMIC.dataLen);
|
|
||||||
u8x8.clearLine(7);
|
|
||||||
u8x8.setCursor(0, 7);
|
|
||||||
// LMIC.snr = SNR twos compliment [dB] * 4
|
// LMIC.snr = SNR twos compliment [dB] * 4
|
||||||
// LMIC.rssi = RSSI [dBm] (-196...+63)
|
// LMIC.rssi = RSSI [dBm] (-196...+63)
|
||||||
u8x8.printf("RSSI %d SNR %d", LMIC.rssi, (signed char)LMIC.snr / 4);
|
sprintf(display_lmic, "RSSI %d SNR %d", LMIC.rssi, (signed char)LMIC.snr / 4 );
|
||||||
|
|
||||||
// check if payload received on command port, then call remote command interpreter
|
// check if payload received on command port, then call remote command interpreter
|
||||||
if ( (LMIC.txrxFlags & TXRX_PORT) && (LMIC.frame[LMIC.dataBeg-1] == RCMDPORT ) ) {
|
if ( (LMIC.txrxFlags & TXRX_PORT) && (LMIC.frame[LMIC.dataBeg-1] == RCMDPORT ) ) {
|
||||||
// caution: buffering LMIC values here because rcommand() can modify LMIC.frame
|
// caution: buffering LMIC values here because rcommand() can modify LMIC.frame
|
||||||
@ -217,8 +214,7 @@ void onEvent (ev_t ev) {
|
|||||||
// Log & Display if asked
|
// Log & Display if asked
|
||||||
if (*buff) {
|
if (*buff) {
|
||||||
ESP_LOGI(TAG, "EV_%s", buff);
|
ESP_LOGI(TAG, "EV_%s", buff);
|
||||||
u8x8.clearLine(7);
|
sprintf(display_lmic, buff);
|
||||||
u8x8.drawString(0, 7, buff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
19
src/main.cpp
19
src/main.cpp
@ -45,6 +45,7 @@ configData_t cfg; // struct holds current device configuration
|
|||||||
osjob_t sendjob, initjob; // LMIC
|
osjob_t sendjob, initjob; // LMIC
|
||||||
|
|
||||||
// Initialize global variables
|
// Initialize global variables
|
||||||
|
char display_lora[16], display_lmic[16];
|
||||||
uint8_t channel = 0;
|
uint8_t channel = 0;
|
||||||
int macnum = 0;
|
int macnum = 0;
|
||||||
uint64_t uptimecounter = 0;
|
uint64_t uptimecounter = 0;
|
||||||
@ -289,15 +290,13 @@ void sniffer_loop(void * pvParameters) {
|
|||||||
bles.clear(); // clear BLE macs counter
|
bles.clear(); // clear BLE macs counter
|
||||||
#endif
|
#endif
|
||||||
salt_reset(); // get new salt for salting hashes
|
salt_reset(); // get new salt for salting hashes
|
||||||
u8x8.clearLine(0); // clear Display counter
|
|
||||||
u8x8.clearLine(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait until payload is sent, while wifi scanning and mac counting task continues
|
// wait until payload is sent, while wifi scanning and mac counting task continues
|
||||||
lorawait = 0;
|
lorawait = 0;
|
||||||
while(LMIC.opmode & OP_TXRXPEND) {
|
while(LMIC.opmode & OP_TXRXPEND) {
|
||||||
if(!lorawait)
|
if(!lorawait)
|
||||||
u8x8.drawString(0,6,"LoRa wait ");
|
sprintf(display_lora, "LoRa wait");
|
||||||
lorawait++;
|
lorawait++;
|
||||||
// in case sending really fails: reset and rejoin network
|
// in case sending really fails: reset and rejoin network
|
||||||
if( (lorawait % MAXLORARETRY ) == 0) {
|
if( (lorawait % MAXLORARETRY ) == 0) {
|
||||||
@ -473,7 +472,7 @@ void setup() {
|
|||||||
#endif
|
#endif
|
||||||
u8x8.setCursor(0,5);
|
u8x8.setCursor(0,5);
|
||||||
u8x8.printf(!cfg.rssilimit ? "RLIM: off" : "RLIM: %d", cfg.rssilimit);
|
u8x8.printf(!cfg.rssilimit ? "RLIM: off" : "RLIM: %d", cfg.rssilimit);
|
||||||
u8x8.drawString(0,6,"Join Wait ");
|
sprintf(display_lora, "Join wait");
|
||||||
|
|
||||||
// output LoRaWAN keys to console
|
// output LoRaWAN keys to console
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -524,6 +523,7 @@ void loop() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
|
|
||||||
// display counters (lines 0-4)
|
// display counters (lines 0-4)
|
||||||
char buff[16];
|
char buff[16];
|
||||||
snprintf(buff, sizeof(buff), "PAX:%-4d", (int) macs.size()); // convert 16-bit MAC counter to decimal counter value
|
snprintf(buff, sizeof(buff), "PAX:%-4d", (int) macs.size()); // convert 16-bit MAC counter to decimal counter value
|
||||||
@ -534,12 +534,23 @@ void loop() {
|
|||||||
u8x8.setCursor(0,3);
|
u8x8.setCursor(0,3);
|
||||||
u8x8.printf("BLTH: %-4d", (int) bles.size());
|
u8x8.printf("BLTH: %-4d", (int) bles.size());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// display actual wifi channel (line 4)
|
// display actual wifi channel (line 4)
|
||||||
u8x8.setCursor(11,4);
|
u8x8.setCursor(11,4);
|
||||||
u8x8.printf("ch:%02i", channel);
|
u8x8.printf("ch:%02i", channel);
|
||||||
|
|
||||||
// display RSSI status (line 5)
|
// display RSSI status (line 5)
|
||||||
u8x8.setCursor(0,5);
|
u8x8.setCursor(0,5);
|
||||||
u8x8.printf(!cfg.rssilimit ? "RLIM: off" : "RLIM: %-3d", cfg.rssilimit);
|
u8x8.printf(!cfg.rssilimit ? "RLIM: off" : "RLIM: %-3d", cfg.rssilimit);
|
||||||
|
|
||||||
|
// display LoRa status (line 6)
|
||||||
|
u8x8.setCursor(0,6);
|
||||||
|
u8x8.printf("%-16s", display_lora);
|
||||||
|
|
||||||
|
// display LMiC event (line 7)
|
||||||
|
u8x8.setCursor(0,7);
|
||||||
|
u8x8.printf("%-16s", display_lmic);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vTaskDelay(DISPLAYREFRESH/portTICK_PERIOD_MS);
|
vTaskDelay(DISPLAYREFRESH/portTICK_PERIOD_MS);
|
||||||
|
Loading…
Reference in New Issue
Block a user