kopia lustrzana https://github.com/meshtastic/firmware
				
				
				
			WIP kinda works but light sleep still busted
							rodzic
							
								
									c7894f3bc5
								
							
						
					
					
						commit
						fe2ca65a11
					
				|  | @ -49,7 +49,7 @@ off during light sleep, but there is a TODO item to fix this. | |||
| * While in ON: If PRESS event occurs, reset screen_on_secs timer and tell the screen to handle the pess | ||||
| * While in ON: If it has been more than screen_on_secs since a press, lower to DARK | ||||
| * While in DARK: If time since last contact by our phone exceeds phone_timeout_secs (15 minutes), we transition down into NB mode | ||||
| * While in DARK or NB: If nothing above is forcing us to stay in a higher mode (wait_bluetooth_secs, min_wake_secs) we will lower down | ||||
| * While in DARK or NB: If nothing above is forcing us to stay in a higher mode (wait_bluetooth_secs, min_wake_secs) we will lower down to LS state | ||||
| into either LS or SDS levels.  If either phone_sds_timeout_secs (default 1 hr) or mesh_sds_timeout_secs (default 1 hr) are exceeded we will lower into SDS mode for sds_secs (default 1 hr) (or a button press).  Otherwise we will lower into LS mode for ls_secs (default 1 hr) (or until an interrupt, button press) | ||||
| 
 | ||||
| TODO: Eventually these scheduled intervals should be synchronized to the GPS clock, so that we can consider leaving the lora receiver off to save even more power. | ||||
|  |  | |||
|  | @ -49,14 +49,6 @@ void NodeDB::init() | |||
|     devicestate.node_db_count = 0; | ||||
|     devicestate.receive_queue_count = 0; | ||||
| 
 | ||||
|     radioConfig.preferences.send_owner_interval = 4; // per sw-design.md
 | ||||
|     radioConfig.preferences.position_broadcast_secs = 20; // 15 * 60;
 | ||||
|     radioConfig.preferences.wait_bluetooth_secs = 10; // 30;
 | ||||
|     radioConfig.preferences.screen_on_secs = 30; | ||||
|     radioConfig.preferences.mesh_sds_timeout_secs = 60 * 60; | ||||
|     radioConfig.preferences.phone_sds_timeout_sec = 60 * 60; | ||||
|     radioConfig.preferences.sds_secs = 60 * 60; | ||||
| 
 | ||||
| #ifdef GPS_RX_PIN | ||||
|     // some hardware defaults to have a built in GPS
 | ||||
|     myNodeInfo.has_gps = true; | ||||
|  | @ -92,6 +84,17 @@ void NodeDB::init() | |||
|     loadFromDisk(); | ||||
| 
 | ||||
|     DEBUG_MSG("NODENUM=0x%x, dbsize=%d\n", myNodeInfo.my_node_num, *numNodes); | ||||
| 
 | ||||
|     // FIXME - move above
 | ||||
|     radioConfig.preferences.send_owner_interval = 4; // per sw-design.md
 | ||||
|     radioConfig.preferences.position_broadcast_secs = 20; // 15 * 60;
 | ||||
|     radioConfig.preferences.wait_bluetooth_secs = 10; // 30;
 | ||||
|     radioConfig.preferences.screen_on_secs = 30; | ||||
|     radioConfig.preferences.mesh_sds_timeout_secs = 60 * 60; | ||||
|     radioConfig.preferences.phone_sds_timeout_sec = 60 * 60; | ||||
|     radioConfig.preferences.sds_secs = 60 * 60; | ||||
|     radioConfig.preferences.ls_secs = 60 * 60; | ||||
|     radioConfig.preferences.phone_timeout_secs = 15 * 60; | ||||
| } | ||||
| 
 | ||||
| // We reserve a few nodenums for future use
 | ||||
|  |  | |||
|  | @ -57,7 +57,6 @@ static void nbEnter() | |||
| 
 | ||||
| static void darkEnter() | ||||
| { | ||||
|     DEBUG_MSG("screen timeout, turn it off for now...\n"); | ||||
|     screen.setOn(false); | ||||
| } | ||||
| 
 | ||||
