Bluetooth: Peripheral HIDS keyboard sample from the nRF Connect SDK works out of the box for me with Windows, Android, Ubuntu, but not iOS 15.6.1 on an iPhone 13 Pro Max

I followed the directions for pulling down the nRF Connect SDK v2.0.2 via Toolchain Manager v1.1.3 in nRF Connect for Desktop v3.11.1.

I am using Ubuntu 22.04.1 LTS 'Jammy' and am using VS Code with the NRF Connect plug-in to build the Bluetooth: Peripheral HIDS keyboard sample. I'm able to program the sample on the nRF5340 DevKit and the sample interacts as expected with Ubuntu, Windows, and an Android device. Unfortunately it doesn't give me what I'd expect on iOS 15.6.1 on an iPhone 13 Pro Max. Currently I'm trying to de-risk a project that must run on iOS. The project readme mentions testing only with Windows and Android.

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/nrf/samples/bluetooth/peripheral_hids_keyboard/README.html#bluetooth-peripheral-hids-keyboard

What I see on Ubuntu, Windows, and Android is after connecting and pairing with the Nordic_HIDS_keyboard Bluetooth device, going to any text input and pushing the devkit 'button 1' will in fact start typing the expected characters of the 'hello' string that is in the sample.

On iOS what I see is different. The phone gave me a device code, and I pushed button one to pair. That seems ok and is as expected. iPhone tells me that it is paired and in the nRF Connect Terminal in VS Code I see the following:
*** Booting Zephyr OS build v3.0.99-ncs1-1  ***
Starting Bluetooth Peripheral HIDS keyboard example
I: 2 Sectors of 4096 bytes
I: alloc wra: 0, f88
I: data wra: 0, c4
I: HW Platform: Nordic Semiconductor (0x0002)
I: HW Variant: nRF53x (0x0003)
I: Firmware: Standard Bluetooth controller (0x00) Version 51.10872 Build 1643454488
I: No ID address. App must call settings_load()
Bluetooth initialized
I: Identity: EA:.....:88:04 (random)
I: HCI: version 5.3 (0x0c) revision 0x2136, manufacturer 0x0059
I: LMP: version 5.3 (0x0c) subver 0x2136
Advertising successfully started
I: BAS Notifications enabled
Connected F4:....:8D:CA (public)
Advertising successfully started
W: Ignoring data for unknown channel ID 0x003a
Passkey for F4:...:8D:CA (public): 965686
Press Button 1 to confirm, Button 2 to reject.
Numeric Match, conn 0x20001050
Security changed: F4:....:8D:CA (public) level 4
Pairing completed: F4:....:8D:CA (public), bonded: 1

At this point in iOS I go to Settings/General/Keyboards and I see:
Keyboards             2 >
Hardware Keyboard >
...

So now I go to any native text input field, say in the Safari browser, a text message, email or anything and try to press 'DevKit button 1' hoping to see the characters of the 'hello\n' string start to come over. This does not happen. Moreover, I'm under the impression that at this point, iOS would not show the virtual on screen keyboard when I enter focus on a text input field. I still do see the virtual keyboard, and no amount of pressing 'devkit button 1' will result in any characters or anything at all happening on the iOS device.

That is my repro and dev setup.

Now I have done much searching of DevZone, forums, and the net at large to try to determine what is going wrong and have come up surprisingly empty handed. I have also tried to get the BLE Sniffer going on the nRF52840 dongle too and I do see advertising data, but nothing else. I don't see any 'HID Event/button push' packets in WireShark.

Having looked at several manufacturers HIDs descriptions and various report maps I will say I was hoping not to have to complete an entire development project to evaluate the feasibility of this project. I was hoping to de-risk this without going too far into building an entire project and had hoped the samples would work. I will go deep on this if required but any advice will be much appreciated.

My questions are:

1. Have I given enough information to get an answer from the community since this is my first question ever?

2. Are my expectations accurate about this sample? Should it work out of the box on the iOS device I've described?

