Repository navigation
Conversation
NsdManager registers the AirPlay service without any address record on API 34+: `dumpsys servicediscovery` reports "hostAddresses: " and "hostname: null", so the SRV target points at a name that never resolves. Clients receive PTR/SRV/TXT but can never learn the receiver IP and therefore never open a connection to the AirPlay port, while the iPhone UI keeps showing CarPlay as connected. Publish the records ourselves on a socket bound to the hotspot interface (RawMdnsResponder): PTR/SRV/TXT plus an explicit A record in the additional section, answered as multicast and as a unicast reply to the querier, because some SoftAP drivers drop multicast towards power-saving stations. Announcements repeat every 30 s and a goodbye (TTL 0) is sent on close. _raop._tcp is published as well, since iOS browses it together with _airplay._tcp when it enumerates receivers. The NSD path is kept as a fallback when the socket cannot be opened, so a busy port 5353 cannot break the wireless bring-up.
The advertised features value 0x44540380 clears bit 0 (Video), so the TXT record describes an audio-only receiver. iOS filters on that bit before it offers a device: the receiver never appeared in Control Center's screen mirroring list, and wireless CarPlay stayed on the iPhone's "connected" screen without ever opening a TCP connection to port 7000, even with correct MFi authentication, a live iAP2 session and the iPhone joined to the accessory hotspot. Advertise 0x5A7FFFF7,0x1E instead. On the same unit and iPhone, the receiver then shows up in the mirroring list, connects, and CarPlay renders H.264 (1080x1826, ~40 fps, no sync skips). The bitmap is intentionally Apple-TV shaped rather than a minimal CarPlay set: the exact bit-to-capability mapping for CarPlay is not documented, and over-claiming has been verified not to break the session. It should still be narrowed once the required bits are isolated.
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.
设备:三星 Z Flip 5(Android 14,xcertplay 1.4.2,MFi 走 CH341A/I2C);iPhone 16(iOS 18.2.1,无线 CarPlay);热点为配件自带 SoftAP。
现象:无线 CarPlay 起不来,且两端都不报错。MFi 认证成功、iAP2 正常(0x4300 / 0x4301 / 0x5703)、iPhone 已加入热点,但 7000 端口从未收到任何 TCP 连接。
根因(两处静默失败):
API 34+ 忽略 NsdServiceInfo.setHost(),_airplay._tcp 发布时没有 A 记录(hostname: null),SRV 目标无法解析 → 客户端拿不到 IP。
TXT features=0x44540380 的 bit0(Video)为 0,iOS 按位图过滤,该接收端不会被提供。
修复:
新增 RawMdnsResponder,自发布 PTR/SRV/TXT + 显式 A 记录(NSD 保留为回退),并补发 _raop._tcp。
features 改为 0x5A7FFFF7,0x1E。
验证:同机同 iPhone,接收端出现在镜像列表,:7000 ESTAB,H.264 1080x1826 约 40fps 解码,CarPlay 界面出现。
详细说明: