本文整理汇总了C++中EventQueue::event方法的典型用法代码示例。如果您正苦于以下问题:C++ EventQueue::event方法的具体用法?C++ EventQueue::event怎么用?C++ EventQueue::event使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventQueue
的用法示例。
在下文中一共展示了EventQueue::event方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}