T-vK / ESP32-BLE-Keyboard

Bluetooth LE Keyboard library for the ESP32 (Arduino IDE compatible)
2.4k stars 399 forks source link

after arduino shutsdown must re-pair to work properly... #212

Open lf1969 opened 1 year ago

lf1969 commented 1 year ago

hi.

if shutdown the arduino while a connection is established, when arduino is restarted, the arduino says is connected and sending messages, the host device is also connected but messages are not processed.

if I upair/pair, it works again. after the pairing if I restart the BT connection for the host, all is fine.

Just cant stop the arduino :( .

ekoslav commented 1 year ago

Try using NimBLE mode, it worked for me with the same problem.

lf1969 commented 1 year ago

Hi.

Thanks for your reply.

You referring to:

https://github.com/h2zero/NimBLE-Arduino

On Sat, Feb 4, 2023, 13:53 Ekoslav @.***> wrote:

Try using NimBLE mode, it worked for me with the same problem.

— Reply to this email directly, view it on GitHub https://github.com/T-vK/ESP32-BLE-Keyboard/issues/212#issuecomment-1416824805, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5VLWVJDWEDQ4LCEECUFFRLWV2QRRANCNFSM6AAAAAAURDDULE . You are receiving this because you authored the thread.Message ID: @.***>

ekoslav commented 1 year ago

This library has it.

https://github.com/T-vK/ESP32-BLE-Keyboard#nimble-mode

NimBLE-Mode The NimBLE mode enables a significant saving of RAM and FLASH memory.

Hot to activate NimBLE mode

lf1969 commented 1 year ago

Hi.

Sorry to bother you again.

I've enabled nimble, flashed my chip with latest firmware, still not working properly.

I'm using this board:

Teyleten Robot ESP32S ESP32 ESP-WROOM-32 Development Board 2.4GHz Dual-Core WiFi +Bluetooth 2 Function Microcontroller for Arduino (ESP32 38P, 3PCS) https://a.co/d/hkgr0ai

If you like I can send you money to purchase a board to determine why this is an issue?

On Mon, Feb 6, 2023, 11:36 Ekoslav @.***> wrote:

This library has it.

https://github.com/T-vK/ESP32-BLE-Keyboard#nimble-mode https://github.com/T-vK/ESP32-BLE-Keyboard:

NimBLE-Mode The NimBLE mode enables a significant saving of RAM and FLASH memory.

Hot to activate NimBLE mode https://github.com/T-vK/ESP32-BLE-Keyboard#how-to-activate-nimble-mode

— Reply to this email directly, view it on GitHub https://github.com/T-vK/ESP32-BLE-Keyboard/issues/212#issuecomment-1419380100, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5VLWVPFGVIYSQA72GVFNFLWWESANANCNFSM6AAAAAAURDDULE . You are receiving this because you authored the thread.Message ID: @.***>

ekoslav commented 1 year ago

I am not sure if you noticed, to enable NimBLE you need to make a change in the library file, not your application. To test it yourself, I think it is probably easiest is to temporary flash one of your boards with the tested to work software ( without compiling). Here is the link to my project that is tested to automatically re-connect to Win 11: https://www.tenpurplebirds.com/?page_id=375

image Select the version 1.13, and flash it over the web. This way, if it does work, there is an issue with you library setup. Otherwise it may be the compatibility of your board. This way test cost nothing but about 10 minutes of your time :)

ekoslav commented 1 year ago

I forgot to mention that you do not need to attach anything to ESP32 board. Once booted it should show up as this: image The last 4 digits in the name a re specific to a board MAC. Once paired, you can power cycle ESP or the Windows machine, and see if they connect automatically. On the ESP you can monitor events in the serial console. Also the board you mentioned, looks almost identical to ones I use.

lf1969 commented 1 year ago

Thanks for the tip!

On Tue, Feb 7, 2023, 14:24 Ekoslav @.***> wrote:

I forgot to mention that you do not need to attach anything to ESP32 board. Once booted it should show up as this: [image: image] https://user-images.githubusercontent.com/1462377/217344520-49fb40cc-a2ef-4bed-99a7-95349c663b28.png The last 4 digits in the name a re specific to a board MAC. Once paired, you can power cycle ESP or the Windows machine, and see if they connect automatically. On the ESP you can monitor events in the serial console.

— Reply to this email directly, view it on GitHub https://github.com/T-vK/ESP32-BLE-Keyboard/issues/212#issuecomment-1421325972, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5VLWVLYZD6SEAQ4SVN5IPLWWKOPHANCNFSM6AAAAAAURDDULE . You are receiving this because you authored the thread.Message ID: @.***>

joostbijl commented 1 year ago

I had the same issues, see #166 for a way that works for me.

I never became friends with NimBLE so far

lf1969 commented 1 year ago

Thanks for getting back to me.

Its related to having ble classes in multiple locations and to make matters worse if I use a different board it works.

On Tue, Feb 14, 2023, 18:46 joostbijl @.***> wrote:

I had the same issues, see #166 https://github.com/T-vK/ESP32-BLE-Keyboard/issues/166 for a way that works for me.

I never became friends with NimBLE so far

— Reply to this email directly, view it on GitHub https://github.com/T-vK/ESP32-BLE-Keyboard/issues/212#issuecomment-1430539171, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5VLWVORRK3AMMXRVC6D7I3WXQKPFANCNFSM6AAAAAAURDDULE . You are receiving this because you authored the thread.Message ID: @.***>

luissperber commented 1 year ago

I am not sure if you noticed, to enable NimBLE you need to make a change in the library file, not your application. To test it yourself, I think it is probably easiest is to temporary flash one of your boards with the tested to work software ( without compiling). Here is the link to my project that is tested to automatically re-connect to Win 11: https://www.tenpurplebirds.com/?page_id=375

image Select the version 1.13, and flash it over the web. This way, if it does work, there is an issue with you library setup. Otherwise it may be the compatibility of your board. This way test cost nothing but about 10 minutes of your time :)

This library has it.

https://github.com/T-vK/ESP32-BLE-Keyboard#nimble-mode

NimBLE-Mode The NimBLE mode enables a significant saving of RAM and FLASH memory.

Hot to activate NimBLE mode

Works perfectly! Could you tell me what version of NinBLE is used and what version of BLE-Keyboard? Is there another secret?

pookzilla commented 5 months ago

For those who are having issues with this I found switching to NimBLE and replacing BLEDevice::setSecurityAuth(true, true, true); with BLEDevice::setSecurityAuth(true, false, false); in BleKeyboard.cpp fixed my issues (on MacOS at least - I still can't connect at all via Steam deck.) I can now power cycle the device and it will reconnect.