2.a If so, has anyone else been able to get this sample working with iOS and how?

2.b If not, why not and are there any projects, sources, or any information otherwise on how to get a HIDs over GATT Profile (HOGP) keyboard or game controller working with iOS on the nRF5340 DK and then nRF5340 which we plan to use on our hardware?

Thanks for your time.

Parents
  • Hi,

    You can do a small change min the report map that seems to resolve the issue. I am not sure why the existing report map causes problems with Apple devices, though. Setting INPUT_REP_KEYS_REF_ID and OUTPUT_REP_KEYS_REF_ID in main.c to 0 seems to resolve the issue.

    This diff is for the peripheral_hids_keyboard sample from nRF Connect SDK 2.0.2 shows everything removed (so you see how/where it is used as well):

    diff --git a/samples/bluetooth/peripheral_hids_keyboard/src/main.c b/samples/bluetooth/peripheral_hids_keyboard/src/main.c
    index 6441362e9..46c4af5c7 100644
    --- a/samples/bluetooth/peripheral_hids_keyboard/src/main.c
    +++ b/samples/bluetooth/peripheral_hids_keyboard/src/main.c
    @@ -38,8 +38,6 @@
     
     #define OUTPUT_REPORT_MAX_LEN            1
     #define OUTPUT_REPORT_BIT_MASK_CAPS_LOCK 0x02
    -#define INPUT_REP_KEYS_REF_ID            1
    -#define OUTPUT_REP_KEYS_REF_ID           1
     #define MODIFIER_KEY_POS                 0
     #define SHIFT_KEY_CODE                   0x02
     #define SCAN_CODE_POS                    2
    @@ -437,9 +435,6 @@ static void hid_init(void)
     		0xA1, 0x01,       /* Collection (Application) */
     
     		/* Keys */
    -#if INPUT_REP_KEYS_REF_ID
    -		0x85, INPUT_REP_KEYS_REF_ID,
    -#endif
     		0x05, 0x07,       /* Usage Page (Key Codes) */
     		0x19, 0xe0,       /* Usage Minimum (224) */
     		0x29, 0xe7,       /* Usage Maximum (231) */
    @@ -463,9 +458,6 @@ static void hid_init(void)
     		0x81, 0x00,       /* Input (Data, Array) Key array(6 bytes) */
     
     		/* LED */
    -#if OUTPUT_REP_KEYS_REF_ID
    -		0x85, OUTPUT_REP_KEYS_REF_ID,
    -#endif
     		0x95, 0x05,       /* Report Count (5) */
     		0x75, 0x01,       /* Report Size (1) */
     		0x05, 0x08,       /* Usage Page (Page# for LEDs) */
    @@ -492,13 +484,13 @@ static void hid_init(void)
     	hids_inp_rep =
     		&hids_init_obj.inp_rep_group_init.reports[INPUT_REP_KEYS_IDX];
     	hids_inp_rep->size = INPUT_REPORT_KEYS_MAX_LEN;
    -	hids_inp_rep->id = INPUT_REP_KEYS_REF_ID;
    +	hids_inp_rep->id = 0;
     	hids_init_obj.inp_rep_group_init.cnt++;
     
     	hids_outp_rep =
     		&hids_init_obj.outp_rep_group_init.reports[OUTPUT_REP_KEYS_IDX];
     	hids_outp_rep->size = OUTPUT_REPORT_MAX_LEN;
    -	hids_outp_rep->id = OUTPUT_REP_KEYS_REF_ID;
    +	hids_outp_rep->id = 0;
     	hids_outp_rep->handler = hids_outp_rep_handler;
     	hids_init_obj.outp_rep_group_init.cnt++;
     
    

  • I found another dev zone post that gave me the solution to my environment problems below for anyone wondering how to get this all set up:

    devzone.nordicsemi.com/.../ubuntu-20-04-installing-automatically-broken---nrfjprog-not-found

Reply Children
No Data
Related