Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NUS SDK15 EVT_COMM_STARTED onConnect

Hello Nordic

I'm using nRF5_SDK_15.0.0_a53641a.

I think I found a bug with the ble_nus.c, line: 96

err_code = sd_ble_gatts_value_get(p_ble_evt->evt.gap_evt.conn_handle,
                                      p_nus->rx_handles.cccd_handle,
                                      &gatts_val);

    if ((err_code == NRF_SUCCESS)     &&
        (p_nus->data_handler != NULL) &&
        ble_srv_is_notification_enabled(gatts_val.p_value))
    {
        if (p_client != NULL)
        {
            p_client->is_notification_enabled = true;
        }

        memset(&evt, 0, sizeof(ble_nus_evt_t));
        evt.type        = BLE_NUS_EVT_COMM_STARTED;
        evt.p_nus       = p_nus;
        evt.conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
        evt.p_link_ctx  = p_client;

        p_nus->data_handler(&evt);
    }

I think the rx_handles.cccd_handle should be the tx_handles.cccd_handle.

This change resulted in giving me the BLE_NUS_EVT_COMM_STARTED event on reconnect with a bonded device where it previously didn't.

I am just looking for a conformation that this is correct.

Related