From c1f51ee21e4fce10fe2ff2195a6e0f881a8ad592 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 15 Jul 2018 23:40:42 +0200 Subject: [PATCH] code sanitizations --- src/display.cpp | 7 +++++++ src/globals.h | 7 ------- src/macsniff.h | 1 + src/main.cpp | 3 --- src/main.h | 3 ++- src/rcommand.cpp | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 21719a2d..319d77ba 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -6,6 +6,13 @@ HAS_DISPLAY u8x8(OLED_RST, OLED_SCL, OLED_SDA); +// helper string for converting LoRa spread factor values +#if defined(CFG_eu868) +const char lora_datarate[] = {"1211100908077BFSNA"}; +#elif defined(CFG_us915) +const char lora_datarate[] = {"100908078CNA121110090807"}; +#endif + // helper function, prints a hex key on display void DisplayKey(const uint8_t *key, uint8_t len, bool lsb) { const uint8_t *p; diff --git a/src/globals.h b/src/globals.h index ca25a9a9..b6cb1c2f 100644 --- a/src/globals.h +++ b/src/globals.h @@ -17,17 +17,10 @@ extern char display_line6[], display_line7[]; extern int countermode, screensaver, adrmode, lorasf, txpower, rlim; extern uint8_t channel, DisplayState; extern uint16_t macs_total, macs_wifi, macs_ble; // MAC counters -extern uint64_t uptimecounter; extern std::set macs; extern hw_timer_t *channelSwitch, *sendCycle; extern portMUX_TYPE timerMux; -#if defined(CFG_eu868) -const char lora_datarate[] = {"1211100908077BFSNA"}; -#elif defined(CFG_us915) -const char lora_datarate[] = {"100908078CNA121110090807"}; -#endif - #ifdef HAS_GPS extern gpsStatus_t gps_status; // struct for storing gps data extern TinyGPSPlus gps; // Make TinyGPS++ instance globally availabe diff --git a/src/macsniff.h b/src/macsniff.h index fe1b0f5a..442b5068 100644 --- a/src/macsniff.h +++ b/src/macsniff.h @@ -4,6 +4,7 @@ // ESP32 Functions #include +// Hash function for scrambling MAC addresses #include "hash.h" #define MAC_SNIFF_WIFI 0 diff --git a/src/main.cpp b/src/main.cpp index 4417be8e..684f12de 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,7 +32,6 @@ char display_line6[16], display_line7[16]; // display buffers uint8_t DisplayState = 0, channel = 0; // globals for state machine uint16_t macs_total = 0, macs_wifi = 0, macs_ble = 0; // MAC counters globals for display -uint64_t uptimecounter = 0; // timer global for uptime counter hw_timer_t *channelSwitch = NULL, *displaytimer = NULL, *sendCycle = NULL; // configure hardware timer for cyclic tasks @@ -438,8 +437,6 @@ void loop() { // state machine for uptime, display, LED, button, lowmemory, senddata - uptimecounter = uptime() / 1000; // counts uptime in seconds (64bit) - #if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) led_loop(); #endif diff --git a/src/main.h b/src/main.h index 6cdc011b..218034f2 100644 --- a/src/main.h +++ b/src/main.h @@ -73,4 +73,5 @@ extern TinyGPSPlus gps; // Make TinyGPS++ instance globally availabe void reset_counters(void); void blink_LED(uint16_t set_color, uint16_t set_blinkduration); -void led_loop(void); \ No newline at end of file +void led_loop(void); +uint64_t uptime(); \ No newline at end of file diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 972daed2..a8d735a5 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -284,7 +284,7 @@ void get_status(uint8_t val) { uint16_t voltage = 0; #endif payload.reset(); - payload.addStatus(voltage, uptimecounter, temperatureRead()); + payload.addStatus(voltage, uptime() / 1000, temperatureRead()); senddata(STATUSPORT); };