Rename adapter_remove_device to btd_adapter_remove_device
PATCH 1/1 Rename adapter_remove_device to btd_adapter_remove_device
Allow this symbol to be exported and usable from external plugins.
--- src/adapter.c | 14 +++++++------- src/adapter.h | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-)
src/adapter.c +7 -7
@@ -1036,8 +1036,8 @@ static void service_auth_cancel(struct service_auth *auth)g_free (auth); } -static void adapter_remove_device (struct btd_adapter *adapter, -struct btd_device *dev) +void btd_adapter_remove_device (struct btd_adapter *adapter, +struct btd_device *dev) {GList *l;
@@ -1531,7 +1531,7 @@ static gboolean remove_temp_devices(gpointer user_data) next =g_slist_next (l);if (device_is_temporary (dev)) -adapter_remove_device (adapter, dev); +btd_adapter_remove_device (adapter, dev); }return FALSE;
@@ -2159,7 +2159,7 @@ static DBusMessage *remove_device(DBusConnection *conn,btd_device_set_temporary (device, TRUE);if (!btd_device_is_connected (device)) { -adapter_remove_device (adapter, device); +btd_adapter_remove_device (adapter, device);return dbus_message_new_method_return (msg); }
@@ -4268,7 +4268,7 @@ static void adapter_remove_connection(struct btd_adapter *adapter,const char *path =device_get_path (device);DBG ("Removing temporary device %s" , path); -adapter_remove_device (adapter, device); +btd_adapter_remove_device (adapter, device); } }
@@ -5834,7 +5834,7 @@ static void connect_failed_callback(uint16_t index, uint16_t length,* when it is temporary. */ if (device && !device_is_bonding (device,NULL ) &&device_is_temporary (device)) -adapter_remove_device (adapter, device); +btd_adapter_remove_device (adapter, device); } static void unpaired_callback(uint16_t index, uint16_t length,
@@ -5865,7 +5865,7 @@ static void unpaired_callback(uint16_t index, uint16_t length,if (btd_device_is_connected (device))device_request_disconnect (device,NULL );else -adapter_remove_device (adapter, device); +btd_adapter_remove_device (adapter, device); } static void read_info_complete(uint8_t status, uint16_t length,
src/adapter.h +3 -0
@@ -36,6 +36,7 @@#define INVALID_PASSKEY 0xffffffffstruct btd_adapter ; +struct btd_device ;struct btd_adapter *btd_adapter_get_default (void );bool btd_adapter_is_default (struct btd_adapter *adapter);
@@ -90,6 +91,8 @@ bool btd_adapter_get_connectable(struct btd_adapter *adapter);uint32_t btd_adapter_get_class (struct btd_adapter *adapter);const char *btd_adapter_get_name (struct btd_adapter *adapter); +void btd_adapter_remove_device (struct btd_adapter *adapter, +struct btd_device *dev);struct btd_device *btd_adapter_get_device (struct btd_adapter *adapter,const bdaddr_t *addr,uint8_t addr_type);
Signature · 1 line
1.8.5.3
Hi Petri,
Quoted 5 lines · Petri Gynther
Allow this symbol to be exported and usable from external plugins.
--- src/adapter.c | 14 +++++++------- src/adapter.h | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-)
The patch looks fine, but we usually don't export symbols without knowing that there exists a valid use case for it. So could you perhaps give some background (or even a follow-up patch) to explain what you need this for?
Johan
Hi Johan,
I would need this for the IR-assist device discovery plugin that I'm writing. Basically, I have a HID remote control which is not discoverable (but it is connectable). When this HID remote is in unpaired state, it sends its BD address to the host via IR. The plugin will get the BD address and do the following:
device = btd_adapter_find_device(adapter, &device_bdaddr);
if (device) {
/* remove old pairing and device info */
btd_device_set_temporary(device, TRUE);
btd_adapter_remove_device(adapter, device);
}/* (re)create the device */
device = btd_adapter_get_device(adapter, &device_bdaddr, BDADDR_BREDR); btd_device_device_set_name(device, ...); btd_device_set_pnpid(device, ...); btd_device_set_temporary(device, FALSE);
-- Petri
Quoted 15 lines · Johan Hedberg
Hi Petri,
Quoted 5 lines · Petri Gynther
Allow this symbol to be exported and usable from external plugins.
--- src/adapter.c | 14 +++++++------- src/adapter.h | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-)The patch looks fine, but we usually don't export symbols without knowing that there exists a valid use case for it. So could you perhaps give some background (or even a follow-up patch) to explain what you need this for?
Johan
Hi Petri,
Quoted 6 lines · Petri Gynther
I would need this for the IR-assist device discovery plugin that I'm writing. Basically, I have a HID remote control which is not discoverable (but it is connectable). When this HID remote is in unpaired state, it sends its BD address to the host via IR. The plugin will get the BD address and do the following:
Quoted 6 lines
device =
btd_adapter_find_device(adapter, &device_bdaddr);if (device) { /* remove old pairing and device info */ btd_device_set_temporary(device, TRUE); btd_adapter_remove_device(adapter, device); }
If the device is only discoverable through IR why would there be an existing device object for it? And if there does exist a device object doesn't it mean it's already paired and you don't need to repair?
Johan
Hi Johan,
Once BlueZ host and the remote have been paired successfully the first time, the remote has a key combination available that allows it to be unpaired and reset to initial state. But, BlueZ won't know about that. It still considers the remote paired. Thus, when the BD address arrives to the IR-assist plugin again, the plugin needs to clear all old state from BlueZ side and start over as if the device had never been discovered before.
The old device removal and new device creation are handled in the plugin, since the device creation part is not possible over D-Bus. However, once the device is created, the pairing is handled in a separate Python script.
-- Petri
Quoted 21 lines · Johan Hedberg
Hi Petri,
Quoted 6 lines · Petri Gynther
I would need this for the IR-assist device discovery plugin that I'm writing. Basically, I have a HID remote control which is not discoverable (but it is connectable). When this HID remote is in unpaired state, it sends its BD address to the host via IR. The plugin will get the BD address and do the following:
Quoted 6 lines
device =
btd_adapter_find_device(adapter, &device_bdaddr);if (device) { /* remove old pairing and device info */ btd_device_set_temporary(device, TRUE); btd_adapter_remove_device(adapter, device); }If the device is only discoverable through IR why would there be an existing device object for it? And if there does exist a device object doesn't it mean it's already paired and you don't need to repair?
Johan
Hi Petri,
Quoted 8 lines · Petri Gynther
Once BlueZ host and the remote have been paired successfully the first time, the remote has a key combination available that allows it to be unpaired and reset to initial state. But, BlueZ won't know about that. It still considers the remote paired. Thus, when the BD address arrives to the IR-assist plugin again, the plugin needs to clear all old state from BlueZ side and start over as if the device had never been discovered before.
Quoted 4 lines
The old device removal and new device creation are handled in the plugin, since the device creation part is not possible over D-Bus. However, once the device is created, the pairing is handled in a separate Python script.
Fair enough. I've now applied the patch.
Btw, please don't use top-posting on this list. It makes it difficult to track the discussion when we've got inline quoting and top posting mixed together.
Johan