Compare commits

...

14 Commits

Author SHA1 Message Date
bsncubed 02c02a821d Added factory reset todo item
Added factory reset todo item
2026-09-27 22:19:42 +10:00
bsncubed 41103e3b5e Licences: MIT for the AES67 core and web page, GPL-3.0 for the rest
- LICENSE (GPL-3.0) at the root; an MIT LICENSE in each components/aes67_*
  and in web/, so they travel with the code when reused.
- THIRD_PARTY.md: third-party code and licences, and the known conflict of
  the Espressif binary audio libraries with GPL-3.0 (firmware contains cspot).
- CLAUDE.md: rule to keep GPL code out of the core; phase 2 item to replace
  the Espressif binaries (opencore-aacdec, Speex resampler).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 08:37:38 +10:00
bsncubed c641671d24 CLAUDE.md: AirPlay 1 source check (licences, what to take, caveats)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 08:34:19 +10:00
bsncubed 4c16686c6b CLAUDE.md: phase 2 gets clock-drift correction and AirPlay 1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 08:27:04 +10:00
bsncubed fd30ac3eb1 CLAUDE.md: autoplay off the to-do list
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 08:51:33 +10:00
bsncubed e2721d6bd1 CLAUDE.md: step 8 status (mono sum, gain, polish done so far), step 6 roles
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 08:48:46 +10:00
bsncubed d4aa9c7be1 PTP status: 2-min average offset, details split; uptime as d/h/m/s
- Firmware: status.ptp.offset_avg_ns = mean |offset| over the last 2 min
  (one bucket per second, cleared on a clock step).
- Main panel: Time Offset (2 min avg) shows only the Bolero bracket of the
  average. Details: the current offset (coloured by the same brackets),
  hops, time/frequency traceable, version and own clock class.
