Skip to content

Ancs ble fixes#20

Open
mfalkvidd wants to merge 2 commits into
cyberneel:ancsfrom
mfalkvidd:ancs-ble-fixes
Open

Ancs ble fixes#20
mfalkvidd wants to merge 2 commits into
cyberneel:ancsfrom
mfalkvidd:ancs-ble-fixes

Conversation

@mfalkvidd
Copy link
Copy Markdown

Sorry, there were two commits to fix the ble ancs issues. The patch isn't that small unfortunately. But it works, and maybe it is possible to make it smaller before merging by removing changes that aren't strictly required.

Disclosure: I used Codex to find the problem and implement the patch.

mfalkvidd added 2 commits May 7, 2026 15:45
Delay BLE service discovery until the link is encrypted instead of starting it
immediately after connection. Some phones appear to reject or ignore ANCS setup
while pairing/security is still in progress, leaving notifications stuck until
Bluetooth is toggled on the phone.

Also make ANCS descriptor setup more robust by discovering CCCDs one at a time,
using each characteristic's actual handle range, subscribing sequentially, and
finishing discovery only once subscription state is known.
Start BLE service discovery only after the connection has reached an
encrypted state instead of using the generic BleConnected delay. iOS only
exposes and authorizes ANCS after pairing/security is complete, so the old
timer-based path could race the pairing flow and miss ANCS entirely. In that
case the notification permission dialog would not appear until a later
Bluetooth reconnect.

Also tighten the ANCS setup path so descriptor discovery and CCCD writes are
serialized and scoped to the actual Notification Source and Data Source
characteristics. This removes the bogus write to the ANCS service end handle
and avoids treating the Control Point as a subscribable characteristic.

Finally, fix the advertising data to describe ANCS correctly. InfiniTime is an
ANCS client, not an ANCS server, so the ANCS UUID should not be advertised as a
local service. Keep DFU in the local 128-bit service UUID list and place ANCS
in the scan response as a 128-bit Service Solicitation UUID. This keeps the
legacy advertising payload within size limits and should make LE scanners such
as bluetoothctl behave more reliably.
@liamcharger
Copy link
Copy Markdown
Collaborator

@cyberneel can you look over this :))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants