Merge branch 'meshtastic:master' into master

This commit is contained in:
Mictronics 2024-02-25 10:13:11 +01:00 committed by GitHub
commit 4e9a522b05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 71 additions and 20 deletions

@ -1 +1 @@
Subproject commit 24edea64429de4474c00d09990ef4c496614dc5d Subproject commit 5241583565ccbbb4986180bf4c6eb7f8a0dec285

View File

@ -245,6 +245,7 @@ Fsm powerFSM(&stateBOOT);
void PowerFSM_setup() void PowerFSM_setup()
{ {
bool isRouter = (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ? 1 : 0); bool isRouter = (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ? 1 : 0);
bool isInfrastructureRole = isRouter || config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER;
bool isTrackerOrSensor = config.device.role == meshtastic_Config_DeviceConfig_Role_TRACKER || bool isTrackerOrSensor = config.device.role == meshtastic_Config_DeviceConfig_Role_TRACKER ||
config.device.role == meshtastic_Config_DeviceConfig_Role_TAK_TRACKER || config.device.role == meshtastic_Config_DeviceConfig_Role_TAK_TRACKER ||
config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR; config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR;
@ -357,10 +358,10 @@ void PowerFSM_setup()
// Don't add power saving transitions if we are a power saving tracker or sensor. Sleep will be initiatiated through the // Don't add power saving transitions if we are a power saving tracker or sensor. Sleep will be initiatiated through the
// modules // modules
if ((isRouter || config.power.is_power_saving) && !isTrackerOrSensor) { if ((isRouter || config.power.is_power_saving) && !isTrackerOrSensor) {
powerFSM.add_timed_transition(&stateNB, &stateLS, powerFSM.add_timed_transition(&stateNB, isInfrastructureRole ? &stateSDS : &stateLS,
getConfiguredOrDefaultMs(config.power.min_wake_secs, default_min_wake_secs), NULL, getConfiguredOrDefaultMs(config.power.min_wake_secs, default_min_wake_secs), NULL,
"Min wake timeout"); "Min wake timeout");
powerFSM.add_timed_transition(&stateDARK, &stateLS, powerFSM.add_timed_transition(&stateDARK, isInfrastructureRole ? &stateSDS : &stateLS,
getConfiguredOrDefaultMs(config.power.wait_bluetooth_secs, default_wait_bluetooth_secs), getConfiguredOrDefaultMs(config.power.wait_bluetooth_secs, default_wait_bluetooth_secs),
NULL, "Bluetooth timeout"); NULL, "Bluetooth timeout");
} }

View File

@ -274,7 +274,7 @@ static void drawWelcomeScreen(OLEDDisplay *display, OLEDDisplayUiState *state, i
if ((millis() / 10000) % 2) { if ((millis() / 10000) % 2) {
display->drawString(x, y + FONT_HEIGHT_SMALL * 2 - 3, "Set the region using the"); display->drawString(x, y + FONT_HEIGHT_SMALL * 2 - 3, "Set the region using the");
display->drawString(x, y + FONT_HEIGHT_SMALL * 3 - 3, "Meshtastic Android, iOS,"); display->drawString(x, y + FONT_HEIGHT_SMALL * 3 - 3, "Meshtastic Android, iOS,");
display->drawString(x, y + FONT_HEIGHT_SMALL * 4 - 3, "Flasher or CLI client."); display->drawString(x, y + FONT_HEIGHT_SMALL * 4 - 3, "Web or CLI clients.");
} else { } else {
display->drawString(x, y + FONT_HEIGHT_SMALL * 2 - 3, "Visit meshtastic.org"); display->drawString(x, y + FONT_HEIGHT_SMALL * 2 - 3, "Visit meshtastic.org");
display->drawString(x, y + FONT_HEIGHT_SMALL * 3 - 3, "for more information."); display->drawString(x, y + FONT_HEIGHT_SMALL * 3 - 3, "for more information.");

View File

@ -88,6 +88,7 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
channelSettings.psk.size = 1; channelSettings.psk.size = 1;
strncpy(channelSettings.name, "", sizeof(channelSettings.name)); strncpy(channelSettings.name, "", sizeof(channelSettings.name));
channelSettings.module_settings.position_precision = 32; // default to sending location on the primary channel channelSettings.module_settings.position_precision = 32; // default to sending location on the primary channel
channelSettings.has_module_settings = true;
ch.has_settings = true; ch.has_settings = true;
ch.role = meshtastic_Channel_Role_PRIMARY; ch.role = meshtastic_Channel_Role_PRIMARY;

View File

@ -75,6 +75,8 @@ typedef enum _meshtastic_HardwareModel {
meshtastic_HardwareModel_CANARYONE = 29, meshtastic_HardwareModel_CANARYONE = 29,
/* Waveshare RP2040 LoRa - https://www.waveshare.com/rp2040-lora.htm */ /* Waveshare RP2040 LoRa - https://www.waveshare.com/rp2040-lora.htm */
meshtastic_HardwareModel_RP2040_LORA = 30, meshtastic_HardwareModel_RP2040_LORA = 30,
/* B&Q Consulting Station G2: https://wiki.uniteng.com/en/meshtastic/station-g2 */
meshtastic_HardwareModel_STATION_G2 = 31,
/* --------------------------------------------------------------------------- /* ---------------------------------------------------------------------------
Less common/prototype boards listed here (needs one more byte over the air) Less common/prototype boards listed here (needs one more byte over the air)
--------------------------------------------------------------------------- */ --------------------------------------------------------------------------- */
@ -530,8 +532,7 @@ typedef PB_BYTES_ARRAY_T(256) meshtastic_MeshPacket_encrypted_t;
typedef struct _meshtastic_MeshPacket { typedef struct _meshtastic_MeshPacket {
/* The sending node number. /* The sending node number.
Note: Our crypto implementation uses this field as well. Note: Our crypto implementation uses this field as well.
See [crypto](/docs/overview/encryption) for details. See [crypto](/docs/overview/encryption) for details. */
FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. */
uint32_t from; uint32_t from;
/* The (immediatSee Priority description for more details.y should be fixed32 instead, this encoding only /* The (immediatSee Priority description for more details.y should be fixed32 instead, this encoding only
hurts the ble link though. */ hurts the ble link though. */
@ -558,9 +559,7 @@ typedef struct _meshtastic_MeshPacket {
needs to be unique for a few minutes (long enough to last for the length of needs to be unique for a few minutes (long enough to last for the length of
any ACK or the completion of a mesh broadcast flood). any ACK or the completion of a mesh broadcast flood).
Note: Our crypto implementation uses this id as well. Note: Our crypto implementation uses this id as well.
See [crypto](/docs/overview/encryption) for details. See [crypto](/docs/overview/encryption) for details. */
FIXME - really should be fixed32 instead, this encoding only
hurts the ble link though. */
uint32_t id; uint32_t id;
/* The time this message was received by the esp32 (secs since 1970). /* The time this message was received by the esp32 (secs since 1970).
Note: this field is _never_ sent on the radio link itself (to save space) Times Note: this field is _never_ sent on the radio link itself (to save space) Times

View File

@ -83,7 +83,13 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
} }
nodeDB.updatePosition(getFrom(&mp), p); nodeDB.updatePosition(getFrom(&mp), p);
precision = channels.getByIndex(mp.channel).settings.module_settings.position_precision; if (channels.getByIndex(mp.channel).settings.has_module_settings) {
precision = channels.getByIndex(mp.channel).settings.module_settings.position_precision;
} else if (channels.getByIndex(mp.channel).role == meshtastic_Channel_Role_PRIMARY) {
precision = 32;
} else {
precision = 0;
}
return false; // Let others look at this message also if they want return false; // Let others look at this message also if they want
} }
@ -117,8 +123,8 @@ meshtastic_MeshPacket *PositionModule::allocReply()
// We want the imprecise position to be the middle of the possible location, not // We want the imprecise position to be the middle of the possible location, not
if (precision < 31 && precision > 1) { if (precision < 31 && precision > 1) {
p.latitude_i += (1 << 31 - precision); p.latitude_i += (1 << (31 - precision));
p.longitude_i += (1 << 31 - precision); p.longitude_i += (1 << (31 - precision));
} }
p.precision_bits = precision; p.precision_bits = precision;
p.time = localPosition.time; p.time = localPosition.time;
@ -217,7 +223,13 @@ void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies, uint8_t cha
service.cancelSending(prevPacketId); service.cancelSending(prevPacketId);
// Set's the class precision value for this particular packet // Set's the class precision value for this particular packet
precision = channels.getByIndex(channel).settings.module_settings.position_precision; if (channels.getByIndex(channel).settings.has_module_settings) {
precision = channels.getByIndex(channel).settings.module_settings.position_precision;
} else if (channels.getByIndex(channel).role == meshtastic_Channel_Role_PRIMARY) {
precision = 32;
} else {
precision = 0;
}
meshtastic_MeshPacket *p = allocReply(); meshtastic_MeshPacket *p = allocReply();
if (p == nullptr) { if (p == nullptr) {

View File

@ -186,7 +186,15 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false)
// not using wifi yet, but once we are this is needed to shutoff the radio hw // not using wifi yet, but once we are this is needed to shutoff the radio hw
// esp_wifi_stop(); // esp_wifi_stop();
waitEnterSleep(skipPreflight); waitEnterSleep(skipPreflight);
#ifdef ARCH_ESP32
if (shouldLoraWake(msecToWake)) {
notifySleep.notifyObservers(NULL);
} else {
notifyDeepSleep.notifyObservers(NULL);
}
#else
notifyDeepSleep.notifyObservers(NULL); notifyDeepSleep.notifyObservers(NULL);
#endif
screen->doDeepSleep(); // datasheet says this will draw only 10ua screen->doDeepSleep(); // datasheet says this will draw only 10ua
@ -240,6 +248,11 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false)
} }
#endif #endif
#ifdef ARCH_ESP32
if (shouldLoraWake(msecToWake)) {
enableLoraInterrupt();
}
#endif
cpuDeepSleep(msecToWake); cpuDeepSleep(msecToWake);
} }
@ -294,12 +307,7 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
gpio_wakeup_enable((gpio_num_t)BUTTON_PIN, GPIO_INTR_LOW_LEVEL); gpio_wakeup_enable((gpio_num_t)BUTTON_PIN, GPIO_INTR_LOW_LEVEL);
#endif #endif
#endif #endif
#if defined(LORA_DIO1) && (LORA_DIO1 != RADIOLIB_NC) enableLoraInterrupt();
gpio_wakeup_enable((gpio_num_t)LORA_DIO1, GPIO_INTR_HIGH_LEVEL); // SX126x/SX128x interrupt, active high
#endif
#ifdef RF95_IRQ
gpio_wakeup_enable((gpio_num_t)RF95_IRQ, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high
#endif
#ifdef PMU_IRQ #ifdef PMU_IRQ
// wake due to PMU can happen repeatedly if there is no battery installed or the battery fills // wake due to PMU can happen repeatedly if there is no battery installed or the battery fills
if (pmu_found) if (pmu_found)
@ -359,4 +367,30 @@ void enableModemSleep()
int rv = esp_pm_configure(&esp32_config); int rv = esp_pm_configure(&esp32_config);
LOG_DEBUG("Sleep request result %x\n", rv); LOG_DEBUG("Sleep request result %x\n", rv);
} }
bool shouldLoraWake(uint32_t msecToWake)
{
return msecToWake < portMAX_DELAY && (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER);
}
void enableLoraInterrupt()
{
#if SOC_PM_SUPPORT_EXT_WAKEUP && defined(LORA_DIO1) && (LORA_DIO1 != RADIOLIB_NC)
rtc_gpio_pulldown_en((gpio_num_t)LORA_DIO1);
#if defined(LORA_RESET) && (LORA_RESET != RADIOLIB_NC)
rtc_gpio_pullup_en((gpio_num_t)LORA_RESET);
#endif
#if defined(LORA_CS) && (LORA_CS != RADIOLIB_NC)
rtc_gpio_pullup_en((gpio_num_t)LORA_CS);
#endif
// Setup deep sleep with wakeup by external source
esp_sleep_enable_ext0_wakeup((gpio_num_t)LORA_DIO1, RISING);
#elif defined(LORA_DIO1) && (LORA_DIO1 != RADIOLIB_NC)
gpio_wakeup_enable((gpio_num_t)LORA_DIO1, GPIO_INTR_HIGH_LEVEL); // SX126x/SX128x interrupt, active high
#endif
#ifdef RF95_IRQ
gpio_wakeup_enable((gpio_num_t)RF95_IRQ, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high
#endif
}
#endif #endif

View File

@ -43,4 +43,8 @@ extern Observable<void *> notifyDeepSleep;
/// Called to tell GPS thread to enter deep sleep independently of LoRa/MCU sleep, prior to full poweroff. Must return 0 /// Called to tell GPS thread to enter deep sleep independently of LoRa/MCU sleep, prior to full poweroff. Must return 0
extern Observable<void *> notifyGPSSleep; extern Observable<void *> notifyGPSSleep;
void enableModemSleep(); void enableModemSleep();
#ifdef ARCH_ESP32
void enableLoraInterrupt();
bool shouldLoraWake(uint32_t msecToWake);
#endif