Packet traffic indicator

This commit is contained in:
Verkehrsrot 2019-07-15 00:14:33 +02:00
parent 912da7eace
commit 0e3f7af0ce
4 changed files with 29 additions and 14 deletions

View File

@ -108,9 +108,9 @@ 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 uint16_t volatile macs_total, macs_wifi, macs_ble,
batt_voltage; // display values
batt_voltage; // display values
extern uint32_t volatile PacketCounter; // sniffed packet counter
extern bool volatile TimePulseTick; // 1sec pps flag set by GPS or RTC
extern timesource_t timeSource;
extern hw_timer_t *displayIRQ, *matrixDisplayIRQ, *ppsIRQ, *gpsIRQ;

View File

@ -11,12 +11,13 @@ Display-Mask (128 x 64 pixel):
1|PAX:aabbccddee
2|B:a.bcV Sats:ab
3|BLTH:abcde SF:ab
4|WIFI:abcde ch:ab
4|WIFI:abcde ****
5|RLIM:abcd abcdKB
6|xxxxxxxxxxxxxxxx
6|20:27:00* 27.Feb
7|yyyyyyyyyyyyyyab
line 4: **** = Packet traffic indicator
line 6: x = Text for LORA status OR time/date
line 7: y = Text for LMIC status; ab = payload queue
@ -224,11 +225,22 @@ void draw_page(time_t t, uint8_t page) {
u8x8.setInverseFont(0);
#endif // HAS_LORA
// line 4: update wifi counter + channel display
// line 4: update wifi counter + packet density display
u8x8.setCursor(0, 4);
u8x8.printf("WIFI:%-5d", macs_wifi);
u8x8.setCursor(11, 4);
u8x8.printf("ch:%02d", channel);
// display and reset packetcounter
u8x8.setCursor(12, 4);
if (PacketCounter > (100000 / DISPLAYREFRESH_MS))
u8x8.printf("****");
else if (PacketCounter > (10000 / DISPLAYREFRESH_MS))
u8x8.printf(" ***");
else if (PacketCounter > (1000 / DISPLAYREFRESH_MS))
u8x8.printf(" **");
else if (PacketCounter > 0)
u8x8.printf(" *");
else
u8x8.printf(" ");
PacketCounter = 0;
// line 5: update RSSI limiter status & free memory display
u8x8.setCursor(0, 5);

View File

@ -81,9 +81,9 @@ triggers pps 1 sec impulse
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
uint16_t volatile macs_total = 0, macs_wifi = 0, macs_ble = 0,
batt_voltage = 0; // globals for display
batt_voltage = 0; // globals for display
uint32_t volatile PacketCounter = 0; // sniffed packet counter
hw_timer_t *ppsIRQ = NULL, *displayIRQ = NULL, *matrixDisplayIRQ = NULL,
*gpsIRQ = NULL;

View File

@ -37,6 +37,8 @@ IRAM_ATTR void wifi_sniffer_packet_handler(void *buff,
(wifi_ieee80211_packet_t *)ppkt->payload;
const wifi_ieee80211_mac_hdr_t *hdr = &ipkt->hdr;
PacketCounter++; // increase packets per second counter
if ((cfg.rssilimit) &&
(ppkt->rx_ctrl.rssi < cfg.rssilimit)) // rssi is negative value
ESP_LOGD(TAG, "WiFi RSSI %d -> ignoring (limit: %d)", ppkt->rx_ctrl.rssi,
@ -45,8 +47,9 @@ IRAM_ATTR void wifi_sniffer_packet_handler(void *buff,
mac_add((uint8_t *)hdr->addr2, ppkt->rx_ctrl.rssi, MAC_SNIFF_WIFI);
}
// Software-timer driven Wifi channel rotation callback function
// Software-timer driven Wifi channel rotation function
void switchWifiChannel(TimerHandle_t xTimer) {
static uint8_t channel = 0; // channel rotation counter
channel =
(channel % WIFI_CHANNEL_MAX) + 1; // rotate channel 1..WIFI_CHANNEL_MAX
esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
@ -57,13 +60,13 @@ void wifi_sniffer_init(void) {
wificfg.nvs_enable = 0; // we don't need any wifi settings from NVRAM
wificfg.wifi_task_core_id = 0; // we want wifi task running on core 0
// wifi_promiscuous_filter_t filter = {
// .filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT}; // only MGMT frames
wifi_promiscuous_filter_t filter = {
.filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT}; // only MGMT frames
// .filter_mask = WIFI_PROMIS_FILTER_MASK_ALL}; // we use all frames
wifi_promiscuous_filter_t filter = {.filter_mask =
WIFI_PROMIS_FILTER_MASK_MGMT |
WIFI_PROMIS_FILTER_MASK_DATA};
// wifi_promiscuous_filter_t filter = {.filter_mask =
// WIFI_PROMIS_FILTER_MASK_MGMT |
// WIFI_PROMIS_FILTER_MASK_DATA};
ESP_ERROR_CHECK(esp_wifi_init(&wificfg)); // configure Wifi with cfg
ESP_ERROR_CHECK(