Revert "Removed all display code if not HAS_DISPLAY"
This reverts commit 3640a62b93
.
This commit is contained in:
parent
f4ecc3924b
commit
47f0f90cf3
@ -289,9 +289,7 @@ void loadConfig() {
|
||||
ESP_LOGI(TAG, "Done");
|
||||
|
||||
// put actions to be triggered on loaded config here
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.setPowerSave(!cfg.screenon); // set display on/off
|
||||
#endif
|
||||
#ifdef HAS_ANTENNA_SWITCH // set antenna type, if device has one
|
||||
antenna_select(cfg.wifiant);
|
||||
#endif
|
||||
|
@ -49,6 +49,8 @@ extern std::set<uint16_t> macs;
|
||||
|
||||
#ifdef HAS_DISPLAY
|
||||
extern HAS_DISPLAY u8x8;
|
||||
#else
|
||||
extern U8X8_NULL u8x8;
|
||||
#endif
|
||||
|
||||
#ifdef BLECOUNTER
|
||||
|
@ -99,18 +99,14 @@ void do_send(osjob_t* j){
|
||||
// Check if there is not a current TX/RX job running
|
||||
if (LMIC.opmode & OP_TXRXPEND) {
|
||||
ESP_LOGI(TAG, "OP_TXRXPEND, not sending");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "LORA BUSY");
|
||||
#endif
|
||||
} else {
|
||||
// Prepare upstream data transmission at the next possible time.
|
||||
LMIC_setTxData2(1, mydata, sizeof(mydata)-1, (cfg.countermode & 0x02));
|
||||
ESP_LOGI(TAG, "Packet queued");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "PACKET QUEUED");
|
||||
#endif
|
||||
}
|
||||
// Next TX is scheduled after TX_COMPLETE event.
|
||||
}
|
||||
@ -119,46 +115,34 @@ void onEvent (ev_t ev) {
|
||||
switch(ev) {
|
||||
case EV_SCAN_TIMEOUT:
|
||||
ESP_LOGI(TAG, "EV_SCAN_TIMEOUT");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "SCAN TIMEOUT");
|
||||
#endif
|
||||
break;
|
||||
case EV_BEACON_FOUND:
|
||||
ESP_LOGI(TAG, "EV_BEACON_FOUND");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "BEACON FOUND");
|
||||
#endif
|
||||
break;
|
||||
case EV_BEACON_MISSED:
|
||||
ESP_LOGI(TAG, "EV_BEACON_MISSED");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "BEACON MISSED");
|
||||
#endif
|
||||
break;
|
||||
case EV_BEACON_TRACKED:
|
||||
ESP_LOGI(TAG, "EV_BEACON_TRACKED");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "BEACON TRACKED");
|
||||
#endif
|
||||
break;
|
||||
case EV_JOINING:
|
||||
ESP_LOGI(TAG, "EV_JOINING");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "JOINING");
|
||||
#endif
|
||||
break;
|
||||
case EV_JOINED:
|
||||
ESP_LOGI(TAG, "EV_JOINED");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(6); // erase "Join Wait" message from display, see main.cpp
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "JOINED");
|
||||
#endif
|
||||
// Disable link check validation (automatically enabled
|
||||
// during join, but not supported by TTN at this time).
|
||||
LMIC_setLinkCheckMode(0);
|
||||
@ -172,41 +156,30 @@ void onEvent (ev_t ev) {
|
||||
break;
|
||||
case EV_RFU1:
|
||||
ESP_LOGI(TAG, "EV_RFU1");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "RFUI");
|
||||
#endif
|
||||
break;
|
||||
case EV_JOIN_FAILED:
|
||||
ESP_LOGI(TAG, "EV_JOIN_FAILED");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "JOIN FAILED");
|
||||
#endif
|
||||
break;
|
||||
case EV_REJOIN_FAILED:
|
||||
ESP_LOGI(TAG, "EV_REJOIN_FAILED");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "REJOIN FAILED");
|
||||
#endif
|
||||
break;
|
||||
case EV_TXCOMPLETE:
|
||||
ESP_LOGI(TAG, "EV_TXCOMPLETE (includes waiting for RX windows)");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "TX COMPLETE");
|
||||
#endif
|
||||
if (LMIC.txrxFlags & TXRX_ACK) {
|
||||
ESP_LOGI(TAG, "Received ack");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "RECEIVED ACK");
|
||||
#endif
|
||||
}
|
||||
if (LMIC.dataLen) {
|
||||
ESP_LOGI(TAG, "Received %i bytes of payload", LMIC.dataLen);
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(6);
|
||||
u8x8.setCursor(0, 6);
|
||||
u8x8.printf("Rcvd %i bytes", LMIC.dataLen);
|
||||
@ -215,7 +188,6 @@ void onEvent (ev_t ev) {
|
||||
// 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);
|
||||
#endif
|
||||
// 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
|
||||
@ -230,47 +202,35 @@ void onEvent (ev_t ev) {
|
||||
break;
|
||||
case EV_LOST_TSYNC:
|
||||
ESP_LOGI(TAG, "EV_LOST_TSYNC");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "LOST TSYNC");
|
||||
#endif
|
||||
break;
|
||||
case EV_RESET:
|
||||
ESP_LOGI(TAG, "EV_RESET");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "RESET");
|
||||
#endif
|
||||
break;
|
||||
case EV_RXCOMPLETE:
|
||||
// data received in ping slot
|
||||
ESP_LOGI(TAG, "EV_RXCOMPLETE");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "RX COMPLETE");
|
||||
#endif
|
||||
break;
|
||||
case EV_LINK_DEAD:
|
||||
ESP_LOGI(TAG, "EV_LINK_DEAD");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "LINK DEAD");
|
||||
#endif
|
||||
break;
|
||||
case EV_LINK_ALIVE:
|
||||
ESP_LOGI(TAG, "EV_LINK_ALIVE");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.drawString(0, 7, "LINK ALIVE");
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
ESP_LOGI(TAG, "Unknown event");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(7);
|
||||
u8x8.setCursor(0, 7);
|
||||
u8x8.printf("UNKNOWN EVENT %d", ev);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -60,9 +60,7 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
|
||||
|
||||
if (newmac.second) { // first time seen this WIFI or BLE MAC
|
||||
snprintf(counter, 6, "%i", macs.size()); // convert 16-bit MAC counter to decimal counter value
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.draw2x2String(0, 0, counter);
|
||||
#endif
|
||||
ESP_LOGI(TAG, "%s RSSI %04d -> Hash %04x -> #%05i", typebuff, rssi, hashedmac, macs.size());
|
||||
} else { // already seen WIFI or BLE MAC
|
||||
ESP_LOGI(TAG, "%s RSSI %04d -> already seen", typebuff, rssi);
|
||||
@ -89,10 +87,8 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
||||
// Current devices seen on this scan session
|
||||
currentScanDevice++;
|
||||
mac_add(p, advertisedDevice.getRSSI(), MAC_SNIFF_BLE);
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.setCursor(12,3);
|
||||
u8x8.printf("%d", currentScanDevice);
|
||||
#endif
|
||||
rgb_set_color(COLOR_NONE);
|
||||
|
||||
}
|
||||
@ -101,21 +97,17 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
||||
void BLECount() {
|
||||
int blenum = 0; // Total device seen on this scan session
|
||||
currentScanDevice = 0; // Set 0 seen device on this scan session
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(3);
|
||||
u8x8.drawString(0,3,"BLE Scan...");
|
||||
#endif
|
||||
BLEDevice::init(PROGNAME);
|
||||
BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan
|
||||
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
|
||||
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
|
||||
BLEScanResults foundDevices = pBLEScan->start(cfg.blescantime);
|
||||
blenum=foundDevices.getCount();
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(3);
|
||||
u8x8.setCursor(0,3);
|
||||
u8x8.printf("BLE#: %-5i %-3i",bles.size(), blenum);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -59,11 +59,9 @@ void set_reset(int val) {
|
||||
switch (val) {
|
||||
case 0: // restart device
|
||||
ESP_LOGI(TAG, "Remote command: restart device");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(5);
|
||||
u8x8.setCursor(0, 5);
|
||||
u8x8.printf("Reset pending ");
|
||||
#endif
|
||||
vTaskDelay(10000/portTICK_PERIOD_MS); // wait for LMIC to confirm LoRa downlink to server
|
||||
esp_restart();
|
||||
break;
|
||||
@ -73,20 +71,16 @@ void set_reset(int val) {
|
||||
wifis.clear(); // clear Wifi macs container
|
||||
bles.clear(); // clear BLE macs container
|
||||
salt = random(65536); // get new 16bit random for salting hashes
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(0); u8x8.clearLine(1); // clear Display counter
|
||||
u8x8.clearLine(5);
|
||||
u8x8.setCursor(0, 5);
|
||||
u8x8.printf("Reset counter ");
|
||||
#endif
|
||||
break;
|
||||
case 2: // reset device to factory settings
|
||||
ESP_LOGI(TAG, "Remote command: reset device to factory settings");
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(5);
|
||||
u8x8.setCursor(0, 5);
|
||||
u8x8.printf("Factory reset ");
|
||||
#endif
|
||||
eraseConfig();
|
||||
break;
|
||||
}
|
||||
@ -95,11 +89,9 @@ void set_reset(int val) {
|
||||
void set_rssi(int val) {
|
||||
cfg.rssilimit = val * -1;
|
||||
ESP_LOGI(TAG, "Remote command: set RSSI limit to %i", cfg.rssilimit);
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(5);
|
||||
u8x8.setCursor(0, 5);
|
||||
u8x8.printf(!cfg.rssilimit ? "RLIM: off" : "RLIM: -%4i", cfg.rssilimit);
|
||||
#endif
|
||||
};
|
||||
|
||||
void set_wifiscancycle(int val) {
|
||||
@ -145,9 +137,7 @@ void set_screensaver(int val) {
|
||||
case 1: cfg.screensaver = val; break;
|
||||
default: cfg.screensaver = 0; break;
|
||||
}
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.setPowerSave(cfg.screensaver); // set display 0=on / 1=off
|
||||
#endif
|
||||
};
|
||||
|
||||
void set_display(int val) {
|
||||
@ -156,9 +146,7 @@ void set_display(int val) {
|
||||
case 1: cfg.screenon = val; break;
|
||||
default: cfg.screenon = 0; break;
|
||||
}
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.setPowerSave(!cfg.screenon); // set display 0=on / 1=off
|
||||
#endif
|
||||
};
|
||||
|
||||
void set_lorasf(int val) {
|
||||
@ -182,9 +170,7 @@ void set_blescan(int val) {
|
||||
default:
|
||||
cfg.blescan = 0;
|
||||
btStop();
|
||||
#ifdef HAS_DISPLAY
|
||||
u8x8.clearLine(3); // clear BLE results from display
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user