|  | @ -92,6 +91,7 @@ void PowerFSM_setup() | |||
|     powerFSM.add_transition(&stateDARK, &stateON, EVENT_BOOT, NULL, "Boot"); | ||||
|     powerFSM.add_transition(&stateLS, &stateDARK, EVENT_WAKE_TIMER, wakeForPing, "Wake timer"); | ||||
|     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, &stateON, EVENT_PRESS, NULL, "Press"); | ||||
|     powerFSM.add_transition(&stateNB, &stateON, EVENT_PRESS, NULL, "Press"); | ||||
|  | @ -104,9 +104,13 @@ void PowerFSM_setup() | |||
| 
 | ||||
|     powerFSM.add_transition(&stateNB, &stateDARK, EVENT_PACKET_FOR_PHONE, NULL, "Packet for phone"); | ||||
| 
 | ||||
|     powerFSM.add_timed_transition(&stateON, &stateDARK, radioConfig.preferences.screen_on_secs, NULL, "Screen-on timeout"); | ||||
|     powerFSM.add_timed_transition(&stateON, &stateDARK, radioConfig.preferences.screen_on_secs * 1000, NULL, "Screen-on timeout"); | ||||
| 
 | ||||
|     powerFSM.add_timed_transition(&stateDARK, &stateNB, radioConfig.preferences.phone_timeout_secs, NULL, "Phone timeout"); | ||||
|     powerFSM.add_timed_transition(&stateDARK, &stateNB, radioConfig.preferences.phone_timeout_secs * 1000, NULL, "Phone timeout"); | ||||
| 
 | ||||
|     powerFSM.add_timed_transition(&stateNB, &stateLS, radioConfig.preferences.min_wake_secs * 1000, NULL, "Min wake timeout"); | ||||
| 
 | ||||
|     powerFSM.add_timed_transition(&stateDARK, &stateLS, radioConfig.preferences.wait_bluetooth_secs * 1000, NULL, "Bluetooth timeout"); | ||||
| 
 | ||||
|     powerFSM.run_machine(); // run one interation of the state machine, so we run our on enter tasks for the initial DARK state
 | ||||
| } | ||||
|  | @ -43,8 +43,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. | |||
| 
 | ||||
| // Select which board is being used. If the outside build environment has sent a choice, just use that
 | ||||
| #if !defined(T_BEAM_V10) && !defined(HELTEC_LORA32) | ||||
| #define T_BEAM_V10  // AKA Rev1 (second board released)
 | ||||
| //#define HELTEC_LORA32
 | ||||
| //#define T_BEAM_V10  // AKA Rev1 (second board released)
 | ||||
| #define HELTEC_LORA32 | ||||
| 
 | ||||
| #define HW_VERSION_US // We encode the hardware freq range in the hw version string, so sw update can eventually install the correct build
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -339,7 +339,8 @@ void loop() | |||
|   static bool wasPressed = false; | ||||
|   static uint32_t minPressMs; // what tick should we call this press long enough
 | ||||
|   static uint32_t lastPingMs; | ||||
|   if (!digitalRead(BUTTON_PIN)) | ||||
| 
 | ||||
|   if (!digitalRead(BUTTON_PIN))  | ||||
|   { | ||||
|     if (!wasPressed) | ||||
|     { // just started a new press
 | ||||
|  | @ -373,7 +374,7 @@ void loop() | |||
|       // ESP.restart();
 | ||||
|     } | ||||
|   } | ||||
| #endif | ||||
|   #endif | ||||
| 
 | ||||
|   // No GPS lock yet, let the OS put the main CPU in low power mode for 100ms (or until another interrupt comes in)
 | ||||
|   // i.e. don't just keep spinning in loop as fast as we can.
 | ||||
