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:
@@ -1,7 +1,10 @@
|
||||
#include "aes67_ptp.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "aes67_cfg.h"
|
||||
#include "aes67_web.h"
|
||||
#include "esp_log.h"
|
||||
#include "ptp_clock.h"
|
||||
#include "ptp_hw.h"
|
||||
|
||||
@@ -14,7 +17,7 @@ static const char PTP_DEFAULTS[] =
|
||||
static bool ptp_validate(const cJSON *g, char *err, size_t n)
|
||||
{
|
||||
static const char *const modes[] = { "multicast", "hybrid", NULL };
|
||||
static const char *const roles[] = { "slave", "auto", "master", NULL };
|
||||
static const char *const roles[] = { "slave", "auto", NULL };
|
||||
return cfg_check_enum(g, "mode", modes, err, n) &&
|
||||
cfg_check_enum(g, "role", roles, err, n) &&
|
||||
cfg_check_int(g, "domain", 0, 127, err, n) &&
|
||||
@@ -34,7 +37,20 @@ static void ptp_apply(const cJSON *g)
|
||||
|
||||
esp_err_t aes67_ptp_init(void)
|
||||
{
|
||||
return cfg_register("ptp", PTP_DEFAULTS, ptp_validate, ptp_apply);
|
||||
esp_err_t err = cfg_register("ptp", PTP_DEFAULTS, ptp_validate, ptp_apply);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
// Role "master" was dropped (it behaved like auto; a low priority1 does the same). Stored values
|
||||
// aren't re-validated, so convert it here.
|
||||
cJSON *c = cfg_get("ptp");
|
||||
bool master = !strcmp(cJSON_GetObjectItemCaseSensitive(c, "role")->valuestring, "master");
|
||||
cJSON_Delete(c);
|
||||
if (master) {
|
||||
ESP_LOGW("ptp", "stored role \"master\" is no longer offered: now \"auto\" (same behaviour)");
|
||||
cfg_set_string("ptp", "role", "auto", false);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t aes67_ptp_start(esp_eth_handle_t eth)
|
||||
|
||||
Reference in New Issue
Block a user