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

Get insufficient authentication error to change Client characteristic Configuration

Hi: i write very simple BLE App, it used open link. No security/encrypt. 1 service with 2 characteristics. tx(serviceTXID, rxBuffer, 0, sizeof(rxBuffer), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE ), rx(serviceRXID, txBuffer, 0, sizeof(txBuffer), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY )

when up, use nRF Connect with nrf51 dongle hardware connected. discovered "Generic Access", "generic attribute" and my service with 2 characteristics. the characteristic with BLE_GATT_CHAR_PROPERTIES_NOTIFY has an "Client Characteristic Configuration".

the write is fine. But trigger Notify has problem. when i set Notify CCCD value: "01 00", get "Write operation failed: BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION (0x0105)"

but the "service Changed" in "generic attribute" is working fine.

we don't want use pairing/bonding phase.

question: 1) is SoftDevice add "Client Characteristic Configuration"? 2) How to solve this issue?

  • Sorry, I found the place of the "Client Characteristic Configuration" set security policy. in custom_add_in_characteristic() function in custom_helper.cpp file error_t custom_add_in_characteristic(uint16_t service_handle, ble_uuid_t *p_uuid, uint8_t properties, SecurityManager::SecurityMode_t requiredSecurity, uint8_t *p_data, uint16_t min_length, uint16_t max_length, const uint8_t *userDescriptionDescriptorValuePtr, uint16_t userDescriptionDescriptorValueLen, bool readAuthorization, bool writeAuthorization, ble_gatts_char_handles_t p_char_handle) { / Characteristic metadata */ ble_gatts_attr_md_t cccd_md; ble_gatt_char_props_t char_props;

    memcpy(&char_props, &properties, 1);
    
    if (char_props.notify || char_props.indicate) {
        /* Notification requires cccd */
        memclr_( &cccd_md, sizeof(ble_gatts_attr_md_t));
        cccd_md.vloc = BLE_GATTS_VLOC_STACK;
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
        **//BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&cccd_md.write_perm);**
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);
    }
    

    .....

Related