lots of changes:

* preflightSleep, notifySleep, notifyDeepSleep now allow arbitrary
drivers/devices/software to register for sleep notification.
* Use the proceeding to clean up MeshRadio - now the mesh radio is more
like an independent driver that doesn't care so much about other systems
* clean up MeshService so that it can work with zero MeshRadios added.
This is a prelude to supporting boards with multiple interfaces (wifi,
extra LORA radios etc) and allows development/testing in sim with a bare
ESP32 board
* Remove remaining ESP32 dependencies from the bare simulation target
this allows running on anything that implements the arduino API
This commit is contained in:
geeksville
2020-04-14 11:40:49 -07:00
parent ac7f3cd603
commit 4757b6807e
9 changed files with 147 additions and 65 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include "Arduino.h"
#include "Observer.h"
#include "esp_sleep.h"
void doDeepSleep(uint64_t msecToWake);
@@ -17,4 +18,13 @@ extern int bootCount;
extern esp_sleep_source_t wakeCause;
// is bluetooth sw currently running?
extern bool bluetoothOn;
extern bool bluetoothOn;
/// Called to ask any observers if they want to veto sleep. Return 1 to veto or 0 to allow sleep to happen
extern Observable<void *> preflightSleep;
/// Called to tell observers we are now entering (light or deep) sleep and you should prepare. Must return 0
extern Observable<void *> notifySleep;
/// Called to tell observers we are now entering (deep) sleep and you should prepare. Must return 0
extern Observable<void *> notifyDeepSleep;