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.

  • I don't think this is wise way to send many indications. Do you want to have high throughput? If not, maybe call that ble_digitsole_param_update() periodically (app_timer?) OR just only after receiving HVC- that will save you some power because cpu can sleep more. If you want to have high throughput, I would go back to using notifications and just wait for TX_COMPLETE events to fill all available buffers.

Reply
  • I don't think this is wise way to send many indications. Do you want to have high throughput? If not, maybe call that ble_digitsole_param_update() periodically (app_timer?) OR just only after receiving HVC- that will save you some power because cpu can sleep more. If you want to have high throughput, I would go back to using notifications and just wait for TX_COMPLETE events to fill all available buffers.

Children
No Data
Related