diff --git a/platformio.ini b/platformio.ini index 279e5e46..4e3045c2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -70,7 +70,7 @@ lib_deps = https://github.com/meshtastic/esp8266-oled-ssd1306.git#35d796226b853b0c0ff818b2f1aa3d35e7296a96 ; ESP8266_SSD1306 https://github.com/geeksville/OneButton.git ; OneButton library for non-blocking button debounce 1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib - https://github.com/meshtastic/arduino-fsm.git#829e967b8a95c094f73c60ef8dacfe66eae38940 + https://github.com/meshtastic/arduino-fsm.git https://github.com/meshtastic/SparkFun_Ublox_Arduino_Library.git#31015a55e630a2df77d9d714669c621a5bf355ad https://github.com/meshtastic/RadioLib.git#80ed10d689a0568782c5bd152906b0f97d2bce93 https://github.com/meshtastic/TinyGPSPlus.git#f0f47067ef2f67c856475933188251c1ef615e79 diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index 3412bdf3..38b2672b 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -27,6 +27,7 @@ static bool isPowered() static void sdsEnter() { + DEBUG_MSG("Enter state: SDS\n"); // FIXME - make sure GPS and LORA radio are off first - because we want close to zero current draw doDeepSleep(getPref_sds_secs() * 1000LL); } @@ -112,6 +113,7 @@ static void lsIdle() static void lsExit() { + DEBUG_MSG("Exit state: LS\n"); // setGPSPower(true); // restore GPS power if (gps) gps->forceWake(true); @@ -119,6 +121,7 @@ static void lsExit() static void nbEnter() { + DEBUG_MSG("Enter state: NB\n"); screen->setOn(false); setBluetoothEnable(false); @@ -133,6 +136,7 @@ static void darkEnter() static void serialEnter() { + DEBUG_MSG("Enter state: SERIAL\n"); setBluetoothEnable(false); screen->setOn(true); screen->print("Serial connected\n"); @@ -145,6 +149,7 @@ static void serialExit() static void powerEnter() { + DEBUG_MSG("Enter state: POWER\n"); if (!isPowered()) { // If we got here, we are in the wrong state - we should be in powered, let that state ahndle things DEBUG_MSG("Loss of power in Powered\n"); @@ -174,6 +179,7 @@ static void powerExit() static void onEnter() { + DEBUG_MSG("Enter state: ON\n"); screen->setOn(true); setBluetoothEnable(true); @@ -202,7 +208,9 @@ static void screenPress() screen->onPress(); } -static void bootEnter() {} +static void bootEnter() { + DEBUG_MSG("Enter state: BOOT\n"); +} State stateSDS(sdsEnter, NULL, NULL, "SDS"); State stateLS(lsEnter, lsIdle, lsExit, "LS"); diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 4b4d3a0c..7e92919f 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -4,6 +4,7 @@ #include "mesh/Channels.h" #include "mesh/Router.h" #include "mesh/generated/mqtt.pb.h" +#include "PowerFSM.h" #include "sleep.h" #include #include @@ -59,7 +60,7 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), pubSub(mqttClient) pubSub.setCallback(mqttCallback); - preflightSleepObserver.observe(&preflightSleep); + // preflightSleepObserver.observe(&preflightSleep); } void MQTT::reconnect() @@ -151,6 +152,7 @@ int32_t MQTT::runOnce() pubSub.disconnect(); } + powerFSM.trigger(EVENT_CONTACT_FROM_PHONE); // Suppress entering light sleep (because that would turn off bluetooth) return 20; } } diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h index fd02db61..f5ef9bf1 100644 --- a/src/mqtt/MQTT.h +++ b/src/mqtt/MQTT.h @@ -19,8 +19,8 @@ class MQTT : private concurrency::OSThread WiFiClient mqttClient; PubSubClient pubSub; - CallbackObserver preflightSleepObserver = - CallbackObserver(this, &MQTT::preflightSleepCb); + // instead we supress sleep from our runOnce() callback + // CallbackObserver preflightSleepObserver = CallbackObserver(this, &MQTT::preflightSleepCb); public: MQTT(); @@ -58,7 +58,7 @@ class MQTT : private concurrency::OSThread void onPublish(char *topic, byte *payload, unsigned int length); /// Return 0 if sleep is okay, veto sleep if we are connected to pubsub server - int preflightSleepCb(void *unused = NULL) { return pubSub.connected() ? 1 : 0; } + // int preflightSleepCb(void *unused = NULL) { return pubSub.connected() ? 1 : 0; } }; void mqttInit();