- Uptime shown as "1d 2h 3m 4s".
- Preset buttons renamed: "Riedel PTP defaults", "AES67 Media PTP defaults".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 08:32:15 +10:00
bsncubed 5f27262b27 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>
2026-09-26 07:58:26 +10:00
bsncubed ee03d9f9f1 PTP: hardware timestamping is not a setting any more
The hw_ts config key was never read (hardware timestamps are always used);
the checkbox suggested it could be turned off. Removed from the config,
the page and the docs; status.ptp.hw_ts still reports it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 07:55:54 +10:00
bsncubed ec65374e8d Web UI: firmware table without build date, project and ESP-IDF
Only version, slots and state are shown; GET /api/ota still reports them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 07:54:28 +10:00
bsncubed 214d6b2c29 Firmware version: <version.txt>-<git short hash>, starting at 0.0.1
e.g. 0.0.1-1d613b1: the first part is set by hand, the hash says which
commit was built. No dirty flag (the build always patches cspot).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 07:52:23 +10:00
bsncubed 1d613b16c1 Firmware version from version.txt (0.9.0) instead of git describe
The version is now set by hand in version.txt, so it's readable and only
changes on purpose. git describe gave commit hashes, and always "-dirty"
because the build applies patches to the cspot submodule. Editing the file
is enough; the next build picks it up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 07:41:53 +10:00
bsncubed 05f4ce45c3 48 kHz only: drop 96 kHz from the AES67 output
All sources (player, test signals) are 48 kHz; at 96 kHz Spotify and HLS
played at the wrong speed. Validation, the page and the docs allow 48000
only, and a 96000 stored before is reset to 48000 at boot (stored values
aren't re-validated, and the SDP would still have said 96 kHz).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 07:30:39 +10:00
bsncubed 62b32c31ff Docs: end-user guide; README brought up to date
docs/user-guide.md covers setup, the web page, sources and failover, the
Spotify developer app, AES67 output and SDP/SAP, PTP presets, network and
static IP, logging, firmware updates (OTA and USB), the player API,
troubleshooting and known limitations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 07:26:52 +10:00
25 changed files with 1358 additions and 57 deletions
+1
View File
@@ -3,3 +3,4 @@ sdkconfig
sdkconfig.old sdkconfig.old
managed_components/ managed_components/
build-*/ build-*/
tools/__pycache__/
+21 -2
View File
@@ -15,6 +15,7 @@ Repo: https://gitea.apointless.space/bsncubed/aes67-ESP32-P4
- After every change: `idf.py build`, flash, and check the serial monitor output. Show the relevant log lines. - After every change: `idf.py build`, flash, and check the serial monitor output. Show the relevant log lines.
- Don't mark a step done until it has been verified on the board. - Don't mark a step done until it has been verified on the board.
- Keep core and project separate: `components/aes67_*` must not depend on `main/` (sources/player). Project code plugs in through the config, status and route registries. - Keep core and project separate: `components/aes67_*` must not depend on `main/` (sources/player). Project code plugs in through the config, status and route registries.
- Licences: core (`components/aes67_*`) and `web/` are MIT, the rest GPL-3.0-or-later (see THIRD_PARTY.md). Never pull GPL code (cspot, bell, squeezelite) into the core. New third-party code: check its licence first and add it to THIRD_PARTY.md.
- `web/index.html`: keep the CORE / PROJECT markers. If the firmware needs an API change, change the doc and the page together. - `web/index.html`: keep the CORE / PROJECT markers. If the firmware needs an API change, change the doc and the page together.
- Small, focused commits per step. - Small, focused commits per step.
@@ -28,6 +29,7 @@ Repo: https://gitea.apointless.space/bsncubed/aes67-ESP32-P4
- Rev < 3 also limits Espressif's prebuilt audio libraries: `esp_audio_codec` must stay < 2.6 and `esp_audio_effects` < 1.4 (newer versions use P4 assembly that needs rev >= 3; the build fails with a message saying so). Check this for any new Espressif binary component. - Rev < 3 also limits Espressif's prebuilt audio libraries: `esp_audio_codec` must stay < 2.6 and `esp_audio_effects` < 1.4 (newer versions use P4 assembly that needs rev >= 3; the build fails with a message saying so). Check this for any new Espressif binary component.
- Embed `web/index.html` via `EMBED_TXTFILES` in `aes67_web`. - Embed `web/index.html` via `EMBED_TXTFILES` in `aes67_web`.
- cspot (Spotify, `external/cspot` git submodule, philippe44 fork, pinned): after cloning run `git submodule update --init external/cspot && git -C external/cspot submodule update --init cspot/bell`. Its nanopb code generator needs, in the IDF Python env: `python -m pip install protobuf grpcio-tools 'setuptools<81'` (after `. export.sh`). Our fixes to cspot/bell live in `components/spotify/patches/{cspot,bell}/*.patch` and are applied automatically at configure time; don't edit the submodule directly, add a patch. - cspot (Spotify, `external/cspot` git submodule, philippe44 fork, pinned): after cloning run `git submodule update --init external/cspot && git -C external/cspot submodule update --init cspot/bell`. Its nanopb code generator needs, in the IDF Python env: `python -m pip install protobuf grpcio-tools 'setuptools<81'` (after `. export.sh`). Our fixes to cspot/bell live in `components/spotify/patches/{cspot,bell}/*.patch` and are applied automatically at configure time; don't edit the submodule directly, add a patch.
- Firmware version: `<version.txt>-<git short hash>`, e.g. `0.0.1-1d613b1`. Bump `version.txt` for a release; the hash is the commit that was built (commit first, then build, so it matches). No dirty flag.
- Flash over the network (normal way since step 2b; keep USB for recovery): - Flash over the network (normal way since step 2b; keep USB for recovery):
`curl -f --data-binary @build/aes67_p4.bin -H 'Content-Type: application/octet-stream' http://p4-aes67/api/ota` `curl -f --data-binary @build/aes67_p4.bin -H 'Content-Type: application/octet-stream' http://p4-aes67/api/ota`
The board reboots into the new image on trial; check `GET /api/ota` shows the new version with `pending_verify: false`. The board reboots into the new image on trial; check `GET /api/ota` shows the new version with `pending_verify: false`.
@@ -43,7 +45,7 @@ Repo: https://gitea.apointless.space/bsncubed/aes67-ESP32-P4
- On-die temperature sensor only (driver/temperature_sensor.h). - On-die temperature sensor only (driver/temperature_sensor.h).
## Build order / status ## Build order / status
- [x] 0. Check chip revision and flash size; create IDF project and empty component stubs (layout in aes67-core-base.md). Set up the OTA partition table (two app slots, no factory) and PROJECT_VER from git now, so the layout never changes later. - [x] 0. Check chip revision and flash size; create IDF project and empty component stubs (layout in aes67-core-base.md). Set up the OTA partition table (two app slots, no factory) and PROJECT_VER now, so the layout never changes later. (PROJECT_VER = `version.txt` + git short hash.)
- [x] 1. Ethernet: IP101 up, DHCP, IP logged. Ping works. - [x] 1. Ethernet: IP101 up, DHCP, IP logged. Ping works.
- [x] 2. Web server + config store (cJSON in NVS) + embedded index.html; /api/config, /api/status (stub values), /api/reboot. - [x] 2. Web server + config store (cJSON in NVS) + embedded index.html; /api/config, /api/status (stub values), /api/reboot.
- [x] 2a. Finding the device: mDNS (hostname.local + _http._tcp), then LLDP (switch shows name + IP). - [x] 2a. Finding the device: mDNS (hostname.local + _http._tcp), then LLDP (switch shows name + IP).
@@ -52,7 +54,7 @@ Repo: https://gitea.apointless.space/bsncubed/aes67-ESP32-P4
- [ ] 4. AES67 TX with a 1 kHz test tone, PTP-paced; /stream.sdp. Verify: import SDP on a Riedel Artist 4-wire AES67 port, and check packets/timestamps in Wireshark. - [ ] 4. AES67 TX with a 1 kHz test tone, PTP-paced; /stream.sdp. Verify: import SDP on a Riedel Artist 4-wire AES67 port, and check packets/timestamps in Wireshark.
Done and checked with a receiver script (all ptimes, L16/L24, tone phase-locked to PTP); still open: the Riedel import and a Wireshark capture. Done and checked with a receiver script (all ptimes, L16/L24, tone phase-locked to PTP); still open: the Riedel import and a Wireshark capture.
- [x] 5. SAP discovery, then syslog, then health/temperatures (one at a time). VLAN split moved to phase 2. - [x] 5. SAP discovery, then syslog, then health/temperatures (one at a time). VLAN split moved to phase 2.
- [x] 6. PTP TimeTransmitter: BMCA roles (auto/master), hybrid mode. - [x] 6. PTP TimeTransmitter: BMCA roles (slave/auto; the separate "master" role was dropped later, auto with a low priority1 does the same), hybrid mode.
- [ ] 7. Sources: HLS player, then cspot (Spotify Connect), then failover + /api/player. - [ ] 7. Sources: HLS player, then cspot (Spotify Connect), then failover + /api/player.
- [x] 7.1-7.4 HLS plays on AES67 (PSRAM ring, TS demux + AAC, 44.1 -> 48 kHz). Tested with Triple J Hottest (TS, AAC-LC 44.1k). - [x] 7.1-7.4 HLS plays on AES67 (PSRAM ring, TS demux + AAC, 44.1 -> 48 kHz). Tested with Triple J Hottest (TS, AAC-LC 44.1k).
- [ ] Come back to HLS (open items): - [ ] Come back to HLS (open items):
@@ -72,10 +74,27 @@ Repo: https://gitea.apointless.space/bsncubed/aes67-ESP32-P4
- Open: `aes67_tx resync` (TX 20-27 ms late) ~11 s after each switch to Spotify (seen 3 times); clicks at switches not yet checked in a recording; HLS start sometimes hits CDN read timeouts. - Open: `aes67_tx resync` (TX 20-27 ms late) ~11 s after each switch to Spotify (seen 3 times); clicks at switches not yet checked in a recording; HLS start sometimes hits CDN read timeouts.
- [x] /api/player: GET, transport, seek, volume (the app follows), source override and url (runtime, not saved); web UI progress bar. - [x] /api/player: GET, transport, seek, volume (the app follows), source override and url (runtime, not saved); web UI progress bar.
- [ ] 8. Mono sum, gain, polish. - [ ] 8. Mono sum, gain, polish.
- [x] Mono sum: stereo source mapped to a 1-channel stream in the core ((L+R)/2, 64 bit). Checked: 156 B packets, SDP L24/48000/1.
- [x] Gain: source.gain_db as a trim on top of the volume, saturating. Checked: -12 dB = -12 dB peak, +12 dB clips at 0 dBFS.
- [x] Pink noise source (-18 dBFS RMS, octaves flat within 0.4 dB 63 Hz-4 kHz).
- [x] 48 kHz only (96 kHz dropped: all sources are 48 kHz).
- [x] Network: status mask/gw/dns, UI shows the lease; static IP (reboot on change, validation).
- [x] Web UI: sticky save bar, dark default + light toggle, progress bar, PTP panel (2 min average offset, details), uptime d/h/m/s, VLAN option hidden, no hw_ts / preferred-TimeTransmitter options.
- [x] Versioning `<version.txt>-<git hash>`; tools/flash_board.py (tested on this board); docs/user-guide.md.
- [ ] Mute at 0 % volume: confirm on the board.
## Phase 2 (parked) ## Phase 2 (parked)
- [ ] Replace the Espressif binary audio libraries (GPL-3 conflict, see THIRD_PARTY.md): AAC via opencore-aacdec (Apache-2.0, in bell/external), 44.1 -> 48 kHz via the Speex resampler (BSD). Do together with / right before the clock-drift correction (Speex can steer the ratio).
- [ ] Clock-drift correction (do before AirPlay): steer the 44.1 -> 48 kHz converter by a few ppm from the ring level / distance to the live edge, so push sources that run on the sender's clock don't slowly over- or underrun. Closes the HLS clock-drift item in step 7; AirPlay needs the same.
- [ ] AirPlay 1 (RAOP) as a source: `_raop._tcp` via our mDNS, RTSP control, AES (mbedTLS), ALAC decode, RTP audio + timing, 44.1 kHz into the existing converter, uses the clock-drift correction. Start from philippe44's RAOP code in squeezelite-esp32 (`components/raop`, checked 2026-09-27 at commit 1d542bd):
- Take `raop.c`, `util.c` (MIT, philippe44) and `rtp.c` (MIT, James Laird/shairport); keep their headers. Write our own glue to the player (their `raop_sink.c` has no licence header and the repo has no LICENSE file; it's specific to squeezelite anyway).
- ALAC: they link a prebuilt `libalac.a`; build Apple's ALAC from source instead (Apache-2.0, already in `external/cspot/cspot/bell/external/alac`).
- `dmap_parser.c` (track metadata) has no header: confirm its origin (likely the MIT dmap-parser project) or leave it out.
- `raop.c` contains the AirPort Express RSA private key (reverse-engineered in 2011, in every AirPlay 1 receiver): known grey area.
- Code is written for squeezelite-esp32's platform (pthreads, their logging, OpenSSL/mbedTLS switches, NVS): needs porting like cspot. `rtp.c` hands each frame to the sink with its play time (NTP-synced to the sender); following the sender's clock is the sink's job, i.e. our clock-drift correction. Covers iPhone/iPad/Mac (incl. Tidal and Apple Music apps) and Windows via AirPlay senders (TuneBlade, Airfoil). Not AirPlay 2 (HomeKit pairing, its own PTP on ports 319/320 clashes with ours). Then: auto mode as a priority list (whichever source plays wins, HLS as fallback). Check internal heap with Spotify + AirPlay sessions (buffers to PSRAM).
- [ ] VLAN split: AES67 untagged + internet tagged (inet.vlan_id/pcp), per aes67-core-base.md "Network". Needs a tagged VLAN with DHCP on the switch port. Config group `inet` and the UI fields exist already; nothing is applied yet. The "VLAN split" checkbox is hidden in web/index.html (`<label hidden>`); unhide it when this is done. - [ ] VLAN split: AES67 untagged + internet tagged (inet.vlan_id/pcp), per aes67-core-base.md "Network". Needs a tagged VLAN with DHCP on the switch port. Config group `inet` and the UI fields exist already; nothing is applied yet. The "VLAN split" checkbox is hidden in web/index.html (`<label hidden>`); unhide it when this is done.
- [ ] NTP (SNTP): servers as hostnames or IPs (e.g. `pool.ntp.org`, several allowed; names resolved via DNS, re-resolved on failure). Uses: seed the PTP clock with real time before becoming GM (today it starts at 1970), syslog timestamps. Needs a `time` config group + UI fields (change doc and page together). - [ ] NTP (SNTP): servers as hostnames or IPs (e.g. `pool.ntp.org`, several allowed; names resolved via DNS, re-resolved on failure). Uses: seed the PTP clock with real time before becoming GM (today it starts at 1970), syslog timestamps. Needs a `time` config group + UI fields (change doc and page together).
- [ ] Factory reset buton in the webgui with a confromation popup.
## Phase 3 (parked) ## Phase 3 (parked)
- [ ] Remote access via VPN / Tailscale. There is no official Tailscale client for ESP32; options to evaluate first: - [ ] Remote access via VPN / Tailscale. There is no official Tailscale client for ESP32; options to evaluate first:
+11 -9
View File
@@ -1,19 +1,21 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
# Firmware version = git describe (tags, dirty flag). Reported by esp_app_get_description() # Firmware version = "<version.txt>-<git short hash>", e.g. 0.0.1-1d613b1. The first part is set by
# and in status.fw / GET /api/ota. CMake re-runs when git's HEAD log or index changes (commit, # hand in version.txt; the hash says which commit was built (no dirty flag: the build always patches
# checkout, add), so the version follows. A new tag or unstaged edits need `idf.py reconfigure`. # the cspot submodule). Reported by esp_app_get_description(), status.fw and GET /api/ota.
# CMake re-runs when version.txt or the checked-out commit changes.
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
${CMAKE_CURRENT_LIST_DIR}/.git/logs/HEAD ${CMAKE_CURRENT_LIST_DIR}/version.txt
${CMAKE_CURRENT_LIST_DIR}/.git/index) ${CMAKE_CURRENT_LIST_DIR}/.git/logs/HEAD)
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/version.txt PROJECT_VER LIMIT_COUNT 1)
execute_process( execute_process(
COMMAND git describe --tags --always --dirty COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE PROJECT_VER OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET) ERROR_QUIET)
if(NOT PROJECT_VER) if(GIT_HASH)
set(PROJECT_VER "0.0.0-nogit") set(PROJECT_VER "${PROJECT_VER}-${GIT_HASH}")
endif() endif()
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
+674
View File
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+24 -6
View File
@@ -1,10 +1,28 @@
# aes67-ESP32-P4 # aes67-ESP32-P4
AES67 sender for the Waveshare ESP32-P4-ETH (PoE): Spotify Connect and HLS/m3u8 streams out as an AES67 multicast stream, PTP-locked, with a simple web UI for settings and SDP export. AES67 sender for the Waveshare ESP32-P4-ETH (PoE): Spotify Connect and HLS/m3u8 internet radio (with failover between them) go out as an AES67 multicast stream, locked to PTP. Everything is set up from a built-in web page, with SAP announcements and SDP export for receivers (tested with Riedel PTP).
- `docs/aes67-core-base.md` — reusable AES67 core design (PTP, RTP, SDP/SAP, VLAN, syslog, web UI contract) **Using it:** see the [user guide](docs/user-guide.md).
- `docs/hardware-and-design-notes.md` — board details and project-specific design
- `web/index.html` — web UI (served by the device)
- `CLAUDE.md` — working rules and build order
Status: design complete, firmware not started. See the build order in CLAUDE.md. **Quick start:** power the board over PoE and open http://p4-aes67.local/. Pick a source and save. Then find "P4 AES67" via SAP on the receiver, or import the SDP from the page.
## Building and flashing
- ESP-IDF 5.5 or later, target `esp32p4`: `idf.py set-target esp32p4 && idf.py build`
- cspot submodule: `git submodule update --init external/cspot && git -C external/cspot submodule update --init cspot/bell`
- New board over USB: `tools/flash_board.py`
- Update over the network: web page → Firmware, or `curl -f --data-binary @build/aes67_p4.bin -H 'Content-Type: application/octet-stream' http://p4-aes67.local/api/ota`
Toolchain details and caveats (chip revision, Python packages for cspot) are in `CLAUDE.md`.
## Documentation
- `docs/user-guide.md`: setup, web page, sources, Spotify, AES67, PTP, network, updates, player API, troubleshooting
- `docs/aes67-core-base.md`: reusable AES67 core design (PTP, RTP, SDP/SAP, syslog, web UI and API contract)
- `docs/hardware-and-design-notes.md`: board details and project-specific design
- `web/index.html`: the web page (served by the device)
- `CLAUDE.md`: working rules, build order and status
## Licence
The AES67 core (`components/aes67_*`) and the web page (`web/`) are MIT. Everything else is GPL-3.0-or-later (`LICENSE`). The firmware image contains cspot (GPL-3.0), so distributing it falls under GPL-3.0. Third-party code, its licences and a known conflict with two Espressif binary libraries: [THIRD_PARTY.md](THIRD_PARTY.md).
+37
View File
@@ -0,0 +1,37 @@
# Licences
## This project
| Part | Licence |
|---|---|
| AES67 core: `components/aes67_*` (each has its own `LICENSE`) | MIT |
| Web page: `web/index.html` (`web/LICENSE`) | MIT |
| Everything else: `main/`, `components/spotify/` (incl. our cspot/bell patches), `tools/`, docs, build files | GPL-3.0-or-later (`LICENSE`) |
The core is MIT so it can be reused in other AES67 projects, including closed ones. It must not depend on GPL code: nothing in `components/aes67_*` may include or link cspot or `main/`.
The firmware image as a whole contains cspot (GPL-3.0), so anyone who distributes the firmware (a `.bin` or a flashed board) must do so under GPL-3.0, with the complete corresponding source.
## Third-party code in the firmware
| Code | Used for | Licence | Notes |
|---|---|---|---|
| [cspot](https://github.com/philippe44/cspot) (philippe44 fork, `external/cspot`) | Spotify Connect | GPL-3.0-or-later | Our patches: `components/spotify/patches/cspot` |
| [bell](https://github.com/philippe44/bell) (cspot submodule) | cspot's I/O and utilities | no licence file | Part of the cspot project; licence to be confirmed with the author |
| tremor (via bell) | Vorbis decoding (Spotify) | BSD-3-Clause (Xiph.Org) | |
| nanopb (via bell) | Protobuf (Spotify protocol) | zlib | |
| ESP-IDF, incl. mbedTLS, esp_http_server, esp_eth | Platform, TLS, web server, Ethernet | Apache-2.0 | mbedTLS is dual Apache-2.0 / GPL-2.0-or-later |
| lwIP | TCP/IP | BSD-3-Clause | |
| FreeRTOS | RTOS | MIT | |
| cJSON | JSON | MIT | |
| espressif/mdns | mDNS | Apache-2.0 | |
| **espressif/esp_audio_codec** | AAC decoding (HLS) | **Espressif Modified MIT, prebuilt binary** | Only allowed with Espressif chips; no source |
| **espressif/esp_audio_effects**, gmf_fft | 44.1 → 48 kHz conversion | **Espressif Modified MIT**; esp_audio_effects is a prebuilt binary | as above |
Algorithms: pink noise uses Paul Kellet's filter and a xorshift32 generator (both public domain).
## Known conflict
The two Espressif binary libraries can't be distributed under GPL-3.0: there is no source, and "Espressif chips only" is an additional restriction that GPL-3.0 forbids. A firmware image containing both them and cspot therefore can't be distributed in line with GPL-3.0. Private use is not affected.
Planned fix (phase 2 in `CLAUDE.md`): replace them with open code, e.g. opencore-aacdec (Apache-2.0, already in `bell/external`) for AAC and the Speex resampler (BSD) for the sample-rate conversion. The Speex resampler can also do the fine rate steering the clock-drift correction needs.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ben Nicholson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ben Nicholson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ben Nicholson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ben Nicholson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ben Nicholson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+19 -3
View File
@@ -1,7 +1,10 @@
#include "aes67_ptp.h" #include "aes67_ptp.h"
#include <string.h>
#include "aes67_cfg.h" #include "aes67_cfg.h"
#include "aes67_web.h" #include "aes67_web.h"
#include "esp_log.h"
#include "ptp_clock.h" #include "ptp_clock.h"
#include "ptp_hw.h" #include "ptp_hw.h"
@@ -9,12 +12,12 @@
static const char PTP_DEFAULTS[] = static const char PTP_DEFAULTS[] =
"{\"mode\":\"multicast\",\"role\":\"auto\",\"domain\":0,\"priority1\":250,\"priority2\":250," "{\"mode\":\"multicast\",\"role\":\"auto\",\"domain\":0,\"priority1\":250,\"priority2\":250,"
"\"log_sync\":0,\"log_announce\":1,\"announce_timeout\":3,\"log_delay_req\":0," "\"log_sync\":0,\"log_announce\":1,\"announce_timeout\":3,\"log_delay_req\":0,"
"\"dscp\":46,\"hw_ts\":true}"; "\"dscp\":46}"; // hardware timestamps always (status.ptp.hw_ts)
static bool ptp_validate(const cJSON *g, char *err, size_t n) static bool ptp_validate(const cJSON *g, char *err, size_t n)
{ {
static const char *const modes[] = { "multicast", "hybrid", NULL }; 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) && return cfg_check_enum(g, "mode", modes, err, n) &&
cfg_check_enum(g, "role", roles, err, n) && cfg_check_enum(g, "role", roles, err, n) &&
cfg_check_int(g, "domain", 0, 127, 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) 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) esp_err_t aes67_ptp_start(esp_eth_handle_t eth)
+49 -3
View File
@@ -26,6 +26,7 @@
#define MAX_DRIFT_PPB 500000.0 #define MAX_DRIFT_PPB 500000.0
#define WINDOW 64 // samples for interval/delay statistics #define WINDOW 64 // samples for interval/delay statistics
#define SUMMARY_US (60 * 1000000LL) #define SUMMARY_US (60 * 1000000LL)
#define AVG_S 120 // status.ptp.offset_avg_ns: mean |offset| over 2 min
#define FLAG_PTP_TIMESCALE 0x0008 // flagField octet 1 bit 3 #define FLAG_PTP_TIMESCALE 0x0008 // flagField octet 1 bit 3
#define FLAG_UNICAST 0x0400 // flagField octet 0 bit 2 #define FLAG_UNICAST 0x0400 // flagField octet 0 bit 2
#define UTC_OFFSET 37 // TAI - UTC (s), announced as information only #define UTC_OFFSET 37 // TAI - UTC (s), announced as information only
@@ -102,8 +103,48 @@ static struct {
uint32_t delay_req, delay_resp; uint32_t delay_req, delay_resp;
uint8_t own_class; uint8_t own_class;
int64_t sum_max_ns, sum_start_us; int64_t sum_max_ns, sum_start_us;
// Mean |offset| over the last AVG_S seconds (status.ptp.offset_avg_ns): one bucket per second.
struct {
int64_t sec, sum;
uint32_t n;
} avg[AVG_S];
} s; } s;
static void avg_add(int64_t offset)
{
int64_t sec = esp_timer_get_time() / 1000000;
typeof(s.avg[0]) *b = &s.avg[sec % AVG_S];
if (b->sec != sec) {
b->sec = sec;
b->sum = 0;
b->n = 0;
}
b->sum += llabs(offset);
b->n++;
}
static void avg_clear(void)
{
memset(s.avg, 0, sizeof(s.avg));
}
// False while no offset was measured in the window.
static bool avg_get(double *mean)
{
int64_t now = esp_timer_get_time() / 1000000, sum = 0;
uint32_t n = 0;
for (int i = 0; i < AVG_S; i++) {
if (s.avg[i].n && now - s.avg[i].sec < AVG_S) {
sum += s.avg[i].sum;
n += s.avg[i].n;
}
}
if (n) {
*mean = (double)sum / n;
}
return n > 0;
}
static void win_add(window_t *w, int64_t v) static void win_add(window_t *w, int64_t v)
{ {
w->v[w->next] = v; w->v[w->next] = v;
@@ -309,6 +350,7 @@ static void servo(int64_t offset)
s.stepped = true; s.stepped = true;
s.offset_ns = 0; // the pre-step offset is history: not for status or the summary s.offset_ns = 0; // the pre-step offset is history: not for status or the summary
s.sum_max_ns = 0; s.sum_max_ns = 0;
avg_clear();
s.sum_start_us = 0; s.sum_start_us = 0;
s.prev_t2 = 0; // rate across the step is meaningless s.prev_t2 = 0; // rate across the step is meaningless
s.bad = 0; s.bad = 0;
@@ -323,6 +365,7 @@ static void servo(int64_t offset)
s.drift_ppb = fmax(-MAX_DRIFT_PPB, fmin(MAX_DRIFT_PPB, s.drift_ppb + ki * offset)); s.drift_ppb = fmax(-MAX_DRIFT_PPB, fmin(MAX_DRIFT_PPB, s.drift_ppb + ki * offset));
s.freq_ppb = -ppb; s.freq_ppb = -ppb;
ptp_hw_adj_freq(s.freq_ppb); ptp_hw_adj_freq(s.freq_ppb);
avg_add(offset);
if (llabs(offset) < LOCK_NS) { if (llabs(offset) < LOCK_NS) {
s.bad = 0; s.bad = 0;
@@ -622,8 +665,8 @@ static void load_config(void)
s.cfg_log_sync = cJSON_GetObjectItem(c, "log_sync")->valueint; s.cfg_log_sync = cJSON_GetObjectItem(c, "log_sync")->valueint;
s.cfg_log_announce = cJSON_GetObjectItem(c, "log_announce")->valueint; s.cfg_log_announce = cJSON_GetObjectItem(c, "log_announce")->valueint;
s.cfg_log_dreq = cJSON_GetObjectItem(c, "log_delay_req")->valueint; s.cfg_log_dreq = cJSON_GetObjectItem(c, "log_delay_req")->valueint;
// Roles (docs): slave = clockClass 255, never transmits; auto/master = 248 with the configured // Roles (docs): slave = clockClass 255, never transmits; auto = 248 with the configured priorities
// priorities (auto 250/250 by default, master e.g. p1 100). // (250/250 by default: loses to any real GM; a lower priority1 prefers this device).
s.slave_only = strcmp(cJSON_GetObjectItem(c, "role")->valuestring, "slave") == 0; s.slave_only = strcmp(cJSON_GetObjectItem(c, "role")->valuestring, "slave") == 0;
s.hybrid = strcmp(cJSON_GetObjectItem(c, "mode")->valuestring, "hybrid") == 0; s.hybrid = strcmp(cJSON_GetObjectItem(c, "mode")->valuestring, "hybrid") == 0;
s.own_class = s.slave_only ? 255 : 248; s.own_class = s.slave_only ? 255 : 248;
@@ -711,7 +754,7 @@ static void ptp_task(void *arg)
int tos2 = s.dscp << 2; int tos2 = s.dscp << 2;
setsockopt(s.gen, IPPROTO_IP, IP_TOS, &tos2, sizeof(tos2)); setsockopt(s.gen, IPPROTO_IP, IP_TOS, &tos2, sizeof(tos2));
ESP_LOGI(TAG, "config applied: role %s, mode %s, p1 %u p2 %u, domain %u", ESP_LOGI(TAG, "config applied: role %s, mode %s, p1 %u p2 %u, domain %u",
s.slave_only ? "slave" : "auto/master", s.hybrid ? "hybrid" : "multicast", s.slave_only ? "slave" : "auto", s.hybrid ? "hybrid" : "multicast",
s.own.p1, s.own.p2, s.domain); s.own.p1, s.own.p2, s.domain);
// Re-run the decision: a foreign GM worse than our new dataset is dropped; as // Re-run the decision: a foreign GM worse than our new dataset is dropped; as
// TimeTransmitter with role slave we stop. // TimeTransmitter with role slave we stop.
@@ -838,6 +881,9 @@ void ptp_clock_status(cJSON *st)
cJSON_AddBoolToObject(p, "gm_freq_traceable", s.gm.flags & 0x20); cJSON_AddBoolToObject(p, "gm_freq_traceable", s.gm.flags & 0x20);
if (s.stepped) { if (s.stepped) {
cJSON_AddNumberToObject(p, "offset_ns", s.offset_ns); cJSON_AddNumberToObject(p, "offset_ns", s.offset_ns);
if (avg_get(&mean)) {
cJSON_AddNumberToObject(p, "offset_avg_ns", round(mean));
}
cJSON_AddNumberToObject(p, "freq_ppb", round(s.freq_ppb)); cJSON_AddNumberToObject(p, "freq_ppb", round(s.freq_ppb));
} }
if (s.delays.n) { if (s.delays.n) {
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ben Nicholson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ben Nicholson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ben Nicholson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+14 -5
View File
@@ -16,6 +16,7 @@
#include "lwip/inet.h" #include "lwip/inet.h"
#include "lwip/sockets.h" #include "lwip/sockets.h"
#define AES67_RATE 48000 // the only sample rate (all sources are 48 kHz)
#define MAX_FRAMES 192 // 4 ms at 48 kHz #define MAX_FRAMES 192 // 4 ms at 48 kHz
#define MAX_CH 2 #define MAX_CH 2
#define RTP_HDR 12 #define RTP_HDR 12
@@ -56,7 +57,7 @@ static bool aes67_validate(const cJSON *g, char *err, size_t n)
{ {
static const char *const discovery[] = { "manual", "sap", NULL }; static const char *const discovery[] = { "manual", "sap", NULL };
static const char *const encodings[] = { "L16", "L24", NULL }; static const char *const encodings[] = { "L16", "L24", NULL };
static const double rates[] = { 48000, 96000 }; static const double rates[] = { AES67_RATE }; // the sources (player, test signals) are 48 kHz
static const double ptimes[] = { 0.125, 0.25, 0.333, 1, 4 }; static const double ptimes[] = { 0.125, 0.25, 0.333, 1, 4 };
bool ok = cfg_check_str(g, "name", 1, 63, err, n) && bool ok = cfg_check_str(g, "name", 1, 63, err, n) &&
@@ -67,7 +68,7 @@ static bool aes67_validate(const cJSON *g, char *err, size_t n)
cfg_check_int(g, "dscp", 0, 63, err, n) && cfg_check_int(g, "dscp", 0, 63, err, n) &&
cfg_check_int(g, "channels", 1, 2, err, n) && cfg_check_int(g, "channels", 1, 2, err, n) &&
cfg_check_enum(g, "encoding", encodings, err, n) && cfg_check_enum(g, "encoding", encodings, err, n) &&
cfg_check_num_in(g, "rate", rates, 2, err, n) && cfg_check_num_in(g, "rate", rates, 1, err, n) &&
cfg_check_num_in(g, "ptime", ptimes, 5, err, n) && cfg_check_num_in(g, "ptime", ptimes, 5, err, n) &&
cfg_check_int(g, "pt", 96, 127, err, n) && cfg_check_int(g, "pt", 96, 127, err, n) &&
cfg_check_int(g, "ssrc", 0, 4294967295.0, err, n) && cfg_check_int(g, "ssrc", 0, 4294967295.0, err, n) &&
@@ -168,8 +169,6 @@ static int64_t samples_to_ns(int64_t s, int rate)
return (s / rate) * 1000000000LL + ((s % rate) * 1000000000LL + rate - 1) / rate; return (s / rate) * 1000000000LL + ((s % rate) * 1000000000LL + rate - 1) / rate;
} }
// 1 kHz tone, phase from the PTP sample index, so every sender's tone lines up.
// One period is rate / 1000 samples (48 at 48 kHz, 96 at 96 kHz): precomputed table.
// Pink noise: xorshift32 white noise through Paul Kellet's refined pink filter (within 0.05 dB // Pink noise: xorshift32 white noise through Paul Kellet's refined pink filter (within 0.05 dB
// above 9 Hz). The scale gives -18 dBFS RMS (measured over 10 s; peaks about -6 dBFS). // above 9 Hz). The scale gives -18 dBFS RMS (measured over 10 s; peaks about -6 dBFS).
#define PINK_SCALE 0.0714f #define PINK_SCALE 0.0714f
@@ -209,9 +208,11 @@ static void to_mono(int32_t *buf, int frames, bool sum)
} }
} }
// 1 kHz tone, phase from the PTP sample index, so every sender's tone lines up.
// One period is rate / 1000 samples (48 at 48 kHz): precomputed table.
static void tone(int32_t *buf, int frames, int channels, int rate, int64_t s0) static void tone(int32_t *buf, int frames, int channels, int rate, int64_t s0)
{ {
static int32_t table[96000 / TONE_HZ]; static int32_t table[AES67_RATE / TONE_HZ];
static int table_rate; static int table_rate;
int period = rate / TONE_HZ; int period = rate / TONE_HZ;
if (table_rate != rate) { if (table_rate != rate) {
@@ -361,5 +362,13 @@ esp_err_t aes67_tx_init(void)
if (err != ESP_OK) { if (err != ESP_OK) {
return err; return err;
} }
// Stored before 96 kHz was dropped: stored values aren't re-validated, so fix it here (SDP too).
cJSON *a = cfg_get("aes67");
double rate = cJSON_GetObjectItemCaseSensitive(a, "rate")->valuedouble;
cJSON_Delete(a);
if (rate != AES67_RATE) {
ESP_LOGW(TAG, "stored sample rate %.0f not supported: using %d", rate, AES67_RATE);
cfg_set_number("aes67", "rate", AES67_RATE, false);
}
return status_register(tx_status); return status_register(tx_status);
} }
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ben Nicholson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+31
View File
@@ -295,6 +295,37 @@ esp_err_t cfg_set_number(const char *group, const char *key, double value, bool
return err; 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 ----- */ /* ----- HTTP ----- */
static esp_err_t config_get(httpd_req_t *req) static esp_err_t config_get(httpd_req_t *req)
+2
View File
@@ -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. // 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). // 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); 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. // 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); bool cfg_check_num(const cJSON *g, const char *key, double min, double max, char *err, size_t n);
+8 -12
View File
@@ -13,13 +13,13 @@ Reference devices for UI and defaults: Riedel Bolero (PTP status), Riedel Direct
- Status table values can be text or {cls: ok|warn|bad, text} for colour. - Status table values can be text or {cls: ok|warn|bad, text} for colour.
- Device config is merged over defaults on load, so older firmware missing keys still renders. - Device config is merged over defaults on load, so older firmware missing keys still renders.
- Save bumps `aes67.session_ver` (SDP o= version). Save is blocked while any field is invalid (e.g. multicast out of range). - Save bumps `aes67.session_ver` (SDP o= version). Save is blocked while any field is invalid (e.g. multicast out of range).
- UI uses IEEE 1588-2019 terms (TimeTransmitter / TimeReceiver), like Riedel. Config/API values stay master/slave/auto. - UI uses IEEE 1588-2019 terms (TimeTransmitter / TimeReceiver), like Riedel. Config/API values stay slave/auto.
- AES67 fields carry Riedel Director-style "Default / Range" hints. - AES67 fields carry Riedel Director-style "Default / Range" hints.
- PTP preset buttons: "Riedel SIC defaults" and "AES67 media profile defaults" fill the form (Save to apply). - PTP preset buttons: "Riedel PTP defaults" and "AES67 Media PTP defaults" fill the form (Save to apply).
## Config schema (core groups) ## Config schema (core groups)
- ptp: {mode: multicast|hybrid, role: slave|auto|master, domain, priority1, priority2, log_sync, log_announce, announce_timeout, log_delay_req, dscp, hw_ts} - ptp: {mode: multicast|hybrid, role: slave|auto, domain, priority1, priority2, log_sync, log_announce, announce_timeout, log_delay_req, dscp} (hardware timestamps always; not configurable)
- aes67: {name, enabled, discovery: manual|sap, mcast, port, ttl, dscp, channels, mono_sum, encoding: L16|L24, rate, ptime, pt, ssrc, clk_offset, session_id, session_ver} - aes67: {name, enabled, discovery: manual|sap, mcast, port, ttl, dscp, channels, mono_sum, encoding: L16|L24, rate: 48000 only (all sources are 48 kHz), ptime, pt, ssrc, clk_offset, session_id, session_ver}
- net: {hostname, vlan, web_on: both|inet|aes67, dhcp, ip, mask, gw, dns} (AES67 / untagged interface) - net: {hostname, vlan, web_on: both|inet|aes67, dhcp, ip, mask, gw, dns} (AES67 / untagged interface)
- inet: {vlan_id, pcp, dhcp, ip, mask, gw, dns} (internet / tagged, only if net.vlan) - inet: {vlan_id, pcp, dhcp, ip, mask, gw, dns} (internet / tagged, only if net.vlan)
- log: {syslog, host, port, level: error|warn|info|debug, facility, format: rfc5424|rfc3164} - log: {syslog, host, port, level: error|warn|info|debug, facility, format: rfc5424|rfc3164}
@@ -52,7 +52,7 @@ Reference devices for UI and defaults: Riedel Bolero (PTP status), Riedel Direct
- Roles / BMCA dataset: - Roles / BMCA dataset:
- slave (TimeReceiver only): clockClass 255, never transmits time. - slave (TimeReceiver only): clockClass 255, never transmits time.
- auto (default): clockClass 248, priority1 250, priority2 250. Loses to any real GM (Riedel default 128); takes over only if none. - auto (default): clockClass 248, priority1 250, priority2 250. Loses to any real GM (Riedel default 128); takes over only if none.
- master (preferred TimeTransmitter): clockClass 248, priority1 100 (UI suggestion, editable). - To prefer this device as TimeTransmitter, use auto with a lower priority1 (e.g. 100). (A separate "master" role was dropped: it behaved like auto; a stored "master" is converted to auto at boot.)
- clockAccuracy 0xFE (unknown), offsetScaledLogVariance 0xFFFF, timeSource 0xA0 (internal oscillator). - clockAccuracy 0xFE (unknown), offsetScaledLogVariance 0xFFFF, timeSource 0xA0 (internal oscillator).
- clockIdentity = EUI-64 from MAC (xx-xx-xx-FF-FE-xx-xx-xx). - clockIdentity = EUI-64 from MAC (xx-xx-xx-FF-FE-xx-xx-xx).
- Note: Riedel Bolero reports its own clock class as 228. - Note: Riedel Bolero reports its own clock class as 228.
@@ -76,15 +76,11 @@ Reference devices for UI and defaults: Riedel Bolero (PTP status), Riedel Direct
| PTP State | state | INITIALIZING/LISTENING/UNCALIBRATED/SLAVE/MASTER/PASSIVE/FAULTY/DISABLED, shown as TimeReceiver/TimeTransmitter/… | | PTP State | state | INITIALIZING/LISTENING/UNCALIBRATED/SLAVE/MASTER/PASSIVE/FAULTY/DISABLED, shown as TimeReceiver/TimeTransmitter/… |
| Lock State | locked | servo converged (e.g. \|offset\| < 1 µs for N consecutive syncs) | | Lock State | locked | servo converged (e.g. \|offset\| < 1 µs for N consecutive syncs) |
| TimeTransmitter | gm_id | shown as MAC + "(FFFE)" when EUI-64 from MAC | | TimeTransmitter | gm_id | shown as MAC + "(FFFE)" when EUI-64 from MAC |
| Time Offset | offset_ns | Bolero brackets in ns: <100 (green), 100-500 (green), 500-1000 (amber), 1000-10000 (red), >10000 (red); exact value in brackets | | Time Offset (2 min avg) | offset_avg_ns | mean \|offset\| over the last 2 min (reset on a clock step); Bolero brackets in ns: <100 (green), 100-500 (green), 500-1000 (amber), 1000-10000 (red), >10000 (red). The current offset_ns is in Details |
| Frequency Deviation | freq_ppb | servo frequency correction; buckets <100 ppb, 100-500 ppb, 500 ppb-1 ppm, 1-10 ppm, 10-50 ppm, >50 ppm | | Frequency Deviation | freq_ppb | servo frequency correction; buckets <100 ppb, 100-500 ppb, 500 ppb-1 ppm, 1-10 ppm, 10-50 ppm, >50 ppm |
| Network Delay | path_delay_ns ± path_delay_sd_ns | mean path delay ± std dev over the rolling window | | Network Delay | path_delay_ns ± path_delay_sd_ns | mean path delay ± std dev over the rolling window |
| Hops | steps_removed | |
| Time/Frequency Traceable | gm_time_traceable, gm_freq_traceable | Announce flagField bits |
| Version | version | 2 |
| Own Clock Class | own_class | 255 / 248 per role |
Details (collapsed): clock_id, gm_class, gm_accuracy, gm_p1, gm_p2, sync_avg_ms/min/max + sync_jitter_us (measured Sync interval over the last `window` = 64 messages; RX as receiver, TX as transmitter), announce_avg_ms, delay_req/delay_resp counters, hw_ts. Details (collapsed): clock_id, current offset_ns, gm_class, gm_accuracy, gm_p1, gm_p2, hops (steps_removed), time/frequency traceable (gm_time_traceable, gm_freq_traceable: Announce flagField bits), version (2), own clock class (own_class: 255 / 248 per role), sync_avg_ms/min/max + sync_jitter_us (measured Sync interval over the last `window` = 64 messages; RX as receiver, TX as transmitter), announce_avg_ms, delay_req/delay_resp counters, hw_ts.
When this device is the GM, offset/frequency/delay show "–". When this device is the GM, offset/frequency/delay show "–".
## AES67 TX ## AES67 TX
@@ -125,7 +121,7 @@ When this device is the GM, offset/frequency/delay show "–".
## Firmware update (OTA) ## Firmware update (OTA)
- Partition table: nvs, otadata, phy_init, ota_0, ota_1 (no factory app). Size the slots from flash_id; e.g. on 16 MB, 2 × 6 MB leaves room for growth (cspot + TLS + codecs). Keep NVS outside the app slots so config survives updates. - Partition table: nvs, otadata, phy_init, ota_0, ota_1 (no factory app). Size the slots from flash_id; e.g. on 16 MB, 2 × 6 MB leaves room for growth (cspot + TLS + codecs). Keep NVS outside the app slots so config survives updates.
- Version: `PROJECT_VER` from `git describe --tags --dirty`, read at runtime from `esp_app_get_description()`; also reported as `status.fw`. - Version: `PROJECT_VER` = `<version.txt>-<git short hash>` (e.g. `0.0.1-1d613b1`; the first part set by hand), read at runtime from `esp_app_get_description()`; also reported as `status.fw`.
- API: - API:
- GET /api/ota -> {version, project, build_date, idf, running, previous, previous_version, pending_verify, can_rollback} - GET /api/ota -> {version, project, build_date, idf, running, previous, previous_version, pending_verify, can_rollback}
- POST /api/ota: raw .bin as `application/octet-stream`, streamed with esp_ota_begin/write/end into the inactive slot (never buffered whole in RAM). 200 then reboot; 4xx with a message if rejected. - POST /api/ota: raw .bin as `application/octet-stream`, streamed with esp_ota_begin/write/end into the inactive slot (never buffered whole in RAM). 200 then reboot; 4xx with a message if rejected.
+230
View File
@@ -0,0 +1,230 @@
# P4 AES67 Streamer: user guide
The P4 AES67 Streamer turns Spotify Connect or an internet radio stream (HLS / m3u8) into an **AES67 multicast stream**, locked to your PTP clock. Any AES67 receiver on the network can play it: a Riedel Artist 4-wire port, a Dante device in AES67 mode, a DAW, and so on.
It runs on a **Waveshare ESP32-P4-ETH** board, powered over PoE, and is set up entirely from a web page.
Contents: [Getting started](#getting-started) · [The web page](#the-web-page) · [Sources](#sources) · [Spotify](#spotify) · [AES67 output](#aes67-output) · [PTP](#ptp) · [Network](#network) · [Logging](#logging) · [Firmware updates](#firmware-updates) · [Player API](#player-api) · [Troubleshooting](#troubleshooting) · [Limitations](#limitations)
---
## Getting started
1. **Connect** the board's Ethernet port to a PoE switch port, or to a normal port and power it over USB-C. Use the same network (or VLAN) as your AES67 devices and your PTP grandmaster.
2. **Wait about 20 seconds.** The board gets an address by DHCP and locks to PTP.
3. **Open the web page** at **http://p4-aes67.local/**. Alternatively, look up the board's IP in your router's DHCP list (the name is `p4-aes67`) and open `http://<IP>/`.
4. **Pick a source** under *Source* and click **Save** (see [Sources](#sources)).
5. **On the receiver**, either find the stream via SAP, or copy the SDP from the page's *SDP* section (see [AES67 output](#aes67-output)).
Out of the box the board streams **2-channel, 24-bit, 48 kHz audio with 1 ms packets to 239.69.1.10:5004** and announces it by SAP under the name "P4 AES67".
> **More than one board?** Each board needs its own hostname, stream name and multicast address, or they clash. Change them under *Network* and *AES67 output*, or let `tools/flash_board.py` ask for them when you flash a new board.
---
## The web page
The page is split into sections, from top to bottom:
| Section | What it's for |
|---|---|
| **Status** | Firmware version, IP / MAC, link speed, active source, Spotify state, buffer, packets sent, underruns, uptime, memory, chip temperature. |
| **PTP status** | Whether the clock is locked, which grandmaster it follows, the time offset (bracket of the 2-minute average) and path delay. *Details* shows the current offset, hops and more. |
| **Player** | What's playing now, transport buttons, progress bar (drag to seek), volume. |
| **Source**, **PTP**, **AES67 output**, **Network**, **Logging** | Settings. They take effect only when you click **Save**. |
| **SDP** | The stream description, to copy or download for receivers. |
| **Firmware** | Update the firmware (see [Firmware updates](#firmware-updates)). |
**Saving:** *Save*, *Revert* (throw away unsaved edits) and *Reboot* stay at the bottom of the window while you scroll through the settings. Messages such as "Saved." or error texts appear next to them. Invalid values are rejected with the reason, and nothing is saved.
**Light / dark:** the page is dark by default. The **◐** button at the top right switches to light, and your browser remembers the choice.
---
## Sources
Choose the source under **Source → Source**:
| Source | What it plays |
|---|---|
| **Spotify Connect** | The board appears as a speaker in the Spotify app (default). Needs your own Spotify app credentials; see [Spotify](#spotify). |
| **HLS / M3U8 URL** | An internet radio stream, e.g. `https://…/playlist.m3u8`. Enter it under *Stream URL*. |
| **Spotify, fail over to HLS** | Spotify when someone plays to it, otherwise the stream (see below). |
| **Test tone** | 1 kHz sine at −18 dBFS, locked to PTP. For line-up and receiver tests. |
| **Pink noise** | Pink noise at −18 dBFS RMS (peaks around −6 dBFS), the same signal on both channels. For level and EQ checks. |
| **Off** | Silence. The stream keeps running. |
### Failover (Spotify, fail over to HLS)
- **Spotify playing:** the board plays Spotify, switching over within about a second of pressing play.
- **No Spotify connection:** after *Failover delay* seconds (default 5), the board switches to the HLS stream.
- **Paused:** with **Also fail over when paused** ticked, a paused Spotify counts as "not playing" and the stream takes over after the delay. Unticked (default), a pause gives silence and the board stays on Spotify.
- **Fades:** switches fade out and in over 30 ms, so there are no clicks.
- **Resuming:** Spotify is held while the stream plays. When you press play again, the song continues where you paused.
### Volume and gain
- **Volume (Player section):** the everyday volume. With Spotify it follows the app's volume slider, and the other way round.
- **Output gain (dB):** a fixed trim on top of the volume, −60 to +12 dB. Above 0 dB, loud passages can clip at full scale.
- **Neither affects** the test tone or pink noise. Those always come out at their calibrated level.
---
## Spotify
Since 2025, Spotify requires every Spotify Connect device to use a **developer app registered to your own account**. You need **Spotify Premium**. Setup takes about five minutes:
1. Go to **https://developer.spotify.com/dashboard** and log in.
2. **Create app**:
- Name and description: anything, e.g. "P4 AES67".
- Redirect URI: `http://127.0.0.1:8888/callback`. Spotify requires one, but this device never uses it.
- API: tick **Web API**, then save.
3. Open the app's **Settings**. Copy the **Client ID**, and click *View client secret* to copy the **Client secret**.
4. On the board's page under **Source**, paste them into **Spotify client ID** and **Spotify client secret**, then **Save**.
The secret is write-only: after saving, the field shows empty. Leave it empty to keep the stored secret, or type a new one to replace it.
**Connecting:** make sure your phone or computer is on the **same network** as the board. In the Spotify app, open the device list and pick **P4 AES67** (or the name you set under *Spotify device name*). Play, pause, skip, seek and volume all work from the app. The web page shows the track and position and can control playback too.
- **Spotify bitrate:** 96, 160 or 320 kbit/s (default 320).
- **Spotify device name:** the name shown in the app. Changing it disconnects a running session.
- **Status → Spotify** shows the state: e.g. *waiting for Spotify app*, *connected*, *no client credentials*, *login failed*.
---
## AES67 output
| Setting | Default | Notes |
|---|---|---|
| Stream name (s=) | P4 AES67 | The name receivers show. |
| Enabled | on | Off stops sending. |
| Discovery | SAP | **SAP**: announced every 30 s on 239.255.255.255:9875, so receivers that support SAP find it by themselves. **Manual**: no announcements; use the SDP. |
| RTP multicast IP / port | 239.69.1.10 : 5004 | Must be unique per stream on your network. |
| TTL | 32 | |
| DSCP (media) | 34 (AF41) | QoS marking for the audio packets. |
| Channels | 2 | 1 or 2. |
| Mono sum | off | Sends (left + right) / 2 as a 1-channel stream. Forces *Channels* to 1; it can't clip. |
| Bit depth | L24 | L24 or L16. |
| Sample rate | 48000 | Fixed; all sources are 48 kHz. |
| Packet time | 1 ms | 0.125, 0.25, 0.333, 1 or 4 ms. 1 ms is the AES67 default and works with nearly all receivers. |
| Payload type / SSRC / time stamp offset | 96 / 0 / 0 | Only change these if a receiver needs it. |
**Getting the SDP to a receiver:**
- **SAP:** receivers that listen for SAP (Riedel, many AES67 devices) list the stream by its name.
- **By hand:** in the *SDP* section, **Copy** or **Download .sdp** and import it on the receiver. The board also serves it at `http://p4-aes67.local/stream.sdp`.
- **When the SDP changes:** after a setting that changes the stream, the SDP gets a new version number. Re-import it on receivers that were set up by hand.
---
## PTP
The board locks its media clock to the PTP grandmaster on the network (IEEE 1588-2008, UDP/IPv4, E2E, always with hardware timestamps). *PTP status* shows the lock state and the grandmaster.
| Setting | Default | Notes |
|---|---|---|
| Mode | multicast | **hybrid** sends the delay requests unicast (fewer multicast packets). |
| Role | Auto | **TimeReceiver only**: never becomes grandmaster. **Auto**: becomes grandmaster only if there is none (fallback). To make this board the preferred grandmaster, keep *Auto* and set a low *Priority 1* (e.g. 100). |
| Domain | 0 | Must match your grandmaster. |
| Priority 1 / 2 | 250 / 250 | Lower wins the grandmaster election. |
| Intervals, timeout, DSCP (46) | | Presets below set them. |
**Presets:**
- **Riedel PTP defaults:** TimeReceiver only, priorities 128/126, Riedel's intervals. Use this when a Riedel system provides the clock.
- **AES67 Media PTP defaults:** the faster intervals of the AES67 profile.
A preset only fills in the fields; click **Save** to apply them.
Audio starts only when PTP is locked, usually about 20 s after power-up. When the board is itself the grandmaster (no other clock on the network), its clock starts at 1 January 1970. That's fine for AES67, but it isn't real time.
---
## Network
- **Hostname:** the name in DHCP, mDNS (`<hostname>.local`) and LLDP (the switch's neighbour list). Changing it applies at once.
- **DHCP (default):** with DHCP on, the greyed-out IP, netmask, gateway and DNS fields show the addresses DHCP handed out.
- **Static IP:** untick **DHCP**. The current addresses stay in the fields as a starting point; edit them and **Save**. The board **reboots** to apply them, and the page switches to the new address after 20 s. The page checks that the netmask is valid, that the IP isn't the subnet's network or broadcast address, and that the gateway is in the subnet.
- **A wrong static address makes the board unreachable** over the network. Double-check before saving; see [Troubleshooting](#troubleshooting) for recovery.
- With a static IP, your router's DNS name for the board can go stale. `http://<hostname>.local/` keeps working.
---
## Logging
The board can send its log to a syslog server (UDP):
- Tick **Send to syslog** and enter the server (hostname or IP) and port (default 514).
- **Minimum level:** Error, Warning, Info or Debug.
- **Facility and format:** RFC 5424 or RFC 3164 (BSD).
- **Send test message** checks the path.
The log shows PTP lock/unlock, source switches, stream errors and firmware updates, which makes it useful for troubleshooting.
---
## Firmware updates
**Over the network (normal way):** in the **Firmware** section, choose the new `aes67_p4.bin` and click **Upload & install**. The board installs it to its second firmware slot and reboots into it.
- The new firmware must **prove itself** within 60 s: network up and web page answering. Only then is it kept. If it fails or crashes, the board automatically goes back to the previous firmware.
- While the new firmware is on trial, the page offers **Keep this firmware** and **Roll back to previous**.
- During the upload the Spotify session ends and the stream pauses. Reconnect from the app afterwards.
- From a computer: `curl -f --data-binary @aes67_p4.bin -H 'Content-Type: application/octet-stream' http://p4-aes67.local/api/ota`
**Over USB (new board, or recovery):** `tools/flash_board.py` (needs ESP-IDF or `pip install esptool`, plus a build). It:
- checks the board (chip revision, 32 MB flash),
- optionally erases it (this clears all settings),
- flashes the firmware and finds the board's IP,
- asks for a hostname, stream name and multicast address.
**Making an update file:**
1. Set the version in **`version.txt`** (first line, e.g. `0.0.2`) and commit your changes.
2. Build: `idf.py build`. The firmware version becomes `<version>-<commit>`, e.g. `0.0.2-1d613b1`, as shown under *Firmware* and *Status*.
3. The update file is **`build/aes67_p4.bin`**. Upload it in the *Firmware* section, or with the `curl` command above.
The .bin is for ESP32-P4 chips of **revision v1.x** (the current Waveshare boards). A board with a v3 chip needs a build for that revision; the flash script refuses it with a hint.
---
## Player API
Everything the Player section does is also available over HTTP, e.g. for a control panel or Companion. Every command returns the current player state as JSON.
```
GET /api/player state, source, track, position, volume
POST /api/player/play | pause | toggle | stop | next | prev
POST /api/player/seek {"ms": 90000}
POST /api/player/volume {"value": 0-100} or {"delta": -5}
POST /api/player/source {"source": "spotify" | "hls" | "off" | "config"}
POST /api/player/url {"url": "https://…/playlist.m3u8"}
```
Example: `curl -X POST http://p4-aes67.local/api/player/next`
- **With Spotify:** the app follows every command. *stop* equals *pause*. *prev* restarts the song if it has played more than 3 s, like the Spotify apps.
- **With HLS (live radio):** *pause* stops downloading, and *play* rejoins the live stream. *next*, *prev* and *seek* return an error (409).
- **`source` and `url`:** temporary overrides; they're not saved, and a reboot or `"source": "config"` returns to the saved setting. `url` plays a stream right away.
- **Security:** there is no password. Keep the device on a trusted network.
The full device API (status, config, SDP, firmware) is described in `docs/aes67-core-base.md`.
---
## Troubleshooting
| Problem | What to try |
|---|---|
| **Can't find the page** | Try `http://p4-aes67.local/`, or the IP from your router's DHCP list. If the board has a static IP you no longer know, use `tools/flash_board.py` over USB with erase (resets all settings). |
| **Board doesn't appear in the Spotify app** | Phone or computer on the same network? *Status → Spotify* should say *waiting for Spotify app*. *no client credentials*: enter ID and secret. *login failed*: check them, and check that the account is Premium. |
| **"Can't connect" in Spotify on the first try** | Try again; a second attempt usually works. |
| **Spotify controls do nothing** after a long idle session | Quit and reopen the Spotify app, then connect again. |
| **No audio at the receiver** | *PTP status* locked? *Status → AES67 TX* counting packets? The receiver on the same grandmaster and domain? After changing stream settings, re-import the SDP. |
| **Stutter or dropouts** | *Status → underruns* rising? With HLS, check the internet connection. During a firmware upload short stutters are normal. |
| **HLS stream doesn't start** | Check the URL in a browser. *Status → Source* shows *buffering* while it loads, usually for a few seconds. |
---
## Limitations
These are known limitations in the current firmware:
- **Autoplay stream on boot:** the checkbox has no effect yet. HLS always starts on boot.
- **VLAN split** (separate VLANs for AES67 and internet) isn't available yet.
- **No password** on the web page or API.
- **HLS clock drift:** the radio station's clock and PTP drift slightly apart. Over many hours of continuous playback, the stream can skip ahead to catch up with the live edge.
+1
View File
@@ -0,0 +1 @@
0.0.1
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ben Nicholson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+26 -17
View File
@@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
<title>AES67 device</title> <title>AES67 device</title>
<!-- <!--
SPDX-License-Identifier: MIT (see web/LICENSE)
AES67 device web UI – reusable base. AES67 device web UI – reusable base.
CORE : status, PTP, AES67 output, network/VLAN, logging, SDP. Keep identical across projects. CORE : status, PTP, AES67 output, network/VLAN, logging, SDP. Keep identical across projects.
PROJECT: blocks between "PROJECT START/END" markers (HTML and the PROJECT object in the script). PROJECT: blocks between "PROJECT START/END" markers (HTML and the PROJECT object in the script).
@@ -98,15 +99,14 @@ e.g. curl -X POST http://p4-aes67.local/api/player/next
<!-- ===== PROJECT END ===== --> <!-- ===== PROJECT END ===== -->
<fieldset><legend>PTP</legend> <fieldset><legend>PTP</legend>
<button type="button" onclick="ptpPreset('riedel')">Riedel SIC defaults</button> <button type="button" onclick="ptpPreset('riedel')">Riedel PTP defaults</button>
<button type="button" onclick="ptpPreset('aes67')">AES67 media profile defaults</button> <button type="button" onclick="ptpPreset('aes67')">AES67 Media PTP defaults</button>
<label><span>Mode</span><select name="ptp.mode"> <label><span>Mode</span><select name="ptp.mode">
<option value="multicast">multicast</option><option value="hybrid">hybrid</option></select> <option value="multicast">multicast</option><option value="hybrid">hybrid</option></select>
<small>hybrid: Delay_Req/Resp unicast</small></label> <small>hybrid: Delay_Req/Resp unicast</small></label>
<label><span>Role</span><select name="ptp.role"> <label><span>Role</span><select name="ptp.role">
<option value="slave">TimeReceiver only</option> <option value="slave">TimeReceiver only</option>
<option value="auto">Auto (TimeTransmitter if none)</option> <option value="auto">Auto (TimeTransmitter if none)</option></select></label>
<option value="master">Preferred TimeTransmitter</option></select></label>
<label><span>Domain</span><input name="ptp.domain" type="number" min="0" max="127"></label> <label><span>Domain</span><input name="ptp.domain" type="number" min="0" max="127"></label>
<label><span>Priority 1</span><input name="ptp.priority1" type="number" min="0" max="255"></label> <label><span>Priority 1</span><input name="ptp.priority1" type="number" min="0" max="255"></label>
<label><span>Priority 2</span><input name="ptp.priority2" type="number" min="0" max="255"></label> <label><span>Priority 2</span><input name="ptp.priority2" type="number" min="0" max="255"></label>
@@ -122,7 +122,6 @@ e.g. curl -X POST http://p4-aes67.local/api/player/next
<option value="-4">-4 (16/s)</option><option value="-3">-3 (8/s)</option><option value="-2">-2 (4/s)</option> <option value="-4">-4 (16/s)</option><option value="-3">-3 (8/s)</option><option value="-2">-2 (4/s)</option>
<option value="-1">-1 (2/s)</option><option value="0">0 (1/s)</option><option value="1">1 (every 2 s)</option></select></label> <option value="-1">-1 (2/s)</option><option value="0">0 (1/s)</option><option value="1">1 (every 2 s)</option></select></label>
<label><span>DSCP (PTP)</span><input name="ptp.dscp" type="number" min="0" max="63"></label> <label><span>DSCP (PTP)</span><input name="ptp.dscp" type="number" min="0" max="63"></label>
<label><span>HW timestamping</span><input name="ptp.hw_ts" type="checkbox"></label>
<small>Transport UDP/IPv4 224.0.1.129 (ports 319/320), delay mechanism E2E.</small> <small>Transport UDP/IPv4 224.0.1.129 (ports 319/320), delay mechanism E2E.</small>
</fieldset> </fieldset>
@@ -145,7 +144,7 @@ e.g. curl -X POST http://p4-aes67.local/api/player/next
<small>(Ch 1 + Ch 2) / 2 → 1-channel stream</small></label> <small>(Ch 1 + Ch 2) / 2 → 1-channel stream</small></label>
<label><span>Bit depth</span><select name="aes67.encoding"><option>L24</option><option>L16</option></select> <label><span>Bit depth</span><select name="aes67.encoding"><option>L24</option><option>L16</option></select>
<small>Default L24</small></label> <small>Default L24</small></label>
<label><span>Sample rate</span><select name="aes67.rate"><option>48000</option><option>96000</option></select></label> <label><span>Sample rate</span><select name="aes67.rate"><option>48000</option></select></label>
<label><span>Packet time</span><select name="aes67.ptime"> <label><span>Packet time</span><select name="aes67.ptime">
<option value="0.125">0.125 ms</option><option value="0.25">0.250 ms</option><option value="0.333">0.333 ms</option> <option value="0.125">0.125 ms</option><option value="0.25">0.250 ms</option><option value="0.333">0.333 ms</option>
<option value="1">1.000 ms</option><option value="4">4.000 ms</option></select> <option value="1">1.000 ms</option><option value="4">4.000 ms</option></select>
@@ -284,7 +283,7 @@ function showPlayer(p) {
const CORE_DEF = { const CORE_DEF = {
// Intervals follow Riedel SIC AES67 defaults; role/priorities are the "fallback TimeTransmitter" setup. // Intervals follow Riedel SIC AES67 defaults; role/priorities are the "fallback TimeTransmitter" setup.
ptp:{mode:'multicast',role:'auto',domain:0,priority1:250,priority2:250,log_sync:0,log_announce:1, ptp:{mode:'multicast',role:'auto',domain:0,priority1:250,priority2:250,log_sync:0,log_announce:1,
announce_timeout:3,log_delay_req:0,dscp:46,hw_ts:true}, announce_timeout:3,log_delay_req:0,dscp:46},
aes67:{name:'AES67',enabled:true,mcast:'239.69.1.10',port:5004,ttl:32,dscp:34,pt:96,encoding:'L24', aes67:{name:'AES67',enabled:true,mcast:'239.69.1.10',port:5004,ttl:32,dscp:34,pt:96,encoding:'L24',
rate:'48000',channels:'2',ptime:'1',ssrc:0,clk_offset:0,mono_sum:false,discovery:'sap',session_id:1,session_ver:1}, rate:'48000',channels:'2',ptime:'1',ssrc:0,clk_offset:0,mono_sum:false,discovery:'sap',session_id:1,session_ver:1},
net:{hostname:'aes67',vlan:false,web_on:'both',dhcp:true,ip:'',mask:'',gw:'',dns:''}, net:{hostname:'aes67',vlan:false,web_on:'both',dhcp:true,ip:'',mask:'',gw:'',dns:''},
@@ -292,7 +291,7 @@ const CORE_DEF = {
log:{syslog:false,host:'',port:514,level:'info',facility:'16',format:'rfc5424'} log:{syslog:false,host:'',port:514,level:'info',facility:'16',format:'rfc5424'}
}; };
// Priority1 suggested when the role is changed in the UI (user can still edit it). // Priority1 suggested when the role is changed in the UI (user can still edit it).
const ROLE_P1 = {auto:250, master:100}; const ROLE_P1 = {auto:250};
// PTP presets. riedel = Riedel Director defaults for a SIC AES67 card. // PTP presets. riedel = Riedel Director defaults for a SIC AES67 card.
const PTP_PRESETS = { const PTP_PRESETS = {
riedel: {mode:'multicast', role:'slave', domain:0, priority1:128, priority2:126, riedel: {mode:'multicast', role:'slave', domain:0, priority1:128, priority2:126,
@@ -303,7 +302,7 @@ function ptpPreset(name) {
for (const [k, v] of Object.entries(PTP_PRESETS[name])) f['ptp.' + k].value = v; for (const [k, v] of Object.entries(PTP_PRESETS[name])) f['ptp.' + k].value = v;
toggle(); sdp(); msg.textContent = `Loaded ${name} PTP defaults – Save to apply.`; toggle(); sdp(); msg.textContent = `Loaded ${name} PTP defaults – Save to apply.`;
} }
const CLOCK_CLASS = {slave:255, auto:248, master:248}; const CLOCK_CLASS = {slave:255, auto:248};
const $ = id => document.getElementById(id); const $ = id => document.getElementById(id);
const f = $('f'), sdpEl = $('sdp'), msg = $('msg'); const f = $('f'), sdpEl = $('sdp'), msg = $('msg');
@@ -460,7 +459,7 @@ function offsetBucket(ns) {
// Same brackets and colours as Riedel Bolero. // Same brackets and colours as Riedel Bolero.
const [t, cls] = a < 100 ? ['< 100 ns','ok'] : a < 500 ? ['100-500 ns','ok'] : a < 1e3 ? ['500-1000 ns','warn'] const [t, cls] = a < 100 ? ['< 100 ns','ok'] : a < 500 ? ['100-500 ns','ok'] : a < 1e3 ? ['500-1000 ns','warn']
: a < 1e4 ? ['1000-10000 ns','bad'] : ['> 10000 ns','bad']; : a < 1e4 ? ['1000-10000 ns','bad'] : ['> 10000 ns','bad'];
return {cls, text: `${t} (${n(ns)} ns)`}; return {cls, text: t};
} }
function freqBucket(ppb) { function freqBucket(ppb) {
if (ppb == null) return '–'; if (ppb == null) return '–';
@@ -470,6 +469,13 @@ function freqBucket(ppb) {
return `${t} (${n(ppb)} ppb)`; return `${t} (${n(ppb)} ppb)`;
} }
const yn = v => v == null ? '–' : v ? 'Yes' : 'No'; const yn = v => v == null ? '–' : v ? 'Yes' : 'No';
// 93784 -> "1d 2h 3m 4s"; leading zero units left out.
function uptime(s) {
if (s == null) return '–';
const parts = [[Math.floor(s / 86400), 'd'], [Math.floor(s / 3600) % 24, 'h'], [Math.floor(s / 60) % 60, 'm'], [s % 60, 's']];
const i = parts.findIndex(([v]) => v > 0);
return parts.slice(i < 0 ? 3 : i).map(([v, u]) => v + u).join(' ');
}
function showPtp(p) { function showPtp(p) {
if (!p) { table($('ptpmore'), {}); return table($('ptpstat'), {'PTP': 'no data'}); } if (!p) { table($('ptpmore'), {}); return table($('ptpstat'), {'PTP': 'no data'}); }
@@ -478,18 +484,21 @@ function showPtp(p) {
'PTP State': PTP_STATE[p.state] || p.state, 'PTP State': PTP_STATE[p.state] || p.state,
'Lock State': p.locked ? {cls:'ok', text:'Locked'} : {cls:'bad', text:'Unlocked'}, 'Lock State': p.locked ? {cls:'ok', text:'Locked'} : {cls:'bad', text:'Unlocked'},
'TimeTransmitter': clockId(p.gm_id) + (gmSelf ? ' (this device)' : ''), 'TimeTransmitter': clockId(p.gm_id) + (gmSelf ? ' (this device)' : ''),
'Time Offset': gmSelf ? '–' : offsetBucket(p.offset_ns), // Bracket from the mean |offset| over the last 2 min; the current value is in Details.
'Time Offset (2 min avg)': gmSelf ? '–' : offsetBucket(p.offset_avg_ns),
'Frequency Deviation': gmSelf ? '–' : freqBucket(p.freq_ppb), 'Frequency Deviation': gmSelf ? '–' : freqBucket(p.freq_ppb),
'Network Delay': gmSelf ? '–' : `${n(p.path_delay_ns)} ± ${n(p.path_delay_sd_ns)} ns`, 'Network Delay': gmSelf ? '–' : `${n(p.path_delay_ns)} ± ${n(p.path_delay_sd_ns)} ns`,
'Hops': p.steps_removed,
'Time/Frequency Traceable': `${yn(p.gm_time_traceable)} / ${yn(p.gm_freq_traceable)}`,
'Version': p.version ?? 2,
'Own Clock Class': p.own_class
}); });
table($('ptpmore'), { table($('ptpmore'), {
'This clock': clockId(p.clock_id), 'This clock': clockId(p.clock_id),
// Same colours as the average's brackets, for the current value.
'Time offset now': gmSelf || p.offset_ns == null ? '–' : {cls: offsetBucket(p.offset_ns).cls, text: `${n(p.offset_ns)} ns`},
'TT class / accuracy': `${p.gm_class ?? '–'} / 0x${(p.gm_accuracy ?? 0).toString(16).toUpperCase()}`, 'TT class / accuracy': `${p.gm_class ?? '–'} / 0x${(p.gm_accuracy ?? 0).toString(16).toUpperCase()}`,
'TT priority 1 / 2': `${p.gm_p1 ?? '–'} / ${p.gm_p2 ?? '–'}`, 'TT priority 1 / 2': `${p.gm_p1 ?? '–'} / ${p.gm_p2 ?? '–'}`,
'Hops': p.steps_removed ?? '–',
'Time/Frequency Traceable': `${yn(p.gm_time_traceable)} / ${yn(p.gm_freq_traceable)}`,
'Version': p.version ?? 2,
'Own Clock Class': p.own_class ?? '–',
// Measured over the last p.window Sync messages (RX as receiver, TX as transmitter). // Measured over the last p.window Sync messages (RX as receiver, TX as transmitter).
'Sync interval avg': `${n(p.sync_avg_ms, 3)} ms (min ${n(p.sync_min_ms, 3)} / max ${n(p.sync_max_ms, 3)}, jitter ${n(p.sync_jitter_us, 1)} µs)`, 'Sync interval avg': `${n(p.sync_avg_ms, 3)} ms (min ${n(p.sync_min_ms, 3)} / max ${n(p.sync_max_ms, 3)}, jitter ${n(p.sync_jitter_us, 1)} µs)`,
'Announce interval avg': n(p.announce_avg_ms, 1) + ' ms', 'Announce interval avg': n(p.announce_avg_ms, 1) + ' ms',
@@ -523,7 +532,7 @@ async function poll() {
...(st.power ? {'Power source': st.power} : {}), ...(st.power ? {'Power source': st.power} : {}),
...PROJECT.statusRows?.(st), ...PROJECT.statusRows?.(st),
'AES67 TX': `${st.tx_packets} pkts, ${st.underruns} underruns`, 'AES67 TX': `${st.tx_packets} pkts, ${st.underruns} underruns`,
'Uptime': st.uptime_s + ' s', 'Heap / PSRAM free': `${st.heap_free} / ${st.psram_free}`, 'Uptime': uptime(st.uptime_s), 'Heap / PSRAM free': `${st.heap_free} / ${st.psram_free}`,
...temps(st.temps) ...temps(st.temps)
}); });
showPtp(st.ptp); showPtp(st.ptp);
@@ -544,7 +553,7 @@ async function otaInfo() {
try { try {
const o = await api('GET', '/api/ota'); const o = await api('GET', '/api/ota');
table($('fwinfo'), { table($('fwinfo'), {
'Version': o.version, 'Project': o.project, 'Built': o.build_date, 'ESP-IDF': o.idf, 'Version': o.version,
'Running slot': o.running, 'Previous slot': o.previous ? `${o.previous} (${o.previous_version ?? '?'})` : '–', 'Running slot': o.running, 'Previous slot': o.previous ? `${o.previous} (${o.previous_version ?? '?'})` : '–',
'State': o.pending_verify ? {cls:'warn', text:'New firmware on trial – confirm or roll back'} : 'Confirmed' 'State': o.pending_verify ? {cls:'warn', text:'New firmware on trial – confirm or roll back'} : 'Confirmed'
}); });