diff --git a/src/antenna.h b/include/antenna.h similarity index 100% rename from src/antenna.h rename to include/antenna.h diff --git a/src/battery.h b/include/battery.h similarity index 100% rename from src/battery.h rename to include/battery.h diff --git a/src/beacon_array.h b/include/beacon_array.h similarity index 100% rename from src/beacon_array.h rename to include/beacon_array.h diff --git a/src/blescan.h b/include/blescan.h similarity index 100% rename from src/blescan.h rename to include/blescan.h diff --git a/src/button.h b/include/button.h similarity index 100% rename from src/button.h rename to include/button.h diff --git a/src/configmanager.h b/include/configmanager.h similarity index 100% rename from src/configmanager.h rename to include/configmanager.h diff --git a/src/cyclic.h b/include/cyclic.h similarity index 100% rename from src/cyclic.h rename to include/cyclic.h diff --git a/src/display.h b/include/display.h similarity index 100% rename from src/display.h rename to include/display.h diff --git a/src/globals.h b/include/globals.h similarity index 96% rename from src/globals.h rename to include/globals.h index 703b46d0..947b4cfa 100644 --- a/src/globals.h +++ b/include/globals.h @@ -1,97 +1,97 @@ -#ifndef _GLOBALS_H -#define _GLOBALS_H - -// The mother of all embedded development... -#include - -// std::set for unified array functions -#include -#include -#include - -// Struct holding devices's runtime configuration -typedef struct { - uint8_t lorasf; // 7-12, lora spreadfactor - uint8_t txpower; // 2-15, lora tx power - uint8_t adrmode; // 0=disabled, 1=enabled - uint8_t screensaver; // 0=disabled, 1=enabled - uint8_t screenon; // 0=disabled, 1=enabled - uint8_t countermode; // 0=cyclic unconfirmed, 1=cumulative, 2=cyclic confirmed - int16_t rssilimit; // threshold for rssilimiter, negative value! - uint8_t sendcycle; // payload send cycle [seconds/2] - uint8_t wifichancycle; // wifi channel switch cycle [seconds/100] - uint8_t blescantime; // BLE scan cycle duration [seconds] - uint8_t blescan; // 0=disabled, 1=enabled - uint8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4) - uint8_t vendorfilter; // 0=disabled, 1=enabled - uint8_t rgblum; // RGB Led luminosity (0..100%) - uint8_t gpsmode; // 0=disabled, 1=enabled - uint8_t monitormode; // 0=disabled, 1=enabled - uint8_t runmode; // 0=normal, 1=update - char version[10]; // Firmware version -} configData_t; - -// Struct holding payload for data send queue -typedef struct { - uint8_t MessageSize; - uint8_t MessagePort; - uint8_t Message[PAYLOAD_BUFFER_SIZE]; -} MessageBuffer_t; - -// global variables -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 -extern std::set macs; // temp storage for MACs -extern hw_timer_t *channelSwitch, *sendCycle; - -extern std::array::iterator it; -extern std::array beacons; - -extern TaskHandle_t irqHandlerTask, wifiSwitchTask; - -#ifdef HAS_GPS -#include "gps.h" -#endif - -#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) -#include "led.h" -#endif - -#include "payload.h" - -#ifdef HAS_LORA -#include "lorawan.h" -#endif - -#ifdef HAS_SPI -#include "spi.h" -#endif - -#ifdef HAS_DISPLAY -#include "display.h" -#endif - -#ifdef HAS_BUTTON -#include "button.h" -#endif - -#ifdef BLECOUNTER -#include "blescan.h" -#endif - -#ifdef HAS_BATTERY_PROBE -#include "battery.h" -#endif - -#ifdef HAS_ANTENNA_SWITCH -#include "antenna.h" -#endif - -void reset_counters(void); -void blink_LED(uint16_t set_color, uint16_t set_blinkduration); -uint64_t uptime(); - +#ifndef _GLOBALS_H +#define _GLOBALS_H + +// The mother of all embedded development... +#include + +// std::set for unified array functions +#include +#include +#include + +// Struct holding devices's runtime configuration +typedef struct { + uint8_t lorasf; // 7-12, lora spreadfactor + uint8_t txpower; // 2-15, lora tx power + uint8_t adrmode; // 0=disabled, 1=enabled + uint8_t screensaver; // 0=disabled, 1=enabled + uint8_t screenon; // 0=disabled, 1=enabled + uint8_t countermode; // 0=cyclic unconfirmed, 1=cumulative, 2=cyclic confirmed + int16_t rssilimit; // threshold for rssilimiter, negative value! + uint8_t sendcycle; // payload send cycle [seconds/2] + uint8_t wifichancycle; // wifi channel switch cycle [seconds/100] + uint8_t blescantime; // BLE scan cycle duration [seconds] + uint8_t blescan; // 0=disabled, 1=enabled + uint8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4) + uint8_t vendorfilter; // 0=disabled, 1=enabled + uint8_t rgblum; // RGB Led luminosity (0..100%) + uint8_t gpsmode; // 0=disabled, 1=enabled + uint8_t monitormode; // 0=disabled, 1=enabled + uint8_t runmode; // 0=normal, 1=update + char version[10]; // Firmware version +} configData_t; + +// Struct holding payload for data send queue +typedef struct { + uint8_t MessageSize; + uint8_t MessagePort; + uint8_t Message[PAYLOAD_BUFFER_SIZE]; +} MessageBuffer_t; + +// global variables +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 +extern std::set macs; // temp storage for MACs +extern hw_timer_t *channelSwitch, *sendCycle; + +extern std::array::iterator it; +extern std::array beacons; + +extern TaskHandle_t irqHandlerTask, wifiSwitchTask; + +#ifdef HAS_GPS +#include "gps.h" +#endif + +#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) +#include "led.h" +#endif + +#include "payload.h" + +#ifdef HAS_LORA +#include "lorawan.h" +#endif + +#ifdef HAS_SPI +#include "spi.h" +#endif + +#ifdef HAS_DISPLAY +#include "display.h" +#endif + +#ifdef HAS_BUTTON +#include "button.h" +#endif + +#ifdef BLECOUNTER +#include "blescan.h" +#endif + +#ifdef HAS_BATTERY_PROBE +#include "battery.h" +#endif + +#ifdef HAS_ANTENNA_SWITCH +#include "antenna.h" +#endif + +void reset_counters(void); +void blink_LED(uint16_t set_color, uint16_t set_blinkduration); +uint64_t uptime(); + #endif \ No newline at end of file diff --git a/src/gps.h b/include/gps.h similarity index 100% rename from src/gps.h rename to include/gps.h diff --git a/src/hash.h b/include/hash.h similarity index 100% rename from src/hash.h rename to include/hash.h diff --git a/src/irqhandler.h b/include/irqhandler.h similarity index 100% rename from src/irqhandler.h rename to include/irqhandler.h diff --git a/src/led.h b/include/led.h similarity index 100% rename from src/led.h rename to include/led.h diff --git a/src/lorawan.h b/include/lorawan.h similarity index 100% rename from src/lorawan.h rename to include/lorawan.h diff --git a/src/macsniff.h b/include/macsniff.h similarity index 100% rename from src/macsniff.h rename to include/macsniff.h diff --git a/src/main.h b/include/main.h similarity index 100% rename from src/main.h rename to include/main.h diff --git a/src/ota.h b/include/ota.h similarity index 100% rename from src/ota.h rename to include/ota.h diff --git a/src/payload.h b/include/payload.h similarity index 100% rename from src/payload.h rename to include/payload.h diff --git a/src/rcommand.h b/include/rcommand.h similarity index 100% rename from src/rcommand.h rename to include/rcommand.h diff --git a/include/readme.txt b/include/readme.txt new file mode 100644 index 00000000..194dcd43 --- /dev/null +++ b/include/readme.txt @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/src/senddata.h b/include/senddata.h similarity index 100% rename from src/senddata.h rename to include/senddata.h diff --git a/src/spi.h b/include/spi.h similarity index 100% rename from src/spi.h rename to include/spi.h diff --git a/src/update.h b/include/update.h similarity index 100% rename from src/update.h rename to include/update.h diff --git a/src/vendor_array.h b/include/vendor_array.h similarity index 100% rename from src/vendor_array.h rename to include/vendor_array.h diff --git a/src/wifiscan.h b/include/wifiscan.h similarity index 100% rename from src/wifiscan.h rename to include/wifiscan.h diff --git a/src/main.cpp b/src/main.cpp index 4268bb3a..6346a71f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -285,7 +285,7 @@ void setup() { ESP_LOGI(TAG, "Starting GPSloop..."); xTaskCreatePinnedToCore(gps_loop, // task function "gpsloop", // name of task - 1024, // stack size of task + 2048, // stack size of task (void *)1, // parameter of the task 2, // priority of the task &GpsTask, // task handle