This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52832 Peripheral to iOS central that will reconnect after power loss

Hello,

I am developing a device that will reconnect to an apple iPad if it looses connection and be able to send a couple of bits over ble_UART.

I have tried merging the ble_app_uart with the ble_app_hids_keyboard examples with some success. It seems like there is a lot of extra code in there that I am not sure what it is doing and probably isn't necessary. I am not experienced enough yet to write my own services and characteristics from scratch, although I aspire to learn, time is also a factor.

Is there a simpler example with the peer manager bonding and pairing code already set up that I can use to merge with the ble_uart example?

Thank you. 

Parents
  • Check out this thread where I have provided code for respectively ble_app_uart and ble_app_uart_c that implements Legacy bonding using a static key. It is written for SDK 15.x.0

    You can build upon this code if you want to use other bonding methods, e.g. Legacy just works, LESC OOB or LESC Numeric comparison etc...

    Best regards,

    Simon

  • Thank you for the reply Simon.

    The example given in the thread that you referenced is a good starting point. The ble_app_hid_keyboard example prompts you if you would like to pair the device. If you power cycle the BLE device after the pairing it reconnects automatically to iOS. What functions would I use to enable this feature?

    I have set the security parameters in the peer_manager_init() the same as the HID example but no joy. I notice that the HID uses a whitelist, is this a necessary part of the equation?

    Best,

Reply
  • Thank you for the reply Simon.

    The example given in the thread that you referenced is a good starting point. The ble_app_hid_keyboard example prompts you if you would like to pair the device. If you power cycle the BLE device after the pairing it reconnects automatically to iOS. What functions would I use to enable this feature?

    I have set the security parameters in the peer_manager_init() the same as the HID example but no joy. I notice that the HID uses a whitelist, is this a necessary part of the equation?

    Best,

Children
  • CanTech1 said:
    If you power cycle the BLE device after the pairing it reconnects automatically to iOS. What functions would I use to enable this feature?

    The ble_app_hid_keyboard example is a a peripheral example, which means the iPad/computer is the central and will initiate the connection (see the this link). This means that the iPad will initiate the connection, and there is no function you can add to the ble_app_hids example to enable this.

    The reason the iPad automatically reconnects (I think), is because the devices are bonded, and the iPad has stored the BLE device in a list of bonded devices. When the BLE device advertises, the iPad recognizes it and initiates a connection. In order to enable bonding on the peripheral side, you should set the security parameter sec_param.bond (which is fed into pm_sec_params_set)  to true.

     

    CanTech1 said:
    I have set the security parameters in the peer_manager_init() the same as the HID example but no joy.

    You should look at the Message Sequence chart for Bonding:Just Works (which the hid keyboard example uses, as you can see here), to see how to set up the example. In this case, all you have to do is to call sd_ble_gap_sec_params_reply() when receiving BLE_GAP_EVT_SEC_PARAMS_REQUEST (The peer manager library will handle this for you, if you have called pm_sec_params_set() earlier).

    The ble app uart example I provided uses Bonding and Passkey Entry, but I can not think of what else you need to change except for the security parameters. Could you try to comment out the call to sd_ble_opt_set()? Which is not needed for just works. You should study the ble app hids example more to see what needs to be implemented.

    Could you try to figure out where the application fails? What function specifically and what error it returns. Also, if you are able to catch a sniffer trace of the ble communication, you will be able to see where it fails.

    Best regards,

    Simon

Related