bdstr_t bdstr = {0};
if(remote_bd_addr)
bd2str(remote_bd_addr, &bdstr);
- BTIF_TRACE_DEBUG3("in, bd addr:%s, prop type:%d, len:%d", bdstr, prop->type, prop->len);
+ BTIF_TRACE_DEBUG("in, bd addr:%s, prop type:%d, len:%d", bdstr, prop->type, prop->len);
char value[1024];
if(prop->len <= 0 || prop->len > (int)sizeof(value) - 1)
{
- BTIF_TRACE_ERROR2("property type:%d, len:%d is invalid", prop->type, prop->len);
+ BTIF_TRACE_ERROR("property type:%d, len:%d is invalid", prop->type, prop->len);
return FALSE;
}
switch(prop->type)
} break;
default:
- BTIF_TRACE_ERROR1("Unknow prop type:%d", prop->type);
+ BTIF_TRACE_ERROR("Unknow prop type:%d", prop->type);
return FALSE;
}
return TRUE;
bdstr_t bdstr = {0};
if(remote_bd_addr)
bd2str(remote_bd_addr, &bdstr);
- BTIF_TRACE_DEBUG3("in, bd addr:%s, prop type:%d, len:%d", bdstr, prop->type, prop->len);
+ BTIF_TRACE_DEBUG("in, bd addr:%s, prop type:%d, len:%d", bdstr, prop->type, prop->len);
if(prop->len <= 0)
{
- BTIF_TRACE_ERROR2("property type:%d, len:%d is invalid", prop->type, prop->len);
+ BTIF_TRACE_ERROR("property type:%d, len:%d is invalid", prop->type, prop->len);
return FALSE;
}
int ret = FALSE;
} break;
default:
- BTIF_TRACE_ERROR1("Unknow prop type:%d", prop->type);
+ BTIF_TRACE_ERROR("Unknow prop type:%d", prop->type);
return FALSE;
}
return ret;
}
+/*******************************************************************************
+**
+** Function btif_in_fetch_bonded_devices
+**
+** Description Internal helper function to fetch the bonded devices
+** from NVRAM
+**
+** Returns BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+static bt_status_t btif_in_fetch_bonded_device(char *bdstr)
+{
+ BOOLEAN bt_linkkey_file_found=FALSE;
+
+ int type = BTIF_CFG_TYPE_BIN;
+ LINK_KEY link_key;
+ int size = sizeof(link_key);
+ if(btif_config_get("Remote", bdstr, "LinkKey", (char*)link_key, &size, &type))
+ {
+ int linkkey_type;
+ if(btif_config_get_int("Remote", bdstr, "LinkKeyType", &linkkey_type))
+ {
+ bt_linkkey_file_found = TRUE;
+ }
+ else
+ {
+ bt_linkkey_file_found = FALSE;
+ }
+ }
+#if (BLE_INCLUDED == TRUE)
+ if((btif_in_fetch_bonded_ble_device(bdstr, FALSE, NULL) != BT_STATUS_SUCCESS)
+ && (!bt_linkkey_file_found))
+ {
+ BTIF_TRACE_DEBUG("Remote device:%s, no link key or ble key found", bdstr);
+ return BT_STATUS_FAIL;
+ }
+#else
+ if((!bt_linkkey_file_found))
+ {
+ BTIF_TRACE_DEBUG("Remote device:%s, no link key found", bdstr);
+ return BT_STATUS_FAIL;
+ }
+#endif
+ return BT_STATUS_SUCCESS;
+}
/*******************************************************************************
**
*******************************************************************************/
static bt_status_t btif_in_fetch_bonded_devices(btif_bonded_devices_t *p_bonded_devices, int add)
{
- BTIF_TRACE_DEBUG1("in add:%d", add);
+ BTIF_TRACE_DEBUG("in add:%d", add);
memset(p_bonded_devices, 0, sizeof(btif_bonded_devices_t));
- char kname[128], vname[128];
+ char kname[128];
short kpos;
int kname_size;
kname_size = sizeof(kname);
do
{
kpos = btif_config_next_key(kpos, "Remote", kname, &kname_size);
- BTIF_TRACE_DEBUG2("Remote device:%s, size:%d", kname, kname_size);
+ BTIF_TRACE_DEBUG("Remote device:%s, size:%d", kname, kname_size);
int type = BTIF_CFG_TYPE_BIN;
LINK_KEY link_key;
int size = sizeof(link_key);
#if (BLE_INCLUDED == TRUE)
bt_linkkey_file_found = FALSE;
#else
- BTIF_TRACE_ERROR1("bounded device:%s, LinkKeyType or PinLength is invalid", kname);
+ BTIF_TRACE_ERROR("bounded device:%s, LinkKeyType or PinLength is invalid", kname);
#endif
}
}
#if (BLE_INCLUDED == TRUE)
if(!(btif_in_fetch_bonded_ble_device(kname,add, p_bonded_devices)) && (!bt_linkkey_file_found))
{
- BTIF_TRACE_DEBUG1("Remote device:%s, no link key or ble key found", kname);
+ BTIF_TRACE_DEBUG("Remote device:%s, no link key or ble key found", kname);
}
#else
if(!bt_linkkey_file_found)
- BTIF_TRACE_DEBUG1("Remote device:%s, no link key", kname);
+ BTIF_TRACE_DEBUG("Remote device:%s, no link key", kname);
#endif
kname_size = sizeof(kname);
kname[0] = 0;
} while(kpos != -1);
- BTIF_TRACE_DEBUG0("out");
+ BTIF_TRACE_DEBUG("out");
return BT_STATUS_SUCCESS;
}
/* Special handling for adapter BD_ADDR and BONDED_DEVICES */
if (property->type == BT_PROPERTY_BDADDR)
{
- BD_ADDR addr;
bt_bdaddr_t *bd_addr = (bt_bdaddr_t*)property->val;
/* This has been cached in btif. Just fetch it from there */
memcpy(bd_addr, &btif_local_bd_addr, sizeof(bt_bdaddr_t));
btif_in_fetch_bonded_devices(&bonded_devices, 0);
- BTIF_TRACE_DEBUG2("%s: Number of bonded devices: %d Property:BT_PROPERTY_ADAPTER_BONDED_DEVICES", __FUNCTION__, bonded_devices.num_devices);
+ BTIF_TRACE_DEBUG("%s: Number of bonded devices: %d Property:BT_PROPERTY_ADAPTER_BONDED_DEVICES", __FUNCTION__, bonded_devices.num_devices);
if (bonded_devices.num_devices > 0)
{
uint32_t i;
tBTA_SERVICE_MASK service_mask = btif_get_enabled_services_mask();
- BTIF_TRACE_ERROR2("%s service_mask:0x%x", __FUNCTION__, service_mask);
+ BTIF_TRACE_ERROR("%s service_mask:0x%x", __FUNCTION__, service_mask);
for (i=0; i < BTA_MAX_SERVICE_ID; i++)
{
/* This should eventually become a function when more services are enabled */
{
bdstr_t bdstr;
bd2str(remote_bd_addr, &bdstr);
- BTIF_TRACE_DEBUG1("in bd addr:%s", bdstr);
+ BTIF_TRACE_DEBUG("in bd addr:%s", bdstr);
int ret = 1;
if(btif_config_exist("Remote", bdstr, "LinkKeyType"))
ret &= btif_config_remove("Remote", bdstr, "LinkKeyType");
*******************************************************************************/
bt_status_t btif_storage_load_bonded_devices(void)
{
- char *fname;
btif_bonded_devices_t bonded_devices;
uint32_t i = 0;
bt_property_t adapter_props[6];
free(devices_list);
}
- BTIF_TRACE_EVENT2("%s: %d bonded devices found", __FUNCTION__, bonded_devices.num_devices);
+ BTIF_TRACE_EVENT("%s: %d bonded devices found", __FUNCTION__, bonded_devices.num_devices);
{
for (i = 0; i < bonded_devices.num_devices; i++)
{
bdstr_t bdstr;
bd2str(remote_bd_addr, &bdstr);
- BTIF_TRACE_DEBUG2(" %s in bd addr:%s",__FUNCTION__, bdstr);
+ BTIF_TRACE_DEBUG(" %s in bd addr:%s",__FUNCTION__, bdstr);
int ret = 1;
if(btif_config_exist("Remote", bdstr, "LE_KEY_PENC"))
ret &= btif_config_remove("Remote", bdstr, "LE_KEY_PENC");
bt_bdaddr_t bd_addr;
BD_ADDR bta_bd_addr;
BOOLEAN is_device_added =FALSE;
+ BOOLEAN key_found = FALSE;
tBTA_LE_KEY_VALUE *p;
if(!btif_config_get_int("Remote", remote_bd_addr,"DevType", &device_type))
return BT_STATUS_FAIL;
if(device_type == BT_DEVICE_TYPE_BLE)
{
- BTIF_TRACE_DEBUG2("%s %s found a BLE device", __FUNCTION__,remote_bd_addr);
+ BTIF_TRACE_DEBUG("%s %s found a BLE device", __FUNCTION__,remote_bd_addr);
str2bd(remote_bd_addr, &bd_addr);
bdcpy(bta_bd_addr, bd_addr.address);
if (btif_storage_get_remote_addr_type(&bd_addr, &addr_type) != BT_STATUS_SUCCESS)
p = (tBTA_LE_KEY_VALUE *)buf;
for (i=0; i<16; i++)
{
- BTIF_TRACE_DEBUG2("penc_key.ltk[%d]=0x%02x",i,p->penc_key.ltk[i]);
+ BTIF_TRACE_DEBUG("penc_key.ltk[%d]=0x%02x",i,p->penc_key.ltk[i]);
}
for (i=0; i<8; i++)
{
- BTIF_TRACE_DEBUG2("penc_key.rand[%d]=0x%02x",i,p->penc_key.rand[i]);
+ BTIF_TRACE_DEBUG("penc_key.rand[%d]=0x%02x",i,p->penc_key.rand[i]);
}
- BTIF_TRACE_DEBUG1("p->penc_key.ediv=0x%04x",p->penc_key.ediv);
- BTIF_TRACE_DEBUG1("p->penc_key.sec_level=0x%02x",p->penc_key.sec_level);
- BTIF_TRACE_DEBUG1("p->penc_key.key_size=0x%02x",p->penc_key.key_size);
+ BTIF_TRACE_DEBUG("p->penc_key.ediv=0x%04x",p->penc_key.ediv);
+ BTIF_TRACE_DEBUG("p->penc_key.sec_level=0x%02x",p->penc_key.sec_level);
+ BTIF_TRACE_DEBUG("p->penc_key.key_size=0x%02x",p->penc_key.key_size);
BTA_DmAddBleKey (bta_bd_addr, (tBTA_LE_KEY_VALUE *)buf, BTIF_DM_LE_KEY_PENC);
}
+ key_found = TRUE;
}
memset(buf, 0, sizeof(buf));
p = (tBTA_LE_KEY_VALUE *)buf;
for (i=0; i<16; i++)
{
- BTIF_TRACE_DEBUG2("p->pid_key[%d]=0x%02x",i,p->pid_key.irk[i]);
+ BTIF_TRACE_DEBUG("p->pid_key[%d]=0x%02x",i,p->pid_key.irk[i]);
}
BTA_DmAddBleKey (bta_bd_addr, (tBTA_LE_KEY_VALUE *)buf, BTIF_DM_LE_KEY_PID);
}
+ key_found = TRUE;
}
memset(buf, 0, sizeof(buf));
p = (tBTA_LE_KEY_VALUE *)buf;
for (i=0; i<16; i++)
{
- BTIF_TRACE_DEBUG2("p->pcsrk_key.csrk[%d]=0x%02x",i, p->psrk_key.csrk[i]);
+ BTIF_TRACE_DEBUG("p->pcsrk_key.csrk[%d]=0x%02x",i, p->psrk_key.csrk[i]);
}
- BTIF_TRACE_DEBUG1("p->pcsrk_key.counter=0x%08x",p->psrk_key.counter);
- BTIF_TRACE_DEBUG1("p->pcsrk_key.sec_level=0x%02x",p->psrk_key.sec_level);
+ BTIF_TRACE_DEBUG("p->pcsrk_key.counter=0x%08x",p->psrk_key.counter);
+ BTIF_TRACE_DEBUG("p->pcsrk_key.sec_level=0x%02x",p->psrk_key.sec_level);
BTA_DmAddBleKey (bta_bd_addr, (tBTA_LE_KEY_VALUE *)buf, BTIF_DM_LE_KEY_PCSRK);
}
+ key_found = TRUE;
}
memset(buf, 0, sizeof(buf));
is_device_added = TRUE;
}
p = (tBTA_LE_KEY_VALUE *)buf;
- BTIF_TRACE_DEBUG1("p->lenc_key.div=0x%04x",p->lenc_key.div);
- BTIF_TRACE_DEBUG1("p->lenc_key.key_size=0x%02x",p->lenc_key.key_size);
- BTIF_TRACE_DEBUG1("p->lenc_key.sec_level=0x%02x",p->lenc_key.sec_level);
+ BTIF_TRACE_DEBUG("p->lenc_key.div=0x%04x",p->lenc_key.div);
+ BTIF_TRACE_DEBUG("p->lenc_key.key_size=0x%02x",p->lenc_key.key_size);
+ BTIF_TRACE_DEBUG("p->lenc_key.sec_level=0x%02x",p->lenc_key.sec_level);
BTA_DmAddBleKey (bta_bd_addr, (tBTA_LE_KEY_VALUE *)buf, BTIF_DM_LE_KEY_LENC);
}
+ key_found = TRUE;
}
memset(buf, 0, sizeof(buf));
is_device_added = TRUE;
}
p = (tBTA_LE_KEY_VALUE *)buf;
- BTIF_TRACE_DEBUG1("p->lcsrk_key.div=0x%04x",p->lcsrk_key.div);
- BTIF_TRACE_DEBUG1("p->lcsrk_key.counter=0x%08x",p->lcsrk_key.counter);
- BTIF_TRACE_DEBUG1("p->lcsrk_key.sec_level=0x%02x",p->lcsrk_key.sec_level);
+ BTIF_TRACE_DEBUG("p->lcsrk_key.div=0x%04x",p->lcsrk_key.div);
+ BTIF_TRACE_DEBUG("p->lcsrk_key.counter=0x%08x",p->lcsrk_key.counter);
+ BTIF_TRACE_DEBUG("p->lcsrk_key.sec_level=0x%02x",p->lcsrk_key.sec_level);
BTA_DmAddBleKey (bta_bd_addr, (tBTA_LE_KEY_VALUE *)buf, BTIF_DM_LE_KEY_LCSRK);
}
+ key_found = TRUE;
}
/* Fill in the bonded devices */
btif_gatts_add_bonded_dev_from_nv(bta_bd_addr);
}
- return BT_STATUS_SUCCESS;
+ if(key_found)
+ return BT_STATUS_SUCCESS;
+ else
+ return BT_STATUS_FAIL;
}
return BT_STATUS_FAIL;
}
UINT16 ssr_min_tout, UINT16 dl_len, UINT8 *dsc_list)
{
bdstr_t bdstr;
- BTIF_TRACE_DEBUG0("btif_storage_add_hid_device_info:");
+ BTIF_TRACE_DEBUG("btif_storage_add_hid_device_info:");
bd2str(remote_bd_addr, &bdstr);
btif_config_set_int("Remote", bdstr, "HidAttrMask", attr_mask);
btif_config_set_int("Remote", bdstr, "HidSubClass", sub_class);
{
bt_bdaddr_t bd_addr;
tBTA_HH_DEV_DSCP_INFO dscp_info;
- uint32_t i;
uint16_t attr_mask;
uint8_t sub_class;
uint8_t app_id;
- char kname[128], vname[128];
+ char kname[128];
short kpos;
int kname_size;
kname_size = sizeof(kname);
do
{
kpos = btif_config_next_key(kpos, "Remote", kname, &kname_size);
- BTIF_TRACE_DEBUG2("Remote device:%s, size:%d", kname, kname_size);
+ BTIF_TRACE_DEBUG("Remote device:%s, size:%d", kname, kname_size);
int value;
- if(btif_config_get_int("Remote", kname, "HidAttrMask", &value))
+ if(btif_in_fetch_bonded_device(kname) == BT_STATUS_SUCCESS)
{
- attr_mask = (uint16_t)value;
+ if(btif_config_get_int("Remote", kname, "HidAttrMask", &value))
+ {
+ attr_mask = (uint16_t)value;
- btif_config_get_int("Remote", kname, "HidSubClass", &value);
- sub_class = (uint8_t)value;
+ btif_config_get_int("Remote", kname, "HidSubClass", &value);
+ sub_class = (uint8_t)value;
- btif_config_get_int("Remote", kname, "HidAppId", &value);
- app_id = (uint8_t)value;
+ btif_config_get_int("Remote", kname, "HidAppId", &value);
+ app_id = (uint8_t)value;
- btif_config_get_int("Remote", kname, "HidVendorId", &value);
- dscp_info.vendor_id = (uint16_t) value;
+ btif_config_get_int("Remote", kname, "HidVendorId", &value);
+ dscp_info.vendor_id = (uint16_t) value;
- btif_config_get_int("Remote", kname, "HidProductId", &value);
- dscp_info.product_id = (uint16_t) value;
+ btif_config_get_int("Remote", kname, "HidProductId", &value);
+ dscp_info.product_id = (uint16_t) value;
- btif_config_get_int("Remote", kname, "HidVersion", &value);
- dscp_info.version = (uint8_t) value;
+ btif_config_get_int("Remote", kname, "HidVersion", &value);
+ dscp_info.version = (uint8_t) value;
- btif_config_get_int("Remote", kname, "HidCountryCode", &value);
- dscp_info.ctry_code = (uint8_t) value;
+ btif_config_get_int("Remote", kname, "HidCountryCode", &value);
+ dscp_info.ctry_code = (uint8_t) value;
- value = 0;
- btif_config_get_int("Remote", kname, "HidSSRMaxLatency", &value);
- dscp_info.ssr_max_latency = (uint16_t) value;
+ value = 0;
+ btif_config_get_int("Remote", kname, "HidSSRMaxLatency", &value);
+ dscp_info.ssr_max_latency = (uint16_t) value;
- value = 0;
- btif_config_get_int("Remote", kname, "HidSSRMinTimeout", &value);
- dscp_info.ssr_min_tout = (uint16_t) value;
+ value = 0;
+ btif_config_get_int("Remote", kname, "HidSSRMinTimeout", &value);
+ dscp_info.ssr_min_tout = (uint16_t) value;
- int len = 0;
- int type;
- btif_config_get("Remote", kname, "HidDescriptor", NULL, &len, &type);
- if(len > 0)
- {
- dscp_info.descriptor.dl_len = (uint16_t)len;
- dscp_info.descriptor.dsc_list = (uint8_t*)alloca(len);
- btif_config_get("Remote", kname, "HidDescriptor", (char*)dscp_info.descriptor.dsc_list, &len, &type);
+ int len = 0;
+ int type;
+ btif_config_get("Remote", kname, "HidDescriptor", NULL, &len, &type);
+ if(len > 0)
+ {
+ dscp_info.descriptor.dl_len = (uint16_t)len;
+ dscp_info.descriptor.dsc_list = (uint8_t*)alloca(len);
+ btif_config_get("Remote", kname, "HidDescriptor", (char*)dscp_info.descriptor.dsc_list, &len, &type);
+ }
+ str2bd(kname, &bd_addr);
+ // add extracted information to BTA HH
+ if (btif_hh_add_added_dev(bd_addr,attr_mask))
+ {
+ BTA_HhAddDev(bd_addr.address, attr_mask, sub_class,
+ app_id, dscp_info);
+ }
}
- str2bd(kname, &bd_addr);
- // add extracted information to BTA HH
- if (btif_hh_add_added_dev(bd_addr,attr_mask))
+ }
+ else
+ {
+ if(btif_config_get_int("Remote", kname, "HidAttrMask", &value))
{
- BTA_HhAddDev(bd_addr.address, attr_mask, sub_class,
- app_id, dscp_info);
+ btif_storage_remove_hid_info(&bd_addr);
+ str2bd(kname, &bd_addr);
}
}
} while(kpos != -1);
*******************************************************************************/
bt_status_t btif_storage_remove_hid_info(bt_bdaddr_t *remote_bd_addr)
{
- char *fname;
- int ret;
bdstr_t bdstr;
bd2str(remote_bd_addr, &bdstr);
{
if ((read_size != value_size) || (read_type != BTIF_CFG_TYPE_BIN) )
{
- BTIF_TRACE_ERROR4("%s value_size=%d read_size=%d read_type=%d",
+ BTIF_TRACE_ERROR("%s value_size=%d read_size=%d read_type=%d",
__FUNCTION__, value_size, read_size, read_type);
bt_status = BT_STATUS_FAIL;
}
}
- BTIF_TRACE_DEBUG3("%s status=%d value_size=%d", __FUNCTION__, bt_status, value_size);
+ BTIF_TRACE_DEBUG("%s status=%d value_size=%d", __FUNCTION__, bt_status, value_size);
return bt_status;
}
BOOLEAN btif_storage_is_device_autopair_blacklisted(bt_bdaddr_t *remote_bd_addr)
{
char *token;
- int ret;
bdstr_t bdstr;
char *dev_name_str;
- uint8_t i = 0;
char value[BTIF_STORAGE_MAX_LINE_SZ];
int value_size = sizeof(value);
*******************************************************************************/
BOOLEAN btif_storage_is_fixed_pin_zeros_keyboard(bt_bdaddr_t *remote_bd_addr)
{
- int ret;
bdstr_t bdstr;
- char *dev_name_str;
- uint8_t i = 0;
char linebuf[BTIF_STORAGE_MAX_LINE_SZ];
bd2str(remote_bd_addr, &bdstr);
}
else
{
- BTIF_TRACE_ERROR1("%s NULL BD Address", __FUNCTION__);
+ BTIF_TRACE_ERROR("%s NULL BD Address", __FUNCTION__);
return BT_STATUS_FAIL;
}
}
else
{
- BTIF_TRACE_ERROR1("%s NULL BD Address", __FUNCTION__);
+ BTIF_TRACE_ERROR("%s NULL BD Address", __FUNCTION__);
return FALSE;
}