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

Error reply on Read Auth request

When I try to read attribute with authorization and reply on request with status BLE_GATT_STATUS_ATTERR_INVALID_HANDLE, my device (nRF51822) goto app_error_handler method. If status is'not equal BLE_GATT_STATUS_ATTERR_INVALID_HANDLE, data exchange continue with no error.


case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
{
    ble_gatts_rw_authorize_reply_params_t reply;            
    memset(&reply, 0, sizeof(ble_gatts_rw_authorize_reply_params_t));

    reply.type = evt->evt.gatts_evt.params.authorize_request.type;

    switch (reply.type)
    {
    case BLE_GATTS_AUTHORIZE_TYPE_WRITE:
        {
        }
        break;

    case BLE_GATTS_AUTHORIZE_TYPE_READ:
        {
            ble_gatts_evt_read_t* evt_read = &evt->evt.gatts_evt.params.authorize_request.request.read;
            ble_gatts_read_authorize_params_t* reply_read = &reply.params.read;
            
            // ...

            reply_read->gatt_status = BLE_GATT_STATUS_ATTERR_INVALID_HANDLE;
        }
        break;
    };

    err_code = sd_ble_gatts_rw_authorize_reply(evt->evt.gap_evt.conn_handle, &reply);
    APP_ERROR_CHECK(err_code);
}

Is this S110 SoftDevice error or my program error? What reason of this problem?

  • Hi,

    first time I saw that problem, I was wrong. All status codes in authorize_reply_param except BLE_GATT_STATUS_SUCCESS, BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH, BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR lead to error and exception at SoftDevice layer. May be SoftDevice allow to use only these 3 status codes for programmer? And others codes used by SoftDevice only.

  • Hi Konstantin,

    By spec, when you want to reject a read/write request, you should use BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION. Have you tried this error code ?