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

the characteristic could not be write

dear Nordic: i created a new characteristic assigned UUID 0x18e1.in order to be writable,i set its properties with following in static uint32_t pressure_high_byte_char_add(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init) char_md.char_properties.read = 1; char_md.char_properties.write = 1; char_md.char_properties.notify = (p_bas->is_notification_supported) ? 1 : 0;

then i use a app named lightblue to monitor it.when i want to write a value to this characteristic a error appeared .what is wrong?

IMG_0125.png

IMG_0126.png

IMG_0124.png

Parents
  • This error most likely comes because you haven't set the security level of your characterstic properly.

    The security level for the different properies are set separately from the properties themselves. If you've based yourself on the battery service, you can see this in the original ble_bas.c, lines 151-152:

    
        attr_md.read_perm  = p_bas_init->battery_level_char_attr_md.read_perm;
        attr_md.write_perm = p_bas_init->battery_level_char_attr_md.write_perm;
    
    

    These parameters are then set in the calling code, for example like this in ble_app_hrs, lines 434-435:

    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.read_perm);
        BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bas_init.battery_level_char_attr_md.write_perm);
    
    

    As you can see, this sets NO_ACCESS for the write property, so to enable writes, you have to change this to for example OPEN.

Reply
  • This error most likely comes because you haven't set the security level of your characterstic properly.

    The security level for the different properies are set separately from the properties themselves. If you've based yourself on the battery service, you can see this in the original ble_bas.c, lines 151-152:

    
        attr_md.read_perm  = p_bas_init->battery_level_char_attr_md.read_perm;
        attr_md.write_perm = p_bas_init->battery_level_char_attr_md.write_perm;
    
    

    These parameters are then set in the calling code, for example like this in ble_app_hrs, lines 434-435:

    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.read_perm);
        BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bas_init.battery_level_char_attr_md.write_perm);
    
    

    As you can see, this sets NO_ACCESS for the write property, so to enable writes, you have to change this to for example OPEN.

Children
No Data
Related