本文整理汇总了C++中EventQueue::dispatch_forever方法的典型用法代码示例。如果您正苦于以下问题:C++ EventQueue::dispatch_forever方法的具体用法?C++ EventQueue::dispatch_forever怎么用?C++ EventQueue::dispatch_forever使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventQueue
的用法示例。
在下文中一共展示了EventQueue::dispatch_forever方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
if (devaddr == 0x0) {
printf("Set your LoRaWAN credentials first!\n");
return -1;
}
printf("Press BUTTON1 to send the current value of the temperature sensor!\n");
if (lorawan.initialize(&ev_queue) != LORAWAN_STATUS_OK) {
printf("LoRa initialization failed!\n");
return -1;
}
// Enable trace output for this demo, so we can see what the LoRaWAN stack does
mbed_trace_init();
// Fire a message when the button is pressed
btn.fall(ev_queue.event(&send_message));
// prepare application callbacks
callbacks.events = mbed::callback(lora_event_handler);
lorawan.add_app_callbacks(&callbacks);
// Disable adaptive data rating
if (lorawan.disable_adaptive_datarate() != LORAWAN_STATUS_OK) {
printf("disable_adaptive_datarate failed!\n");
return -1;
}
lorawan.set_datarate(5); // SF7BW125
lorawan_connect_t connect_params;
connect_params.connect_type = LORAWAN_CONNECTION_ABP;
connect_params.connection_u.abp.nwk_id = net_id;
connect_params.connection_u.abp.dev_addr = devaddr;
connect_params.connection_u.abp.nwk_skey = nwk_s_key;
connect_params.connection_u.abp.app_skey = app_s_key;
lorawan_status_t retcode = lorawan.connect(connect_params);
if (retcode == LORAWAN_STATUS_OK ||
retcode == LORAWAN_STATUS_CONNECT_IN_PROGRESS) {
} else {
printf("Connection error, code = %d\n", retcode);
return -1;
}
printf("Connection - In Progress ...\r\n");
// make your event queue dispatching events forever
ev_queue.dispatch_forever();
return 0;
}
示例2: worker_loop_start
void worker_loop_start(void (*test_step_cb_fnc)(void), int timeout)
{
int test_step_cb_timer = worker_loop_event_queue.call_every(timeout, test_step_cb_fnc);
int timeout_outgoing_msg_timer = worker_loop_event_queue.call_every(1000, emac_if_timeout_outgoing_msg);
#if MBED_CONF_APP_ECHO_SERVER
worker_loop_event_queue.dispatch_forever();
#else
worker_loop_event_queue.dispatch(600 * SECOND_TO_MS);
#endif
worker_loop_event_queue.cancel(test_step_cb_timer);
worker_loop_event_queue.cancel(timeout_outgoing_msg_timer);
worker_loop_event_queue.dispatch(5);
}