I am using Xbee with STM32F4 micro controller as a coordinator and end devices. I am looking to send 3 different RF packets to my end device whenever timer interrupt is called. My current issue is if I send all 3 packets together to same end device, then my end device will drop 2 packets and receives only one packet. So I want to send all three packets in a different time interval.I found that I cannot use delay function inside timer interrupt callback function. So can any one pleases tell me how do I set delay between 2 sends or is there any other way to resolve this issue.
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
uint8_t temp[10] = {0};
// send query to Thermal Sensor
temp[0] = EN_TYPE_QUERY_TO_PD;
Send_To_Target(PD_SENSOR_ADDR_SL,temp,1);
***/*I want to Set Delay Here*/***
//Send Data to Thermal Sensor
temp[0] = EN_TYPE_DATA_TO_PD;
Send_To_Target(PD_SENSOR_ADDR_SL,temp,1);
***/*I want to Set Delay Here*/***
//Send command to Thermal Sensor
temp[0] = EN_TYPE_COMMAND_TO_PD;
Send_To_Target(PD_SENSOR_ADDR_SL,temp,1);
}
Just have the ISR set a flag that an external function will read after ISR exits. Or better yet, put the data you want to send into a queue that an external function will empty out and insert whatever delays you want in there.