From 87d93f6978feb134ac13da6d80d29344c98e60ef Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 29 Mar 2020 18:08:52 +0200 Subject: [PATCH] #include cleanup --- include/bmesensor.h | 5 ++++- include/button.h | 4 ++++ include/cyclic.h | 18 +----------------- include/globals.h | 38 -------------------------------------- include/irqhandler.h | 2 ++ include/led.h | 3 +-- include/ledmatrixdisplay.h | 1 + include/macsniff.h | 1 + include/main.h | 7 +++---- include/ota.h | 4 +++- include/payload.h | 4 ---- include/power.h | 1 + include/rcommand.h | 9 ++++----- include/reset.h | 4 ++++ include/rtctime.h | 5 +++-- include/sdcard.h | 3 ++- include/sds011read.h | 2 +- include/senddata.h | 10 +--------- include/spislave.h | 1 + include/timekeeper.h | 7 ------- include/vendor_array.h | 2 +- include/wifiscan.h | 12 ++++++++---- src/blecsan.cpp | 5 ++--- src/configmanager.cpp | 1 + src/gpsread.cpp | 1 + src/ledmatrixdisplay.cpp | 1 + src/macsniff.cpp | 1 + src/sensor.cpp | 1 + src/timekeeper.cpp | 1 - src/timesync.cpp | 6 +----- src/wifiscan.cpp | 2 -- 31 files changed, 54 insertions(+), 108 deletions(-) diff --git a/include/bmesensor.h b/include/bmesensor.h index b73a712a..d8ffaa7b 100644 --- a/include/bmesensor.h +++ b/include/bmesensor.h @@ -1,9 +1,12 @@ #ifndef _BMESENSOR_H #define _BMESENSOR_H -#include "globals.h" #include +#include "globals.h" +#include "irqhandler.h" +#include "configmanager.h" + #ifdef HAS_BME680 #include #elif defined HAS_BME280 diff --git a/include/button.h b/include/button.h index e7799847..fd6e046a 100644 --- a/include/button.h +++ b/include/button.h @@ -2,6 +2,10 @@ #define _BUTTON_H #include +#include "irqhandler.h" +#include "senddata.h" +#include "display.h" +#include "payload.h" void button_init(int pin); void readButton(); diff --git a/include/cyclic.h b/include/cyclic.h index ccadbb65..7d90d408 100644 --- a/include/cyclic.h +++ b/include/cyclic.h @@ -1,31 +1,15 @@ #ifndef _CYCLIC_H #define _CYCLIC_H +//#include #include "globals.h" #include "senddata.h" #include "rcommand.h" #include "spislave.h" - -#if(HAS_LORA) -#include -#endif - -#if (HAS_BME) #include "bmesensor.h" -#endif - -#ifdef HAS_DISPLAY #include "display.h" -#endif - -#if (HAS_SDS011) #include "sds011read.h" -#endif - -#if (HAS_SDCARD) #include "sdcard.h" -#endif - extern Ticker housekeeper; diff --git a/include/globals.h b/include/globals.h index d56998e3..c4ad3871 100644 --- a/include/globals.h +++ b/include/globals.h @@ -134,42 +134,4 @@ extern TimerHandle_t WifiChanTimer; extern Timezone myTZ; extern RTC_DATA_ATTR runmode_t RTC_runmode; -// application includes -#include "led.h" -#include "payload.h" -#include "blescan.h" -#include "power.h" - -#if (HAS_GPS) -#include "gpsread.h" -#endif - -#if (HAS_LORA) -#include "lorawan.h" -#endif - -#ifdef HAS_DISPLAY -#include "display.h" -#endif - -#ifdef HAS_MATRIX_DISPLAY -#include "ledmatrixdisplay.h" -#endif - -#ifdef HAS_BUTTON -#include "button.h" -#endif - -#ifdef HAS_ANTENNA_SWITCH -#include "antenna.h" -#endif - -#if (HAS_SENSORS) -#include "sensor.h" -#endif - -#if (HAS_BME) -#include "bmesensor.h" -#endif - #endif \ No newline at end of file diff --git a/include/irqhandler.h b/include/irqhandler.h index 193e32d5..04e62d93 100644 --- a/include/irqhandler.h +++ b/include/irqhandler.h @@ -13,11 +13,13 @@ #define PMU_IRQ 0x200 #include "globals.h" +#include "button.h" #include "cyclic.h" #include "senddata.h" #include "timekeeper.h" #include "bmesensor.h" #include "power.h" +#include "ledmatrixdisplay.h" void irqHandler(void *pvParameters); void mask_user_IRQ(); diff --git a/include/led.h b/include/led.h index de4d2227..1bc0ccde 100644 --- a/include/led.h +++ b/include/led.h @@ -1,9 +1,8 @@ #ifndef _LED_H #define _LED_H -#ifdef HAS_RGB_LED #include -#endif +#include "lorawan.h" // value for HSL color // see http://www.workwithcolor.com/blue-color-hue-range-01.htm diff --git a/include/ledmatrixdisplay.h b/include/ledmatrixdisplay.h index b2863146..9db9ebee 100644 --- a/include/ledmatrixdisplay.h +++ b/include/ledmatrixdisplay.h @@ -3,6 +3,7 @@ #include "LEDMatrix.h" #include "ledmatrixfonts.h" +#include "ledmatrixdisplay.h" extern uint8_t MatrixDisplayIsOn; diff --git a/include/macsniff.h b/include/macsniff.h index d41fc787..a04b7cc8 100644 --- a/include/macsniff.h +++ b/include/macsniff.h @@ -8,6 +8,7 @@ #include "hash.h" #include "senddata.h" #include "cyclic.h" +#include "led.h" #define MAC_SNIFF_WIFI 0 #define MAC_SNIFF_BLE 1 diff --git a/include/main.h b/include/main.h index 9037ccec..bc63ff4e 100644 --- a/include/main.h +++ b/include/main.h @@ -17,9 +17,8 @@ #include "ota.h" #include "irqhandler.h" #include "spislave.h" - -#if (HAS_LORA) +#include "sensor.h" #include "lorawan.h" -#endif #include "timekeeper.h" -#endif + +#endif \ No newline at end of file diff --git a/include/ota.h b/include/ota.h index cec28750..900ef530 100644 --- a/include/ota.h +++ b/include/ota.h @@ -4,7 +4,9 @@ #ifdef USE_OTA #include "globals.h" -#include +#include "led.h" +#include "display.h" + #include #include #include diff --git a/include/payload.h b/include/payload.h index 889c164d..9963ff02 100644 --- a/include/payload.h +++ b/include/payload.h @@ -1,11 +1,7 @@ #ifndef _PAYLOAD_H_ #define _PAYLOAD_H_ -#include "paxcounter.conf" - -#if (HAS_SDS011) #include "sds011read.h" -#endif // MyDevices CayenneLPP 1.0 channels for Synamic sensor payload format // all payload goes out on LoRa FPort 1 diff --git a/include/power.h b/include/power.h index 2db12da5..5e0ee363 100644 --- a/include/power.h +++ b/include/power.h @@ -4,6 +4,7 @@ #include #include #include + #include "i2c.h" #include "reset.h" diff --git a/include/rcommand.h b/include/rcommand.h index 2f6ae64f..488b7005 100644 --- a/include/rcommand.h +++ b/include/rcommand.h @@ -1,20 +1,19 @@ #ifndef _RCOMMAND_H #define _RCOMMAND_H +#include + #include "senddata.h" #include "cyclic.h" #include "configmanager.h" -#if(HAS_LORA) #include "lorawan.h" -#endif +#include "sensor.h" #include "macsniff.h" #include "wifiscan.h" -#include #include "cyclic.h" #include "timekeeper.h" -#if(TIME_SYNC_LORASERVER) #include "timesync.h" -#endif +#include "blescan.h" // table of remote commands and assigned functions typedef struct { diff --git a/include/reset.h b/include/reset.h index 533a79c1..be40bd3a 100644 --- a/include/reset.h +++ b/include/reset.h @@ -3,7 +3,11 @@ #include #include + #include "i2c.h" +#include "lorawan.h" +#include "display.h" +#include "power.h" void do_reset(bool warmstart); void do_after_reset(int reason); diff --git a/include/rtctime.h b/include/rtctime.h index 3429d44e..d4d64935 100644 --- a/include/rtctime.h +++ b/include/rtctime.h @@ -1,11 +1,12 @@ #ifndef _RTCTIME_H #define _RTCTIME_H -#include "globals.h" -#include "timekeeper.h" #include // must be included here so that Arduino library object file references work #include +#include "globals.h" +#include "timekeeper.h" + extern RtcDS3231 Rtc; // make RTC instance globally available uint8_t rtc_init(void); diff --git a/include/sdcard.h b/include/sdcard.h index 99e784cb..4323c6a3 100644 --- a/include/sdcard.h +++ b/include/sdcard.h @@ -3,10 +3,11 @@ #include #include - #include #include +#include "sds011read.h" + #define SDCARD_FILE_NAME "paxcount.%02d" #define SDCARD_FILE_HEADER "date, time, wifi, bluet" diff --git a/include/sds011read.h b/include/sds011read.h index 97307d1c..f49c34f0 100644 --- a/include/sds011read.h +++ b/include/sds011read.h @@ -1,8 +1,8 @@ #ifndef _SDS011READ_H #define _SDS011READ_H -#include "globals.h" #include +#include "globals.h" #define SDCARD_FILE_HEADER_SDS011 ", PM10,PM25" diff --git a/include/senddata.h b/include/senddata.h index 5022800c..7be85016 100644 --- a/include/senddata.h +++ b/include/senddata.h @@ -3,18 +3,10 @@ #include "spislave.h" #include "cyclic.h" - -#if(HAS_LORA) +#include "sensor.h" #include "lorawan.h" -#endif - -#ifdef HAS_DISPLAY #include "display.h" -#endif - -#ifdef HAS_SDCARD #include "sdcard.h" -#endif extern Ticker sendcycler; diff --git a/include/spislave.h b/include/spislave.h index cf1db7a3..6db35d00 100644 --- a/include/spislave.h +++ b/include/spislave.h @@ -25,6 +25,7 @@ licenses. Refer to LICENSE.txt file in repository for more details. #define _SPISLAVE_H #include "globals.h" +#include "rcommand.h" esp_err_t spi_init(); diff --git a/include/timekeeper.h b/include/timekeeper.h index 7a98eb61..035cec6a 100644 --- a/include/timekeeper.h +++ b/include/timekeeper.h @@ -6,16 +6,9 @@ #include "TimeLib.h" #include "irqhandler.h" #include "timesync.h" - -#if (HAS_GPS) #include "gpsread.h" -#endif - -#ifdef HAS_IF482 #include "if482.h" -#elif defined HAS_DCF77 #include "dcf77.h" -#endif extern const char timeSetSymbols[]; extern Ticker timesyncer; diff --git a/include/vendor_array.h b/include/vendor_array.h index 76ee4618..b3bc7744 100644 --- a/include/vendor_array.h +++ b/include/vendor_array.h @@ -240,4 +240,4 @@ std::array vendors = { 0xb84fd5, 0xc0eefb, 0x206e9c, 0x6c2f2c, 0x18227e, 0x30c7ae, 0x501ac5, 0x6045bd, 0x1cb094, 0xe85b5b, 0x0025ae, 0x001dd8, 0x000a75, 0xa4c939, 0xc0dcda, 0x04b429, 0x48794d, -}; +}; \ No newline at end of file diff --git a/include/wifiscan.h b/include/wifiscan.h index 2e093cf8..88de6d26 100644 --- a/include/wifiscan.h +++ b/include/wifiscan.h @@ -3,13 +3,17 @@ // ESP32 Functions #include +#include +#include "coexist_internal.h" -// Hash function for scrambling MAC addresses -#include "hash.h" +#include "hash.h" // Hash function for scrambling MAC addresses +#include "antenna.h" // code for switching wifi antennas +#include "macsniff.h" void wifi_sniffer_init(void); -void switch_wifi_sniffer (uint8_t state); -void IRAM_ATTR wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type); +void switch_wifi_sniffer(uint8_t state); +void IRAM_ATTR wifi_sniffer_packet_handler(void *buff, + wifi_promiscuous_pkt_type_t type); void switchWifiChannel(TimerHandle_t xTimer); #endif \ No newline at end of file diff --git a/src/blecsan.cpp b/src/blecsan.cpp index 90761f75..d305680e 100644 --- a/src/blecsan.cpp +++ b/src/blecsan.cpp @@ -1,6 +1,5 @@ -/* code snippets taken from -https://github.com/nkolban/esp32-snippets/tree/master/BLE/scanner -*/ +// some code snippets taken from +// https://github.com/nkolban/esp32-snippets/tree/master/BLE/scanner #include "blescan.h" diff --git a/src/configmanager.cpp b/src/configmanager.cpp index 84f8e603..b4de1a56 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -1,6 +1,7 @@ /* configmanager persists runtime configuration using NVRAM of ESP32*/ #include "globals.h" +#include "configmanager.h" // Local logging tag static const char TAG[] = "flash"; diff --git a/src/gpsread.cpp b/src/gpsread.cpp index 49a579f4..45f1b65d 100644 --- a/src/gpsread.cpp +++ b/src/gpsread.cpp @@ -1,6 +1,7 @@ #if (HAS_GPS) #include "globals.h" +#include "gpsread.h" // Local logging tag static const char TAG[] = __FILE__; diff --git a/src/ledmatrixdisplay.cpp b/src/ledmatrixdisplay.cpp index d31abf73..ad484e34 100644 --- a/src/ledmatrixdisplay.cpp +++ b/src/ledmatrixdisplay.cpp @@ -1,6 +1,7 @@ #ifdef HAS_MATRIX_DISPLAY #include "globals.h" +#include "ledmatrixdisplay.h" #define MATRIX_DISPLAY_PAGES (2) // number of display pages #define LINE_DIAGRAM_DIVIDER (2) // scales pax numbers to led rows diff --git a/src/macsniff.cpp b/src/macsniff.cpp index 7307f345..213a0aff 100644 --- a/src/macsniff.cpp +++ b/src/macsniff.cpp @@ -1,6 +1,7 @@ // Basic Config #include "globals.h" +#include "macsniff.h #if (VENDORFILTER) #include "vendor_array.h" diff --git a/src/sensor.cpp b/src/sensor.cpp index 807e6f78..abed9b75 100644 --- a/src/sensor.cpp +++ b/src/sensor.cpp @@ -1,5 +1,6 @@ // Basic Config #include "globals.h" +#include "sensor.h" // Local logging tag static const char TAG[] = __FILE__; diff --git a/src/timekeeper.cpp b/src/timekeeper.cpp index df178dcb..6d8439ec 100644 --- a/src/timekeeper.cpp +++ b/src/timekeeper.cpp @@ -1,5 +1,4 @@ #include "timekeeper.h" -#include "paxcounter.conf" #if !(HAS_LORA) #if (TIME_SYNC_LORASERVER) diff --git a/src/timesync.cpp b/src/timesync.cpp index e50f4353..ce32d4e6 100644 --- a/src/timesync.cpp +++ b/src/timesync.cpp @@ -13,8 +13,6 @@ accept this. */ -#if (HAS_LORA) - #if (TIME_SYNC_LORASERVER) && (TIME_SYNC_LORAWAN) #error Duplicate timesync method selected. You must select either LORASERVER or LORAWAN timesync. #endif @@ -274,6 +272,4 @@ Exit: // inform processing task xTaskNotify(timeSyncProcTask, (rc ? rcv_seqNo : TIME_SYNC_END_FLAG), eSetBits); -} - -#endif // HAS_LORA \ No newline at end of file +} \ No newline at end of file diff --git a/src/wifiscan.cpp b/src/wifiscan.cpp index 13e03e2b..6409298c 100644 --- a/src/wifiscan.cpp +++ b/src/wifiscan.cpp @@ -1,8 +1,6 @@ // Basic Config #include "globals.h" #include "wifiscan.h" -#include -#include "coexist_internal.h" // Local logging tag static const char TAG[] = "wifi";