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

Modifying NUS - Make it bond with smart phones

Hi, I use the NUS most of the time.

(SDK 7.2 & S110 7.1 with IAR 7.1)

As you know, HID keyboard or mouse bond with centrals (smart phones).

After bonding, when using iOS devices for example, the bonded devices' information are left.

Bond Just like this picture.

However, when a device is only using the NUS does not leave the device's info.

  1. This is because the peripherals that only use NUS just pairs with the central,

not bonding, is it?

  1. Can I modify the NUS code (in SDK 7.2) in order to bond with the central?

If this is possible, what changes are needed?

The reason to make it bond is I want connect the peripheral to the central directly.

Or is there other ways to make this service to perform a direct advertising?

Or the only solution is to make an app that make it seems to connect each other automatically?

-Regards, Mango922

/**************/

Added : 7, July, 2015 :

Thanks for answering!

You said : the iOS/Android system won't show your device and bond to your

device if they are note(you mean "not"?) HID device.

Nexus 5

However, after downloading the NUS(didn't changed the service) example,

I checked with my Nexus 5 and I showed the device. It uses Android 5.1.1.

Anyway you mean, after I change the NUS to make it bond, it will still not appear at the

"Settings -> Bluetooth"?

// Edited, Feb. 25, 2016

I edited the ble_nus.c like this.

I call device_manager_init before ble_nus_init.

#define SEC_PARAM_BOND                   1       /**< Perform bonding. */
#define SEC_PARAM_MITM                   0       /**< Man In The Middle protection not required. */

// static uint32_t rx_char_add
BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&cccd_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&cccd_md.write_perm);

BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.write_perm);

// static uint32_t tx_char_add
BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.write_perm);

Error 7

Parents
  • @Mango:

    1. Pair means encrypt the link, and bond is storing the key so next time the link can be re-encrypted. If the device is not bonded, you won't see it in the Bluetooth setting. NUS by default doesn't require bonding so there will be no bond by default. On the other hand, HID keyboard requires bonding, so that explains what you observed.

    2. Yes you can modify NUS to require bonding. To do that in the service declaration in the nRF51 firmware, instead of using BLE_GAP_CONN_SEC_MODE_SET_OPEN you should use BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM or other option depend on which type of bonding you want (Just work, Passkey, etc)

    Note that the iOS/Android system won't show your device and bond to your device if they are not HID device. You would need to have an app for that. For the NUS we have the nRF UART app.

  • About BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&cccd_md.read_perm);
    If I remember correctly CCCD read permission has to be open.

Reply Children
No Data
Related