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

How do I wait for BLE_EVT_TX_COMPLETE?

Here:devzone.nordicsemi.com/.../group__ble__api.html

Choose to simply not keep track of available buffers at all, and instead handle the BLE_ERROR_NO_TX_BUFFERS error by queueing the packet to be transmitted and try again as soon as a BLE_EVT_TX_COMPLETE event arrives.

I want to know how do I wait for BLE_EVT_TX_COMPLETE?

This is what I did but BLE_EVT_TX_COMPLETE never got triggered at all:

FLAG: if(notification_buffer_is_free ==true)
	{

		data_cache+=i;
		logger_gatt_value_set(LOG_DATA_DATA, (uint8_t*)data_cache,sizeof(log_data_t));
		
	}
	else
	{
		
		goto FLAG;
	}

in the relevant event handler:

			case BLE_EVT_TX_COMPLETE:
     
            notification_buffer_is_free = true;
            break;

Like I said BLE_EVT_TX_COMPLETE never got triggered at all. I'm suspecting that my code turned into an infinite loop and the BLE_EVT_TX_COMPLETE isn't a high priority interrupt so it never got the chance to change the notification_buffer_is_free flag.

How am I supposed to do it? And please don't tell me in order to use BLE_EVT_TX_COMPLETE, I need to get all the other 999,998 of 999,999 things necessary right to be successfully using BLE_EVT_TX_COMPLETE, lol.

Parents
  • Hello, there is no interrupt involved here, my code is straight up infinite loop. My previous experience with other chips tells me that it should work, but I don't know about cortex-m0 powered nrf51.

    As you can see the code, if the "notification_buffer_is_free" flag is true, then hvx() will be called again. But if it is not, the program will be forcefully redirected to FLAG using goto.

    The "notification_buffer_is_free" flag can only be set true at the beginning of the entire program and the "BLE_EVT_TX_COMPLETE" case.

    Hope it helps clear things up a bit.

    So my confusion is that does my "infinite loop" using goto hinder the correct throwing of the "BLE_EVT_TX_COMPLETE" event? I don't think it should but I don't know.

Reply
  • Hello, there is no interrupt involved here, my code is straight up infinite loop. My previous experience with other chips tells me that it should work, but I don't know about cortex-m0 powered nrf51.

    As you can see the code, if the "notification_buffer_is_free" flag is true, then hvx() will be called again. But if it is not, the program will be forcefully redirected to FLAG using goto.

    The "notification_buffer_is_free" flag can only be set true at the beginning of the entire program and the "BLE_EVT_TX_COMPLETE" case.

    Hope it helps clear things up a bit.

    So my confusion is that does my "infinite loop" using goto hinder the correct throwing of the "BLE_EVT_TX_COMPLETE" event? I don't think it should but I don't know.

Children
No Data
Related