Loading system/btif/include/btif_gatt_util.h +4 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ #ifndef BTIF_GATT_UTIL_H #define BTIF_GATT_UTIL_H #include "bta_api.h" void btif_to_bta_uuid(tBT_UUID *p_dest, bt_uuid_t *p_src); void btif_to_bta_gatt_id(tBTA_GATT_ID *p_dest, btgatt_gatt_id_t *p_src); void btif_to_bta_srvc_id(tBTA_GATT_SRVC_ID *p_dest, btgatt_srvc_id_t *p_src); Loading @@ -34,5 +36,7 @@ uint16_t get_uuid16(tBT_UUID *p_uuid); void btif_gatt_check_encrypted_link(BD_ADDR bd_addr); BOOLEAN btif_get_device_type(BD_ADDR bd_addr, int *addr_type, int *device_type); #endif system/btif/src/btif_gatt_client.c +12 −0 Original line number Diff line number Diff line Loading @@ -597,11 +597,23 @@ static void btgattc_handle_event(uint16_t event, char* p_param) break; case BTIF_GATTC_OPEN: { // Ensure device is in inquiry database int addr_type = 0; int device_type = 0; if (btif_get_device_type(p_cb->bd_addr.address, &addr_type, &device_type) == TRUE && device_type != BT_DEVICE_TYPE_BREDR) BTA_DmAddBleDevice(p_cb->bd_addr.address, addr_type, device_type); // Mark background connections if (!p_cb->is_direct) BTA_DmBleSetBgConnType(BTM_BLE_CONN_AUTO, NULL); // Connect! BTA_GATTC_Open(p_cb->client_if, p_cb->bd_addr.address, p_cb->is_direct); break; } case BTIF_GATTC_CLOSE: // Disconnect established connections Loading system/btif/src/btif_gatt_server.c +13 −0 Original line number Diff line number Diff line Loading @@ -365,11 +365,24 @@ static void btgatts_handle_event(uint16_t event, char* p_param) break; case BTIF_GATTS_OPEN: { // Ensure device is in inquiry database int addr_type = 0; int device_type = 0; if (btif_get_device_type(p_cb->bd_addr.address, &addr_type, &device_type) == TRUE && device_type != BT_DEVICE_TYPE_BREDR) BTA_DmAddBleDevice(p_cb->bd_addr.address, addr_type, device_type); // Mark background connections if (!p_cb->is_direct) BTA_DmBleSetBgConnType(BTM_BLE_CONN_AUTO, NULL); // Connect! BTA_GATTS_Open(p_cb->server_if, p_cb->bd_addr.address, p_cb->is_direct); break; } case BTIF_GATTS_CLOSE: // Cancel pending foreground/background connections Loading system/btif/src/btif_gatt_util.c +26 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #include "btif_util.h" #include "btif_gatt.h" #include "btif_gatt_util.h" #include "btif_config.h" #if BTA_GATT_INCLUDED == TRUE Loading Loading @@ -295,4 +296,29 @@ void btif_gatt_check_encrypted_link (BD_ADDR bd_addr) } } /******************************************************************************* * Device information *******************************************************************************/ BOOLEAN btif_get_device_type(BD_ADDR bd_addr, int *addr_type, int *device_type) { if (device_type == NULL || addr_type == NULL) return FALSE; bt_bdaddr_t bda; bdcpy(bda.address, bd_addr); char bd_addr_str[18] = {0}; bd2str(&bda, &bd_addr_str); if (!btif_config_get_int("Remote", bd_addr_str, "DevType", device_type)) return FALSE; if (!btif_config_get_int("Remote", bd_addr_str, "AddrType", addr_type)) return FALSE; ALOGD("%s: Device [%s] type %d, addr. type %d", __FUNCTION__, bd_addr_str, *device_type, *addr_type); return TRUE; } #endif system/stack/btm/btm_ble.c +3 −1 Original line number Diff line number Diff line Loading @@ -596,8 +596,10 @@ void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type, tBLE_ADDR { *p_dev_type = p_inq_info->results.device_type ; *p_addr_type = p_inq_info->results.ble_addr_type; } } else { /* unknown device, assume BR/EDR */ BTM_TRACE_DEBUG0 ("btm_find_dev_type - unknown device, BR/EDR assumed"); } } else /* there is a security device record exisitng */ { Loading Loading
system/btif/include/btif_gatt_util.h +4 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ #ifndef BTIF_GATT_UTIL_H #define BTIF_GATT_UTIL_H #include "bta_api.h" void btif_to_bta_uuid(tBT_UUID *p_dest, bt_uuid_t *p_src); void btif_to_bta_gatt_id(tBTA_GATT_ID *p_dest, btgatt_gatt_id_t *p_src); void btif_to_bta_srvc_id(tBTA_GATT_SRVC_ID *p_dest, btgatt_srvc_id_t *p_src); Loading @@ -34,5 +36,7 @@ uint16_t get_uuid16(tBT_UUID *p_uuid); void btif_gatt_check_encrypted_link(BD_ADDR bd_addr); BOOLEAN btif_get_device_type(BD_ADDR bd_addr, int *addr_type, int *device_type); #endif
system/btif/src/btif_gatt_client.c +12 −0 Original line number Diff line number Diff line Loading @@ -597,11 +597,23 @@ static void btgattc_handle_event(uint16_t event, char* p_param) break; case BTIF_GATTC_OPEN: { // Ensure device is in inquiry database int addr_type = 0; int device_type = 0; if (btif_get_device_type(p_cb->bd_addr.address, &addr_type, &device_type) == TRUE && device_type != BT_DEVICE_TYPE_BREDR) BTA_DmAddBleDevice(p_cb->bd_addr.address, addr_type, device_type); // Mark background connections if (!p_cb->is_direct) BTA_DmBleSetBgConnType(BTM_BLE_CONN_AUTO, NULL); // Connect! BTA_GATTC_Open(p_cb->client_if, p_cb->bd_addr.address, p_cb->is_direct); break; } case BTIF_GATTC_CLOSE: // Disconnect established connections Loading
system/btif/src/btif_gatt_server.c +13 −0 Original line number Diff line number Diff line Loading @@ -365,11 +365,24 @@ static void btgatts_handle_event(uint16_t event, char* p_param) break; case BTIF_GATTS_OPEN: { // Ensure device is in inquiry database int addr_type = 0; int device_type = 0; if (btif_get_device_type(p_cb->bd_addr.address, &addr_type, &device_type) == TRUE && device_type != BT_DEVICE_TYPE_BREDR) BTA_DmAddBleDevice(p_cb->bd_addr.address, addr_type, device_type); // Mark background connections if (!p_cb->is_direct) BTA_DmBleSetBgConnType(BTM_BLE_CONN_AUTO, NULL); // Connect! BTA_GATTS_Open(p_cb->server_if, p_cb->bd_addr.address, p_cb->is_direct); break; } case BTIF_GATTS_CLOSE: // Cancel pending foreground/background connections Loading
system/btif/src/btif_gatt_util.c +26 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #include "btif_util.h" #include "btif_gatt.h" #include "btif_gatt_util.h" #include "btif_config.h" #if BTA_GATT_INCLUDED == TRUE Loading Loading @@ -295,4 +296,29 @@ void btif_gatt_check_encrypted_link (BD_ADDR bd_addr) } } /******************************************************************************* * Device information *******************************************************************************/ BOOLEAN btif_get_device_type(BD_ADDR bd_addr, int *addr_type, int *device_type) { if (device_type == NULL || addr_type == NULL) return FALSE; bt_bdaddr_t bda; bdcpy(bda.address, bd_addr); char bd_addr_str[18] = {0}; bd2str(&bda, &bd_addr_str); if (!btif_config_get_int("Remote", bd_addr_str, "DevType", device_type)) return FALSE; if (!btif_config_get_int("Remote", bd_addr_str, "AddrType", addr_type)) return FALSE; ALOGD("%s: Device [%s] type %d, addr. type %d", __FUNCTION__, bd_addr_str, *device_type, *addr_type); return TRUE; } #endif
system/stack/btm/btm_ble.c +3 −1 Original line number Diff line number Diff line Loading @@ -596,8 +596,10 @@ void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type, tBLE_ADDR { *p_dev_type = p_inq_info->results.device_type ; *p_addr_type = p_inq_info->results.ble_addr_type; } } else { /* unknown device, assume BR/EDR */ BTM_TRACE_DEBUG0 ("btm_find_dev_type - unknown device, BR/EDR assumed"); } } else /* there is a security device record exisitng */ { Loading