Add runtime UV protection toggle and treat near-zero sense as external power.
Per-pod NVS enable (default off) via UART/ESP-NOW/dashboard, and skip UV latch when LiPo ADC reads ~0 mV so USB/external supply still boots. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -640,6 +640,30 @@ static void handle_tap_config(const uint8_t *master_mac,
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_battery_uv(const uint8_t *master_mac,
|
||||
const alox_EspNowBatteryUv *msg) {
|
||||
if (!client_id_matches(msg->client_id)) {
|
||||
return;
|
||||
}
|
||||
if (s_joined && !esp_now_core_mac_equal(master_mac, s_master_mac)) {
|
||||
return;
|
||||
}
|
||||
|
||||
char mac_str[18];
|
||||
esp_now_core_mac_to_str(master_mac, mac_str, sizeof(mac_str));
|
||||
ESP_LOGI(TAG, "UV protection %s from master %s (id=%lu)",
|
||||
msg->enabled ? "enabled" : "disabled", mac_str,
|
||||
(unsigned long)my_client_id());
|
||||
|
||||
if (pod_settings_set_uv_enabled(msg->enabled) != ESP_OK) {
|
||||
ESP_LOGW(TAG, "UV enable save failed");
|
||||
return;
|
||||
}
|
||||
if (!msg->enabled) {
|
||||
(void)pod_settings_clear_uv_latched();
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_assign_id(const uint8_t *master_mac,
|
||||
const alox_EspNowAssignId *msg) {
|
||||
if (!from_joined_master(master_mac)) {
|
||||
@@ -853,6 +877,11 @@ void esp_now_slave_on_recv(const esp_now_recv_info_t *info, const uint8_t *data,
|
||||
handle_tap_config(info->src_addr, &msg.payload.tap_config);
|
||||
}
|
||||
break;
|
||||
case alox_EspNowMessage_battery_uv_tag:
|
||||
if (from_joined_master(info->src_addr)) {
|
||||
handle_battery_uv(info->src_addr, &msg.payload.battery_uv);
|
||||
}
|
||||
break;
|
||||
case alox_EspNowMessage_accel_stream_tag:
|
||||
if (from_joined_master(info->src_addr)) {
|
||||
handle_accel_stream(info->src_addr, &msg.payload.accel_stream);
|
||||
|
||||
Reference in New Issue
Block a user