Skip to content

feat(windows-ble): auto-pair on characteristic read#421

Draft
igiona wants to merge 1 commit into
inthehand:mainfrom
igiona:WindowsAutoPairOnRead
Draft

feat(windows-ble): auto-pair on characteristic read#421
igiona wants to merge 1 commit into
inthehand:mainfrom
igiona:WindowsAutoPairOnRead

Conversation

@igiona
Copy link
Copy Markdown
Contributor

@igiona igiona commented Jun 20, 2024

I noticed that on Windows, when I try to read a pairing-protected characteristic the Windows implementation simply returns null.

In the mobile apps though, the OS detect such a read and automatically performs a pairing request and the user gets prompt with the standard pairing UI.
In my case I'm using justworks, hence a simple "yes/no" is prompted.

When I try to read that characteristic while unpaired on Windows, I get a ProtocolError status (I would guess that AccessDenied is more appropriate, but that's what I see..)

This PR as-is, is meant to trigger a discussion on this issue more than being real merge-request.

Attempt1 Basic Pairing

Here for me the pairing never worked, Service.Device.NativeDevice.DeviceInformation.Pairing.PairAsync() always immediately returned the status Failed.
I'll tried to debug further more this. Every suggestion is welcomed.

Attempt2 (this PR) Custom pairing

The code introduces the iOS & Android behaviour on Windows, although I did not implemented any UI hence the pairing happens silently and works only in a justworks scenario (not good of course, but I wanted to get it to work quick&dirty).

What's your opinion on this @peterfoot ?
Do you like to align the behaviour to the mobile platforms?

@peterfoot
Copy link
Copy Markdown
Member

Sorry for the delay in responding. I like the idea of this, and I'm guessing it will need implementing on writes as well. I share your concern about how to handle other pairing types, I think the behaviour on mobile would be to prompt the user with the standard UI but I would need to test this. I think this functionality is very much needed as by following the WebBluetooth model there is no explicit pairing API and so it needs to be smarter like 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