asterics / esp32_mouse_keyboard

ESP32 implementation for HID over GATT Keyboard and Mouse (Bluetooth Low Energy). Including serial API for external modules (similar to Adafruit EZKey HID)
GNU General Public License v3.0
788 stars 111 forks source link

iPhone 12 Pro iOS 14.7.1 - no devices in the list #52

Closed feed4rz closed 2 years ago

feed4rz commented 2 years ago

I am using ESP WROOM 32 DEVKIT V1 and when I run the program the device does not appear in the list of bluetooth devices on my iPhone.

esp logs

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6724
load:0x40078000,len:14812
load:0x40080400,len:3784
0x40080400: _init at ??:?

entry 0x40080694
I (27) boot: ESP-IDF v4.4-dev-3235-g3e370c4296 2nd stage bootloader
I (27) boot: compile time 11:09:35
I (27) boot: chip revision: 1
I (31) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (38) boot.esp32: SPI Speed      : 40MHz
I (43) boot.esp32: SPI Mode       : DIO
I (47) boot.esp32: SPI Flash Size : 4MB
I (52) boot: Enabling RNG early entropy source...
I (57) boot: Partition Table:
I (61) boot: ## Label            Usage          Type ST Offset   Length
I (68) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (76) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (83) boot:  2 factory          factory app      00 00 00010000 00100000
I (91) boot: End of partition table
I (95) boot_comm: chip revision: 1, min. application chip revision: 0
I (102) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=20094h (131220) map
I (158) esp_image: segment 1: paddr=000300bc vaddr=3ffbdb60 size=04a30h ( 18992) load
I (166) esp_image: segment 2: paddr=00034af4 vaddr=40080000 size=0b524h ( 46372) load
I (185) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=807cch (526284) map
I (376) esp_image: segment 4: paddr=000c07f4 vaddr=4008b524 size=0c5e0h ( 50656) load
I (397) esp_image: segment 5: paddr=000ccddc vaddr=50000000 size=00010h (    16) load
I (409) boot: Loaded app from partition at offset 0x10000
I (409) boot: Disabling RNG early entropy source...
I (420) cpu_start: Pro cpu up.
I (421) cpu_start: Starting app cpu, entry point is 0x4008128c
0x4008128c: call_start_cpu1 at /Users/feed4rz/esp/esp-idf/components/esp_system/port/cpu_start.c:155

I (0) cpu_start: App cpu up.
I (437) cpu_start: Pro cpu start user code
I (437) cpu_start: cpu freq: 160000000
I (437) cpu_start: Application information:
I (441) cpu_start: Project name:     esp32_mouse_keyboard
I (447) cpu_start: App version:      v0.3-3-g6fbe015
I (453) cpu_start: Compile time:     Oct 10 2021 11:11:41
I (459) cpu_start: ELF file SHA256:  f6e08d5054a1c8c9...
I (465) cpu_start: ESP-IDF:          v4.4-dev-3235-g3e370c4296
I (472) heap_init: Initializing. RAM available for dynamic allocation:
I (479) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (485) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (491) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (497) heap_init: At 3FFC6F78 len 00019088 (100 KiB): DRAM
I (503) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (510) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (516) heap_init: At 40097B04 len 000084FC (33 KiB): IRAM
I (524) spi_flash: detected chip: generic
I (527) spi_flash: flash io: dio
I (532) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (542) HID_DEMO: pairing enabled by default
I (582) BTDM_INIT: BT controller compile version [078d492]
I (592) system_api: Base MAC address is not set
I (592) system_api: read default base MAC address from EFUSE
I (592) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (1022) MAIN: opening NVS handle for BT names
I (1022) MAIN: opening NVS handle for key/value storage
I (1032) MAIN: loading configuration from NVS
I (1032) MAIN: bt device name is: esp32_mouse_keyboard
I (1042) MAIN: error reading NVS - locale, setting to US_INTERNATIONAL
W (1052) BT_BTM: BTM_BleWriteAdvData, Partial data write into ADV
I (1052) gpio: GPIO[17]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:0 
I (1052) UART: console UART processing task started
W (1072) EXT_UART: Switching pins!
I (1072) EXT_UART: external UART processing task started
I (1082) HID_LE_PRF: esp_hidd_prf_cb_hdl(), start added the hid service to the stack database. incl_handle = 40
I (1092) HID_LE_PRF: hid svc handle = 2d
I (1092) HID_LE_PRF: GATT EVT 12
I (1112) HID_LE_PRF: GATT EVT 12
W (1202) BT_LOG: esp_ble_gatts_send_indicate, The connection not created.
I (1202) HID_DEMO: Idle...
W (1502) BT_LOG: esp_ble_gatts_send_indicate, The connection not created.
I (1502) HID_DEMO: Idle...

