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

why indication callback not called

I have an issue with indications. I try to send the first chunk of data and wait for indication callback, but my code freeze on while loop. I activated indications on phone side (nRF master control). to my understanding, each time the central successfully receives the frame, on_ble_evt BLE_GATTS_EVT_HVC is called

main loop :

indication_pending = true;
        	do {
    err_code = param_update(&m_param, FLASH_DATA, NULL, steps_store_characteristic_value);//update data on BLE
        							} while (err_code == BLE_ERROR_NO_TX_BUFFERS);
    while (indication_pending);

static void on_ble_evt(ble_evt_t * p_ble_evt)
{
...
	case BLE_GATTS_EVT_HVC:
		indication_pending = false;
		break;
...
}

uint32_t param_update(ble_param_t * m_param, enum CHARACT characteristic, uint32_t value, uint8_t *vsoft_value)
{
	uint32_t err_code = NRF_SUCCESS;
	uint8_t tab_value[4];
	uint8_t vsoft_tab_value[16];
	ble_gatts_hvx_params_t params;
if ((m_param->conn_handle != BLE_CONN_HANDLE_INVALID) {
params.type = BLE_GATT_HVX_INDICATION;
params.handle = m_param->flash_data_char_handles.value_handle;
params.p_data = vsoft_tab_value;
params.p_len = &len;
err_code = sd_ble_gatts_hvx(m_param_digitsole->conn_handle, &params);
..........
Parents
  • Ok, now i see what is the problem. You canot wait in while loop cause it is blocking the cpu (you don't pull events from the stack).

    I am not sure what is the flow of your program, but You may try something like that:

    if(!indication_pending)
    {
    	err_code = param_update(&m_param, FLASH_DATA, NULL, steps_store_characteristic_value);
    	if (err_code == NRF_SUCCESS)
    		indication_pending = true;
    }
    

    and call it periodically.

  • If you are using scheduler, you have to manually poll for events from it. If you are waiting in while loop, no events will be pulled from softdevice! (they are received by interrupt, but queued by scheduler - not propagated in application. You have to manually take them from there by app_sched_execute();)

Reply Children
No Data
Related