kopia lustrzana https://github.com/meshtastic/firmware
sleep for a very long time, because the lorawan32 board doesn't have an off switch
rodzic
2474b3b064
commit
02ed249374
2
TODO.md
2
TODO.md
|
@ -18,7 +18,7 @@
|
||||||
* use a freertos thread to remain blocked reading from recvfromAckTimeout, so that we don't need to keep polling it from our main thread
|
* use a freertos thread to remain blocked reading from recvfromAckTimeout, so that we don't need to keep polling it from our main thread
|
||||||
* override peekAtMessage so we can see any messages that pass through our node (even if not broadcast)? would that be useful?
|
* override peekAtMessage so we can see any messages that pass through our node (even if not broadcast)? would that be useful?
|
||||||
* sendToMesh can currently block for a long time, instead have it just queue a packet for a radio freertos thread
|
* sendToMesh can currently block for a long time, instead have it just queue a packet for a radio freertos thread
|
||||||
|
* see section 7.3 of https://cdn.sparkfun.com/assets/learn_tutorials/8/0/4/RFM95_96_97_98W.pdf and have hope radio wake only when a valid packet is received. Possibly even wake the ESP32 from deep sleep via GPIO.
|
||||||
* fix the logo
|
* fix the logo
|
||||||
|
|
||||||
# Pre-beta priority
|
# Pre-beta priority
|
||||||
|
|
|
@ -22,6 +22,9 @@ public:
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
|
/// Prepare the radio to enter sleep mode, where it should draw only 0.2 uA
|
||||||
|
void sleep() { rf95.sleep(); }
|
||||||
|
|
||||||
/// Send a packet - the current implementation blocks for a while possibly (FIXME)
|
/// Send a packet - the current implementation blocks for a while possibly (FIXME)
|
||||||
ErrorCode sendTo(NodeNum dest, const uint8_t *buf, size_t len);
|
ErrorCode sendTo(NodeNum dest, const uint8_t *buf, size_t len);
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#define DEBUG_PORT Serial // Serial debug port
|
#define DEBUG_PORT Serial // Serial debug port
|
||||||
#define SERIAL_BAUD 115200 // Serial debug baud rate
|
#define SERIAL_BAUD 115200 // Serial debug baud rate
|
||||||
#define SLEEP_MSECS (5 * 60 * 1000) // Sleep for these many millis (or a button press or a lora msg?)
|
#define SLEEP_MSECS (24 * 60 * 60 * 1000) // Sleep for these many millis (or a button press or a lora msg?)
|
||||||
#define MESSAGE_TO_SLEEP_DELAY 5000 // Time after message before going to sleep
|
#define MESSAGE_TO_SLEEP_DELAY 5000 // Time after message before going to sleep
|
||||||
#define LOGO_DELAY 5000 // Time to show logo on first boot
|
#define LOGO_DELAY 5000 // Time to show logo on first boot
|
||||||
#define REQUIRE_RADIO true // If true, we will fail to start if the radio is not found
|
#define REQUIRE_RADIO true // If true, we will fail to start if the radio is not found
|
||||||
|
@ -129,9 +129,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define BUTTON_PIN 0
|
#define BUTTON_PIN 0
|
||||||
|
|
||||||
#define RESET_GPIO 14
|
#define RESET_GPIO 14
|
||||||
#define DIO0_GPIO 34
|
#define DIO0_GPIO 26
|
||||||
#define DIO1_GPIO 35
|
#define DIO1_GPIO 35
|
||||||
#define DIO2_GPIO 32 // Note: not really used on this board
|
#define DIO2_GPIO 34
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
24
src/main.ino
24
src/main.ino
|
@ -60,6 +60,9 @@ void doDeepSleep(uint64_t msecToWake)
|
||||||
|
|
||||||
// FIXME, shutdown radiohead interrupts before powering off device
|
// FIXME, shutdown radiohead interrupts before powering off device
|
||||||
|
|
||||||
|
// Put radio in sleep mode (will still draw power but only 0.2uA)
|
||||||
|
radio.sleep();
|
||||||
|
|
||||||
#ifdef T_BEAM_V10
|
#ifdef T_BEAM_V10
|
||||||
if (axp192_found)
|
if (axp192_found)
|
||||||
{
|
{
|
||||||
|
@ -316,7 +319,7 @@ void loop()
|
||||||
#ifdef LED_PIN
|
#ifdef LED_PIN
|
||||||
// toggle the led so we can get some rough sense of how often loop is pausing
|
// toggle the led so we can get some rough sense of how often loop is pausing
|
||||||
digitalWrite(LED_PIN, digitalRead(LED_PIN) ? 0 : 1);
|
digitalWrite(LED_PIN, digitalRead(LED_PIN) ? 0 : 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BUTTON_PIN
|
#ifdef BUTTON_PIN
|
||||||
// if user presses button for more than 3 secs, discard our network prefs and reboot (FIXME, use a debounce lib instead of this boilerplate)
|
// if user presses button for more than 3 secs, discard our network prefs and reboot (FIXME, use a debounce lib instead of this boilerplate)
|
||||||
|
@ -345,19 +348,14 @@ void loop()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Send every SEND_INTERVAL millis
|
|
||||||
static uint32_t last = 0;
|
|
||||||
if (true)
|
|
||||||
{
|
|
||||||
#ifdef MINWAKE_MSECS
|
#ifdef MINWAKE_MSECS
|
||||||
if (millis() > MINWAKE_MSECS)
|
if (millis() > MINWAKE_MSECS)
|
||||||
{
|
{
|
||||||
sleep();
|
sleep();
|
||||||
}
|
}
|
||||||
#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)
|
// 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.
|
// i.e. don't just keep spinning in loop as fast as we can.
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
|
||||||
}
|
}
|
Ładowanie…
Reference in New Issue