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

BLE_GATTC_EVT_HVX event

Hi, all.

I'm using nRF52832 Software Development Kit, PCA10040, S132.

Using the 'ble_app_uart_c' example, I am studying to connect with my beacons and read data.

I have a question.

static void ble_nus_c_evt_handler(ble_nus_c_t * p_ble_nus_c, ble_nus_c_evt_t const * p_ble_nus_evt)
{
    ret_code_t err_code;

    switch (p_ble_nus_evt->evt_type)
    {
        case BLE_NUS_C_EVT_DISCOVERY_COMPLETE:
            NRF_LOG_INFO("Discovery complete.");
            err_code = ble_nus_c_handles_assign(p_ble_nus_c, p_ble_nus_evt->conn_handle, &p_ble_nus_evt->handles);
            APP_ERROR_CHECK(err_code);

            err_code = ble_nus_c_tx_notif_enable(p_ble_nus_c);
            APP_ERROR_CHECK(err_code);
            NRF_LOG_INFO("Connected to device with Nordic UART Service.");
            break;
        ...
    }
}

Let me tell you what I understand about the code role 12: ble_nus_c_tx_notif_enable (p_ble_nus_c);

I understand that central uses ccd value for peripheral to activate notification.
Therefore, if the case is carried out normally,

void ble_nus_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context)
{
    ble_nus_c_t * p_ble_nus_c = (ble_nus_c_t *)p_context;

    if ((p_ble_nus_c == NULL) || (p_ble_evt == NULL))
    {
        return;
    }

    if ( (p_ble_nus_c->conn_handle == BLE_CONN_HANDLE_INVALID)
       ||(p_ble_nus_c->conn_handle != p_ble_evt->evt.gap_evt.conn_handle)
       )
    {
        return;
    }

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GATTC_EVT_HVX:
            on_hvx(p_ble_nus_c, p_ble_evt);
            break;
            
        ...
    }
}

the 19:  'case BLE_GATTC_EVT_HVX' event calls 'on_hvx()'.

1. Am I getting it right up to here?

If number one question is correct, my problem is...

The first code 'BLE_NUS_C_EVT_DISCOVERY_COMPLETE' event was successfully performed - successfully connect with the own device -  but 'BLE_GATTC_EVT_HVX' event is not called.

2. Is this because of the nature of my beacons? Or is there any other room for trouble?

Best regards,

Lyrics

  • Hi Lyrics,

    Let me tell you what I understand about the code role 12: ble_nus_c_tx_notif_enable (p_ble_nus_c);

    I understand that central uses ccd value for peripheral to activate notification.

    Yes.

    the 19:  'case BLE_GATTC_EVT_HVX' event calls 'on_hvx()'.

    1. Am I getting it right up to here?

    Yes. This happens when a notification is received.

    The first code 'BLE_NUS_C_EVT_DISCOVERY_COMPLETE' event was successfully performed - successfully connect with the own device -  but 'BLE_GATTC_EVT_HVX' event is not called.

    2. Is this because of the nature of my beacons? Or is there any other room for trouble?

    I do not know anything about the nature of your beacon/peripheral. But if you have enabled notifications by writing to the CCCD (by successfully calling ble_nus_c_tx_notif_enable()), then you will get events if the peripheral subsequently sends notifications. (You can test this with the NUS peripheral example.). Ar you sure your peripheral sends notifications? (by calling ble_nus_data_send() in this case, which in turn calls sd_ble_gatts_hvx()).

  • My device doesn't signal notification.
    I didn't even think about it. Thank you for reply. :)

Related