What Im trying to achieve is the following:
Run radio in the receive mode and check for incoming packages. Once a second Id like a timer interrupt to execute and switch the radio into transmit mode to send a package and then return back to the receive mode.
Right now I have the following code:
int main(int argc, char** argv)
{
boost::asio::io_service io;
boost::asio::deadline_timer t(io, boost::posix_time::seconds(1));
t.async_wait(boost::bind(sendSyncToDevices, boost::asio::placeholders::error, &t));
io.run();
}
void sendSyncToDevices(const boost::system::error_code& ,
boost::asio::deadline_timer* t)
{
DoSomething();
t->expires_at(t->expires_at() + boost::posix_time::seconds(1));
t->async_wait(boost::bind(sendSyncToDevices, boost::asio::placeholders::error, t));
}
however io.run() is a blocking call. Can somebody advice how I could add additional while(1) loop that would be checking for incoming messages on the radio?
Thanks!