【发布时间】:2014-04-15 12:24:19
【问题描述】:
环境:C、Linux、Bluez 5.4
第三个 gatt_connect 给出错误。似乎有一些资源没有关闭或关闭。不知道是什么。
Connect Device - gatt_connect
Disconnect Device - remove battery
Connect Device - gatt_connect
Disconnect Device - remove battery
Connect Device - gatt_connect
3rd Connect Device 出现此错误:
connect: Device or resource busy (16)
connect_cb connect error: Device or resource busy (16)
// 每次通道断开时调用Watcher。
static gboolean channel_watcher(GIOChannel *iochannel, GIOCondition cond, gpointer user_data)
{
int devid = (int) user_data;
g_io_channel_shutdown(iochannel, FALSE, NULL);
g_io_channel_unref(iochannel);
iochannel = NULL;
return FALSE;
}
建立 GATT 连接:
GIOChannel* GattConnect(int dev_id, char *hwid, int handle, char *value)
{
GIOChannel *chan;
opt_listen=TRUE;
opt_dst = hwid;
opt_handle = handle;
opt_value = value;
chan = gatt_connect(opt_src, opt_dst, opt_dst_type, opt_sec_level, opt_psm, opt_mtu, connect_cb);
if(chan == NULL) {
fprintf(logFile, "GattConnect - null channel\n");
}
else {
g_io_add_watch(chan, G_IO_HUP, channel_watcher, (void *)dev_id);
}
return chan;
}
请提供可能导致资源繁忙的原因
【问题讨论】: