Fix audio-profile NVS persistence and whitespace-intolerant JSON parsers
- NvsAudioProfileStore used the key "audio_profile_json" (18 chars), exceeding NVS's 15-char key-name limit. Every nvs_set_str call failed silently with ESP_ERR_NVS_KEY_TOO_LONG (0x1109): applyProfile() always updated live DSP audio correctly, so the bug was invisible except as "store_failed" in the HTTP response and settings never surviving a reboot. Renamed to "audio_profile" (13 chars); confirmed live, EQ/mixer changes now persist across a reset. - The hand-rolled JSON extractJsonString()/extractJsonBool() helpers (duplicated per-file: TunerJson, DspParamJson, StationListJson, WebRadioJson, WifiProvisionJson, AudioProfileJson, plus inline mac/name/ save parsing in BluetoothJson) matched only the exact literal `"key":"value"` / `"key":true`, with no tolerance for a space after the colon. Standard JSON encoders (e.g. Swift's JSONEncoder in its default, non-compact mode) emit `"key": "value"`, which silently failed to parse as invalid_json/missing_field. Numeric fields were already fine (strtoul/strtof skip leading whitespace per the C standard); fixed only the string/bool extractors to skip whitespace after the colon before matching the value. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,12 @@ namespace secure_store {
|
||||
namespace {
|
||||
constexpr char kTag[] = "NvsAudioProfileStore";
|
||||
constexpr char kNamespace[] = "digiradio";
|
||||
constexpr char kProfileKey[] = "audio_profile_json";
|
||||
// NVS key names are capped at 15 chars (NVS_KEY_NAME_MAX_SIZE=16 incl. NUL);
|
||||
// the previous "audio_profile_json" (18 chars) made every nvs_set_str call
|
||||
// fail with ESP_ERR_NVS_KEY_TOO_LONG (0x1109), silently -- applyProfile()
|
||||
// always updated live audio correctly but persistProfile() never actually
|
||||
// wrote anything, so nothing survived a reboot.
|
||||
constexpr char kProfileKey[] = "audio_profile";
|
||||
} // namespace
|
||||
|
||||
bool NvsAudioProfileStore::hasProfile() const
|
||||
|
||||
Reference in New Issue
Block a user