Repository navigation
Add the ebus_discovery target: TXT records, MdnsBackend, broker discovery - #8
Merged
Merged
Conversation
ebus_discovery is the second component of the split: discovery/include/ ebus/discovery/ and discovery/src/, built by discovery/CMakeLists.txt with only its own include directory and no dependency. broker_discovery.h, broker_discovery.cpp and mdns_strings.h move into it unchanged in behavior. ebus_core links it, so consumers keep one target. <platform/broker_discovery.h> and <platform/mdns_strings.h> stay as forwarding headers, so esp32-sdk's includes build unchanged. The broker suite becomes test_discovery_broker, which links ebus_discovery alone. library.json compiles discovery/src/ and adds discovery/include to the include path. Part of #3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Npk6WmkpnBRzWkuhK6uCuz
ebus/discovery/txt_records.h builds the TXT records of _ebus._tcp, _device-info._tcp, _http._tcp and _telnet._tcp from one EbusIdentity, with the keys, order and omission rules of framework.md and of ebus-service-discovery's Identity and HttpService, plus the homie_domain, homie_version and homie_roles keys esp32-sdk advertises today. Roles and auth methods are bit sets, written in the order framework.md lists them. A TxtRecord holds up to EBUS_TXT_MAX_PAIRS pointers to the caller's strings and to constants; nothing is allocated. txt_record_add() refuses an invalid or duplicate key (case-insensitive) and a "key=value" over 255 bytes, as the Python check_txt() does; a builder that fails leaves the record empty. mdns_strings.h gains broker_ca, hw_version, broker-host and the individual auth method values. test_discovery_txt repeats the Python library's TXT cases and the records esp32-sdk's network.cpp builds, with file:line references. Part of #3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Npk6WmkpnBRzWkuhK6uCuz
ebus/discovery/mdns_backend.h is the interface a port implements over its mDNS stack: advertise() one service type with a TXT record, browse() a service type with a callback per instance, and resolve() a bare host name. Results are borrowed for the callback, so neither side allocates. The host name claim stays in the port's stack setup. ebus/discovery/broker_browse.h moves esp32-sdk's broker selection onto it: broker_browse() takes the first instance with an address, in the list's service order, with the service's default port when the SRV record has none; broker_reresolve() is the single host query after repeated reconnect failures. broker_service_type() gives the DNS-SD type of each broker service, and mdns_strings.h the full types of the services an entity advertises. test_discovery_backend runs both against a fake backend. Part of #3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Npk6WmkpnBRzWkuhK6uCuz
Part of #3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Npk6WmkpnBRzWkuhK6uCuz
doc/discovery.md covers the headers, the builders and their rules, the remaining differences between esp32-sdk, ebus-service-discovery and framework.md, the MdnsBackend contract, broker discovery over it, and the options for a POSIX backend. README, doc/core.md, the changelog and .ebus-spec.json's note name the new target. Part of #3 Closes #5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Npk6WmkpnBRzWkuhK6uCuz
This was referenced Oct 9, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5. Part of #3.
Adds
ebus_discovery, a CMake target that depends on the standard library only (discovery/,doc/discovery.md), linked byebus_coreand built by PlatformIO throughlibrary.jsonlikeebus_mqtt.ebus/discovery/txt_records.hEbusIdentityandtxt_build_ebus(),txt_build_device_info(),txt_build_http(),txt_build_log(), which fill a fixed-sizeTxtRecord(borrowed pointers, no heap)ebus/discovery/mdns_backend.hMdnsBackend:advertise(),browse()with a per-instance callback,resolve()ebus/discovery/broker_browse.hbroker_browse()andbroker_reresolve(), esp32-sdk's broker selection overMdnsBackendebus/discovery/broker_discovery.h,mdns_strings.hinclude/platform/; the old paths forward hereThe TXT keys, order and omission rules follow framework.md, ebus-service-discovery's
Identity/HttpService, and esp32-sdk'snetwork.cpp;test_discovery_txtrepeats both libraries' records with file:line references.doc/discovery.mdlists the remaining differences (the_ebus._tcpport, thehomie_*keys, the HTTPversiondefault).Verified locally: top-level CMake build and CTest (Clang and GCC 16, warnings as errors), the POSIX port and its e2e tests against a local mosquitto,
ebus_discoverycompiled with its own include directory only, and esp32-sdkmainwith this branch aslib/ebus_core:./ebus-esp32 build(esp32-poe-iso) and./ebus-esp32 testpass; flash +92 bytes against cpp-sdk 0.2.0, RAM unchanged.🤖 Generated with Claude Code
https://claude.ai/code/session_01Npk6WmkpnBRzWkuhK6uCuz