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 uint64_t uptimecounter;
|
||||
extern osjob_t sendjob;
|
||||
extern char display_lora[], display_lmic[];
|
||||
extern int countermode, screensaver, adrmode, lorasf, txpower, rlim;
|
||||
extern bool joinstate;
|
||||
extern std::set<uint16_t> wifis;
|
||||
|
@ -65,7 +65,7 @@ void get_hard_deveui(uint8_t *pdeveui) {
|
||||
Wire.requestFrom(MCP_24AA02E64_I2C_ADDRESS, 8);
|
||||
while (Wire.available()) {
|
||||
data = Wire.read();
|
||||
sprintf(deveui+strlen(deveui), "%02X ", data) ;
|
||||
sprintf(deveui+strlen(deveui), "%02X ", data);
|
||||
*pdeveui++ = data;
|
||||
}
|
||||
i2c_ret = Wire.endTransmission();
|
||||
@ -135,15 +135,14 @@ void do_send(osjob_t* j){
|
||||
//mydata[5] = data & 0xff;
|
||||
|
||||
// Check if there is not a current TX/RX job running
|
||||
u8x8.clearLine(7);
|
||||
if (LMIC.opmode & OP_TXRXPEND) {
|
||||
ESP_LOGI(TAG, "OP_TXRXPEND, not sending");
|
||||
u8x8.drawString(0, 7, "LORA BUSY");
|
||||
sprintf(display_lmic, "LORA BUSY");
|
||||
} else {
|
||||
// Prepare upstream data transmission at the next possible time.
|
||||
LMIC_setTxData2(1, mydata, sizeof(mydata), (cfg.countermode & 0x02));
|
||||
ESP_LOGI(TAG, "Packet queued");
|
||||
u8x8.drawString(0, 7, "PACKET QUEUED");
|
||||
sprintf(display_lmic, "PACKET QUEUED");
|
||||
}
|
||||
// Next TX is scheduled after TX_COMPLETE event.
|
||||
}
|
||||
@ -168,7 +167,7 @@ void onEvent (ev_t ev) {
|
||||
|
||||
case EV_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
|
||||
// during join, but not supported by TTN at this time).
|
||||
LMIC_setLinkCheckMode(0);
|
||||
@ -182,23 +181,21 @@ void onEvent (ev_t ev) {
|
||||
break;
|
||||
case EV_TXCOMPLETE:
|
||||
ESP_LOGI(TAG, "EV_TXCOMPLETE (includes waiting for RX windows)");
|
||||
u8x8.clearLine(7);
|
||||
if (LMIC.txrxFlags & TXRX_ACK) {
|
||||
ESP_LOGI(TAG, "Received ack");
|
||||
u8x8.drawString(0, 7, "RECEIVED ACK");
|
||||
sprintf(display_lmic, "RECEIVED ACK");
|
||||
|
||||
} else {
|
||||
u8x8.drawString(0, 7, "TX COMPLETE");
|
||||
sprintf(display_lmic, "TX COMPLETE");
|
||||
}
|
||||
if (LMIC.dataLen) {
|
||||
ESP_LOGI(TAG, "Received %d bytes of payload", LMIC.dataLen);
|
||||
u8x8.clearLine(6);
|
||||
u8x8.setCursor(0, 6);
|
||||
u8x8.printf("Rcvd %d bytes", LMIC.dataLen);
|
||||
u8x8.clearLine(7);
|
||||
u8x8.setCursor(0, 7);
|
||||
sprintf(display_lora, "Rcvd %d bytes", LMIC.dataLen);
|
||||
|
||||
// LMIC.snr = SNR twos compliment [dB] * 4
|
||||
// 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
|
||||
if ( (LMIC.txrxFlags & TXRX_PORT) && (LMIC.frame[LMIC.dataBeg-1] == RCMDPORT ) ) {
|
||||
// caution: buffering LMIC values here because rcommand() can modify LMIC.frame
|
||||
@ -217,8 +214,7 @@ void onEvent (ev_t ev) {
|
||||
// Log & Display if asked
|
||||
if (*buff) {
|
||||
ESP_LOGI(TAG, "EV_%s", buff);
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, buff);
|
||||
sprintf(display_lmic, buff);
|
||||
}
|
||||
|
||||
|
||||
|
21
src/main.cpp
21
src/main.cpp
@ -45,6 +45,7 @@ configData_t cfg; // struct holds current device configuration
|
||||
osjob_t sendjob, initjob; // LMIC
|
||||
|
||||
// Initialize global variables
|
||||
char display_lora[16], display_lmic[16];
|
||||
uint8_t channel = 0;
|
||||
int macnum = 0;
|
||||
uint64_t uptimecounter = 0;
|
||||
@ -289,15 +290,13 @@ void sniffer_loop(void * pvParameters) {
|
||||
bles.clear(); // clear BLE macs counter
|
||||
#endif
|
||||
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
|
||||
lorawait = 0;
|
||||
while(LMIC.opmode & OP_TXRXPEND) {
|
||||
if(!lorawait)
|
||||
u8x8.drawString(0,6,"LoRa wait ");
|
||||
sprintf(display_lora, "LoRa wait");
|
||||
lorawait++;
|
||||
// in case sending really fails: reset and rejoin network
|
||||
if( (lorawait % MAXLORARETRY ) == 0) {
|
||||
@ -473,7 +472,7 @@ void setup() {
|
||||
#endif
|
||||
u8x8.setCursor(0,5);
|
||||
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
|
||||
#ifdef VERBOSE
|
||||
@ -524,7 +523,8 @@ void loop() {
|
||||
#endif
|
||||
|
||||
#ifdef HAS_DISPLAY
|
||||
// display counters(lines 0-4)
|
||||
|
||||
// display counters (lines 0-4)
|
||||
char buff[16];
|
||||
snprintf(buff, sizeof(buff), "PAX:%-4d", (int) macs.size()); // convert 16-bit MAC counter to decimal counter value
|
||||
u8x8.draw2x2String(0, 0, buff); // display number on unique macs total Wifi + BLE
|
||||
@ -534,12 +534,23 @@ void loop() {
|
||||
u8x8.setCursor(0,3);
|
||||
u8x8.printf("BLTH: %-4d", (int) bles.size());
|
||||
#endif
|
||||
|
||||
// display actual wifi channel (line 4)
|
||||
u8x8.setCursor(11,4);
|
||||
u8x8.printf("ch:%02i", channel);
|
||||
|
||||
// display RSSI status (line 5)
|
||||
u8x8.setCursor(0,5);
|
||||
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
|
||||
|
||||
vTaskDelay(DISPLAYREFRESH/portTICK_PERIOD_MS);
|
||||
|
Loading…
Reference in New Issue
Block a user