-
Notifications
You must be signed in to change notification settings - Fork 32
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
Can't Reconnect paired device after power cycling device #2
Comments
This is odd. You're mentioning a reset. Is this a full power cycle on the keyboard? If so, the Bluetooth might require pairing again. Note that this package does not (yet?) support Bluetooth bonding. |
What's happening is that it pairs fine the first time, then any time I do a
d.start() it requires forgetting it in Windows Bluetooth then adding it
again.
I see, well that's unfortunate. Is there any intention to support it
because aside of that, everything works superbly and was easy to implement.
That is literally the only thing that'd prevent usage. For a peripheral
being unable to pair once again is a requirement at this point.
That said, it seems to be ATTEMPTING to. Windows tries to pair again but it
seems the device rejects the pairing, then it tries again and again, it
goes in a pairing loop.
…On Fri, Sep 17, 2021 at 3:53 AM Heerko Groefsema ***@***.***> wrote:
This is odd. You're mentioning a reset. Is this a full power cycle on the
keyboard? If so, the Bluetooth might require pairing again.
Note that this package does not (yet?) support Bluetooth bonding.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH7Y3L6IQ55J3X75H3JQPJLUCLXWHANCNFSM5EGMW6CQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
I'm assuming you are using my keyboard example and that you're calling d.stop() before calling d.start() for the second time. The way this simple keyboard example works is that in the init, it calls self.keyboard.start(), where keyboard is the device from the package. When you call d.stop(), it calls self.keyboard.stop(), which stops all Bluetooth services. When you then call d.start(), it never calls self.keyboard.start() again. If you want this start/stop behavior, I suggest implementing a d.restart() method that first calls self.keyboard.start() and then calls the d.start() loop. I hope this solves the issue! |
The issue I am experiencing is where I reset the device (by pressing the button or unplugging) then it tries to start again but doesn't succeed in reconnecting to Windows. |
Ok, thanks. I think this is an issue where (somehow) Windows doesn't recognize the device as the same one that was paired earlier. I'm unsure why this is happening. It could be the lack of bonding, but I'm unsure. It could also be another Bluetooth issue. I would need to look into this, but can't promise quick results. As a temporary solution, you could consider starting/stopping the device and putting the device in some deep sleep mode instead of fully power cycling. |
Thank you for your answers, I'll try to fiddle with it. Hopefully you figure it out. |
I have been able to replicate your issue. The issue appears when the bluetooth device is restarted either through a hardware reset or by the software calling The issue is indeed a pairing/bonding issue. as confirmed through this MicroPython issue. I have pushed a new version of the package, for which bonding and secure pairing can be enabled, that should work. I say should, because the ESP32 implementation of MicroPython does NOT support this behavior (as confirmed in the linked issue). I own only ESP32 devices and, therefore, can't test properly. Calling methods related to bonding, or secure pairing, on an ESP32 will result in errors. In case your hardware is not an ESP32 device, you may try the code from my latest push and call |
Well, that's unfortunate since my device is an esp32.
Thank you for your hard work. I'll keep it in mind for the future when I
select hardware for ble.
Do you reckon esp8266 have the same issue?
…On Wed., Sep. 22, 2021, 6:08 a.m. Heerko Groefsema, < ***@***.***> wrote:
I have been able to replicate your issue. The issue appears when the
bluetooth device is restarted either through a hardware reset or by the
software calling stop(), creating a new device, and calling start() for
the newly created device.
The issue is indeed a pairing/bonding issue. as confirmed through this
<micropython/micropython#5767> MicroPython
issue.
I have pushed a new version of the package, for which bonding and secure
pairing can be enabled, that *should* work. I say *should*, because the
ESP32 implementation of MicroPython does NOT support this behavior (as
confirmed in the linked issue). I own only ESP32 devices and, therefore,
can't test properly. Calling methods related to bonding, or secure pairing,
on an ESP32 will result in errors. In case your hardware is not an ESP32
device, you may try the code from my latest push and call
set_bonding(True) and set_le_secure(True) before calling start() from the
package. Please do let me know about the results! In case your device is
also an ESP32 device, it seems we will both have to wait until the behavior
is supported in a future MicroPython build (if ever).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH7Y3LY37NDQDG2MLVFWV6LUDGTJTANCNFSM5EGMW6CQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
The MicroPython Bluetooth documentation notes the following under the Pairing and bonding section:
This is all I know. |
Alright, thank you. Good thing this was a personal project and nothing
more. Ultimately it's just an annoyance but can be worked around.
I'm still surprised something as bad was left in. Esp32 is super popular
and mostly because of its Bluetooth. Oh, wait esp8266 doesn't even have
Bluetooth so that answers that question.
…On Wed., Sep. 22, 2021, 6:25 a.m. Heerko Groefsema, < ***@***.***> wrote:
The MicroPython Bluetooth implementation notes the following under the Bonding
section
<https://docs.micropython.org/en/latest/library/bluetooth.html#pairing-and-bonding>
:
This is currently only supported when using the NimBLE stack on STM32 and
Unix (not ESP32).
This is all I know.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH7Y3LYR7MHBOHKNJG4NYJTUDGVKHANCNFSM5EGMW6CQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Now esp32 micropython supported Pairing and bonding section,I have tested,it worked. |
Do you have a source for this information? The documentation still says it's not supported for ESP32.
Call |
Thanks here is link |
Nice! Four days ago. Can you try calling |
I test it with android phone,
when pair first time ,here are the print codes:
Unhandled IRQ event: 4 means |
I'm going to assume that the After calling You can set i/o capabilities by calling |
@jd3096-mpy did this work? |
passkey works |
I have just pushed a version which allows bonding, solving this issue. |
Thanks a lot. |
This issue occurs again on MicroPython version 1.24, and the Bluetooth that has been paired before cannot be connected after restarting. Steps: Restart ESP32 and run the keyboard_example.py to print the following data: |
I've pushed a new version that hopefully fixes the issue. |
Can you try with this earlier version? |
Could be. I can confirm it works perfectly with version 1.23. Could you try that? |
I'll give it a try,thank you! |
When I attempt to reconnect a keyboard that's already been paired with Windows 10, I get this:
Started advertising
Central connected: 0
Central disconnected
Connecting for the first time seems to be fine, but as soon as I do a reset, it doesn't work.
The text was updated successfully, but these errors were encountered: