mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Fix LED manager issues from code review feedback
- Guard LED prefs read for backward compatibility with older prefs files - Gate BLE disconnect LED update on _isEnabled to prevent stale state - Replace hardcoded LED pins with P_LORA_TX_LED macro - Fix inaccurate comment in WioWM1110 board init
This commit is contained in:
parent
e2aa33b3a0
commit
4636ce59e4
5 changed files with 12 additions and 8 deletions
|
|
@ -88,8 +88,12 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
|
|||
file.read((uint8_t *)&_prefs->discovery_mod_timestamp, sizeof(_prefs->discovery_mod_timestamp)); // 162
|
||||
file.read((uint8_t *)&_prefs->adc_multiplier, sizeof(_prefs->adc_multiplier)); // 166
|
||||
file.read((uint8_t *)_prefs->owner_info, sizeof(_prefs->owner_info)); // 170
|
||||
file.read((uint8_t *)&_prefs->led_status_mode, sizeof(_prefs->led_status_mode)); // 290
|
||||
file.read((uint8_t *)&_prefs->led_activity_mode, sizeof(_prefs->led_activity_mode)); // 291
|
||||
|
||||
// LED prefs added later; older prefs files end at offset 290
|
||||
if (file.available() >= 2) {
|
||||
file.read((uint8_t *)&_prefs->led_status_mode, sizeof(_prefs->led_status_mode)); // 290
|
||||
file.read((uint8_t *)&_prefs->led_activity_mode, sizeof(_prefs->led_activity_mode)); // 291
|
||||
}
|
||||
// next: 292
|
||||
|
||||
// sanitise bad pref values
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ void SerialBLEInterface::onDisconnect(uint16_t connection_handle, uint8_t reason
|
|||
instance->_conn_handle = BLE_CONN_HANDLE_INVALID;
|
||||
instance->_isDeviceConnected = false;
|
||||
instance->clearBuffers();
|
||||
// Advertising auto-restarts on disconnect
|
||||
if (instance->_ledManager) instance->_ledManager->setActivityState(LED_CONN_ADVERTISING);
|
||||
// Advertising auto-restarts on disconnect, but only if BLE is still enabled
|
||||
if (instance->_isEnabled && instance->_ledManager) instance->_ledManager->setActivityState(LED_CONN_ADVERTISING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ void RAK11310Board::begin() {
|
|||
delay(10); // give sx1262 some time to power up
|
||||
|
||||
// Start LEDs with defaults; prefs are applied after loadPrefs()
|
||||
static LEDManager _ledManager(23, 24);
|
||||
// green led = 23, blue led = P_LORA_TX_LED (24)
|
||||
static LEDManager _ledManager(23, P_LORA_TX_LED);
|
||||
ledManager = &_ledManager;
|
||||
ledManager->begin(LED_STATUS_BOOT_30S, LED_ACTIVITY_BOTH);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ void ThinkNodeM1Board::begin() {
|
|||
delay(10); // give sx1262 some time to power up
|
||||
|
||||
// Start LEDs with defaults; prefs are applied after loadPrefs()
|
||||
// LED_GREEN is active-LOW (LED_STATE_ON=LOW), P_LORA_TX_LED(13) is active-HIGH
|
||||
static LEDManager _ledManager(LED_GREEN, 13, false, true);
|
||||
// LED_GREEN is active-LOW (LED_STATE_ON=LOW), P_LORA_TX_LED is active-HIGH
|
||||
static LEDManager _ledManager(LED_GREEN, P_LORA_TX_LED, false, true);
|
||||
ledManager = &_ledManager;
|
||||
ledManager->begin(LED_STATUS_BOOT_30S, LED_ACTIVITY_BOTH);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ void WioWM1110Board::begin() {
|
|||
delay(10);
|
||||
|
||||
// Start LEDs with defaults; prefs are applied after loadPrefs()
|
||||
// LED_GREEN was previously always on; LED_STATUS_ALWAYS_ON preserves that behavior
|
||||
static LEDManager _ledManager(LED_GREEN, LED_RED);
|
||||
ledManager = &_ledManager;
|
||||
ledManager->begin(LED_STATUS_BOOT_30S, LED_ACTIVITY_BOTH);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue