-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Pin and Passkey Entry pairing on Linux and Windows #523
Add support for Pin and Passkey Entry pairing on Linux and Windows #523
Conversation
Just curious, what is the use case for this? To have unattended connections? Or for use on headless systems?
Please don't squash all of this into one commit. Having individual commits for each small change is just as helpful to future code archeologist as it is to pull request reviewers. |
All of them in fact. I use Even if pairing with simple devices which have some preset 0000 or 1234 passkey, callback is required. - Oh, I get your question now: I could use Also one other use case which is not possible with manual pairing at all: BLE device has some algorithm in the secure area, which generates TOTP tokens and belonging pairing passkeys. Such "TOTP" token is advertised in advertising data and changes every 10 seconds. Host needs to scan this token, send it via cloud API to the server (which is the only other location containing this algorithm) to get the matching pairing passkey, initiate pairing and use this passkey. Such thing is not possible to do manually.
I agree, but I will tidy them up (e.g. changes from last commit shall be rebased to the commits responsible for them). I've just read that in the contributing guidelines. |
Signed-off-by: Bojan Potočnik <[email protected]>
This agent currently does nothing, it just logs method calls to check if it is properly registered. Signed-off-by: Bojan Potočnik <[email protected]>
Signed-off-by: Bojan Potočnik <[email protected]>
Also pairingAgent is moved to BleakClient class for easier access Signed-off-by: Bojan Potočnik <[email protected]>
Also modify example to use this callback and retrieve passkey from the user. Signed-off-by: Bojan Potočnik <[email protected]>
Signed-off-by: Bojan Potočnik <[email protected]>
Ensure that if no callback is provided, pairing works as before, meaning that Just Works pairing requests are confirmed. Signed-off-by: Bojan Potočnik <[email protected]>
Signed-off-by: Bojan Potočnik <[email protected]>
45e3f75
to
b30b7c2
Compare
i tested the code with my esp32 device, on my linux system and can approve it worked good for me! @hbldh is it possible to release a version with this content? if not public version then a private version package would realy appreciate it. *forgive me about my duplicated questions about the release, i dont really know whats the process. |
@asafs932 thank you for testing. I went to test this on Windows but I think that this needs some more thinking for actual release. And there is a problem with CoreBluetooth - as far as my iPhone experience goes, pairing is handled by the system and you cannot provide the passkey using custom code. So even if this code is added, it will never work on CoreBluetooth (I hope that someone can correct me). In any case, I do not own any CoreBluetooth device to test. I can tidy it up and implement it for Windows in the next few days, remove Draft label and then wait for any additional comments and feedback. Or, if we are OK with some feature being supported only on one platform (Bluez), I can ignore Windows for now and do it faster. |
@bojanpotocnik thanks for the fast response and the kind explanation. |
Do I assume correctly, that you did not provide the pair(callback=) parameter? In that case everything is OK - but if you did provide the callback, then it shall be invoked instead of this popup. |
i did: my connection code:
the callback func:
so it shouldnt raise the pop up? i tried now without the callback and same behavior (pop up rise), what am i doing wrong? is it possible to avoid the pop up and insert the passkey in code? |
You are doing nothing wrong. But the whole point of this PR is to provide the passkey programmatically, so there shall be no popup. Looks like custom pairing agent is being registered and system agent is used instead. import os
os.environ["BLEAK_LOGGING"] = "1" on the very beginning of the file (before you import |
without sudo:@bojanpotocnik
with sudo its the same:
|
Great work here. Have you had a chance to try this out on Windows? I have a requirement to automate testing pairing to an embedded device with a pin and am hoping your fork will help with that. If you haven't been able to test it yet, I'd be happy to help in any way I can. |
Builds on PR hbldh#523 to include pairing for Windowns with both dotnet and winrt backends. Updated timeout in connect to use the same timeout as provided to the connect function.
Added windows pairing to .NET and WinRT backends, following the process started in PR hbldh#523.
Superseded by #640 which builds on this PR. |
This PR currently contains multiple commits so it is easier to follow what changes has been made, will squash before eventual merge.