How to get Disconnect Event from GATT Server on Bluez/Linux

前提是你 提交于 2019-12-06 07:12:16

Watch for G_IO_HUP and shutdown gracefully.

chan = gatt_connect(opt_src, opt_dst, opt_dst_type, opt_sec_level,
                opt_psm, opt_mtu, connect_cb, &gerr);
if (chan == NULL) {
    log_printf(LOG_LEVEL_ERROR,"%s: chan is NULL\n",__func__);
    log_printf(LOG_LEVEL_ERROR,"%s\n", gerr->message);
    g_error_free(gerr);
    g_main_loop_quit(event_loop);
} else {
    log_printf(LOG_LEVEL_INFO,"Connected to %s\n",opt_dst);
    g_io_add_watch(chan, G_IO_HUP, channel_watcher, NULL);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!