PTP: drop the "Preferred TimeTransmitter" role
It behaved exactly like auto (clock class 248); the only difference was a priority1 suggestion in the page. Roles are now slave|auto; to prefer this device, use auto with a low priority1. A stored "master" is converted to auto at boot (new cfg_set_string, like cfg_set_number). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -295,6 +295,37 @@ esp_err_t cfg_set_number(const char *group, const char *key, double value, bool
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t cfg_set_string(const char *group, const char *key, const char *value, bool apply)
|
||||
{
|
||||
if (!s_lock) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
xSemaphoreTake(s_lock, portMAX_DELAY);
|
||||
cfg_group_t *g = find(group);
|
||||
cJSON *cur = g ? cJSON_GetObjectItemCaseSensitive(g->values, key) : NULL;
|
||||
esp_err_t err = ESP_OK;
|
||||
if (!cur || !cJSON_IsString(cur)) {
|
||||
err = ESP_ERR_NOT_FOUND;
|
||||
} else {
|
||||
cJSON_ReplaceItemInObjectCaseSensitive(g->values, key, cJSON_CreateString(value));
|
||||
nvs_handle_t h;
|
||||
if (s_nvs_ok && (err = nvs_open(NVS_NAMESPACE, NVS_READWRITE, &h)) == ESP_OK) {
|
||||
err = store(h, g);
|
||||
if (err == ESP_OK) {
|
||||
err = nvs_commit(h);
|
||||
}
|
||||
nvs_close(h);
|
||||
}
|
||||
}
|
||||
cJSON *copy = err == ESP_OK && apply && g->apply ? cJSON_Duplicate(g->values, true) : NULL;
|
||||
xSemaphoreGive(s_lock);
|
||||
if (copy) {
|
||||
g->apply(copy);
|
||||
cJSON_Delete(copy);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
/* ----- HTTP ----- */
|
||||
|
||||
static esp_err_t config_get(httpd_req_t *req)
|
||||
|
||||
@@ -26,6 +26,8 @@ cJSON *cfg_get(const char *group);
|
||||
// Firmware-side change of one number (e.g. aes67.session_ver): stored like a POST, no validation.
|
||||
// apply = false skips the group's apply callback (e.g. to avoid restarting the stream).
|
||||
esp_err_t cfg_set_number(const char *group, const char *key, double value, bool apply);
|
||||
// Same for a string value.
|
||||
esp_err_t cfg_set_string(const char *group, const char *key, const char *value, bool apply);
|
||||
|
||||
// Validation helpers for validate callbacks. Each returns false and fills err on failure.
|
||||
bool cfg_check_num(const cJSON *g, const char *key, double min, double max, char *err, size_t n);
|
||||
|
||||
Reference in New Issue
Block a user