diff --git a/src/adapter.c b/src/adapter.c
index 86fff72..ee70b00 100644
--- a/src/adapter.c
+++ b/src/adapter.c
struct link_key_info {
bdaddr_t bdaddr;
+ uint8_t bdaddr_type;
unsigned char key[16];
uint8_t type;
uint8_t pin_len;
return false;
}
-static struct link_key_info *get_key_info(GKeyFile *key_file, const char *peer)
+static struct link_key_info *get_key_info(GKeyFile *key_file, const char *peer,
+ uint8_t bdaddr_type)
+
{
struct link_key_info *info = NULL;
char *str;
info = g_new0(struct link_key_info, 1);
str2ba(peer, &info->bdaddr);
+ info->bdaddr_type = bdaddr_type;
if (!strncmp(str, "0x", 2))
str2buf(&str[2], info->key, sizeof(info->key));
struct link_key_info *info = l->data;
bacpy(&key->addr.bdaddr, &info->bdaddr);
- key->addr.type = BDADDR_BREDR;
+ key->addr.type = info->bdaddr_type;
key->type = info->type;
memcpy(key->val, info->key, 16);
key->pin_len = info->pin_len;
btd_error(adapter->dev_id, "Load connection parameters failed");
}
-static uint8_t get_le_addr_type(GKeyFile *keyfile)
+static uint8_t get_addr_type(GKeyFile *keyfile)
{
uint8_t addr_type;
char *type;
+ /* The AddressType is written to file only When dev->le is
+ * set to true, as referenced in the update_technologies().
+ * Therefore, When type is NULL, it default to BDADDR_BREDR.
+ */
type = g_key_file_get_string(keyfile, "General", "AddressType", NULL);
if (!type)
- return BDADDR_LE_PUBLIC;
+ return BDADDR_BREDR;
if (g_str_equal(type, "public"))
addr_type = BDADDR_LE_PUBLIC;
g_clear_error(&gerr);
}
- key_info = get_key_info(key_file, entry->d_name);
+ bdaddr_type = get_addr_type(key_file);
- bdaddr_type = get_le_addr_type(key_file);
+ key_info = get_key_info(key_file, entry->d_name, bdaddr_type);
ltk_info = get_ltk_info(key_file, entry->d_name, bdaddr_type);