From b06899eace1f484b387aae0e568fb1da988b468c Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 23 Dec 2011 13:00:55 +0200 Subject: [PATCH] Fix device address type tracking --- attrib/client.c | 2 +- audio/manager.c | 2 +- health/hdp.c | 2 +- health/hdp_util.c | 8 +++---- input/manager.c | 4 ++-- network/manager.c | 2 +- plugins/hciops.c | 37 ++++++++++++++++++++++---------- plugins/mgmtops.c | 21 ++++++++++++++++--- proximity/monitor.c | 4 ++-- serial/manager.c | 2 +- src/adapter.c | 51 ++++++++++++++++++++++----------------------- src/adapter.h | 13 +++++++++--- src/device.c | 38 ++++++++++++++++----------------- src/device.h | 18 ++++++---------- src/event.c | 15 ++++++------- src/event.h | 6 +++--- 16 files changed, 128 insertions(+), 97 deletions(-) diff --git a/attrib/client.c b/attrib/client.c index bfe587709..e5d6ed21a 100644 --- a/attrib/client.c +++ b/attrib/client.c @@ -151,7 +151,7 @@ static void gatt_get_address(struct gatt_service *gatt, adapter = device_get_adapter(device); adapter_get_address(adapter, sba); - device_get_address(device, dba); + device_get_address(device, dba, NULL); } static int characteristic_handle_cmp(gconstpointer a, gconstpointer b) diff --git a/audio/manager.c b/audio/manager.c index 8de5515f0..e9187ce0a 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -778,7 +778,7 @@ static int audio_probe(struct btd_device *device, GSList *uuids) struct audio_device *audio_dev; adapter_get_address(adapter, &src); - device_get_address(device, &dst); + device_get_address(device, &dst, NULL); audio_dev = manager_get_device(&src, &dst, TRUE); if (!audio_dev) { diff --git a/health/hdp.c b/health/hdp.c index acd35e4c4..812352f48 100644 --- a/health/hdp.c +++ b/health/hdp.c @@ -222,7 +222,7 @@ static gint cmp_dev_addr(gconstpointer a, gconstpointer dst) const struct hdp_device *device = a; bdaddr_t addr; - device_get_address(device->dev, &addr); + device_get_address(device->dev, &addr, NULL); return bacmp(&addr, dst); } diff --git a/health/hdp_util.c b/health/hdp_util.c index f49cb6e12..3b48e44e5 100644 --- a/health/hdp_util.c +++ b/health/hdp_util.c @@ -859,7 +859,7 @@ gboolean hdp_get_mdep(struct hdp_device *device, struct hdp_application *app, bdaddr_t dst, src; uuid_t uuid; - device_get_address(device->dev, &dst); + device_get_address(device->dev, &dst, NULL); adapter_get_address(device_get_adapter(device->dev), &src); mdep_data = g_new0(struct get_mdep_data, 1); @@ -1065,7 +1065,7 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data) conn_data = con_mcl_data_ref(conn_data); - device_get_address(conn_data->dev->dev, &dst); + device_get_address(conn_data->dev->dev, &dst, NULL); if (!mcap_create_mcl(conn_data->dev->hdp_adapter->mi, &dst, ccpsm, create_mcl_cb, conn_data, destroy_con_mcl_data, &gerr)) { @@ -1088,7 +1088,7 @@ gboolean hdp_establish_mcl(struct hdp_device *device, bdaddr_t dst, src; uuid_t uuid; - device_get_address(device->dev, &dst); + device_get_address(device->dev, &dst, NULL); adapter_get_address(device_get_adapter(device->dev), &src); conn_data = g_new0(struct conn_mcl_data, 1); @@ -1158,7 +1158,7 @@ gboolean hdp_get_dcpsm(struct hdp_device *device, hdp_continue_dcpsm_f func, bdaddr_t dst, src; uuid_t uuid; - device_get_address(device->dev, &dst); + device_get_address(device->dev, &dst, NULL); adapter_get_address(device_get_adapter(device->dev), &src); dcpsm_data = g_new0(struct get_dcpsm_data, 1); diff --git a/input/manager.c b/input/manager.c index 496f497b0..ede06be96 100644 --- a/input/manager.c +++ b/input/manager.c @@ -69,7 +69,7 @@ static int hid_device_probe(struct btd_device *device, GSList *uuids) return -1; adapter_get_address(adapter, &src); - device_get_address(device, &dst); + device_get_address(device, &dst, NULL); return input_device_register(connection, device, path, &src, &dst, HID_UUID, rec->handle, idle_timeout * 60); @@ -112,7 +112,7 @@ static int headset_probe(struct btd_device *device, GSList *uuids) } adapter_get_address(adapter, &src); - device_get_address(device, &dst); + device_get_address(device, &dst, NULL); return fake_input_register(connection, device, path, &src, &dst, HSP_HS_UUID, ch); diff --git a/network/manager.c b/network/manager.c index 321640b58..00a55aacf 100644 --- a/network/manager.c +++ b/network/manager.c @@ -80,7 +80,7 @@ static int network_probe(struct btd_device *device, GSList *uuids, uint16_t id) DBG("path %s", path); adapter_get_address(adapter, &src); - device_get_address(device, &dst); + device_get_address(device, &dst, NULL); return connection_register(device, path, &src, &dst, id); } diff --git a/plugins/hciops.c b/plugins/hciops.c index 6d6c6f06a..f3115a17e 100644 --- a/plugins/hciops.c +++ b/plugins/hciops.c @@ -1868,8 +1868,8 @@ static inline void inquiry_result(int index, int plen, void *ptr) (info->dev_class[1] << 8) | (info->dev_class[2] << 16); - btd_event_device_found(&dev->bdaddr, &info->bdaddr, class, - 0, 0, NULL, 0); + btd_event_device_found(&dev->bdaddr, &info->bdaddr, + ADDR_TYPE_BREDR, class, 0, 0, NULL, 0); ptr += INQUIRY_INFO_SIZE; } } @@ -1891,7 +1891,8 @@ static inline void inquiry_result_with_rssi(int index, int plen, void *ptr) | (info->dev_class[2] << 16); btd_event_device_found(&dev->bdaddr, &info->bdaddr, - class, info->rssi, 0, NULL, 0); + ADDR_TYPE_BREDR, class, + info->rssi, 0, NULL, 0); ptr += INQUIRY_INFO_WITH_RSSI_AND_PSCAN_MODE_SIZE; } } else { @@ -1902,7 +1903,8 @@ static inline void inquiry_result_with_rssi(int index, int plen, void *ptr) | (info->dev_class[2] << 16); btd_event_device_found(&dev->bdaddr, &info->bdaddr, - class, info->rssi, 0, NULL, 0); + ADDR_TYPE_BREDR, class, + info->rssi, 0, NULL, 0); ptr += INQUIRY_INFO_WITH_RSSI_SIZE; } } @@ -1920,9 +1922,9 @@ static inline void extended_inquiry_result(int index, int plen, void *ptr) | (info->dev_class[1] << 8) | (info->dev_class[2] << 16); - btd_event_device_found(&dev->bdaddr, &info->bdaddr, class, - info->rssi, 0, info->data, - HCI_MAX_EIR_LENGTH); + btd_event_device_found(&dev->bdaddr, &info->bdaddr, + ADDR_TYPE_BREDR, class, info->rssi, + 0, info->data, HCI_MAX_EIR_LENGTH); ptr += EXTENDED_INQUIRY_INFO_SIZE; } } @@ -2137,6 +2139,17 @@ static inline void conn_request(int index, void *ptr) btd_event_remote_class(&dev->bdaddr, &evt->bdaddr, class); } +static inline addr_type_t le_addr_type(uint8_t bdaddr_type) +{ + switch (bdaddr_type) { + case LE_RANDOM_ADDRESS: + return ADDR_TYPE_LE_RANDOM; + case LE_PUBLIC_ADDRESS: + default: + return ADDR_TYPE_LE_PUBLIC; + } +} + static inline void le_advertising_report(int index, evt_le_meta_event *meta) { struct dev_info *dev = &devs[index]; @@ -2149,8 +2162,9 @@ static inline void le_advertising_report(int index, evt_le_meta_event *meta) info = (le_advertising_info *) &meta->data[1]; rssi = *(info->data + info->length); - btd_event_device_found(&dev->bdaddr, &info->bdaddr, 0, rssi, - 0, info->data, info->length); + btd_event_device_found(&dev->bdaddr, &info->bdaddr, + le_addr_type(info->bdaddr_type), 0, rssi, 0, + info->data, info->length); num_reports--; @@ -2159,8 +2173,9 @@ static inline void le_advertising_report(int index, evt_le_meta_event *meta) RSSI_SIZE); rssi = *(info->data + info->length); - btd_event_device_found(&dev->bdaddr, &info->bdaddr, 0, rssi, - 0, info->data, info->length); + btd_event_device_found(&dev->bdaddr, &info->bdaddr, + le_addr_type(info->bdaddr_type), + 0, rssi, 0, info->data, info->length); } } diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c index 6d5862e6f..94b721f19 100644 --- a/plugins/mgmtops.c +++ b/plugins/mgmtops.c @@ -1236,6 +1236,20 @@ static void mgmt_local_name_changed(int sk, uint16_t index, void *buf, size_t le adapter_name_changed(adapter, (char *) ev->name); } +static inline addr_type_t mgmt_addr_type(uint8_t mgmt_addr_type) +{ + switch (mgmt_addr_type) { + case MGMT_ADDR_BREDR: + return ADDR_TYPE_BREDR; + case MGMT_ADDR_LE_PUBLIC: + return ADDR_TYPE_LE_PUBLIC; + case MGMT_ADDR_LE_RANDOM: + return ADDR_TYPE_LE_RANDOM; + default: + return ADDR_TYPE_BREDR; + } +} + static void mgmt_device_found(int sk, uint16_t index, void *buf, size_t len) { struct mgmt_ev_device_found *ev = buf; @@ -1269,9 +1283,10 @@ static void mgmt_device_found(int sk, uint16_t index, void *buf, size_t len) DBG("hci%u addr %s, class %u rssi %d %s", index, addr, cls, ev->rssi, eir ? "eir" : ""); - btd_event_device_found(&info->bdaddr, &ev->addr.bdaddr, cls, - ev->rssi, ev->confirm_name, - eir, HCI_MAX_EIR_LENGTH); + btd_event_device_found(&info->bdaddr, &ev->addr.bdaddr, + mgmt_addr_type(ev->addr.type), cls, + ev->rssi, ev->confirm_name, + eir, HCI_MAX_EIR_LENGTH); } static void mgmt_remote_name(int sk, uint16_t index, void *buf, size_t len) diff --git a/proximity/monitor.c b/proximity/monitor.c index 29ae42543..76020eeea 100644 --- a/proximity/monitor.c +++ b/proximity/monitor.c @@ -417,7 +417,7 @@ static DBusMessage *set_link_loss_alert(DBusConnection *conn, DBusMessage *msg, monitor->linklosslevel = g_strdup(level); adapter_get_address(device_get_adapter(device), &sba); - device_get_address(device, &dba); + device_get_address(device, &dba, NULL); write_proximity_config(&sba, &dba, "LinkLossAlertLevel", level); @@ -592,7 +592,7 @@ int monitor_register(DBusConnection *conn, struct btd_device *device, char *level; adapter_get_address(device_get_adapter(device), &sba); - device_get_address(device, &dba); + device_get_address(device, &dba, NULL); level = read_proximity_config(&sba, &dba, "LinkLossAlertLevel"); diff --git a/serial/manager.c b/serial/manager.c index e97f1a9ff..b6090544b 100644 --- a/serial/manager.c +++ b/serial/manager.c @@ -95,7 +95,7 @@ static int serial_probe(struct btd_device *device, const char *uuid) } adapter_get_address(adapter, &src); - device_get_address(device, &dst); + device_get_address(device, &dst, NULL); return port_register(connection, path, &src, &dst, uuid, ch); } diff --git a/src/adapter.c b/src/adapter.c index a776997c7..8b2a6d88b 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -621,7 +621,7 @@ static GSList *remove_bredr(GSList *all) for (l = all, le = NULL; l; l = l->next) { struct remote_dev_info *dev = l->data; - if (dev->le == FALSE) { + if (dev->type == ADDR_TYPE_BREDR) { dev_info_free(dev); continue; } @@ -1072,7 +1072,7 @@ void adapter_service_remove(struct btd_adapter *adapter, void *r) static struct btd_device *adapter_create_device(DBusConnection *conn, struct btd_adapter *adapter, const char *address, - device_type_t type) + addr_type_t type) { struct btd_device *device; const char *path; @@ -1139,7 +1139,7 @@ struct btd_device *adapter_get_device(DBusConnection *conn, return device; return adapter_create_device(conn, adapter, address, - DEVICE_TYPE_BREDR); + ADDR_TYPE_BREDR); } static int start_discovery(struct btd_adapter *adapter) @@ -1543,21 +1543,21 @@ static DBusMessage *cancel_device_creation(DBusConnection *conn, static struct btd_device *create_device_internal(DBusConnection *conn, struct btd_adapter *adapter, - const gchar *address, int *err) + const char *address, int *err) { struct remote_dev_info *dev, match; struct btd_device *device; - device_type_t type; + addr_type_t type; memset(&match, 0, sizeof(struct remote_dev_info)); str2ba(address, &match.bdaddr); match.name_status = NAME_ANY; dev = adapter_search_found_devices(adapter, &match); - if (dev && dev->le) - type = DEVICE_TYPE_LE; + if (dev) + type = dev->type; else - type = DEVICE_TYPE_BREDR; + type = ADDR_TYPE_BREDR; device = adapter_create_device(conn, adapter, address, type); if (!device && err) @@ -1594,7 +1594,7 @@ static DBusMessage *create_device(DBusConnection *conn, if (!device) goto failed; - if (device_get_type(device) != DEVICE_TYPE_LE) + if (device_is_bredr(device)) err = device_browse_sdp(device, conn, msg, NULL, FALSE); else err = device_browse_primary(device, conn, msg, FALSE); @@ -1676,7 +1676,7 @@ static DBusMessage *create_paired_device(DBusConnection *conn, return btd_error_failed(msg, strerror(-err)); } - if (device_get_type(device) != DEVICE_TYPE_LE) + if (device_is_bredr(device)) return device_create_bonding(device, conn, msg, agent_path, cap); @@ -1874,7 +1874,7 @@ static void create_stored_device_from_profiles(char *key, char *value, key, (GCompareFunc) device_address_cmp)) return; - device = device_create(connection, adapter, key, DEVICE_TYPE_BREDR); + device = device_create(connection, adapter, key, ADDR_TYPE_BREDR); if (!device) return; @@ -1946,7 +1946,7 @@ static void create_stored_device_from_linkkeys(char *key, char *value, (GCompareFunc) device_address_cmp)) return; - device = device_create(connection, adapter, key, DEVICE_TYPE_BREDR); + device = device_create(connection, adapter, key, ADDR_TYPE_BREDR); if (device) { device_set_temporary(device, FALSE); adapter->devices = g_slist_append(adapter->devices, device); @@ -1963,7 +1963,7 @@ static void create_stored_device_from_blocked(char *key, char *value, key, (GCompareFunc) device_address_cmp)) return; - device = device_create(connection, adapter, key, DEVICE_TYPE_BREDR); + device = device_create(connection, adapter, key, ADDR_TYPE_BREDR); if (device) { device_set_temporary(device, FALSE); adapter->devices = g_slist_append(adapter->devices, device); @@ -2016,7 +2016,8 @@ static void create_stored_device_from_primary(char *key, char *value, key, (GCompareFunc) device_address_cmp)) return; - device = device_create(connection, adapter, key, DEVICE_TYPE_LE); + /* FIXME: Get the correct LE addr type (public/random) */ + device = device_create(connection, adapter, key, ADDR_TYPE_LE_PUBLIC); if (!device) return; @@ -2782,7 +2783,7 @@ void adapter_emit_device_found(struct btd_adapter *adapter, } else alias = g_strdup(dev->alias); - if (dev->le) { + if (dev->type != ADDR_TYPE_BREDR) { gboolean broadcaster; if (dev->flags & (EIR_LIM_DISC | EIR_GEN_DISC)) @@ -2820,7 +2821,7 @@ void adapter_emit_device_found(struct btd_adapter *adapter, } static struct remote_dev_info *found_device_new(const bdaddr_t *bdaddr, - gboolean le, const char *name, + addr_type_t type, const char *name, const char *alias, uint32_t class, gboolean legacy, name_status_t status, int flags) @@ -2829,7 +2830,7 @@ static struct remote_dev_info *found_device_new(const bdaddr_t *bdaddr, dev = g_new0(struct remote_dev_info, 1); bacpy(&dev->bdaddr, bdaddr); - dev->le = le; + dev->type = type; dev->name = g_strdup(name); dev->alias = g_strdup(alias); dev->class = class; @@ -2899,14 +2900,15 @@ static char *read_stored_data(bdaddr_t *local, bdaddr_t *peer, const char *file) } void adapter_update_found_devices(struct btd_adapter *adapter, - bdaddr_t *bdaddr, uint32_t class, - int8_t rssi, uint8_t confirm_name, + bdaddr_t *bdaddr, addr_type_t type, + uint32_t class, int8_t rssi, + uint8_t confirm_name, uint8_t *data, uint8_t data_len) { struct remote_dev_info *dev, match; struct eir_data eir_data; char *alias, *name; - gboolean legacy, le; + gboolean legacy; name_status_t name_status; int err; @@ -2941,9 +2943,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter, name = read_stored_data(&adapter->bdaddr, bdaddr, "names"); - if (eir_data.flags < 0) { - le = FALSE; - + if (type == ADDR_TYPE_BREDR) { legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr, data, name); @@ -2953,7 +2953,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, else name_status = NAME_NOT_REQUIRED; } else { - le = TRUE; legacy = FALSE; name_status = NAME_NOT_REQUIRED; } @@ -2972,7 +2971,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter, alias = read_stored_data(&adapter->bdaddr, bdaddr, "aliases"); - dev = found_device_new(bdaddr, le, name, alias, class, legacy, + dev = found_device_new(bdaddr, type, name, alias, class, legacy, name_status, eir_data.flags); free(name); free(alias); @@ -3483,7 +3482,7 @@ ssize_t btd_adapter_get_pin(struct btd_adapter *adapter, struct btd_device *dev, } adapter_get_address(adapter, &sba); - device_get_address(dev, &dba); + device_get_address(dev, &dba, NULL); return read_pin_code(&sba, &dba, pin_buf); } diff --git a/src/adapter.h b/src/adapter.h index 23bc8a57d..50e27d43e 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -54,6 +54,12 @@ typedef enum { NAME_REQUESTED, /* HCI remote name request was sent */ } name_status_t; +typedef enum { + ADDR_TYPE_BREDR, + ADDR_TYPE_LE_PUBLIC, + ADDR_TYPE_LE_RANDOM, +} addr_type_t; + struct btd_adapter; struct link_key_info { @@ -65,13 +71,13 @@ struct link_key_info { struct remote_dev_info { bdaddr_t bdaddr; + addr_type_t type; int8_t rssi; uint32_t class; char *name; char *alias; dbus_bool_t legacy; name_status_t name_status; - gboolean le; char **uuids; size_t uuid_count; GSList *services; @@ -110,8 +116,9 @@ int adapter_get_state(struct btd_adapter *adapter); struct remote_dev_info *adapter_search_found_devices(struct btd_adapter *adapter, struct remote_dev_info *match); void adapter_update_found_devices(struct btd_adapter *adapter, - bdaddr_t *bdaddr, uint32_t class, - int8_t rssi, uint8_t confirm_name, + bdaddr_t *bdaddr, addr_type_t type, + uint32_t class, int8_t rssi, + uint8_t confirm_name, uint8_t *data, uint8_t data_len); int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr); void adapter_emit_device_found(struct btd_adapter *adapter, diff --git a/src/device.c b/src/device.c index bb97089a5..e49e9bc9c 100644 --- a/src/device.c +++ b/src/device.c @@ -121,7 +121,7 @@ struct attio_data { struct btd_device { bdaddr_t bdaddr; - device_type_t type; + addr_type_t type; gchar *path; char name[MAX_NAME_LENGTH + 1]; char *alias; @@ -255,6 +255,16 @@ static void device_free(gpointer user_data) g_free(device); } +gboolean device_is_bredr(struct btd_device *device) +{ + return (device->type == ADDR_TYPE_BREDR); +} + +gboolean device_is_le(struct btd_device *device) +{ + return (device->type != ADDR_TYPE_BREDR); +} + gboolean device_is_paired(struct btd_device *device) { return device->paired; @@ -970,7 +980,7 @@ static void device_set_version(struct btd_device *device, uint16_t value) struct btd_device *device_create(DBusConnection *conn, struct btd_adapter *adapter, - const gchar *address, device_type_t type) + const gchar *address, addr_type_t type) { gchar *address_up; struct btd_device *device; @@ -1051,11 +1061,6 @@ void device_get_name(struct btd_device *device, char *name, size_t len) strncpy(name, device->name, len); } -device_type_t device_get_type(struct btd_device *device) -{ - return device->type; -} - uint16_t btd_device_get_vendor(struct btd_device *device) { return device->vendor; @@ -1590,7 +1595,7 @@ cleanup: bdaddr_t sba, dba; adapter_get_address(device->adapter, &sba); - device_get_address(device, &dba); + device_get_address(device, &dba, NULL); store_profiles(device); } @@ -1678,7 +1683,7 @@ static void store_services(struct btd_device *device) char *str = primary_list_to_string(device->primaries); adapter_get_address(adapter, &sba); - device_get_address(device, &dba); + device_get_address(device, &dba, NULL); write_device_services(&sba, &dba, str); @@ -1852,7 +1857,7 @@ static gboolean att_connect(gpointer user_data) DBG("Connection attempt to: %s", addr); - if (device->type != DEVICE_TYPE_LE) { + if (device_is_bredr(device)) { io = bt_io_connect(BT_IO_L2CAP, att_connect_cb, device, NULL, &gerr, BT_IO_OPT_SOURCE_BDADDR, &sba, @@ -1991,9 +1996,12 @@ struct btd_adapter *device_get_adapter(struct btd_device *device) return device->adapter; } -void device_get_address(struct btd_device *device, bdaddr_t *bdaddr) +void device_get_address(struct btd_device *device, bdaddr_t *bdaddr, + addr_type_t *type) { bacpy(bdaddr, &device->bdaddr); + if (type != NULL) + *type = device->type; } const gchar *device_get_path(struct btd_device *device) @@ -2082,14 +2090,6 @@ void device_set_auto_connect(struct btd_device *device, gboolean enable) att_connect_dispatched); } -void device_set_type(struct btd_device *device, device_type_t type) -{ - if (!device) - return; - - device->type = type; -} - static gboolean start_discovery(gpointer user_data) { struct btd_device *device = user_data; diff --git a/src/device.h b/src/device.h index 1ea5ce420..13005ae06 100644 --- a/src/device.h +++ b/src/device.h @@ -33,19 +33,11 @@ typedef enum { AUTH_TYPE_NOTIFY, } auth_type_t; -typedef enum { - DEVICE_TYPE_UNKNOWN, - DEVICE_TYPE_BREDR, - DEVICE_TYPE_LE, - DEVICE_TYPE_DUALMODE -} device_type_t; - struct btd_device *device_create(DBusConnection *conn, - struct btd_adapter *adapter, - const gchar *address, device_type_t type); + struct btd_adapter *adapter, + const char *address, addr_type_t type); void device_set_name(struct btd_device *device, const char *name); void device_get_name(struct btd_device *device, char *name, size_t len); -device_type_t device_get_type(struct btd_device *device); uint16_t btd_device_get_vendor(struct btd_device *device); uint16_t btd_device_get_product(struct btd_device *device); uint16_t btd_device_get_version(struct btd_device *device); @@ -65,9 +57,12 @@ GSList *device_services_from_record(struct btd_device *device, GSList *profiles); void btd_device_add_uuid(struct btd_device *device, const char *uuid); struct btd_adapter *device_get_adapter(struct btd_device *device); -void device_get_address(struct btd_device *device, bdaddr_t *bdaddr); +void device_get_address(struct btd_device *device, bdaddr_t *bdaddr, + addr_type_t *type); const gchar *device_get_path(struct btd_device *device); struct agent *device_get_agent(struct btd_device *device); +gboolean device_is_bredr(struct btd_device *device); +gboolean device_is_le(struct btd_device *device); gboolean device_is_busy(struct btd_device *device); gboolean device_is_temporary(struct btd_device *device); gboolean device_is_paired(struct btd_device *device); @@ -75,7 +70,6 @@ gboolean device_is_bonded(struct btd_device *device); gboolean device_is_trusted(struct btd_device *device); void device_set_paired(struct btd_device *device, gboolean paired); void device_set_temporary(struct btd_device *device, gboolean temporary); -void device_set_type(struct btd_device *device, device_type_t type); void device_set_bonded(struct btd_device *device, gboolean bonded); void device_set_auto_connect(struct btd_device *device, gboolean enable); gboolean device_is_connected(struct btd_device *device); diff --git a/src/event.c b/src/event.c index 454056082..cc0e85f27 100644 --- a/src/event.c +++ b/src/event.c @@ -93,7 +93,7 @@ static void pincode_cb(struct agent *agent, DBusError *derr, bdaddr_t dba; int err; - device_get_address(device, &dba); + device_get_address(device, &dba, NULL); if (derr) { err = btd_adapter_pincode_reply(adapter, &dba, NULL, 0); @@ -139,7 +139,7 @@ static int confirm_reply(struct btd_adapter *adapter, { bdaddr_t bdaddr; - device_get_address(device, &bdaddr); + device_get_address(device, &bdaddr, NULL); return btd_adapter_confirm_reply(adapter, &bdaddr, success); } @@ -160,7 +160,7 @@ static void passkey_cb(struct agent *agent, DBusError *err, uint32_t passkey, struct btd_adapter *adapter = device_get_adapter(device); bdaddr_t bdaddr; - device_get_address(device, &bdaddr); + device_get_address(device, &bdaddr, NULL); if (err) passkey = INVALID_PASSKEY; @@ -264,9 +264,10 @@ static void update_lastused(bdaddr_t *sba, bdaddr_t *dba) write_lastused_info(sba, dba, tm); } -void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class, - int8_t rssi, uint8_t confirm_name, - uint8_t *data, uint8_t data_len) +void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, addr_type_t type, + uint32_t class, int8_t rssi, + uint8_t confirm_name, uint8_t *data, + uint8_t data_len) { struct btd_adapter *adapter; @@ -282,7 +283,7 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class, if (data) write_remote_eir(local, peer, data); - adapter_update_found_devices(adapter, peer, class, rssi, + adapter_update_found_devices(adapter, peer, type, class, rssi, confirm_name, data, data_len); } diff --git a/src/event.h b/src/event.h index cce292e95..f91b42f2b 100644 --- a/src/event.h +++ b/src/event.h @@ -23,9 +23,9 @@ */ int btd_event_request_pin(bdaddr_t *sba, bdaddr_t *dba, gboolean secure); -void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class, - int8_t rssi, uint8_t confirm_name, - uint8_t *data, uint8_t data_len); +void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, addr_type_t type, + uint32_t cls, int8_t rssi, uint8_t confirm_name, + uint8_t *data, uint8_t data_len); void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer, gboolean legacy); void btd_event_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class); void btd_event_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status, char *name);