Skip to content
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

Does not work properly on ESP32-C3 #285

Open
maker114 opened this issue Mar 1, 2024 · 7 comments
Open

Does not work properly on ESP32-C3 #285

maker114 opened this issue Mar 1, 2024 · 7 comments

Comments

@maker114
Copy link

maker114 commented Mar 1, 2024

After connecting to the computer, it will keep disconnecting and reconnecting

@sclea
Copy link

sclea commented Mar 1, 2024

I confirm the same behaviour. ESP32-C3 Super Mini board, win11.
Example sketch uploaded.
Device reconnects each 2-3 secs.
Sample keystrokes in the sketch are not printed in notepad in win neither KEY_MEDIA_PLAY_PAUSE have no effect.

@sclea
Copy link

sclea commented Mar 1, 2024

UPD: serial monitor output after pairing:

01:53:34.505 -> Sending Play/Pause media key...
01:53:35.500 -> Waiting 5 seconds...
01:53:40.504 -> Waiting 5 seconds...
01:53:45.507 -> Waiting 5 seconds...
01:53:46.341 -> E (37414) BT_SMP: smp_calculate_link_key_from_long_term_key failed to update link_key. Sec Mode = 2, sm4 = 0x00
01:53:46.341 -> E (37414) BT_SMP: smp_derive_link_key_from_long_term_key failed
01:53:46.341 -> 
01:53:46.341 -> E (37419) BT_BTM: btm_proc_smp_cback received for unknown device
01:53:46.438 -> E (37532) BT_BTM: Device not found
01:53:46.438 -> 
01:53:50.510 -> Waiting 5 seconds...
01:53:55.515 -> Waiting 5 seconds...
01:54:00.519 -> Waiting 5 seconds...
01:54:05.522 -> Waiting 5 seconds...
01:54:10.528 -> Waiting 5 seconds...
01:54:15.530 -> Waiting 5 seconds...
01:54:20.533 -> Waiting 5 seconds...
01:54:25.536 -> Sending 'Hello world'...
01:54:26.563 -> Sending Enter key...
01:54:27.557 -> Sending Play/Pause media key...
01:54:28.582 -> Waiting 5 seconds...
01:54:33.584 -> Waiting 5 seconds...
01:54:38.591 -> Waiting 5 seconds...
01:54:43.596 -> Waiting 5 seconds...
01:54:48.599 -> Sending 'Hello world'...

and somewhere below:

01:57:02.254 -> 3fca0460: 0x3fca05a7 0x00000000 0x3fca046c 0xffffffff 0x3fca046c 0x3fca046c 0x00000000 0x3fca0480
01:57:02.254 -> 3fca0480: 0xffffffff 0x3fca0480 0x3fca0480 0x00000000 0x00000100 0x00000001 0xd900ffff 0x00000000
01:57:02.286 -> 3fca04a0: 0xb33fffff 0x00000000 0x72617453 0x676e6974 0x454c4220 0x726f7720 0x74696157 0x20676e69
01:57:02.286 -> 3fca04c0: 0x65732035 0x646e6f63 0x40c7281d 0xefcf6048 0x28a63051 0x44a01bbf 0x90459c53 0x9fcf0e00
01:57:02.383 -> 
01:57:02.383 -> 
01:57:02.383 -> 
01:57:02.383 -> ELF file SHA256: 06f8c4f7bce5adf0
01:57:02.383 -> 
01:57:02.383 -> Rebooting...
01:57:02.383 -> ESP-ROM:esp32c3-api1-20210207
01:57:02.383 -> Build:Feb  7 2021
01:57:02.383 -> rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
01:57:02.383 -> Saved PC:0x40381950
01:57:02.383 -> SPIWP:0xee
01:57:02.383 -> mode:DIO, clock div:1
01:57:02.383 -> load:0x3fcd5810,len:0x438
01:57:02.383 -> load:0x403cc710,len:0x918
01:57:02.383 -> load:0x403ce710,len:0x25f4
01:57:02.383 -> entry 0x403cc710
01:57:02.576 -> Starting BLE work!
01:57:02.833 -> Waiting 5 seconds...
01:57:07.837 -> Waiting 5 seconds...

@maker114
Copy link
Author

maker114 commented Mar 2, 2024

I solved the problem by changing
pSecurity->setAuthenticationMode(ESP_LE_AUTH_REQ_SC_MITM_BOND);
to
pSecurity->setAuthenticationMode(ESP_LE_AUTH_BOND);
at about line 130 of BleKeyboard.cpp,which looks like a security protocol sort of thing

@sclea
Copy link

sclea commented Mar 2, 2024

I tried this -- no changes. I have found another example, it sated working out of the box
https://gist.github.com/manuelbl/66f059effc8a7be148adb1f104666467

Will compare.

@JJO998123
Copy link

JJO998123 commented May 6, 2024

I can confirm that I'm also having the same issue on an adafruit QTPY-ESP32-C3.
Code worked perfectly on an older ESP32-DevkKit but on the new (smaller) ESP32-C£ board, constant disconnect and reconnect.

The code is looping as expected, the board isn't restarting it's just dropping the bluetooth connection

Maker114's line changed didn't work for me unfortunately.

@ciccior2004
Copy link

I can confirm that I'm also having the same issue on an adafruit QTPY-ESP32-C3. Code worked perfectly on an older ESP32-DevkKit but on the new (smaller) ESP32-C£ board, constant disconnect and reconnect.

The code is looping as expected, the board isn't restarting it's just dropping the bluetooth connection

Maker114's line changed didn't work for me unfortunately.

Delete paired keyboard and create a new pairing with keyboard.
For me it works.

@JJO998123
Copy link

Okay, put the change in, uploaded to the board, deleted it in the bluetooth settings in windows 11 and reconnected and can confirm it works.

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

No branches or pull requests

4 participants