Step 4.1: /stream.sdp from the live config and PTP GM
- aes67_sdp_sap: aes67_sdp_build() builds the AES67 SDP (RFC 4566 + RFC 7273) with the same lines and order as the web UI preview; GET /stream.sdp serves it as application/sdp. - aes67_ptp: public aes67_ptp_gm_id(), aes67_ptp_locked(), aes67_ptp_now_ns(). Clock IDs are now uppercase (RFC 7273 style), also in status.ptp, which the UI copies into ts-refclk. - aes67_net: aes67_net_netif() returns the AES67 interface. - Verified on board: /stream.sdp byte-identical to the UI's sdp() for the same config/status; mono, L16, ptime 0.333, ttl 8, clk_offset 4294967295 and session_ver all follow the config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -45,3 +45,23 @@ esp_err_t aes67_ptp_start(esp_eth_handle_t eth)
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
bool aes67_ptp_gm_id(char out[24])
|
||||
{
|
||||
return ptp_clock_gm_id(out);
|
||||
}
|
||||
|
||||
bool aes67_ptp_locked(void)
|
||||
{
|
||||
return ptp_clock_locked();
|
||||
}
|
||||
|
||||
esp_err_t aes67_ptp_now_ns(int64_t *ns)
|
||||
{
|
||||
eth_mac_time_t t;
|
||||
esp_err_t err = ptp_hw_get_time(&t);
|
||||
if (err == ESP_OK) {
|
||||
*ns = (int64_t)t.seconds * 1000000000LL + t.nanoseconds;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
// Core component: must not depend on main/ (project code).
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_eth_driver.h"
|
||||
|
||||
@@ -9,3 +12,10 @@
|
||||
esp_err_t aes67_ptp_init(void);
|
||||
// Start the EMAC PTP clock and the PTP task on this Ethernet interface.
|
||||
esp_err_t aes67_ptp_start(esp_eth_handle_t eth);
|
||||
|
||||
// Current GM clockIdentity as "XX-XX-XX-XX-XX-XX-XX-XX" (RFC 7273 form). false if none selected.
|
||||
bool aes67_ptp_gm_id(char out[24]);
|
||||
// Servo locked to the GM.
|
||||
bool aes67_ptp_locked(void);
|
||||
// PTP time (EMAC hardware clock) in ns.
|
||||
esp_err_t aes67_ptp_now_ns(int64_t *ns);
|
||||
|
||||
@@ -150,7 +150,7 @@ static int64_t mac_ns(const eth_mac_time_t *t)
|
||||
|
||||
static void fmt_id(char *out, const uint8_t *id)
|
||||
{
|
||||
sprintf(out, "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x", id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]);
|
||||
sprintf(out, "%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X", id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]);
|
||||
}
|
||||
|
||||
// IEEE 1588 dataset comparison (without the topology part): <0 if a is better.
|
||||
@@ -487,6 +487,22 @@ static void ptp_task(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
bool ptp_clock_gm_id(char out[24])
|
||||
{
|
||||
xSemaphoreTake(s.lock, portMAX_DELAY);
|
||||
bool valid = s.gm.valid;
|
||||
if (valid) {
|
||||
fmt_id(out, s.gm.gm_id);
|
||||
}
|
||||
xSemaphoreGive(s.lock);
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool ptp_clock_locked(void)
|
||||
{
|
||||
return s.locked;
|
||||
}
|
||||
|
||||
void ptp_clock_status(cJSON *st)
|
||||
{
|
||||
cJSON *p = cJSON_AddObjectToObject(st, "ptp");
|
||||
|
||||
@@ -6,5 +6,7 @@
|
||||
#include "esp_netif.h"
|
||||
|
||||
esp_err_t ptp_clock_start(esp_netif_t *netif);
|
||||
bool ptp_clock_gm_id(char out[24]);
|
||||
bool ptp_clock_locked(void);
|
||||
// Adds the "ptp" object to /api/status.
|
||||
void ptp_clock_status(cJSON *st);
|
||||
|
||||
Reference in New Issue
Block a user