diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index 38b2672b9..b724f445c 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -235,9 +235,8 @@ void PowerFSM_setup() powerFSM.add_transition(&stateLS, isRouter ? &stateNB : &stateDARK, EVENT_WAKE_TIMER, NULL, "Wake timer"); // We need this transition, because we might not transition if we were waiting to enter light-sleep, because when we wake from light sleep we _always_ transition to NB or dark and - powerFSM.add_transition(&stateLS, &stateNB, EVENT_RECEIVED_PACKET, NULL, "Received packet"); - - powerFSM.add_transition(&stateNB, &stateNB, EVENT_RECEIVED_PACKET, NULL, "Received packet, resetting win wake"); + powerFSM.add_transition(&stateLS, isRouter ? &stateNB : &stateDARK, EVENT_PACKET_FOR_PHONE, NULL, "Received packet, exiting light sleep"); + powerFSM.add_transition(&stateNB, &stateNB, EVENT_PACKET_FOR_PHONE, NULL, "Received packet, resetting win wake"); // Handle press events - note: we ignore button presses when in API mode powerFSM.add_transition(&stateLS, &stateON, EVENT_PRESS, NULL, "Press"); @@ -261,6 +260,9 @@ void PowerFSM_setup() // if we are a router we don't turn the screen on for these things if (!isRouter) { + // if any packet destined for phone arrives, turn on bluetooth at least + powerFSM.add_transition(&stateNB, &stateDARK, EVENT_PACKET_FOR_PHONE, NULL, "Packet for phone"); + // show the latest node when we get a new node db update powerFSM.add_transition(&stateNB, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update"); powerFSM.add_transition(&stateDARK, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update"); @@ -300,8 +302,6 @@ void PowerFSM_setup() powerFSM.add_transition(&stateDARK, &stateON, EVENT_FIRMWARE_UPDATE, NULL, "Got firmware update"); powerFSM.add_transition(&stateON, &stateON, EVENT_FIRMWARE_UPDATE, NULL, "Got firmware update"); - powerFSM.add_transition(&stateNB, &stateDARK, EVENT_PACKET_FOR_PHONE, NULL, "Packet for phone"); - powerFSM.add_timed_transition(&stateON, &stateDARK, getPref_screen_on_secs() * 1000, NULL, "Screen-on timeout"); // On most boards we use light-sleep to be our main state, but on NRF52 we just stay in DARK diff --git a/src/PowerFSM.h b/src/PowerFSM.h index e48b55d87..5541385a3 100644 --- a/src/PowerFSM.h +++ b/src/PowerFSM.h @@ -6,7 +6,7 @@ #define EVENT_PRESS 1 #define EVENT_WAKE_TIMER 2 -#define EVENT_RECEIVED_PACKET 3 +// #define EVENT_RECEIVED_PACKET 3 #define EVENT_PACKET_FOR_PHONE 4 #define EVENT_RECEIVED_TEXT_MSG 5 // #define EVENT_BOOT 6 // now done with a timed transition diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index fbc4031b1..c88650309 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -66,7 +66,7 @@ void MeshService::init() int MeshService::handleFromRadio(const MeshPacket *mp) { - powerFSM.trigger(EVENT_RECEIVED_PACKET); // Possibly keep the node from sleeping + powerFSM.trigger(EVENT_PACKET_FOR_PHONE); // Possibly keep the node from sleeping printPacket("Forwarding to phone", mp); nodeDB.updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio