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

nRF52832: How to add write protected characteristic by KEY

I am working on SDK-15.2, nRF52832 Dev board. My question is how to add write protected characteristic by KEY? Mean when we want to write something from peer device (smartphone) on "write" characteristic it should ask to enter KEY.

 is there any example code or documentation available?

Any suggestions will be appreciated.

Thanks

Raj

Parents
  • I have attached a modified version of the ble app uart example, where I have restricted the write access for the RX Characteristics by demanding the passkey to be typed in. I have used the approach as described in my previous answer. 

    I also changed one line of the ble_nus.c file (which you must do yourself, since the uploded example only contains the project folder)

    uint32_t ble_nus_init(ble_nus_t * p_nus, ble_nus_init_t const * p_nus_init)
    {
        .
        .
        .
        add_char_params.read_access  = SEC_OPEN;
        // In the line below I changed the write access to JUST WORKS 
        add_char_params.write_access = SEC_JUST_WORKS;//SEC_OPEN;
    
        err_code = characteristic_add(p_nus->service_handle, &add_char_params, &p_nus->rx_handles);
        .
        .
        

    Be aware that this file is used by other examples in the SDK, and the change will cause undesirable behaviour for those examples. 

    ble_app_uart_write_prot_char.rar

    Best regards,

    Simon

Reply
  • I have attached a modified version of the ble app uart example, where I have restricted the write access for the RX Characteristics by demanding the passkey to be typed in. I have used the approach as described in my previous answer. 

    I also changed one line of the ble_nus.c file (which you must do yourself, since the uploded example only contains the project folder)

    uint32_t ble_nus_init(ble_nus_t * p_nus, ble_nus_init_t const * p_nus_init)
    {
        .
        .
        .
        add_char_params.read_access  = SEC_OPEN;
        // In the line below I changed the write access to JUST WORKS 
        add_char_params.write_access = SEC_JUST_WORKS;//SEC_OPEN;
    
        err_code = characteristic_add(p_nus->service_handle, &add_char_params, &p_nus->rx_handles);
        .
        .
        

    Be aware that this file is used by other examples in the SDK, and the change will cause undesirable behaviour for those examples. 

    ble_app_uart_write_prot_char.rar

    Best regards,

    Simon

Children
No Data
Related