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

Add security to service Characteristic

In the BLE Characteristics, a beginner's tutorial

Martin mentions: Since this is a beginners tutorial we will keep it simple and leave the doors wide open. No security, encryption, or passkey needed.

Is there an example to add security? I have a server, no IO, so it has to be Just Works bonding. I tried using BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM() as suggested, but then the advertising stops

I use SDK13, so perhaps there is something else I need to do.

Any help appreciated

Parents
  • **Q1:**Yes, you should be able configure the CCCD so that you must have an encrypted link, i.e. be paired or bonded in order to write to the CCCD to enable notifications.

    **Q2:**I did some testing with the ble_app_hrs example and I found that if I set the CCCD read permission to open and the write permissions to encrypted with no MITM protection, i.e.

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&cccd_md.write_perm);
    

    then it should work fine. So it looks like you cannot set the security level of the read permission of a CCCD, which I assume it stted in the BLE spec.

Reply
  • **Q1:**Yes, you should be able configure the CCCD so that you must have an encrypted link, i.e. be paired or bonded in order to write to the CCCD to enable notifications.

    **Q2:**I did some testing with the ble_app_hrs example and I found that if I set the CCCD read permission to open and the write permissions to encrypted with no MITM protection, i.e.

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&cccd_md.write_perm);
    

    then it should work fine. So it looks like you cannot set the security level of the read permission of a CCCD, which I assume it stted in the BLE spec.

Children
Related