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

NUS example, authorize request, sd_ble_gatts_hvx

Hi together,

I'm using the NUS example (NRF52832) for client and peripheral, which is running quite well. My goal is to inform the peripheral application when notification was enabled on central side. Thus I added the line cccd_md.wr_auth = 1; in the function rx_char_add and added

switch (p_ble_evt->header.evt_id)
{
    case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
        {
            /* we get this event on peripheral side, when central enabled notifications */
            if(p_ble_evt->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE)
            {
                /* reply with SUCCESS/ALLOWED */
                ble_gatts_rw_authorize_reply_params_t rw_authorize_reply_params;
                memset(&rw_authorize_reply_params, 0, sizeof(rw_authorize_reply_params));
                rw_authorize_reply_params.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
                rw_authorize_reply_params.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS;
                rw_authorize_reply_params.params.write.update = 1;
                err_code = sd_ble_gatts_rw_authorize_reply(m_ble_nus.conn_handle, &rw_authorize_reply_params);
                APP_ERROR_CHECK(err_code);

in the function on_ble_evt. With this, as soon the the function ble_nus_c_rx_notif_enable was called from central, the peripheral got a BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST such that I was able to inform the application that the central has enabled notifications. The described code was running very well with softdevice S132 1.0.0-3-alpha and sdk 0.9.2.

Now I'm using S132 V2.0.0 and nRF5 SDK 11.0.0 and get the following error: After connection setup, when I want to send data to the central using ble_nus_string_send the function sd_ble_gatts_hvx returns 0x3401. This was not the case, when using the "old" softdevice. How can I solve this problem?

Is there another way to inform the peripheral when a central connected and discovered all services successfully?

Thank you!

Parents Reply Children
No Data
Related