mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-17 18:53:30 +00:00
commit
cb2aa3b29f
@ -59,8 +59,6 @@ Needed to be fully functional at least at the same level of the ESP32 boards. At
|
|||||||
|
|
||||||
Nice ideas worth considering someday...
|
Nice ideas worth considering someday...
|
||||||
|
|
||||||
- Use flego to me an iOS/linux app? https://felgo.com/doc/qt/qtbluetooth-index/ or
|
|
||||||
- Use flutter to make an iOS/linux app? https://github.com/Polidea/FlutterBleLib
|
|
||||||
- enable monitor mode debugging (need to use real jlink): https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/monitor-mode-debugging-with-j-link-and-gdbeclipse
|
- enable monitor mode debugging (need to use real jlink): https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/monitor-mode-debugging-with-j-link-and-gdbeclipse
|
||||||
- Improve efficiency of PeriodicTimer by only checking the next queued timer event, and carefully sorting based on schedule
|
- Improve efficiency of PeriodicTimer by only checking the next queued timer event, and carefully sorting based on schedule
|
||||||
- make a Mfg Controller and device under test classes as examples of custom app code for third party devs. Make a post about this. Use a custom payload type code. Have device under test send a broadcast with max hopcount of 0 for the 'mfgcontroller' payload type. mfg controller will read SNR and reply. DOT will declare failure/success and switch to the regular app screen.
|
- make a Mfg Controller and device under test classes as examples of custom app code for third party devs. Make a post about this. Use a custom payload type code. Have device under test send a broadcast with max hopcount of 0 for the 'mfgcontroller' payload type. mfg controller will read SNR and reply. DOT will declare failure/success and switch to the regular app screen.
|
||||||
|
@ -26,60 +26,70 @@ static void sdsEnter()
|
|||||||
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
|
static uint32_t secsSlept;
|
||||||
|
|
||||||
static void lsEnter()
|
static void lsEnter()
|
||||||
{
|
{
|
||||||
DEBUG_MSG("lsEnter begin, ls_secs=%u\n", radioConfig.preferences.ls_secs);
|
DEBUG_MSG("lsEnter begin, ls_secs=%u\n", radioConfig.preferences.ls_secs);
|
||||||
screen.setOn(false);
|
screen.setOn(false);
|
||||||
|
secsSlept = 0; // How long have we been sleeping this time
|
||||||
|
|
||||||
DEBUG_MSG("lsEnter end\n");
|
DEBUG_MSG("lsEnter end\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lsIdle()
|
static void lsIdle()
|
||||||
{
|
{
|
||||||
DEBUG_MSG("lsIdle begin ls_secs=%u\n", radioConfig.preferences.ls_secs);
|
// DEBUG_MSG("lsIdle begin ls_secs=%u\n", radioConfig.preferences.ls_secs);
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
uint32_t secsSlept = 0;
|
|
||||||
esp_sleep_source_t wakeCause = ESP_SLEEP_WAKEUP_UNDEFINED;
|
esp_sleep_source_t wakeCause = ESP_SLEEP_WAKEUP_UNDEFINED;
|
||||||
bool reached_ls_secs = false;
|
|
||||||
|
|
||||||
while (!reached_ls_secs) {
|
// Do we have more sleeping to do?
|
||||||
|
if (secsSlept < radioConfig.preferences.ls_secs) {
|
||||||
// Briefly come out of sleep long enough to blink the led once every few seconds
|
// Briefly come out of sleep long enough to blink the led once every few seconds
|
||||||
uint32_t sleepTime = 5;
|
uint32_t sleepTime = 30;
|
||||||
|
|
||||||
setLed(false); // Never leave led on while in light sleep
|
// If some other service would stall sleep, don't let sleep happen yet
|
||||||
wakeCause = doLightSleep(sleepTime * 1000LL);
|
if (doPreflightSleep()) {
|
||||||
if (wakeCause != ESP_SLEEP_WAKEUP_TIMER)
|
setLed(false); // Never leave led on while in light sleep
|
||||||
break;
|
wakeCause = doLightSleep(sleepTime * 1000LL);
|
||||||
|
|
||||||
setLed(true); // briefly turn on led
|
if (wakeCause == ESP_SLEEP_WAKEUP_TIMER) {
|
||||||
doLightSleep(1);
|
// Normal case: timer expired, we should just go back to sleep ASAP
|
||||||
if (wakeCause != ESP_SLEEP_WAKEUP_TIMER)
|
|
||||||
break;
|
|
||||||
|
|
||||||
secsSlept += sleepTime;
|
setLed(true); // briefly turn on led
|
||||||
reached_ls_secs = secsSlept >= radioConfig.preferences.ls_secs;
|
wakeCause = doLightSleep(1); // leave led on for 1ms
|
||||||
}
|
|
||||||
setLed(false);
|
|
||||||
|
|
||||||
if (reached_ls_secs) {
|
secsSlept += sleepTime;
|
||||||
// stay in LS mode but let loop check whatever it wants
|
// DEBUG_MSG("sleeping, flash led!\n");
|
||||||
DEBUG_MSG("reached ls_secs, servicing loop()\n");
|
}
|
||||||
} else {
|
if (wakeCause == ESP_SLEEP_WAKEUP_UART) {
|
||||||
DEBUG_MSG("wakeCause %d\n", wakeCause);
|
// Not currently used (because uart triggers in hw have problems)
|
||||||
|
powerFSM.trigger(EVENT_SERIAL_CONNECTED);
|
||||||
|
} else {
|
||||||
|
// We woke for some other reason (button press, uart, device interrupt)
|
||||||
|
//uint64_t status = esp_sleep_get_ext1_wakeup_status();
|
||||||
|
DEBUG_MSG("wakeCause %d\n", wakeCause);
|
||||||
|
|
||||||
#ifdef BUTTON_PIN
|
#ifdef BUTTON_PIN
|
||||||
bool pressed = !digitalRead(BUTTON_PIN);
|
bool pressed = !digitalRead(BUTTON_PIN);
|
||||||
#else
|
#else
|
||||||
bool pressed = false;
|
bool pressed = false;
|
||||||
#endif
|
#endif
|
||||||
if (pressed) // If we woke because of press, instead generate a PRESS event.
|
if (pressed) // If we woke because of press, instead generate a PRESS event.
|
||||||
{
|
{
|
||||||
powerFSM.trigger(EVENT_PRESS);
|
powerFSM.trigger(EVENT_PRESS);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise let the NB state handle the IRQ (and that state will handle stuff like IRQs etc)
|
// Otherwise let the NB state handle the IRQ (and that state will handle stuff like IRQs etc)
|
||||||
powerFSM.trigger(EVENT_WAKE_TIMER);
|
powerFSM.trigger(EVENT_WAKE_TIMER);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Time to stop sleeping!
|
||||||
|
setLed(false);
|
||||||
|
DEBUG_MSG("reached ls_secs, servicing loop()\n");
|
||||||
|
powerFSM.trigger(EVENT_WAKE_TIMER);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#ifdef NO_ESP32
|
#ifdef NO_ESP32
|
||||||
#define USE_SEGGER
|
#define USE_SEGGER
|
||||||
|
#else
|
||||||
|
#define SERIAL0_RX_GPIO 3 // Always GPIO3 on ESP32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_SEGGER
|
#ifdef USE_SEGGER
|
||||||
#include "SEGGER_RTT.h"
|
#include "SEGGER_RTT.h"
|
||||||
#define DEBUG_MSG(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
#define DEBUG_MSG(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
||||||
|
@ -124,7 +124,7 @@ void NodeDB::init()
|
|||||||
// default to no GPS, until one has been found by probing
|
// default to no GPS, until one has been found by probing
|
||||||
myNodeInfo.has_gps = false;
|
myNodeInfo.has_gps = false;
|
||||||
myNodeInfo.message_timeout_msec = FLOOD_EXPIRE_TIME;
|
myNodeInfo.message_timeout_msec = FLOOD_EXPIRE_TIME;
|
||||||
myNodeInfo.min_app_version = 167;
|
myNodeInfo.min_app_version = 172;
|
||||||
generatePacketId(); // FIXME - ugly way to init current_packet_id;
|
generatePacketId(); // FIXME - ugly way to init current_packet_id;
|
||||||
|
|
||||||
// Init our blank owner info to reasonable defaults
|
// Init our blank owner info to reasonable defaults
|
||||||
|
@ -24,7 +24,7 @@ separated by 2.16 MHz with respect to the adjacent channels. Channel zero starts
|
|||||||
// 1kb was too small
|
// 1kb was too small
|
||||||
#define RADIO_STACK_SIZE 4096
|
#define RADIO_STACK_SIZE 4096
|
||||||
|
|
||||||
RadioInterface::RadioInterface() : txQueue(MAX_TX_QUEUE)
|
RadioInterface::RadioInterface()
|
||||||
{
|
{
|
||||||
assert(sizeof(PacketHeader) == 4 || sizeof(PacketHeader) == 16); // make sure the compiler did what we expected
|
assert(sizeof(PacketHeader) == 4 || sizeof(PacketHeader) == 16); // make sure the compiler did what we expected
|
||||||
|
|
||||||
|
@ -59,7 +59,6 @@ class RadioInterface : protected NotifiedWorkerThread
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
MeshPacket *sendingPacket = NULL; // The packet we are currently sending
|
MeshPacket *sendingPacket = NULL; // The packet we are currently sending
|
||||||
PointerQueue<MeshPacket> txQueue;
|
|
||||||
uint32_t lastTxStart = 0L;
|
uint32_t lastTxStart = 0L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,7 +134,7 @@ bool RadioLibInterface::canSleep()
|
|||||||
{
|
{
|
||||||
bool res = txQueue.isEmpty();
|
bool res = txQueue.isEmpty();
|
||||||
if (!res) // only print debug messages if we are vetoing sleep
|
if (!res) // only print debug messages if we are vetoing sleep
|
||||||
DEBUG_MSG("radio wait to sleep, txEmpty=%d\n", txQueue.isEmpty());
|
DEBUG_MSG("radio wait to sleep, txEmpty=%d\n", res);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -173,11 +173,13 @@ void RadioLibInterface::loop()
|
|||||||
case ISR_TX:
|
case ISR_TX:
|
||||||
handleTransmitInterrupt();
|
handleTransmitInterrupt();
|
||||||
startReceive();
|
startReceive();
|
||||||
|
// DEBUG_MSG("tx complete - starting timer\n");
|
||||||
startTransmitTimer();
|
startTransmitTimer();
|
||||||
break;
|
break;
|
||||||
case ISR_RX:
|
case ISR_RX:
|
||||||
handleReceiveInterrupt();
|
handleReceiveInterrupt();
|
||||||
startReceive();
|
startReceive();
|
||||||
|
// DEBUG_MSG("rx complete - starting timer\n");
|
||||||
startTransmitTimer();
|
startTransmitTimer();
|
||||||
break;
|
break;
|
||||||
case TRANSMIT_DELAY_COMPLETED:
|
case TRANSMIT_DELAY_COMPLETED:
|
||||||
@ -192,6 +194,8 @@ void RadioLibInterface::loop()
|
|||||||
assert(txp);
|
assert(txp);
|
||||||
startSend(txp);
|
startSend(txp);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// DEBUG_MSG("done with txqueue\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -216,7 +220,7 @@ void RadioLibInterface::startTransmitTimer(bool withDelay)
|
|||||||
uint32_t delay =
|
uint32_t delay =
|
||||||
!withDelay ? 1 : random(MIN_TX_WAIT_MSEC, MAX_TX_WAIT_MSEC); // See documentation for loop() wrt these values
|
!withDelay ? 1 : random(MIN_TX_WAIT_MSEC, MAX_TX_WAIT_MSEC); // See documentation for loop() wrt these values
|
||||||
// DEBUG_MSG("xmit timer %d\n", delay);
|
// DEBUG_MSG("xmit timer %d\n", delay);
|
||||||
|
// DEBUG_MSG("delaying %u\n", delay);
|
||||||
setPeriod(delay);
|
setPeriod(delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,8 @@ class RadioLibInterface : public RadioInterface, private PeriodicTask
|
|||||||
*/
|
*/
|
||||||
uint32_t rxBad = 0, rxGood = 0, txGood = 0;
|
uint32_t rxBad = 0, rxGood = 0, txGood = 0;
|
||||||
|
|
||||||
|
PointerQueue<MeshPacket> txQueue = PointerQueue<MeshPacket>(MAX_TX_QUEUE);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float bw = 125;
|
float bw = 125;
|
||||||
uint8_t sf = 9;
|
uint8_t sf = 9;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "esp_pm.h"
|
#include "esp_pm.h"
|
||||||
#include "rom/rtc.h"
|
#include "rom/rtc.h"
|
||||||
#include <driver/rtc_io.h>
|
#include <driver/rtc_io.h>
|
||||||
|
#include <driver/uart.h>
|
||||||
|
|
||||||
#include "BluetoothUtil.h"
|
#include "BluetoothUtil.h"
|
||||||
|
|
||||||
@ -111,8 +112,7 @@ void initDeepSleep()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// return true if sleep is allowed
|
bool doPreflightSleep()
|
||||||
static bool doPreflightSleep()
|
|
||||||
{
|
{
|
||||||
if (preflightSleep.notifyObservers(NULL) != 0)
|
if (preflightSleep.notifyObservers(NULL) != 0)
|
||||||
return false; // vetoed
|
return false; // vetoed
|
||||||
@ -257,6 +257,17 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
|
|||||||
gpio_pullup_en((gpio_num_t)BUTTON_PIN);
|
gpio_pullup_en((gpio_num_t)BUTTON_PIN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SERIAL0_RX_GPIO
|
||||||
|
// We treat the serial port as a GPIO for a fast/low power way of waking, if we see a rising edge that means
|
||||||
|
// someone started to send something
|
||||||
|
|
||||||
|
// Alas - doesn't work reliably, instead need to use the uart specific version (which burns a little power)
|
||||||
|
// FIXME: gpio 3 is RXD for serialport 0 on ESP32
|
||||||
|
// Send a few Z characters to wake the port
|
||||||
|
gpio_wakeup_enable((gpio_num_t)SERIAL0_RX_GPIO, GPIO_INTR_LOW_LEVEL);
|
||||||
|
// uart_set_wakeup_threshold(UART_NUM_0, 3);
|
||||||
|
// esp_sleep_enable_uart_wakeup(0);
|
||||||
|
#endif
|
||||||
#ifdef BUTTON_PIN
|
#ifdef BUTTON_PIN
|
||||||
gpio_wakeup_enable((gpio_num_t)BUTTON_PIN, GPIO_INTR_LOW_LEVEL); // when user presses, this button goes low
|
gpio_wakeup_enable((gpio_num_t)BUTTON_PIN, GPIO_INTR_LOW_LEVEL); // when user presses, this button goes low
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,6 +19,9 @@ void initDeepSleep();
|
|||||||
void setCPUFast(bool on);
|
void setCPUFast(bool on);
|
||||||
void setLed(bool ledOn);
|
void setLed(bool ledOn);
|
||||||
|
|
||||||
|
/** return true if sleep is allowed right now */
|
||||||
|
bool doPreflightSleep();
|
||||||
|
|
||||||
extern int bootCount;
|
extern int bootCount;
|
||||||
|
|
||||||
// is bluetooth sw currently running?
|
// is bluetooth sw currently running?
|
||||||
|
Loading…
Reference in New Issue
Block a user