I ve also tried it with an older iPhone 8 but with the same iOS installed and a Macbook Pro on the Apple Silicon running Big Sur 11.6 with no luck.

Seems to be working on some old Lenovo laptop running Win10 tho.

benjaminaigner commented 2 years ago

Dear @feed4rz oh sorry thats of course not good. We don't have any AppleSilicon HW to test, but I will test this with an older iPad. It's always the same, as soon as a new iOS version appears, Apple's Bluetooth policy and requirements are changing :-1:

Greetings

feed4rz commented 2 years ago

Have you been able to reproduce the issue?

benjaminaigner commented 2 years ago

Dear @feed4rz ,

sorry it took me so long, all our iPads were used in lectures. I've tested the current esp32_mouse_keyboard firmware (v0.3) on an iPad 6th gen with following results:

I can test it with iOS 15, but as you are requesting iOS 14.7.1, I don't think there will be a difference here.

what version of the code are you using? If you are using the master branch, would it be possible for you to test the v0.3 release?

Greetings

benjaminaigner commented 2 years ago

Hi @feed4rz , I've got another hint: Is it possible that your iPhone 12 does not support BLE4.0 devices? According to the BT-SIG FAQs there should be compatibility between a 5.0 central and a 4.0 peripheral, but you never now.

If it is possible, could you try a BLE example of the esp-idf to test if the ESP is discoverable with this firmware?

Greetings

benjaminaigner commented 2 years ago

Is it possible that your iPhone 12 does not support BLE4.0 devices? According to the BT-SIG FAQs there should be compatibility between a 5.0 central and a 4.0 peripheral, but you never now.

Oh sorry, I missed that you tried it with an iPhone8 too. Is updating iOS an option for you? According to the Apple community, ~170 people have issues with discovering BLE devices: https://discussions.apple.com/thread/253031699 Here are some suggestions to fix this problem, but I'm not an Apple expert to rate the quality of those: https://wccftech.com/how-to/how-to-fix-bluetooth-issues-after-updating-to-ios-14-and-ipados-14/

Greetings

benjaminaigner commented 2 years ago

Dear @feed4rz

I finally found an iPhone to reproduce this issue, but I'm not quite sure if it would be helpful:

iPhone 6
iOS 12.5.1

I try to have regular access to this phone, but cannot promise anything.

manimathma commented 2 years ago

@benjaminaigner I would like to add same behaviour in Fire Tv as well. I am using this firmware on C3F.

benjaminaigner commented 2 years ago

@manimathma THX for the report, this was a quick build :-). If it is possible: could you please test if your device is discoverable with the new Espressif example: esp-idf/examples/bluetooth/esp_hid_device/ If this works, I have at least the possibility to check differences (@feed4rz Would this be possible for you too?)

THX, Greetings

manimathma commented 2 years ago

@benjaminaigner it didn't work in both (this and esp official example). But by changing the appearance to keyboard i was able to get it to connect with this firmware. Seems like Fire Tv ignore device with generic appearance.

benjaminaigner commented 2 years ago

@manimathma

Thank you very much for this hint!!!

@feed4rz

Could you please try to change the appearance number:

https://github.com/asterics/esp32_mouse_keyboard/blob/5cf45eef416043413b12e0b958afa456020eb179/main/ble_hidd_demo_main.c#L201

To e.g.: 0x03C1 (keyboard) or 0x03C2 (mouse) to see if it works for you?

All possible GAP appearances for HID devices are listed on page 8 in this document: https://specificationrefs.bluetooth.com/assigned-values/Appearance%20Values.pdf

benjaminaigner commented 2 years ago

Dear @manimathma & @feed4rz

is this issue resolved for you or is there something I can do?

I think if this fix works for you, I will change the appearance in general to mouse.

Greetings

manimathma commented 2 years ago

@benjaminaigner

changing appearance to x03c1 or x03c2 worked for me.

Btw really appreciate everything you are doing on this project.

Also note if you are planning to migrate to esp-idf APIs, you can count me in on the work.

benjaminaigner commented 2 years ago

@manimathma

THX, we/I try our best for this repository. It is vital to have a working BLE mouse/keyboard implementation on all platforms for our FABI/FLipMouse devices. Of course I would like to thank you for the bug report and hint to fix it, otherwise we would not fix this error.

tiny1990 commented 10 months ago

it's not working with ios 17.1