ESP32-BLE-Keyboard icon indicating copy to clipboard operation
ESP32-BLE-Keyboard copied to clipboard

How to put ESP32 in 'pairing mode'

Open joostbijl opened this issue 3 years ago • 10 comments

Hi,

i have created a set of handlebar buttons for navigating on my motorcycle, see details here: https://jaxeadv.com/gear-gadgets/navigation-setup/handlebar-buttons/. This library is really useful for that, i'm a big fan!

What i can't seem to work out is how to pair the esp32 to a new phone. I'm looking for the way to put the esp32 in pairing mode so that i can connect it to a different phone (forgetting the previously connected phone).

I'm assuming it has to do with the BLEScan method? But i'm probably missing something, because all the info i can find seems very convoluted for the simple thing i'm trying to do.

Thanks!

joostbijl avatar Feb 19 '22 16:02 joostbijl

Hi @joostbijl ! That is a very nice project! 👍

I'm not a BLE expert and maybe I don't understand the question correctly, but the BleKeyboard is automatically in pairing mode unless there is a connection.

Have you tried the BleKeyboard in NimBLE mode as well?

sivar2311 avatar Feb 19 '22 17:02 sivar2311

Hi @sivar2311! Thanks, it's really useful to control your phone with your motorcycle gloves on ;)

It does indeed accept new connections when it's not connected!.

Now i have the issue that i want to remove the other phone i connected it to. (or: just remove every existing connection).

Earlier today i used NimBLE, but then the esp would connect, but not send actual keystrokes. I reverted back to the original library and now it works. Did not investigate further. Would it help you if i did?

joostbijl avatar Feb 19 '22 18:02 joostbijl

Please download the latest beta version and activate the NimBLE-Mode (uncomment the 2nd line in BleKeyboard.h)

There are a lot of changes since the last official release. I think this will fix your issues.

sivar2311 avatar Feb 19 '22 19:02 sivar2311

NimBLE works, after i have removed the esp from my phone and reconnected.

joostbijl avatar Feb 19 '22 19:02 joostbijl

Does it mean the latest beta solved the issue?

sivar2311 avatar Feb 19 '22 19:02 sivar2311

The original issue is not solved, but not really necessary since you can 'forget' devices from your phone just as easily.

Using NimBLE i can now run the ble_store_clear() command, but that does not appear to clear all bonds stored on the esp.

joostbijl avatar Feb 19 '22 20:02 joostbijl

Maybe you can reset the internal memory on the ESP where the pairing info if stored?

Guillemete avatar Apr 05 '22 13:04 Guillemete

https://github.com/espressif/arduino-esp32/blob/master/libraries/BluetoothSerial/examples/bt_remove_paired_devices/bt_remove_paired_devices.ino

this might help. havent tried it yet

Guillemete avatar Apr 05 '22 13:04 Guillemete

NimBLE supports this: NimBLEDevice::deleteAllBonds();

But I can't say how it is done with the standard BLE library.

sivar2311 avatar Apr 05 '22 14:04 sivar2311

https://icircuit.net/esp-idf-bluetooth-remove-bonded-devices/3040

Guillemete avatar Apr 05 '22 15:04 Guillemete