Compare commits

..

4 Commits

Author SHA1 Message Date
Jonathan Bennett
54a928f47f M6 shutdown and LEDs work (#9065)
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2025-12-24 07:48:14 -06:00
github-actions[bot]
33f18659c8 Upgrade trunk (#9067)
Co-authored-by: vidplace7 <1779290+vidplace7@users.noreply.github.com>
2025-12-24 05:20:22 -06:00
github-actions[bot]
3a7093a973 Upgrade trunk (#9047)
Co-authored-by: vidplace7 <1779290+vidplace7@users.noreply.github.com>
2025-12-23 18:55:54 -06:00
renovate[bot]
a4f6f4515a Update meshtastic-esp8266-oled-ssd1306 digest to b34c681 (#9062)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-23 18:55:37 -06:00
6 changed files with 35 additions and 85 deletions

View File

@@ -9,9 +9,9 @@ plugins:
lint:
enabled:
- checkov@3.2.495
- renovate@42.64.1
- renovate@42.66.2
- prettier@3.7.4
- trufflehog@3.92.3
- trufflehog@3.92.4
- yamllint@1.37.1
- bandit@1.9.2
- trivy@0.68.2

View File

@@ -64,7 +64,7 @@ monitor_speed = 115200
monitor_filters = direct
lib_deps =
# renovate: datasource=git-refs depName=meshtastic-esp8266-oled-ssd1306 packageName=https://github.com/meshtastic/esp8266-oled-ssd1306 gitBranch=master
https://github.com/meshtastic/esp8266-oled-ssd1306/archive/2887bf4a19f64d92c984dcc8fd5ca7429e425e4a.zip
https://github.com/meshtastic/esp8266-oled-ssd1306/archive/b34c6817c25d6faabb3a8a162b5d14fb75395433.zip
# renovate: datasource=git-refs depName=meshtastic-OneButton packageName=https://github.com/meshtastic/OneButton gitBranch=master
https://github.com/meshtastic/OneButton/archive/fa352d668c53f290cfa480a5f79ad422cd828c70.zip
# renovate: datasource=git-refs depName=meshtastic-arduino-fsm packageName=https://github.com/meshtastic/arduino-fsm gitBranch=master

View File

@@ -805,7 +805,8 @@ void NodeDB::installDefaultModuleConfig()
moduleConfig.external_notification.output_ms = 500;
moduleConfig.external_notification.nag_timeout = 2;
#endif
#if defined(RAK4630) || defined(RAK11310) || defined(RAK3312) || defined(MUZI_BASE) || defined(ELECROW_ThinkNode_M3)
#if defined(RAK4630) || defined(RAK11310) || defined(RAK3312) || defined(MUZI_BASE) || defined(ELECROW_ThinkNode_M3) || \
defined(ELECROW_ThinkNode_M6)
// Default to PIN_LED2 for external notification output (LED color depends on device variant)
moduleConfig.external_notification.enabled = true;
moduleConfig.external_notification.output = PIN_LED2;

View File

@@ -26,16 +26,6 @@
#include "nimble/nimble/host/include/host/ble_gap.h"
#endif
#ifdef ARCH_ESP32
#if defined(CONFIG_NIMBLE_CPP_IDF)
#include "host/ble_store.h"
#else
#include "nimble/nimble/host/include/host/ble_store.h"
#endif
#include <nvs.h>
#include <nvs_flash.h>
#endif
namespace
{
constexpr uint16_t kPreferredBleMtu = 517;
@@ -43,72 +33,6 @@ constexpr uint16_t kPreferredBleTxOctets = 251;
constexpr uint16_t kPreferredBleTxTimeUs = (kPreferredBleTxOctets + 14) * 8;
} // namespace
#ifdef ARCH_ESP32
// Credit: https://github.com/h2zero/NimBLE-Arduino/issues/740#issuecomment-2539923656
// Note: Despite the name, this function is invoked on every device boot (from setup()).
// It performs a routine startup check on the stored NimBLE bond data and deletes bonds
// only if a mismatch or migration condition is detected. It is not a one-time hook that
// runs only when the NimBLE version changes.
static void deleteBondsIfNimBLEVersionChanged()
{
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
err = nvs_flash_erase();
if (err != ESP_OK) {
LOG_ERROR("Failed to erase NVS for NimBLE migration, err=%d", err);
return;
}
err = nvs_flash_init();
if (err != ESP_OK) {
LOG_ERROR("Failed to re-init NVS after erase, err=%d", err);
return;
}
} else if (err != ESP_OK) {
LOG_ERROR("nvs_flash_init failed, err=%d", err);
return;
}
nvs_handle_t nimbleHandle = 0;
err = nvs_open("nimble_bond", NVS_READWRITE, &nimbleHandle);
if (err == ESP_ERR_NVS_NOT_FOUND) {
return;
}
if (err != ESP_OK) {
LOG_ERROR("Failed to open nimble_bond namespace, err=%d", err);
return;
}
size_t requiredSize = 0;
bool bondExists = nvs_get_blob(nimbleHandle, "peer_sec_1", nullptr, &requiredSize) == ESP_OK;
bool rpaExists = nvs_get_blob(nimbleHandle, "rpa_rec_1", nullptr, &requiredSize) == ESP_OK;
bool irkExists = nvs_get_blob(nimbleHandle, "local_irk_1", nullptr, &requiredSize) == ESP_OK;
bool erasePartition = false;
#if defined(BLE_STORE_OBJ_TYPE_LOCAL_IRK)
erasePartition = bondExists && !rpaExists;
#else
erasePartition = rpaExists || irkExists;
#endif
bool restartRequired = false;
if (erasePartition) {
LOG_WARN("Clearing NimBLE bonds due to version migration");
if (nvs_erase_all(nimbleHandle) != ESP_OK || nvs_commit(nimbleHandle) != ESP_OK) {
LOG_ERROR("Failed to erase nimble_bond namespace");
} else {
restartRequired = true;
}
}
nvs_close(nimbleHandle);
if (restartRequired) {
LOG_INFO("Restarting after NimBLE bond cleanup");
ESP.restart();
}
}
#endif
// Debugging options: careful, they slow things down quite a bit!
// #define DEBUG_NIMBLE_ON_READ_TIMING // uncomment to time onRead duration
// #define DEBUG_NIMBLE_ON_WRITE_TIMING // uncomment to time onWrite duration
@@ -876,10 +800,6 @@ void NimbleBluetooth::setup()
// Uncomment for testing
// NimbleBluetooth::clearBonds();
#ifdef ARCH_ESP32
deleteBondsIfNimBLEVersionChanged();
#endif
LOG_INFO("Init the NimBLE bluetooth module");
NimBLEDevice::init(getDeviceName());

View File

@@ -41,3 +41,30 @@ void initVariant()
pinMode(VDD_FLASH_EN, OUTPUT);
digitalWrite(VDD_FLASH_EN, HIGH);
}
// called from main-nrf52.cpp during the cpuDeepSleep() function
void variant_shutdown()
{
// This sets the pin to OUTPUT and LOW for the pins *not* in the if block.
for (int pin = 0; pin < 48; pin++) {
if (pin == PIN_GPS_EN || pin == ADC_CTRL || pin == PIN_BUTTON1 || pin == PIN_SPI_MISO || pin == PIN_SPI_MOSI ||
pin == PIN_SPI_SCK) {
continue;
}
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
if (pin >= 32) {
NRF_P1->DIRCLR = (1 << (pin - 32));
} else {
NRF_GPIO->DIRCLR = (1 << pin);
}
}
digitalWrite(PIN_GPS_EN, LOW);
digitalWrite(ADC_CTRL, LOW);
// digitalWrite(RTC_POWER, LOW);
nrf_gpio_cfg_input(PIN_BUTTON1, NRF_GPIO_PIN_PULLUP); // Configure the pin to be woken up as an input
nrf_gpio_pin_sense_t sense1 = NRF_GPIO_PIN_SENSE_LOW;
nrf_gpio_cfg_sense_set(PIN_BUTTON1, sense1);
}

View File

@@ -44,8 +44,10 @@ extern "C" {
#define LED_BLUE -1
#define LED_CHARGE (12)
#define LED_PAIRING (7)
#define PIN_LED2 LED_PAIRING
#define LED_STATE_ON 1
#define LED_STATE_ON HIGH
#define LED_STATE_OFF LOW
// USB power detection
#define EXT_PWR_DETECT (13)