diff --git a/include/display.h b/include/display.h index e7e7c41..ad253f5 100644 --- a/include/display.h +++ b/include/display.h @@ -1,11 +1,11 @@ -#if !defined(_DISPLAY_H) +#if !defined(_DISPLAY_H) && SMART_POC_DISPLAY #define _DISPLAY_H +#include #include +#include #include #include "SSD1306Wire.h" -#include -#include void display_setup(); // void display_loop(bool transmitterActive); diff --git a/include/main.h b/include/main.h index badba73..68c1cbf 100644 --- a/include/main.h +++ b/include/main.h @@ -54,7 +54,11 @@ #ifdef SMART_POC_MODULE_MOWAS #include #endif +#ifdef SMART_POC_DISPLAY #include +#else +#include +#endif void txControllerBatchClear(); void txControllerBatchStart(); diff --git a/platformio.ini b/platformio.ini index 8267516..46fb5d9 100644 --- a/platformio.ini +++ b/platformio.ini @@ -7,8 +7,7 @@ ; ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html - -[env:ttgo-lora32-v2_nodwd_mowas] +[common] build_flags = -DRADIOLIB_EXCLUDE_CC1101=1 -DRADIOLIB_EXCLUDE_NRF24=1 @@ -32,13 +31,10 @@ build_flags = -DRADIOLIB_EXCLUDE_LORAWAN=1 -DRADIOLIB_GODMODE=1 -DRADIOLIB_LOW_LEVEL=1 -platform = espressif32 -board = ttgo-lora32-v2 board_build.embed_txtfiles = data/index.html data/script.js data/style.css -framework = arduino lib_deps = jgromes/RadioLib@^7.1.2 ropg/ezTime@^0.8.3 @@ -48,50 +44,40 @@ lib_deps = knolleary/PubSubClient@^2.8 thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.6.1 monitor_speed = 115200 -board_build.mcu = esp32 upload_speed = 921600 -[env:ttgo-lora32-v2_dwd_mowas] + +[env:ttgo-lora32-v2_nodwd_mowas_noscreen] +platform = espressif32 +framework = arduino +board = ttgo-lora32-v2 +board_build.mcu = esp32 +lib_deps = ${common.lib_deps} +; build_flags = +; -flto +board_build.embed_txtfiles = ${common.board_build.embed_txtfiles} + +[env:ttgo-lora32-v2_dwd_mowas_noscreen] build_flags = + ${common.build_flags} -DSMART_POC_MODULE_DWD=1 -DSMART_POC_MODULE_MOWAS=1 - -DRADIOLIB_EXCLUDE_CC1101=1 - -DRADIOLIB_EXCLUDE_NRF24=1 - -DRADIOLIB_EXCLUDE_RF69=1 - -DRADIOLIB_EXCLUDE_SX1231=1 - -DRADIOLIB_EXCLUDE_SX1233=1 - -DRADIOLIB_EXCLUDE_SI443X=1 - -DRADIOLIB_EXCLUDE_RFM2X=1 - -DRADIOLIB_EXCLUDE_AFSK=1 - -DRADIOLIB_EXCLUDE_BELL=1 - -DRADIOLIB_EXCLUDE_HELLSCHREIBER=1 - -DRADIOLIB_EXCLUDE_MORSE=1 - -DRADIOLIB_EXCLUDE_RTTY=1 - -DRADIOLIB_EXCLUDE_SSTV=1 - -DRADIOLIB_EXCLUDE_AX25=1 - -DRADIOLIB_EXCLUDE_DIRECT_RECEIVE=1 - -DRADIOLIB_EXCLUDE_BELL=1 - -DRADIOLIB_EXCLUDE_PAGER=1 - -DRADIOLIB_EXCLUDE_FSK4=1 - -DRADIOLIB_EXCLUDE_APRS=1 - -DRADIOLIB_EXCLUDE_LORAWAN=1 - -DRADIOLIB_GODMODE=1 - -DRADIOLIB_LOW_LEVEL=1 +lib_deps = ${common.lib_deps} platform = espressif32 -board = ttgo-lora32-v2 -board_build.embed_txtfiles = - data/index.html - data/script.js - data/style.css framework = arduino -lib_deps = - jgromes/RadioLib@^7.1.2 - ropg/ezTime@^0.8.3 - esphome/AsyncTCP-esphome@^2.1.4 - esphome/ESPAsyncWebServer-esphome@^3.3.0 - bblanchon/ArduinoJson@^7.3.1 - knolleary/PubSubClient@^2.8 - thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.6.1 -monitor_speed = 115200 +board = ttgo-lora32-v2 board_build.mcu = esp32 -upload_speed = 921600 +board_build.embed_txtfiles = ${common.board_build.embed_txtfiles} + +[env:ttgo-lora32-v2_dwd_mowas_screen] +build_flags = + ${common.build_flags} + -DSMART_POC_DISPLAY=1 + -DSMART_POC_MODULE_DWD=1 + -DSMART_POC_MODULE_MOWAS=1 +lib_deps = ${common.lib_deps} +platform = espressif32 +framework = arduino +board = ttgo-lora32-v2 +board_build.mcu = esp32 +board_build.embed_txtfiles = ${common.board_build.embed_txtfiles} diff --git a/src/display.cpp b/src/display.cpp index 1f06ad0..f06d827 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -1,5 +1,6 @@ -#include +#ifdef SMART_POC_DISPLAY +#include SSD1306Wire display(0x3c, SDA, SCL); void display_setup() { @@ -128,4 +129,5 @@ void display_loop(bool transmitterActive, POCSAGTransmitter *transmitter, cfg_t display_idle(cfg_ref, timeStr); } -// local time, ip addr, transmitter name? \ No newline at end of file +// local time, ip addr, transmitter name? +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 6714f92..c781afa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,9 +20,13 @@ void setup() delay(2e2); Serial.begin(115200); + #ifdef SMART_POC_DISPLAY display_setup(); + #endif setup_storage(&globcfg); + #ifdef SMART_POC_DISPLAY display_update_state("loaded cfg"); + #endif // memdebug Serial.print("Free Heap Size after reading Config:"); Serial.println(ESP.getFreeHeap()); @@ -35,7 +39,9 @@ void setup() } else { Serial.print(F("failed, code ")); Serial.println(state); + #ifdef SMART_POC_DISPLAY display_update_state("modem fail"); + #endif // TODO: add solution to this while (true) { digitalWrite(PIN_LED, HIGH); @@ -47,10 +53,14 @@ void setup() // radio.setOutputPower(globcfg.tx_power); Serial.println("initialized modem"); + #ifdef SMART_POC_DISPLAY display_update_state("init modem"); + #endif transmitter.begin(&radio); Serial.println("initialized transmitter"); + #ifdef SMART_POC_DISPLAY display_update_state("init pocsag-stack"); + #endif // setup_network(); webserver_setup(); @@ -77,7 +87,9 @@ void setup_network() // if (wifi1valid) { + #ifdef SMART_POC_DISPLAY display_update_state("trying wifi 1"); + #endif Serial.println("connecting to WiFi 1"); WiFi.begin(globcfg.wifi1_ssid, globcfg.wifi1_pass); while ((WiFi.status() != WL_CONNECTED) && (millis() < 10000)) @@ -99,7 +111,9 @@ void setup_network() } if (wifi2valid) { + #ifdef SMART_POC_DISPLAY display_update_state("trying wifi 2"); + #endif Serial.println("connecting to WiFi 2"); WiFi.begin(globcfg.wifi2_ssid, globcfg.wifi2_pass); while ((WiFi.status() != WL_CONNECTED) && (millis() < 22000)) @@ -115,7 +129,9 @@ void setup_network() } } // + #ifdef SMART_POC_DISPLAY display_update_state("init hotspot mode"); + #endif Serial.println("wifi failed to connect, going AP"); WiFi.mode(WIFI_AP); WiFi.softAP(globcfg.ap_ssid, globcfg.ap_pass); @@ -141,7 +157,9 @@ void setup_mqtt() return; } // if we should not do this mqttClient.setServer(globcfg.mqtt_host, globcfg.mqtt_port); + #ifdef SMART_POC_DISPLAY display_update_state("connecting to MQTT"); + #endif Serial.printf("connecting to mqtt %s\n", globcfg.mqtt_host); if (mqttClient.connect(globcfg.mqtt_user, globcfg.mqtt_user, globcfg.mqtt_pass)) { @@ -239,7 +257,9 @@ void serlog_loop(bool tx_state) { void loop() { bool tx_state = transmitter.isActive(); + #ifdef SMART_POC_DISPLAY display_loop(tx_state, &transmitter, &globcfg, timeString); + #endif if (old_tx_state == true && tx_state == false && globcfg.tx_empty_queue) txControllerBatchClear(); //