Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Nus client and write to secure characteristic

Hi,

I have modified the nus service and added two new characteristics called txs and rxs which support read and write protection.

on the peripheral i have set BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM for txs and rxs

The service is working as expected from NRF connect for android.

Now I have modified the nus client service as well and implemented my own ble_nus_c_string_send_secure, which writes to the secure characteristic.

I have bonded the central device with nus client to peripheral with nus service.

the ble_nus_c_string_send command works and peripheral receives the string, but ble_nus_c_string_send_secure command returns NRF_SUCCESS but peripheral does not receive the string.

Am I missing something?

for writing to a secured characteristic, do I have to pass more to the sd_ble_gattc_write function?

Thanks,

Raghav

Parents
  • Hello,

    So, what does your implementation look like? What is the difference between ble_nus_c_string_send and ble_nus_c_string_send_secure? Do they write to the same characteristic, or does it write to the new characteristics, rxs? Is the rxs set up properly on the peripheral?

     

    It is a bit difficult to say what the issue may be only with a brief description of your implementation. Could you upload at least the implementation of ble_nus_c_string_send_secure()?

     

    Best regards,

    Edvin

  • Hi Edvin,

    I will attach files that I have changed and this is how I have configured the NUS service on the peripheral



    Please check the function ble_nus_c_string_send_secure in the nus client
  • Hello,

    I wasn't able to compile with your ble_nus_c and ble_nus files, until I moved the BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM to inside the ble_nus.c file. Where did you place them?

     

     

    Did you actually encrypt the link? Does any of the devices initiate encryption, and do you respond to it in the other device?

     

    Best regards,

    Edvin

  • I called the BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM in the nus_init function in the main.c

    FYI, this is from nRF SDK 15.0.

    I am not sure how I can encrypt the link, Since the peripheral works with nrf connect for android, I am assuming the app takes care of encrypting the link. I was assuming since I am using peer manager and I am connected to a lesc bonded peer, the encryption works automatically.  

    Can you give me sample of how to encrypt the link on the central device?

    Thanks

  • Hello,

    You need to handle the encryotion at one point.

    since there are several levels on encryption (MITM is the highest one), it is not enough to bond.

     

    Please see this example, which uses LESC:

    https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v13.0.0%2Fble_sdk_app_multirole_lesc.html

     

    Best regards,

    Edvin

  • Hi,

    I have modified the lesc example and added the nus service instead of the hrs.

    I have established the bond between central and peripheral and made sure in the event BLE_GAP_EVT_AUTH_STATUSlv4 is set to 1.

    I connect to bonded peripheral, start discovery, once discovered I call assign handles on nus_c and then enable notification for txs characteristic and trying to send to rxs characteristic using ble_nus_c_string_send_secure function. 

    The function returns NRF_SUCCESS but the message is not received by the peripheral.

    Is there anything else to be done?

Reply
  • Hi,

    I have modified the lesc example and added the nus service instead of the hrs.

    I have established the bond between central and peripheral and made sure in the event BLE_GAP_EVT_AUTH_STATUSlv4 is set to 1.

    I connect to bonded peripheral, start discovery, once discovered I call assign handles on nus_c and then enable notification for txs characteristic and trying to send to rxs characteristic using ble_nus_c_string_send_secure function. 

    The function returns NRF_SUCCESS but the message is not received by the peripheral.

    Is there anything else to be done?

Children