You are here: Forum Home → ANT Developers Forums → ANT General Questions → Thread
uint32_t err_code;
static uint8_t burst_wait = 0;
err_code = sd_ant_burst_handler_wait_flag_enable(&burst;_wait);
APP_ERROR_CHECK(err_code);
if(pause != 0) return;
switch (event)
{
// ANT broadcast success.
// Send a new broadcast and increment the counter.
case EVENT_TX:
if(burst == 1) return;
populate_buffer(m_burst_data, BURST_DATA_BUFFER_SIZE);
do{
err_code = sd_ant_burst_handler_request(CHANNEL_0,
(sizeof(m_burst_data)),
m_burst_data,
BURST_SEGMENT_START|BURST_SEGMENT_END);
} while( err_code != NRF_SUCCESS);
byte_counter += 8;
APP_ERROR_CHECK(err_code);
printf("Burst Transfer request succeed!\n");
while(burst_wait)
;
err_code = bsp_indication_set(BSP_INDICATE_SENT_OK);
APP_ERROR_CHECK(err_code);
break;
switch (event)
{
case EVENT_TX:
channel_event_handle(event);
break;
case EVENT_TRANSFER_TX_FAILED:
printf("Burst Transfer failed, bytes sent: %d !!\n",byte_counter);
burst = 1;
break;
case EVENT_TRANSFER_TX_COMPLETED:
printf("Burst Transfer sent successfuly !!\n");
burst = 1;
break;
case EVENT_TRANSFER_NEXT_DATA_BLOCK:
printf("Next Data Block Requested\n");
channel_event_handle(event);
break;
default:
break;
}
}
uint32_t err_code;
ANT_MESSAGE* antMessage = (ANT_MESSAGE*) p_event_message_buffer;
uint8_t* payload = NULL;
uint8_t flag = NULL;
uint16_t m_last_device_id;
uint8_t m_last_rssi;
if(antMessage->ANT_MESSAGE_stExtMesgBF.bANTDeviceID)
m_last_device_id = (uint16_t)(antMessage->ANT_MESSAGE_aucExtData[0] | ((uint16_t)antMessage->ANT_MESSAGE_aucExtData[1] << 8));
if(antMessage->ANT_MESSAGE_stExtMesgBF.bANTRssi)
m_last_rssi = antMessage->ANT_MESSAGE_aucExtData[5];
flag = antMessage ->ANT_MESSAGE_ucExtMesgBF;
switch (p_event_message_buffer[ANT_MSG_IDX_ID])
{
case MESG_BURST_DATA_ID:
//err_code = bsp_indication_set(BSP_INDICATE_RCV_OK);
payload = antMessage->ANT_MESSAGE_aucPayload;
for(int i=0 ;i<MESSAGE_PAYLOAD;i++)
{
m_burst_data[i+byte_counter] = payload[i];
}
byte_counter+=8;
printf("!");
/* printf("Burst Rx@[%d,%d]", m_last_device_id, m_last_rssi);
for(int i=0; i<MESSAGE_PAYLOAD;i++)
{
printf("%d ",payload[i]);
}
printf("\n");*/
//APP_ERROR_CHECK(err_code);
break;
// Broadcast data recieved.
case MESG_BROADCAST_DATA_ID:
err_code = bsp_indication_set(BSP_INDICATE_RCV_OK);
byte_counter = 0;
payload = antMessage->ANT_MESSAGE_aucPayload;
printf("Rx@[%d,%d] ", m_last_device_id, m_last_rssi);
for(int i=0; i<MESSAGE_PAYLOAD;i++)
{
printf("%d ",payload[i]);
m_burst_data[i+byte_counter] = payload[i];
}
printf("\n");
byte_counter+=8;
APP_ERROR_CHECK(err_code);
break;
default:
break;
}