From 4ce550c668ad3ebabbdecafbd1effb99847a755e Mon Sep 17 00:00:00 2001 From: Marcel Peterkau Date: Sun, 21 Aug 2022 11:28:58 +0200 Subject: [PATCH] start of sanitycheck-header --- Software/platformio.ini | 10 ++++----- Software/src/common.h | 19 ++--------------- Software/src/main.cpp | 4 ++-- Software/src/sanitycheck.h | 30 +++++++++++++++++++++++++++ Software/wifi_credentials.example.ini | 4 ++-- 5 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 Software/src/sanitycheck.h diff --git a/Software/platformio.ini b/Software/platformio.ini index b74dd4d..3ee240a 100644 --- a/Software/platformio.ini +++ b/Software/platformio.ini @@ -26,19 +26,19 @@ upload_speed = 921600 build_flags = !python git_rev_macro.py - -DWIFI_SSID=${wifi_cred.wifi_ssid} - -DWIFI_PASSWORD=${wifi_cred.wifi_password} + -DWIFI_SSID_CLIENT=${wifi_cred.wifi_ssid_client} + -DWIFI_PASSWORD_CLIENT=${wifi_cred.wifi_password_client} -DADMIN_PASSWORD=${wifi_cred.admin_password} -DWIFI_AP_PASSWORD=${wifi_cred.wifi_ap_password} -DWIFI_AP_IP_GW=10,0,0,1 - -DFEATURE_ENABLE_WIFI_CLIENT - -DFEATURE_ENABLE_REMOTE_DEBUG + ;-DFEATURE_ENABLE_WIFI_CLIENT + ;-DFEATURE_ENABLE_REMOTE_DEBUG ;-DFEATURE_ENABLE_OLED ;-DFEATURE_ENABLE_CAN ;-DFEATURE_ENABLE_GPS -DPCB_REV=2 -build_type = debug +;build_type = debug board_build.filesystem = littlefs diff --git a/Software/src/common.h b/Software/src/common.h index cfaa9ff..5398f85 100644 --- a/Software/src/common.h +++ b/Software/src/common.h @@ -4,9 +4,7 @@ #define Q(x) #x #define QUOTE(x) Q(x) -#ifndef PCB_REV - #error "You must define PCB_REV" -#elif PCB_REV == 2 +#if PCB_REV == 2 #define GPIO_BUTTON D7 #define GPIO_LED D8 #define GPIO_TRIGGER D6 @@ -16,7 +14,7 @@ #define GPIO_LED D6 #define GPIO_TRIGGER D4 #define GPIO_PUMP D3 -#elif PCB_REV >= 4 +#elif PCB_REV == 4 #define GPIO_BUTTON D4 #define GPIO_LED D3 #define GPIO_TRIGGER D6 @@ -39,17 +37,4 @@ #define ATOMIC_FS_UPDATE -#ifndef ADMIN_PASSWORD -#error "You need to define ADMIN_PASSWORD for OTA-Update" -#endif -#ifndef WIFI_PASSWORD -#error "You must define an WIFI_PASSWORD for OTA-Update" -#endif -#ifndef WIFI_SSID -#error "You must define an WIFI_SSID for OTA-Update" -#endif -#ifndef WIFI_AP_PASSWORD -#error "You must define an WIFI_AP_PASSWORD for Standalone AP-Mode" -#endif - #endif \ No newline at end of file diff --git a/Software/src/main.cpp b/Software/src/main.cpp index 796e9ac..ddd8a1c 100644 --- a/Software/src/main.cpp +++ b/Software/src/main.cpp @@ -34,8 +34,8 @@ #ifdef FEATURE_ENABLE_WIFI_CLIENT #include -const char *ssid = QUOTE(WIFI_SSID); -const char *password = QUOTE(WIFI_PASSWORD); +const char *ssid = QUOTE(WIFI_SSID_CLIENT); +const char *password = QUOTE(WIFI_PASSWORD_CLIENT); const uint32_t connectTimeoutMs = 5000; ESP8266WiFiMulti wifiMulti; diff --git a/Software/src/sanitycheck.h b/Software/src/sanitycheck.h new file mode 100644 index 0000000..c3783a7 --- /dev/null +++ b/Software/src/sanitycheck.h @@ -0,0 +1,30 @@ +#ifndef _SANITYCHECK_H_ +#define _SANITYCHECK_H_ + +#ifndef PCB_REV + #error "You must define PCB_REV" +#else + #if PCB_REV < 1 || PCB_REV > 4 + #error "Unsupported PCB-Revision" + #endif +#endif + +#ifndef ADMIN_PASSWORD + #error "You need to define ADMIN_PASSWORD for OTA-Update" +#endif + +#ifdef FEATURE_ENABLE_WIFI_CLIENT + #ifndef WIFI_PASSWORD_CLIENT + #error "You must define an WIFI_PASSWORD for Client-Mode" + #endif + + #ifndef WIFI_SSID_CLIENT + #error "You must define an WIFI_SSID for Client-Mode" + #endif +#endif + +#ifndef WIFI_AP_PASSWORD +#error "You must define an WIFI_AP_PASSWORD for Standalone AP-Mode" +#endif + +#endif //_SANITYCHECK_H_ \ No newline at end of file diff --git a/Software/wifi_credentials.example.ini b/Software/wifi_credentials.example.ini index ef65110..e57287b 100644 --- a/Software/wifi_credentials.example.ini +++ b/Software/wifi_credentials.example.ini @@ -1,5 +1,5 @@ [wifi_cred] admin_password = adminpass wifi_ap_password = wifiappass -wifi_ssid = wifi-ssid -wifi_password = wifi-pass \ No newline at end of file +wifi_ssid_client = wifi-ssid +wifi_password_client = wifi-pass \ No newline at end of file