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

I have a question about configuration of charateristic value R/W permission.

I saw following code configuring about permission of charateristic value R/W.

it's in uart example of SDK 11.0.0.

static uint32_t tx_char_add (ble_nus_t * p_nus, const ble_nus_init_t * p_nus_init){
   ...
   BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
   BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);
   ...
}

it was not a setting about whether R/W is possible or not.

So, is it the setting about connection security mode that R/W is possible?

Parents
  • You may find this tutorial useful, more specifically Step 2.F. The following code configures a characteristic to allow Read and Notify but reject Write.

    void ble_add_char(){
        ...
    
        //Add Characteristics to stack
        ble_gatts_char_md_t char_md;
    
        memset(&char_md, 0, sizeof(char_md));
        char_md.char_props.write_wo_resp  = 0;
        char_md.char_props.write  = 0;
        char_md.char_props.read   = 1;
        char_md.char_props.notify = 1;
    
        ...
    
        //Add Characteristic to stack
        sd_ble_gatts_characteristic_add(service, &char_md, &attr_char_value, handle);
    }
    
Reply
  • You may find this tutorial useful, more specifically Step 2.F. The following code configures a characteristic to allow Read and Notify but reject Write.

    void ble_add_char(){
        ...
    
        //Add Characteristics to stack
        ble_gatts_char_md_t char_md;
    
        memset(&char_md, 0, sizeof(char_md));
        char_md.char_props.write_wo_resp  = 0;
        char_md.char_props.write  = 0;
        char_md.char_props.read   = 1;
        char_md.char_props.notify = 1;
    
        ...
    
        //Add Characteristic to stack
        sd_ble_gatts_characteristic_add(service, &char_md, &attr_char_value, handle);
    }
    
Children
Related