logtool fix, reboot, only ap mode

This commit is contained in:
Thaddeus Hughes
2026-04-09 07:41:15 -05:00
parent 837ec18fad
commit b0b317a0fe
43 changed files with 3470 additions and 1068 deletions

View File

@@ -11,6 +11,7 @@
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "nvs_flash.h"
#include "nvs.h"
#include "version.h"
#define TAG "STORAGE"
@@ -560,6 +561,40 @@ esp_err_t factory_reset(void) {
return ESP_OK;
}
// ============================================================================
// HARDWARE IDENTITY (separate NVS namespace, survives factory reset)
// ============================================================================
#define HW_NVS_NAMESPACE "hw"
#define HW_NVS_BOARD_REV "board_rev"
static uint16_t cached_board_rev = 0;
static bool board_rev_loaded = false;
uint16_t hw_get_board_rev(void) {
if (board_rev_loaded) return cached_board_rev;
nvs_handle_t h;
if (nvs_open(HW_NVS_NAMESPACE, NVS_READONLY, &h) == ESP_OK) {
nvs_get_u16(h, HW_NVS_BOARD_REV, &cached_board_rev);
nvs_close(h);
}
board_rev_loaded = true;
return cached_board_rev;
}
esp_err_t hw_set_board_rev(uint16_t rev) {
nvs_handle_t h;
esp_err_t err = nvs_open(HW_NVS_NAMESPACE, NVS_READWRITE, &h);
if (err != ESP_OK) return err;
err = nvs_set_u16(h, HW_NVS_BOARD_REV, rev);
if (err == ESP_OK) err = nvs_commit(h);
nvs_close(h);
if (err == ESP_OK) {
cached_board_rev = rev;
board_rev_loaded = true;
}
return err;
}
// ============================================================================
// FLASH POST (Power-On Self-Test)
// ============================================================================