How to wait MSG_CODE_EVENT_TX?

Hi

I wish to send 4 ANT packets within the 1sec time frame of compute(). ANT channel frequency has been set to 4 Hz to fit 4 ANT packets with an exact time interval 250ms inside.

To send all four packets, I believe that it is required to wait for the message `MSG_CODE_EVENT_TX` but I don't know how to do it.

Pseudocode is like:

function WaitForEventTx()
{
 var response = Ant.MessageCode;
 
 while(response!=MSG_CODE_EVENT_TX)
	;
}

function onMessage(msg)
{
//..
// update remote device
GenericChannel.sendBroadcast(msg1);
WaitForEventTx();
GenericChannel.sendBroadcast(msg2);
WaitForEventTx();
GenericChannel.sendBroadcast(msg3);
WaitForEventTx();
GenericChannel.sendBroadcast(msg4);
WaitForEventTx();
//..
}

Is there any example on that?

John