diff --git a/src/adapter.c b/src/adapter.c
index f0b4beb..8d18f40 100644
--- a/src/adapter.c
+++ b/src/adapter.c
static void create_stored_device_from_profiles(char *key, char *value,
void *user_data)
{
+ char address[18];
+ uint8_t bdaddr_type;
struct btd_adapter *adapter = user_data;
GSList *list, *uuids = bt_string2list(value);
struct btd_device *device;
+ if (sscanf(key, "%17s#%hhu", address, &bdaddr_type) < 2)
+ bdaddr_type = BDADDR_BREDR;
+
if (g_slist_find_custom(adapter->devices,
- key, (GCompareFunc) device_address_cmp))
+ address, (GCompareFunc) device_address_cmp))
return;
- device = device_create(connection, adapter, key, BDADDR_BREDR);
+ device = device_create(connection, adapter, address, bdaddr_type);
if (!device)
return;
diff --git a/src/device.c b/src/device.c
index 4459fd5..f94116a 100644
--- a/src/device.c
+++ b/src/device.c
adapter_get_address(adapter, &src);
if (!device->uuids) {
- write_device_profiles(&src, &device->bdaddr, "");
+ write_device_profiles(&src, &device->bdaddr,
+ device->bdaddr_type, "");
return;
}
str = bt_list2string(device->uuids);
- write_device_profiles(&src, &device->bdaddr, str);
+ write_device_profiles(&src, &device->bdaddr, device->bdaddr_type, str);
g_free(str);
}
diff --git a/src/storage.c b/src/storage.c
index c10f9ae..05fb0a8 100644
--- a/src/storage.c
+++ b/src/storage.c
return ret;
}
-int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles)
+int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
+ const char *profiles)
{
- char filename[PATH_MAX + 1], addr[18];
+ char filename[PATH_MAX + 1], key[20];
if (!profiles)
return -EINVAL;
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- ba2str(dst, addr);
- return textfile_put(filename, addr, profiles);
+ ba2str(dst, key);
+ sprintf(&key[17], "#%hhu", dst_type);
+
+ return textfile_put(filename, key, profiles);
}
int delete_entry(bdaddr_t *src, const char *storage, bdaddr_t *dst,
diff --git a/src/storage.h b/src/storage.h
index cd7b161..6af2475 100644
--- a/src/storage.h
+++ b/src/storage.h
ssize_t read_pin_code(bdaddr_t *local, bdaddr_t *peer, char *pin);
gboolean read_trust(const bdaddr_t *local, const char *addr, const char *service);
int write_trust(const char *src, const char *addr, const char *service, gboolean trust);
-int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles);
+int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
+ const char *profiles);
int delete_entry(bdaddr_t *src, const char *storage, bdaddr_t *dst,
uint8_t dst_type);
int store_record(const gchar *src, const gchar *dst, sdp_record_t *rec);