diff --git a/android/hidhost.c b/android/hidhost.c
index ebed56d..657fa8f 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
struct bt_uhid *uhid;
uint8_t last_hid_msg;
struct bt_hog *hog;
- guint reconnect_id;
int sec_level;
};
{
struct hid_device *dev = data;
- if (dev->reconnect_id > 0)
- g_source_remove(dev->reconnect_id);
-
if (dev->ctrl_watch > 0)
g_source_remove(dev->ctrl_watch);
hid_device_remove(dev);
}
-static gboolean hog_reconnect(void *user_data)
-{
- struct hid_device *dev = user_data;
-
- DBG("");
-
- dev->reconnect_id = 0;
-
- bt_gatt_connect_app(hog_app, &dev->dst);
-
- return FALSE;
-}
-
static void hog_conn_cb(const bdaddr_t *addr, int err, void *attrib)
{
GSList *l;
if (err < 0) {
if (!dev)
return;
- if (dev->hog && !dev->reconnect_id) {
+ if (dev->hog) {
bt_hid_notify_state(dev,
HAL_HIDHOST_STATE_DISCONNECTED);
bt_hog_detach(dev->hog);
- dev->reconnect_id = g_idle_add(hog_reconnect, dev);
return;
}
goto fail;
bt_hid_notify_state(dev, HAL_HIDHOST_STATE_CONNECTED);
+ if (!bt_gatt_add_autoconnect(hog_app, &dev->dst))
+ error("hidhost: Could not add to autoconnect list");
+
return;
fail:
ba2str(addr, address);
DBG("Unpaired device %s", address);
+ if (hog_app)
+ bt_gatt_remove_autoconnect(hog_app, addr);
+
hid_device_remove(dev);
}