|  |  | |||
|  | @ -78,6 +78,7 @@ typedef struct _RadioConfig_UserPreferences { | |||
|     uint32_t mesh_sds_timeout_secs; | ||||
|     uint32_t sds_secs; | ||||
|     uint32_t ls_secs; | ||||
|     uint32_t min_wake_secs; | ||||
|     bool keep_all_packets; | ||||
|     bool promiscuous_mode; | ||||
| } RadioConfig_UserPreferences; | ||||
|  | @ -182,7 +183,7 @@ typedef struct _ToRadio { | |||
| #define MeshPacket_init_default                  {0, 0, false, SubPacket_init_default, 0} | ||||
| #define ChannelSettings_init_default             {0, 0, _ChannelSettings_ModemConfig_MIN, {0}, ""} | ||||
| #define RadioConfig_init_default                 {false, RadioConfig_UserPreferences_init_default, false, ChannelSettings_init_default} | ||||
| #define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | ||||
| #define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | ||||
| #define NodeInfo_init_default                    {0, false, User_init_default, false, Position_init_default, 0, 0} | ||||
| #define MyNodeInfo_init_default                  {0, 0, 0} | ||||
| #define DeviceState_init_default                 {false, RadioConfig_init_default, false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default}, _DeviceState_Version_MIN, false, MeshPacket_init_default} | ||||
|  | @ -195,7 +196,7 @@ typedef struct _ToRadio { | |||
| #define MeshPacket_init_zero                     {0, 0, false, SubPacket_init_zero, 0} | ||||
| #define ChannelSettings_init_zero                {0, 0, _ChannelSettings_ModemConfig_MIN, {0}, ""} | ||||
| #define RadioConfig_init_zero                    {false, RadioConfig_UserPreferences_init_zero, false, ChannelSettings_init_zero} | ||||
| #define RadioConfig_UserPreferences_init_zero    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | ||||
| #define RadioConfig_UserPreferences_init_zero    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | ||||
| #define NodeInfo_init_zero                       {0, false, User_init_zero, false, Position_init_zero, 0, 0} | ||||
| #define MyNodeInfo_init_zero                     {0, 0, 0} | ||||
| #define DeviceState_init_zero                    {false, RadioConfig_init_zero, false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero}, _DeviceState_Version_MIN, false, MeshPacket_init_zero} | ||||
|  | @ -229,6 +230,7 @@ typedef struct _ToRadio { | |||
| #define RadioConfig_UserPreferences_mesh_sds_timeout_secs_tag 8 | ||||
| #define RadioConfig_UserPreferences_sds_secs_tag 9 | ||||
| #define RadioConfig_UserPreferences_ls_secs_tag  10 | ||||
| #define RadioConfig_UserPreferences_min_wake_secs_tag 11 | ||||
| #define RadioConfig_UserPreferences_keep_all_packets_tag 100 | ||||
| #define RadioConfig_UserPreferences_promiscuous_mode_tag 101 | ||||
| #define User_id_tag                              1 | ||||
|  | @ -334,6 +336,7 @@ X(a, STATIC,   SINGULAR, UINT32,   phone_sds_timeout_sec,   7) \ | |||
| X(a, STATIC,   SINGULAR, UINT32,   mesh_sds_timeout_secs,   8) \ | ||||
| X(a, STATIC,   SINGULAR, UINT32,   sds_secs,          9) \ | ||||
| X(a, STATIC,   SINGULAR, UINT32,   ls_secs,          10) \ | ||||
| X(a, STATIC,   SINGULAR, UINT32,   min_wake_secs,    11) \ | ||||
| X(a, STATIC,   SINGULAR, BOOL,     keep_all_packets, 100) \ | ||||
| X(a, STATIC,   SINGULAR, BOOL,     promiscuous_mode, 101) | ||||
| #define RadioConfig_UserPreferences_CALLBACK NULL | ||||
|  | @ -423,11 +426,11 @@ extern const pb_msgdesc_t ToRadio_msg; | |||
| #define SubPacket_size                           261 | ||||
| #define MeshPacket_size                          292 | ||||
| #define ChannelSettings_size                     50 | ||||
| #define RadioConfig_size                         120 | ||||
| #define RadioConfig_UserPreferences_size         66 | ||||
| #define RadioConfig_size                         126 | ||||
| #define RadioConfig_UserPreferences_size         72 | ||||
| #define NodeInfo_size                            157 | ||||
| #define MyNodeInfo_size                          24 | ||||
| #define DeviceState_size                         15079 | ||||
| #define DeviceState_size                         15085 | ||||
| #define FromRadio_size                           301 | ||||
| #define ToRadio_size                             295 | ||||
| 
 | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 geeksville
						geeksville