summaryrefslogtreecommitdiffstats
path: root/stack
diff options
context:
space:
mode:
Diffstat (limited to 'stack')
-rw-r--r--stack/Android.mk5
-rw-r--r--stack/a2dp/a2d_sbc.c58
-rw-r--r--stack/btm/btm_acl.c4
-rw-r--r--stack/btm/btm_ble.c3
-rw-r--r--stack/btm/btm_ble_bgconn.c2
-rw-r--r--stack/btm/btm_ble_gap.c216
-rw-r--r--stack/btm/btm_sec.c7
-rw-r--r--stack/btu/btu_hcif.c28
-rw-r--r--stack/gap/gap_ble.c1
-rw-r--r--stack/gatt/att_protocol.c39
-rw-r--r--stack/gatt/gatt_api.c41
-rw-r--r--stack/gatt/gatt_attr.c1
-rw-r--r--stack/gatt/gatt_cl.c14
-rw-r--r--stack/gatt/gatt_db.c2
-rw-r--r--stack/gatt/gatt_int.h3
-rw-r--r--stack/gatt/gatt_main.c86
-rw-r--r--stack/include/btm_ble_api.h53
-rw-r--r--stack/include/gatt_api.h5
-rw-r--r--stack/include/l2c_api.h9
-rw-r--r--stack/l2cap/l2c_api.c19
-rw-r--r--stack/l2cap/l2c_ble.c6
-rw-r--r--stack/l2cap/l2c_csm.c2
-rw-r--r--stack/l2cap/l2c_utils.c42
-rw-r--r--stack/pan/pan_api.c2
-rw-r--r--stack/sdp/sdp_api.c11
-rw-r--r--stack/smp/smp_l2c.c1
-rw-r--r--stack/srvc/srvc_dis.c3
-rw-r--r--stack/srvc/srvc_eng.c1
28 files changed, 543 insertions, 121 deletions
diff --git a/stack/Android.mk b/stack/Android.mk
index 6c1652468..fd76ed8b9 100644
--- a/stack/Android.mk
+++ b/stack/Android.mk
@@ -1,5 +1,3 @@
-ifneq ($(TARGET_SIMULATOR),true)
-
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
@@ -154,7 +152,6 @@ LOCAL_MODULE := libbt-brcm_stack
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_SHARED_LIBRARIES := libcutils libc
+LOCAL_MULTILIB := 32
include $(BUILD_STATIC_LIBRARY)
-
-endif # TARGET_SIMULATOR != true
diff --git a/stack/a2dp/a2d_sbc.c b/stack/a2dp/a2d_sbc.c
index a4e5255ef..3858b4a21 100644
--- a/stack/a2dp/a2d_sbc.c
+++ b/stack/a2dp/a2d_sbc.c
@@ -24,12 +24,13 @@
******************************************************************************/
#include "bt_target.h"
-
-#if (A2D_SBC_INCLUDED == TRUE)
#include <string.h>
#include "a2d_api.h"
#include "a2d_int.h"
#include "a2d_sbc.h"
+#include "bt_utils.h"
+
+#if (A2D_SBC_INCLUDED == TRUE)
/*************************************************************************************************
* SBC descramble code
@@ -398,4 +399,57 @@ void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag, BOOLEAN *p_start, BOOLEAN
}
}
+#else /* A2D_SBC_INCLUDED == TRUE */
+
+void A2D_SbcChkFrInit(UINT8 *p_pkt)
+{
+ UNUSED(p_pkt);
+}
+
+void A2D_SbcDescramble(UINT8 *p_pkt, UINT16 len)
+{
+ UNUSED(p_pkt);
+ UNUSED(len);
+}
+
+tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie,
+ UINT8 *p_result)
+{
+ UNUSED(media_type);
+ UNUSED(p_ie);
+ UNUSED(p_result);
+ return A2D_FAIL;
+}
+
+tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info,
+ BOOLEAN for_caps)
+{
+ UNUSED(p_ie);
+ UNUSED(p_info);
+ UNUSED(for_caps);
+ return A2D_FAIL;
+}
+
+void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start,
+ BOOLEAN last, UINT8 num)
+{
+ UNUSED(p_dst);
+ UNUSED(frag);
+ UNUSED(start);
+ UNUSED(last);
+ UNUSED(num);
+}
+
+void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag,
+ BOOLEAN *p_start, BOOLEAN *p_last,
+ UINT8 *p_num)
+{
+ UNUSED(p_src);
+ UNUSED(p_frag);
+ UNUSED(p_start);
+ UNUSED(p_last);
+ UNUSED(p_num);
+}
+
+
#endif /* A2D_SBC_INCLUDED == TRUE */
diff --git a/stack/btm/btm_acl.c b/stack/btm/btm_acl.c
index 07f6e4339..07ad501cc 100644
--- a/stack/btm/btm_acl.c
+++ b/stack/btm/btm_acl.c
@@ -38,6 +38,7 @@
#include "l2c_int.h"
#include "hcidefs.h"
#include "bd.h"
+#include "bt_utils.h"
static void btm_establish_continue (tACL_CONN *p_acl_cb);
static void btm_read_remote_features (UINT16 handle);
@@ -235,6 +236,9 @@ BOOLEAN btm_ble_get_acl_remote_addr(tBTM_SEC_DEV_REC *p_dev_rec, BD_ADDR conn_ad
return st;
#else
+ UNUSED(p_dev_rec);
+ UNUSED(conn_addr);
+ UNUSED(p_addr_type);
return FALSE;
#endif
}
diff --git a/stack/btm/btm_ble.c b/stack/btm/btm_ble.c
index 518531b4a..86d126026 100644
--- a/stack/btm/btm_ble.c
+++ b/stack/btm/btm_ble.c
@@ -564,7 +564,7 @@ void BTM_BleSetPrefConnParams (BD_ADDR bd_addr,
if (supervision_tout != BTM_BLE_CONN_PARAM_UNDEF)
p_dev_rec->conn_params.supervision_tout = supervision_tout;
else
- p_dev_rec->conn_params.slave_latency = BTM_BLE_CONN_TIMEOUT_DEF;
+ p_dev_rec->conn_params.supervision_tout = BTM_BLE_CONN_TIMEOUT_DEF;
}
@@ -851,6 +851,7 @@ BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div)
bd_addr[2],bd_addr[3],
bd_addr[4],bd_addr[5]);
+ *p_div = 0;
p_dev_rec = btm_find_dev (bd_addr);
if (p_dev_rec && p_dev_rec->ble.keys.div)
diff --git a/stack/btm/btm_ble_bgconn.c b/stack/btm/btm_ble_bgconn.c
index b61fcb939..4f1c14572 100644
--- a/stack/btm/btm_ble_bgconn.c
+++ b/stack/btm/btm_ble_bgconn.c
@@ -86,10 +86,12 @@ BOOLEAN btm_add_dev_to_controller (BOOLEAN to_add, BD_ADDR bd_addr, UINT8 attr)
{
if (p_dev_rec->ble.ble_addr_type == BLE_ADDR_PUBLIC || !BTM_BLE_IS_RESOLVE_BDA(bd_addr))
{
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
/* add device into IRK list */
btm_ble_vendor_irk_list_load_dev(p_dev_rec);
#endif
+#endif
started = btsnd_hcic_ble_add_white_list (p_dev_rec->ble.ble_addr_type, bd_addr);
}
if (memcmp(p_dev_rec->ble.static_addr, bd_addr, BD_ADDR_LEN) != 0 &&
diff --git a/stack/btm/btm_ble_gap.c b/stack/btm/btm_ble_gap.c
index 496f57eef..0e9133fef 100644
--- a/stack/btm/btm_ble_gap.c
+++ b/stack/btm/btm_ble_gap.c
@@ -330,11 +330,12 @@ tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT8 duration,
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type,
BTM_BLE_DEFAULT_SFP); /* assume observe always not using white list */
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
/* enable IRK list */
btm_ble_vendor_irk_list_known_dev (TRUE);
#endif
-
+#endif
status = btm_ble_start_scan(BTM_BLE_DUPLICATE_DISABLE);
}
if (status == BTM_CMD_STARTED)
@@ -2044,6 +2045,133 @@ UINT8 btm_ble_is_discoverable(BD_ADDR bda, UINT8 evt_type, UINT8 *p)
return rt;
}
+static void btm_ble_appearance_to_cod(UINT16 appearance, UINT8 *dev_class)
+{
+ dev_class[0] = 0;
+
+ switch (appearance)
+ {
+ case BTM_BLE_APPEARANCE_GENERIC_PHONE:
+ dev_class[1] = BTM_COD_MAJOR_PHONE;
+ dev_class[2] = BTM_COD_MINOR_UNCLASSIFIED;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_COMPUTER:
+ dev_class[1] = BTM_COD_MAJOR_COMPUTER;
+ dev_class[2] = BTM_COD_MINOR_UNCLASSIFIED;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_REMOTE:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_REMOTE_CONTROL;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_THERMOMETER:
+ case BTM_BLE_APPEARANCE_THERMOMETER_EAR:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_THERMOMETER;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_HEART_RATE:
+ case BTM_BLE_APPEARANCE_HEART_RATE_BELT:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_HEART_PULSE_MONITOR;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE:
+ case BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM:
+ case BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_BLOOD_MONITOR;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER:
+ case BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP:
+ case BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_PULSE_OXIMETER;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_GLUCOSE:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_GLUCOSE_METER;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_WEIGHT:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_WEIGHING_SCALE;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_WALKING:
+ case BTM_BLE_APPEARANCE_WALKING_IN_SHOE:
+ case BTM_BLE_APPEARANCE_WALKING_ON_SHOE:
+ case BTM_BLE_APPEARANCE_WALKING_ON_HIP:
+ dev_class[1] = BTM_COD_MAJOR_HEALTH;
+ dev_class[2] = BTM_COD_MINOR_STEP_COUNTER;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_WATCH:
+ case BTM_BLE_APPEARANCE_SPORTS_WATCH:
+ dev_class[1] = BTM_COD_MAJOR_WEARABLE;
+ dev_class[2] = BTM_COD_MINOR_WRIST_WATCH;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES:
+ dev_class[1] = BTM_COD_MAJOR_WEARABLE;
+ dev_class[2] = BTM_COD_MINOR_GLASSES;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_DISPLAY:
+ dev_class[1] = BTM_COD_MAJOR_IMAGING;
+ dev_class[2] = BTM_COD_MINOR_DISPLAY;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER:
+ dev_class[1] = BTM_COD_MAJOR_AUDIO;
+ dev_class[2] = BTM_COD_MINOR_UNCLASSIFIED;
+ break;
+ case BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER:
+ case BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER:
+ case BTM_BLE_APPEARANCE_GENERIC_HID:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_UNCLASSIFIED;
+ break;
+ case BTM_BLE_APPEARANCE_HID_KEYBOARD:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_KEYBOARD;
+ break;
+ case BTM_BLE_APPEARANCE_HID_MOUSE:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_POINTING;
+ break;
+ case BTM_BLE_APPEARANCE_HID_JOYSTICK:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_JOYSTICK;
+ break;
+ case BTM_BLE_APPEARANCE_HID_GAMEPAD:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_GAMEPAD;
+ break;
+ case BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_DIGITIZING_TABLET;
+ break;
+ case BTM_BLE_APPEARANCE_HID_CARD_READER:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_CARD_READER;
+ break;
+ case BTM_BLE_APPEARANCE_HID_DIGITAL_PEN:
+ dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ dev_class[2] = BTM_COD_MINOR_DIGITAL_PAN;
+ break;
+ case BTM_BLE_APPEARANCE_UKNOWN:
+ case BTM_BLE_APPEARANCE_GENERIC_CLOCK:
+ case BTM_BLE_APPEARANCE_GENERIC_TAG:
+ case BTM_BLE_APPEARANCE_GENERIC_KEYRING:
+ case BTM_BLE_APPEARANCE_GENERIC_CYCLING:
+ case BTM_BLE_APPEARANCE_CYCLING_COMPUTER:
+ case BTM_BLE_APPEARANCE_CYCLING_SPEED:
+ case BTM_BLE_APPEARANCE_CYCLING_CADENCE:
+ case BTM_BLE_APPEARANCE_CYCLING_POWER:
+ case BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE:
+ case BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS:
+ case BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION:
+ case BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV:
+ case BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD:
+ case BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV:
+ default:
+ dev_class[1] = BTM_COD_MAJOR_UNCLASSIFIED;
+ dev_class[2] = BTM_COD_MINOR_UNCLASSIFIED;
+ };
+}
+
/*******************************************************************************
**
** Function btm_ble_update_inq_result
@@ -2114,19 +2242,31 @@ BOOLEAN btm_ble_update_inq_result(tINQ_DB_ENT *p_i, UINT8 addr_type, UINT8 evt_t
if (p_le_inq_cb->adv_len != 0)
{
- if ((p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache,
- BTM_BLE_AD_TYPE_16SRV_CMPL, &len)) != NULL)
+ /* Check to see the BLE device has the Appearance UUID in the advertising data. If it does
+ * then try to convert the appearance value to a class of device value Bluedroid can use.
+ * Otherwise fall back to trying to infer if it is a HID device based on the service class.
+ */
+ p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, BTM_BLE_AD_TYPE_APPEARANCE, &len);
+ if (p_uuid16 && len == 2)
{
- UINT8 i;
- for (i = 0; i + 2 <= len; i = i + 2)
+ btm_ble_appearance_to_cod((UINT16)p_uuid16[0] | (p_uuid16[1] << 8), p_cur->dev_class);
+ }
+ else
+ {
+ if ((p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache,
+ BTM_BLE_AD_TYPE_16SRV_CMPL, &len)) != NULL)
{
- /* if this BLE device support HID over LE, set HID Major in class of device */
- if ((p_uuid16[i] | (p_uuid16[i+1] << 8)) == UUID_SERVCLASS_LE_HID)
+ UINT8 i;
+ for (i = 0; i + 2 <= len; i = i + 2)
{
- p_cur->dev_class[0] = 0;
- p_cur->dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
- p_cur->dev_class[2] = 0;
- break;
+ /* if this BLE device support HID over LE, set HID Major in class of device */
+ if ((p_uuid16[i] | (p_uuid16[i+1] << 8)) == UUID_SERVCLASS_LE_HID)
+ {
+ p_cur->dev_class[0] = 0;
+ p_cur->dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+ p_cur->dev_class[2] = 0;
+ break;
+ }
}
}
}
@@ -2214,24 +2354,28 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
BD_ADDR bda;
UINT8 evt_type = 0, *p = p_data;
UINT8 addr_type = 0;
+ UINT8 num_reports;
+ UINT8 data_len;
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
BOOLEAN match = FALSE;
#endif
- /* always get one device at a time */
- p ++;
+ /* Extract the number of reports in this event. */
+ STREAM_TO_UINT8(num_reports, p);
- /* Extract inquiry results */
- STREAM_TO_UINT8 (evt_type, p);
- STREAM_TO_UINT8 (addr_type, p);
- STREAM_TO_BDADDR (bda, p);
+ while (num_reports--)
+ {
+ /* Extract inquiry results */
+ STREAM_TO_UINT8 (evt_type, p);
+ STREAM_TO_UINT8 (addr_type, p);
+ STREAM_TO_BDADDR (bda, p);
#ifdef BTM_BLE_PC_ADV_TEST_MODE /* For general stack code (e.g. BTInsight testing), we simply do not define it to exclude or set it to TRUE to include */
- if (BTM_BLE_PC_ADV_TEST_MODE) /* For stack component, it is always defined and maps to a global variable g_bDraculaAdvertisingMode */
- {
- if (btm_cb.ble_ctr_cb.p_scan_req_cback)
- (*btm_cb.ble_ctr_cb.p_scan_req_cback)(bda, addr_type, evt_type);
- }
+ if (BTM_BLE_PC_ADV_TEST_MODE) /* For stack component, it is always defined and maps to a global variable g_bDraculaAdvertisingMode */
+ {
+ if (btm_cb.ble_ctr_cb.p_scan_req_cback)
+ (*btm_cb.ble_ctr_cb.p_scan_req_cback)(bda, addr_type, evt_type);
+ }
#endif
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
@@ -2243,24 +2387,30 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
#endif
#endif
- /* Only process the results if the inquiry is still active */
- if (!BTM_BLE_IS_SCAN_ACTIVE(btm_cb.ble_ctr_cb.scan_activity))
- return;
+ /* Only process the results if the inquiry is still active */
+ if (!BTM_BLE_IS_SCAN_ACTIVE(btm_cb.ble_ctr_cb.scan_activity))
+ return;
BTM_TRACE_DEBUG("btm_ble_process_adv_pkt:bda= %0x:%0x:%0x:%0x:%0x:%0x",
bda[0],bda[1],bda[2],bda[3],bda[4],bda[5]);
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
#if SMP_INCLUDED == TRUE
- /* always do RRA resolution on host */
- if (!match && BTM_BLE_IS_RESOLVE_BDA(bda))
- {
- btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_adv, p_data);
- }
- else
+ /* always do RRA resolution on host */
+ if (!match && BTM_BLE_IS_RESOLVE_BDA(bda))
+ {
+ btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_adv, p_data);
+ }
+ else
#endif
#endif
- {
- btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p);
+ {
+ btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p);
+ }
+
+ STREAM_TO_UINT8(data_len, p);
+
+ /* Advance to the next event data_len + rssi byte */
+ p += data_len + 1;
}
}
diff --git a/stack/btm/btm_sec.c b/stack/btm/btm_sec.c
index a5e2ac382..8623f35e3 100644
--- a/stack/btm/btm_sec.c
+++ b/stack/btm/btm_sec.c
@@ -5044,6 +5044,10 @@ void btm_sec_pin_code_request (UINT8 *p_bda)
tBTM_SEC_DEV_REC *p_dev_rec;
tBTM_CB *p_cb = &btm_cb;
+#ifdef PORCHE_PAIRING_CONFLICT
+ UINT8 default_pin_code_len = 4;
+ PIN_CODE default_pin_code = {0x30, 0x30, 0x30, 0x30};
+#endif
BTM_TRACE_EVENT ("btm_sec_pin_code_request() State: %s, BDA:%04x%08x",
btm_pair_state_descr(btm_cb.pairing_state),
(p_bda[0]<<8)+p_bda[1], (p_bda[2]<<24)+(p_bda[3]<<16)+(p_bda[4]<<8)+p_bda[5] );
@@ -5077,7 +5081,8 @@ void btm_sec_pin_code_request (UINT8 *p_bda)
BTM_TRACE_EVENT ("btm_sec_pin_code_request from remote dev. for local initiated pairing");
if(! btm_cb.pin_code_len_saved)
{
- btsnd_hcic_pin_code_neg_reply (p_bda);
+ btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE);
+ btsnd_hcic_pin_code_req_reply (p_bda, default_pin_code_len, default_pin_code);
}
else
{
diff --git a/stack/btu/btu_hcif.c b/stack/btu/btu_hcif.c
index 1be90db80..23204a789 100644
--- a/stack/btu/btu_hcif.c
+++ b/stack/btu/btu_hcif.c
@@ -37,6 +37,8 @@
#include "btm_api.h"
#include "btm_int.h"
+extern void btm_process_cancel_complete(UINT8 status, UINT8 mode);
+extern void btm_ble_test_command_complete(UINT8 *p);
// btla-specific ++
#define LOG_TAG "BTLD"
@@ -400,8 +402,7 @@ void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_msg)
case HCI_BLE_EVENT:
STREAM_TO_UINT8 (ble_sub_code, p);
- BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, "BLE HCI(id=%d) event = 0x%02x)",
- hci_evt_code, ble_sub_code);
+ HCI_TRACE_EVENT("BLE HCI(id=%d) event = 0x%02x)", hci_evt_code, ble_sub_code);
switch (ble_sub_code)
{
@@ -503,7 +504,7 @@ void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_buf)
else
{
/* Unknown controller */
- BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "BTU HCI(ctrl id=%d) controller ID not recognized", controller_id);
+ HCI_TRACE_WARNING("BTU HCI(ctrl id=%d) controller ID not recognized", controller_id);
GKI_freebuf(p_buf);;
}
@@ -1513,8 +1514,7 @@ static void btu_hcif_command_status_evt (UINT8 controller_id, UINT8 *p)
}
else
{
- BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_WARNING,
- "No command in queue matching opcode %d", opcode);
+ HCI_TRACE_WARNING("No command in queue matching opcode %d", opcode);
}
/* See if we can forward any more commands */
@@ -1542,7 +1542,7 @@ void btu_hcif_cmd_timeout (UINT8 controller_id)
#if (defined(BTU_CMD_CMPL_TOUT_DOUBLE_CHECK) && BTU_CMD_CMPL_TOUT_DOUBLE_CHECK == TRUE)
if (!(p_hci_cmd_cb->checked_hcisu))
{
- BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "BTU HCI(id=%d) command timeout - double check HCISU", controller_id);
+ HCI_TRACE_WARNING("BTU HCI(id=%d) command timeout - double check HCISU", controller_id);
/* trigger HCISU to read any pending data in transport buffer */
GKI_send_event(HCISU_TASK, HCISU_EVT_MASK);
@@ -1564,7 +1564,7 @@ void btu_hcif_cmd_timeout (UINT8 controller_id)
/* get queued command */
if ((p_cmd = (BT_HDR *) GKI_dequeue (&(p_hci_cmd_cb->cmd_cmpl_q))) == NULL)
{
- BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "Cmd timeout; no cmd in queue");
+ HCI_TRACE_WARNING("Cmd timeout; no cmd in queue");
return;
}
@@ -1587,7 +1587,7 @@ void btu_hcif_cmd_timeout (UINT8 controller_id)
if (controller_id == NFC_CONTROLLER_ID)
{
//TODO call nfc_ncif_cmd_timeout
- BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "BTU NCI command timeout - header 0x%02x%02x", p[0], p[1]);
+ HCI_TRACE_WARNING("BTU NCI command timeout - header 0x%02x%02x", p[0], p[1]);
return;
}
#endif
@@ -1603,7 +1603,7 @@ void btu_hcif_cmd_timeout (UINT8 controller_id)
ALOGE("#");
ALOGE("######################################################################");
#else
- BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "BTU HCI(id=%d) command timeout. opcode=0x%x", controller_id, opcode);
+ HCI_TRACE_WARNING("BTU HCI(id=%d) command timeout. opcode=0x%x", controller_id, opcode);
#endif
// btla-specific ++
@@ -1659,8 +1659,7 @@ void btu_hcif_cmd_timeout (UINT8 controller_id)
times, Bluetooth process will be killed and restarted */
if (num_hci_cmds_timed_out >= BTM_MAX_HCI_CMD_TOUT_BEFORE_RESTART)
{
- BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_ERROR,
- "Num consecutive HCI Cmd tout =%d Restarting BT process",num_hci_cmds_timed_out);
+ HCI_TRACE_ERROR("Num consecutive HCI Cmd tout =%d Restarting BT process",num_hci_cmds_timed_out);
usleep(10000); /* 10 milliseconds */
/* Killing the process to force a restart as part of fault tolerance */
@@ -1668,8 +1667,7 @@ void btu_hcif_cmd_timeout (UINT8 controller_id)
}
else
{
- BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "HCI Cmd timeout counter %d",
- num_hci_cmds_timed_out);
+ HCI_TRACE_WARNING("HCI Cmd timeout counter %d", num_hci_cmds_timed_out);
/* If anyone wants device status notifications, give him one */
btm_report_device_status (BTM_DEV_STATUS_CMD_TOUT);
@@ -1689,7 +1687,7 @@ void btu_hcif_cmd_timeout (UINT8 controller_id)
*******************************************************************************/
static void btu_hcif_hardware_error_evt (UINT8 *p)
{
- BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, "Ctlr H/w error event - code:0x%x", *p);
+ HCI_TRACE_ERROR("Ctlr H/w error event - code:0x%x", *p);
/* If anyone wants device status notifications, give him one. */
btm_report_device_status (BTM_DEV_STATUS_DOWN);
@@ -2258,7 +2256,7 @@ static void btu_hcif_encryption_key_refresh_cmpl_evt (UINT8 *p)
static void btu_ble_process_adv_pkt (UINT8 *p)
{
- BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, "btu_ble_process_adv_pkt");
+ HCI_TRACE_EVENT("btu_ble_process_adv_pkt");
btm_ble_process_adv_pkt(p);
}
diff --git a/stack/gap/gap_ble.c b/stack/gap/gap_ble.c
index 0d10f88ca..878295893 100644
--- a/stack/gap/gap_ble.c
+++ b/stack/gap/gap_ble.c
@@ -68,6 +68,7 @@ static tGATT_CBACK gap_cback =
NULL,
NULL,
gap_ble_s_attr_request_cback,
+ NULL,
NULL
};
diff --git a/stack/gatt/att_protocol.c b/stack/gatt/att_protocol.c
index 51ea28490..27c24a08e 100644
--- a/stack/gatt/att_protocol.c
+++ b/stack/gatt/att_protocol.c
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright (C) 2008-2012 Broadcom Corporation
+ * Copyright (C) 2008-2014 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,7 +74,7 @@ BT_HDR *attp_build_exec_write_cmd (UINT8 op_code, UINT8 flag)
BT_HDR *p_buf = NULL;
UINT8 *p;
- if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)(sizeof(BT_HDR) + 10 + L2CAP_MIN_OFFSET))) != NULL)
+ if ((p_buf = (BT_HDR *)GKI_getpoolbuf(GATT_BUF_POOL_ID)) != NULL)
{
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -347,12 +347,12 @@ BT_HDR *attp_build_value_cmd (UINT16 payload_size, UINT8 op_code, UINT16 handle,
/*******************************************************************************
**
-** Function attp_send_msg_to_L2CAP
+** Function attp_send_msg_to_l2cap
**
** Description Send message to L2CAP.
**
*******************************************************************************/
-BOOLEAN attp_send_msg_to_L2CAP(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP)
+tGATT_STATUS attp_send_msg_to_l2cap(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP)
{
UINT16 l2cap_ret;
@@ -366,13 +366,14 @@ BOOLEAN attp_send_msg_to_L2CAP(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP)
{
GATT_TRACE_ERROR1("ATT failed to pass msg:0x%0x to L2CAP",
*((UINT8 *)(p_toL2CAP + 1) + p_toL2CAP->offset));
- GKI_freebuf(p_toL2CAP);
- return FALSE;
+ return GATT_INTERNAL_ERROR;
}
- else
+ else if (l2cap_ret == L2CAP_DW_CONGESTED)
{
- return TRUE;
+ GATT_TRACE_DEBUG0("ATT congested, message accepted");
+ return GATT_CONGESTED;
}
+ return GATT_SUCCESS;
}
/*******************************************************************************
@@ -459,11 +460,7 @@ tGATT_STATUS attp_send_sr_msg (tGATT_TCB *p_tcb, BT_HDR *p_msg)
if (p_msg != NULL)
{
p_msg->offset = L2CAP_MIN_OFFSET;
-
- if (attp_send_msg_to_L2CAP (p_tcb, p_msg))
- cmd_sent = GATT_SUCCESS;
- else
- cmd_sent = GATT_INTERNAL_ERROR;
+ cmd_sent = attp_send_msg_to_l2cap (p_tcb, p_msg);
}
}
return cmd_sent;
@@ -475,22 +472,26 @@ tGATT_STATUS attp_send_sr_msg (tGATT_TCB *p_tcb, BT_HDR *p_msg)
**
** Description Send a ATT command or enqueue it.
**
-** Returns TRUE if command sent, otherwise FALSE.
+** Returns GATT_SUCCESS if command sent
+** GATT_CONGESTED if command sent but channel congested
+** GATT_CMD_STARTED if command queue up in GATT
+** GATT_ERROR if command sending failure
**
*******************************************************************************/
-UINT8 attp_cl_send_cmd(tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 cmd_code, BT_HDR *p_cmd)
+tGATT_STATUS attp_cl_send_cmd(tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 cmd_code, BT_HDR *p_cmd)
{
- UINT8 att_ret = GATT_SUCCESS;
+ tGATT_STATUS att_ret = GATT_SUCCESS;
if (p_tcb != NULL)
{
cmd_code &= ~GATT_AUTH_SIGN_MASK;
+ /* no pending request or value confirmation */
if (p_tcb->pending_cl_req == p_tcb->next_slot_inq ||
cmd_code == GATT_HANDLE_VALUE_CONF)
{
- /* no penindg request or value confirmation */
- if (attp_send_msg_to_L2CAP(p_tcb, p_cmd))
+ att_ret = attp_send_msg_to_l2cap(p_tcb, p_cmd);
+ if (att_ret == GATT_CONGESTED || att_ret == GATT_SUCCESS)
{
/* do not enq cmd if handle value confirmation or set request */
if (cmd_code != GATT_HANDLE_VALUE_CONF && cmd_code != GATT_CMD_WRITE)
@@ -509,7 +510,7 @@ UINT8 attp_cl_send_cmd(tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 cmd_code, BT_HDR
}
}
else
- att_ret = GATT_ILLEGAL_PARAMETER;
+ att_ret = GATT_ERROR;
return att_ret;
}
diff --git a/stack/gatt/gatt_api.c b/stack/gatt/gatt_api.c
index 0321fe841..e3c04751d 100644
--- a/stack/gatt/gatt_api.c
+++ b/stack/gatt/gatt_api.c
@@ -595,7 +595,7 @@ void GATTS_StopService (UINT16 service_handle)
*******************************************************************************/
tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_handle, UINT16 val_len, UINT8 *p_val)
{
- tGATT_STATUS cmd_status = GATT_ILLEGAL_PARAMETER;
+ tGATT_STATUS cmd_status = GATT_NO_RESOURCES;
tGATT_VALUE indication;
BT_HDR *p_msg;
@@ -612,38 +612,39 @@ tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_handle, U
GATT_TRACE_ERROR1 ("GATTS_HandleValueIndication Unknown conn_id: %u ", conn_id);
return(tGATT_STATUS) GATT_INVALID_CONN_ID;
}
+
+ if (! GATT_HANDLE_IS_VALID (attr_handle))
+ return GATT_ILLEGAL_PARAMETER;
+
indication.conn_id = conn_id;
indication.handle = attr_handle;
indication.len = val_len;
memcpy (indication.value, p_val, val_len);
indication.auth_req = GATT_AUTH_REQ_NONE;
- if (GATT_HANDLE_IS_VALID (attr_handle) )
+ if (GATT_HANDLE_IS_VALID(p_tcb->indicate_handle))
{
- if (GATT_HANDLE_IS_VALID(p_tcb->indicate_handle))
+ GATT_TRACE_DEBUG0 ("Add a pending indication");
+ if ((p_buf = gatt_add_pending_ind(p_tcb, &indication)) !=NULL)
{
- GATT_TRACE_DEBUG0 ("Add a pending indication");
- if ((p_buf = gatt_add_pending_ind(p_tcb, &indication)) !=NULL)
- {
- cmd_status = GATT_SUCCESS;
- }
- else
- {
- cmd_status = GATT_NO_RESOURCES;
- }
+ cmd_status = GATT_SUCCESS;
}
else
{
+ cmd_status = GATT_NO_RESOURCES;
+ }
+ }
+ else
+ {
- if ( (p_msg = attp_build_sr_msg (p_tcb, GATT_HANDLE_VALUE_IND, (tGATT_SR_MSG *)&indication)) != NULL)
- {
- cmd_status = attp_send_sr_msg (p_tcb, p_msg);
+ if ( (p_msg = attp_build_sr_msg (p_tcb, GATT_HANDLE_VALUE_IND, (tGATT_SR_MSG *)&indication)) != NULL)
+ {
+ cmd_status = attp_send_sr_msg (p_tcb, p_msg);
- if (cmd_status == GATT_SUCCESS)
- {
- p_tcb->indicate_handle = indication.handle;
- gatt_start_conf_timer(p_tcb);
- }
+ if (cmd_status == GATT_SUCCESS || cmd_status == GATT_CONGESTED)
+ {
+ p_tcb->indicate_handle = indication.handle;
+ gatt_start_conf_timer(p_tcb);
}
}
}
diff --git a/stack/gatt/gatt_attr.c b/stack/gatt/gatt_attr.c
index 60beaa7a7..30fae3cf7 100644
--- a/stack/gatt/gatt_attr.c
+++ b/stack/gatt/gatt_attr.c
@@ -51,6 +51,7 @@ static tGATT_CBACK gatt_profile_cback =
NULL,
NULL,
gatt_profile_request_cback,
+ NULL,
NULL
} ;
diff --git a/stack/gatt/gatt_cl.c b/stack/gatt/gatt_cl.c
index 930cd35ee..9e1f640fd 100644
--- a/stack/gatt/gatt_cl.c
+++ b/stack/gatt/gatt_cl.c
@@ -275,7 +275,7 @@ void gatt_act_write (tGATT_CLCB *p_clcb, UINT8 sec_act)
else
rt = GATT_INTERNAL_ERROR;
- if ((rt != GATT_SUCCESS && rt != GATT_CMD_STARTED)
+ if ((rt != GATT_SUCCESS && rt != GATT_CMD_STARTED && rt != GATT_CONGESTED)
|| (rt != GATT_CMD_STARTED && p_clcb->op_subtype == GATT_WRITE_NO_RSP))
{
if (rt != GATT_SUCCESS)
@@ -1102,15 +1102,17 @@ BOOLEAN gatt_cl_send_next_cmd_inq(tGATT_TCB *p_tcb)
BOOLEAN sent = FALSE;
UINT8 rsp_code;
tGATT_CLCB *p_clcb = NULL;
+ tGATT_STATUS att_ret = GATT_SUCCESS;
while (!sent &&
p_tcb->pending_cl_req != p_tcb->next_slot_inq &&
p_cmd->to_send && p_cmd->p_cmd != NULL)
{
- sent = attp_send_msg_to_L2CAP(p_tcb, p_cmd->p_cmd);
+ att_ret = attp_send_msg_to_l2cap(p_tcb, p_cmd->p_cmd);
- if (sent)
+ if (att_ret == GATT_SUCCESS || att_ret == GATT_CONGESTED)
{
+ sent = TRUE;
p_cmd->to_send = FALSE;
p_cmd->p_cmd = NULL;
@@ -1124,10 +1126,12 @@ BOOLEAN gatt_cl_send_next_cmd_inq(tGATT_TCB *p_tcb)
p_clcb = gatt_cmd_dequeue(p_tcb, &rsp_code);
/* if no ack needed, keep sending */
- sent = FALSE;
+ if (att_ret == GATT_SUCCESS)
+ sent = FALSE;
+
p_cmd = &p_tcb->cl_cmd_q[p_tcb->pending_cl_req];
/* send command complete callback here */
- gatt_end_operation(p_clcb, GATT_SUCCESS, NULL);
+ gatt_end_operation(p_clcb, att_ret, NULL);
}
}
else
diff --git a/stack/gatt/gatt_db.c b/stack/gatt/gatt_db.c
index a1b0a8aa7..098208ffd 100644
--- a/stack/gatt/gatt_db.c
+++ b/stack/gatt/gatt_db.c
@@ -423,7 +423,7 @@ tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb,
BTM_SEC_LINK_KEY_KNOWN)
{
tACL_CONN *p;
- p = btm_bda_to_acl(p_tcb->peer_bda);
+ p = btm_bda_to_acl(p_tcb->peer_bda, BT_TRANSPORT_LE);
if ((p != NULL) && (p->link_role == BTM_ROLE_MASTER))
{
tBTM_BLE_SEC_ACT sec_act = BTM_BLE_SEC_ENCRYPT;
diff --git a/stack/gatt/gatt_int.h b/stack/gatt/gatt_int.h
index b6bb95c7c..663aa7d39 100644
--- a/stack/gatt/gatt_int.h
+++ b/stack/gatt/gatt_int.h
@@ -565,7 +565,7 @@ extern tGATT_PROFILE_CLCB *gatt_profile_clcb_alloc (UINT16 conn_id, BD_ADDR bda,
extern tGATT_STATUS attp_send_cl_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code, tGATT_CL_MSG *p_msg);
extern BT_HDR *attp_build_sr_msg(tGATT_TCB *p_tcb, UINT8 op_code, tGATT_SR_MSG *p_msg);
extern tGATT_STATUS attp_send_sr_msg (tGATT_TCB *p_tcb, BT_HDR *p_msg);
-extern BOOLEAN attp_send_msg_to_L2CAP(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP);
+extern tGATT_STATUS attp_send_msg_to_l2cap(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP);
/* utility functions */
extern UINT8 * gatt_dbg_op_name(UINT8 op_code);
@@ -596,6 +596,7 @@ extern tGATT_VALUE *gatt_add_pending_ind(tGATT_TCB *p_tcb, tGATT_VALUE *p_ind);
extern tGATTS_PENDING_NEW_SRV_START *gatt_add_pending_new_srv_start( tGATTS_HNDL_RANGE *p_new_srv_start);
extern void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id);
extern BOOLEAN gatt_update_listen_mode(void);
+extern BOOLEAN gatt_cl_send_next_cmd_inq(tGATT_TCB *p_tcb);
/* reserved handle list */
extern tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_app_id (tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst);
diff --git a/stack/gatt/gatt_main.c b/stack/gatt/gatt_main.c
index 59c6759d9..793be643d 100644
--- a/stack/gatt/gatt_main.c
+++ b/stack/gatt/gatt_main.c
@@ -46,6 +46,7 @@
/********************************************************************************/
static void gatt_le_connect_cback (BD_ADDR bd_addr, BOOLEAN connected, UINT16 reason, tBT_TRANSPORT transport);
static void gatt_le_data_ind (BD_ADDR bd_addr, BT_HDR *p_buf);
+static void gatt_le_cong_cback(BD_ADDR remote_bda, BOOLEAN congest);
static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UINT8 l2cap_id);
static void gatt_l2cif_connect_cfm_cback (UINT16 l2cap_cid, UINT16 result);
@@ -55,6 +56,7 @@ static void gatt_l2cif_disconnect_ind_cback (UINT16 l2cap_cid, BOOLEAN ack_neede
static void gatt_l2cif_disconnect_cfm_cback (UINT16 l2cap_cid, UINT16 result);
static void gatt_l2cif_data_ind_cback (UINT16 l2cap_cid, BT_HDR *p_msg);
static void gatt_send_conn_cback (tGATT_TCB *p_tcb);
+static void gatt_l2cif_congest_cback (UINT16 cid, BOOLEAN congested);
static const tL2CAP_APPL_INFO dyn_info =
{
@@ -67,7 +69,7 @@ static const tL2CAP_APPL_INFO dyn_info =
gatt_l2cif_disconnect_cfm_cback,
NULL,
gatt_l2cif_data_ind_cback,
- NULL,
+ gatt_l2cif_congest_cback,
NULL
} ;
@@ -110,6 +112,7 @@ void gatt_init (void)
fixed_reg.pL2CA_FixedConn_Cb = gatt_le_connect_cback;
fixed_reg.pL2CA_FixedData_Cb = gatt_le_data_ind;
+ fixed_reg.pL2CA_FixedCong_Cb = gatt_le_cong_cback; /* congestion callback */
fixed_reg.default_idle_tout = 0xffff; /* 0xffff default idle timeout */
L2CA_RegisterFixedChannel (L2CAP_ATT_CID, &fixed_reg);
@@ -452,6 +455,62 @@ static void gatt_le_connect_cback (BD_ADDR bd_addr, BOOLEAN connected,
/*******************************************************************************
**
+** Function gatt_channel_congestion
+**
+** Description This function is called to process the congestion callback
+** from lcb
+**
+** Returns void
+**
+*******************************************************************************/
+static void gatt_channel_congestion(tGATT_TCB *p_tcb, BOOLEAN congested)
+{
+ UINT8 i = 0;
+ tGATT_REG *p_reg=NULL;
+ UINT16 conn_id;
+
+ /* if uncongested, check to see if there is any more pending data */
+ if (p_tcb != NULL && congested == FALSE)
+ {
+ gatt_cl_send_next_cmd_inq(p_tcb);
+ }
+ /* notifying all applications for the connection up event */
+ for (i = 0, p_reg = gatt_cb.cl_rcb ; i < GATT_MAX_APPS; i++, p_reg++)
+ {
+ if (p_reg->in_use)
+ {
+ if (p_reg->app_cb.p_congestion_cb)
+ {
+ conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_reg->gatt_if);
+ (*p_reg->app_cb.p_congestion_cb)(conn_id, congested);
+ }
+ }
+ }
+}
+
+/*******************************************************************************
+**
+** Function gatt_le_cong_cback
+**
+** Description This function is called when GATT fixed channel is congested
+** or uncongested.
+**
+** Returns void
+**
+*******************************************************************************/
+static void gatt_le_cong_cback(BD_ADDR remote_bda, BOOLEAN congested)
+{
+ tGATT_TCB *p_tcb = gatt_find_tcb_by_addr(remote_bda, BT_TRANSPORT_LE);
+
+ /* if uncongested, check to see if there is any more pending data */
+ if (p_tcb != NULL)
+ {
+ gatt_channel_congestion(p_tcb, congested);
+ }
+}
+
+/*******************************************************************************
+**
** Function gatt_le_data_ind
**
** Description This function is called when data is received from L2CAP.
@@ -553,7 +612,7 @@ static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16
** Returns void
**
*******************************************************************************/
-void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result)
+static void gatt_l2cif_connect_cfm_cback(UINT16 lcid, UINT16 result)
{
tGATT_TCB *p_tcb;
tL2CAP_CFG_INFO cfg;
@@ -754,7 +813,7 @@ void gatt_l2cif_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed)
** Returns void
**
*******************************************************************************/
-void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
+static void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
{
tGATT_TCB *p_tcb;
UINT16 reason;
@@ -789,7 +848,7 @@ void gatt_l2cif_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
** Returns void
**
*******************************************************************************/
-void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
+static void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
{
tGATT_TCB *p_tcb;
@@ -806,6 +865,25 @@ void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
/*******************************************************************************
**
+** Function gatt_l2cif_congest_cback
+**
+** Description L2CAP congestion callback
+**
+** Returns void
+**
+*******************************************************************************/
+static void gatt_l2cif_congest_cback (UINT16 lcid, BOOLEAN congested)
+{
+ tGATT_TCB *p_tcb = gatt_find_tcb_by_cid(lcid);
+
+ if (p_tcb != NULL)
+ {
+ gatt_channel_congestion(p_tcb, congested);
+ }
+}
+
+/*******************************************************************************
+**
** Function gatt_send_conn_cback
**
** Description Callback used to notify layer above about a connection.
diff --git a/stack/include/btm_ble_api.h b/stack/include/btm_ble_api.h
index 5f99c33e7..d38c41754 100644
--- a/stack/include/btm_ble_api.h
+++ b/stack/include/btm_ble_api.h
@@ -99,7 +99,6 @@ typedef UINT8 tBTM_BLE_SFP;
#define BTM_BLE_CONN_SUP_TOUT_MIN 0x000A
#define BTM_BLE_CONN_SUP_TOUT_MAX 0x0C80
#define BTM_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
-#define BTM_BLE_CONN_SUP_TOUT_DEF 700
/* default connection parameters if not configured, use GAP recommend value for auto/selective connection */
/* default scan interval */
@@ -163,6 +162,58 @@ typedef UINT8 BLE_SIGNATURE[BTM_BLE_AUTH_SIGN_LEN]; /* Device address */
#define BTM_BLE_SIMULTANEOUS_HOST 0x01
#endif
+/* Appearance Values Reported with BTM_BLE_AD_TYPE_APPEARANCE */
+#define BTM_BLE_APPEARANCE_UKNOWN 0x0000
+#define BTM_BLE_APPEARANCE_GENERIC_PHONE 0x0040
+#define BTM_BLE_APPEARANCE_GENERIC_COMPUTER 0x0080
+#define BTM_BLE_APPEARANCE_GENERIC_WATCH 0x00C0
+#define BTM_BLE_APPEARANCE_SPORTS_WATCH 0x00C1
+#define BTM_BLE_APPEARANCE_GENERIC_CLOCK 0x0100
+#define BTM_BLE_APPEARANCE_GENERIC_DISPLAY 0x0140
+#define BTM_BLE_APPEARANCE_GENERIC_REMOTE 0x0180
+#define BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES 0x01C0
+#define BTM_BLE_APPEARANCE_GENERIC_TAG 0x0200
+#define BTM_BLE_APPEARANCE_GENERIC_KEYRING 0x0240
+#define BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280
+#define BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0
+#define BTM_BLE_APPEARANCE_GENERIC_THERMOMETER 0x0300
+#define BTM_BLE_APPEARANCE_THERMOMETER_EAR 0x0301
+#define BTM_BLE_APPEARANCE_GENERIC_HEART_RATE 0x0340
+#define BTM_BLE_APPEARANCE_HEART_RATE_BELT 0x0341
+#define BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380
+#define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381
+#define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382
+#define BTM_BLE_APPEARANCE_GENERIC_HID 0x03C0
+#define BTM_BLE_APPEARANCE_HID_KEYBOARD 0x03C1
+#define BTM_BLE_APPEARANCE_HID_MOUSE 0x03C2
+#define BTM_BLE_APPEARANCE_HID_JOYSTICK 0x03C3
+#define BTM_BLE_APPEARANCE_HID_GAMEPAD 0x03C4
+#define BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET 0x03C5
+#define BTM_BLE_APPEARANCE_HID_CARD_READER 0x03C6
+#define BTM_BLE_APPEARANCE_HID_DIGITAL_PEN 0x03C7
+#define BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER 0x03C8
+#define BTM_BLE_APPEARANCE_GENERIC_GLUCOSE 0x0400
+#define BTM_BLE_APPEARANCE_GENERIC_WALKING 0x0440
+#define BTM_BLE_APPEARANCE_WALKING_IN_SHOE 0x0441
+#define BTM_BLE_APPEARANCE_WALKING_ON_SHOE 0x0442
+#define BTM_BLE_APPEARANCE_WALKING_ON_HIP 0x0443
+#define BTM_BLE_APPEARANCE_GENERIC_CYCLING 0x0480
+#define BTM_BLE_APPEARANCE_CYCLING_COMPUTER 0x0481
+#define BTM_BLE_APPEARANCE_CYCLING_SPEED 0x0482
+#define BTM_BLE_APPEARANCE_CYCLING_CADENCE 0x0483
+#define BTM_BLE_APPEARANCE_CYCLING_POWER 0x0484
+#define BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485
+#define BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40
+#define BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41
+#define BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42
+#define BTM_BLE_APPEARANCE_GENERIC_WEIGHT 0x0C80
+#define BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS 0x1440
+#define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION 0x1441
+#define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV 0x1442
+#define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD 0x1443
+#define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV 0x1444
+
+
/* Structure returned with Rand/Encrypt complete callback */
typedef struct
{
diff --git a/stack/include/gatt_api.h b/stack/include/gatt_api.h
index 9da7d9c04..392b4b2a0 100644
--- a/stack/include/gatt_api.h
+++ b/stack/include/gatt_api.h
@@ -61,6 +61,7 @@
#define GATT_ENCRYPED_MITM GATT_SUCCESS
#define GATT_ENCRYPED_NO_MITM 0x8d
#define GATT_NOT_ENCRYPTED 0x8e
+#define GATT_CONGESTED 0x8f
/* 0xE0 ~ 0xFC reserved for future use */
#define GATT_CCC_CFG_ERR 0xFD /* Client Characteristic Configuration Descriptor Improperly Configured */
@@ -573,6 +574,9 @@ typedef void (tGATT_CONN_CBACK) (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
typedef void (tGATT_REQ_CBACK )(UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type,
tGATTS_DATA *p_data);
+/* channel congestion/uncongestion callback */
+typedef void (tGATT_CONGESTION_CBACK )(UINT16 conn_id, BOOLEAN congested);
+
/* Define a callback function when encryption is established. */
typedef void (tGATT_ENC_CMPL_CB)(tGATT_IF gatt_if, BD_ADDR bda);
@@ -589,6 +593,7 @@ typedef struct
tGATT_DISC_CMPL_CB *p_disc_cmpl_cb;
tGATT_REQ_CBACK *p_req_cb;
tGATT_ENC_CMPL_CB *p_enc_cmpl_cb;
+ tGATT_CONGESTION_CBACK *p_congestion_cb;
} tGATT_CBACK;
/*********************** Start Handle Management Definitions **********************
diff --git a/stack/include/l2c_api.h b/stack/include/l2c_api.h
index 54c7ddbcb..c85d76b65 100644
--- a/stack/include/l2c_api.h
+++ b/stack/include/l2c_api.h
@@ -929,12 +929,21 @@ typedef void (tL2CA_FIXED_CHNL_CB) (BD_ADDR, BOOLEAN, UINT16, tBT_TRANSPORT);
*/
typedef void (tL2CA_FIXED_DATA_CB) (BD_ADDR, BT_HDR *);
+/* Congestion status callback protype. This callback is optional. If
+** an application tries to send data when the transmit queue is full,
+** the data will anyways be dropped. The parameter is:
+** remote BD_ADDR
+** TRUE if congested, FALSE if uncongested
+*/
+typedef void (tL2CA_FIXED_CONGESTION_STATUS_CB) (BD_ADDR, BOOLEAN);
+
/* Fixed channel registration info (the callback addresses and channel config)
*/
typedef struct
{
tL2CA_FIXED_CHNL_CB *pL2CA_FixedConn_Cb;
tL2CA_FIXED_DATA_CB *pL2CA_FixedData_Cb;
+ tL2CA_FIXED_CONGESTION_STATUS_CB *pL2CA_FixedCong_Cb;
tL2CAP_FCR_OPTS fixed_chnl_opts;
UINT16 default_idle_tout;
diff --git a/stack/l2cap/l2c_api.c b/stack/l2cap/l2c_api.c
index c542a0d6f..f45ecaa19 100644
--- a/stack/l2cap/l2c_api.c
+++ b/stack/l2cap/l2c_api.c
@@ -1431,6 +1431,7 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
|| (l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb == NULL) )
{
L2CAP_TRACE_ERROR ("L2CA_SendFixedChnlData() Invalid CID: 0x%04x", fixed_cid);
+ GKI_freebuf (p_buf);
return (L2CAP_DW_FAILED);
}
@@ -1438,6 +1439,7 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
if (!BTM_IsDeviceUp())
{
L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData(0x%04x) - BTU not ready", fixed_cid);
+ GKI_freebuf (p_buf);
return (L2CAP_DW_FAILED);
}
@@ -1447,12 +1449,14 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
p_lcb->link_state == LST_DISCONNECTING)
{
L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData(0x%04x) - no LCB", fixed_cid);
+ GKI_freebuf (p_buf);
return (L2CAP_DW_FAILED);
}
if ((p_lcb->peer_chnl_mask[0] & (1 << fixed_cid)) == 0)
{
L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData() - peer does not support fixed chnl: 0x%04x", fixed_cid);
+ GKI_freebuf (p_buf);
return (L2CAP_DW_FAILED);
}
@@ -1464,10 +1468,22 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
if (!l2cu_initialize_fixed_ccb (p_lcb, fixed_cid, &l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].fixed_chnl_opts))
{
L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData() - no CCB for chnl: 0x%4x", fixed_cid);
+ GKI_freebuf (p_buf);
return (L2CAP_DW_FAILED);
}
}
+ /* If already congested, do not accept any more packets */
+ if (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->cong_sent)
+ {
+ L2CAP_TRACE_ERROR ("L2CAP - CID: 0x%04x cannot send, already congested \
+ xmit_hold_q.count: %u buff_quota: %u", fixed_cid,
+ p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q.count,
+ p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->buff_quota);
+ GKI_freebuf (p_buf);
+ return (L2CAP_DW_FAILED);
+ }
+
l2c_enqueue_peer_data (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL], p_buf);
l2c_link_check_send_pkts (p_lcb, NULL, NULL);
@@ -1478,6 +1494,9 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
l2cu_no_dynamic_ccbs (p_lcb);
}
+ if (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->cong_sent)
+ return (L2CAP_DW_CONGESTED);
+
return (L2CAP_DW_SUCCESS);
}
diff --git a/stack/l2cap/l2c_ble.c b/stack/l2cap/l2c_ble.c
index fe827e3f9..b46a1c80e 100644
--- a/stack/l2cap/l2c_ble.c
+++ b/stack/l2cap/l2c_ble.c
@@ -644,7 +644,7 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
return FALSE;
}
#if BLE_PRIVACY_SPT == TRUE
-#if (defined BLE_VND_INCLUDED || BLE_VND_INCLUDED == TRUE)
+#if (defined BLE_VND_INCLUDED && BLE_VND_INCLUDED == TRUE)
extern tBTM_STATUS BTM_BleEnableIRKFeature(BOOLEAN enable);
if (btm_ble_vendor_irk_list_load_dev(p_dev_rec))
BTM_BleEnableIRKFeature(TRUE);
@@ -663,9 +663,9 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
(UINT16) ((p_dev_rec->conn_params.max_conn_int != BTM_BLE_CONN_PARAM_UNDEF) ?
p_dev_rec->conn_params.max_conn_int : BTM_BLE_CONN_INT_MAX_DEF), /* conn_int_max */
(UINT16) ((p_dev_rec->conn_params.slave_latency != BTM_BLE_CONN_PARAM_UNDEF) ?
- p_dev_rec->conn_params.slave_latency : 0), /* UINT16 conn_latency */
+ p_dev_rec->conn_params.slave_latency : BTM_BLE_CONN_SLAVE_LATENCY_DEF), /* UINT16 conn_latency */
(UINT16) ((p_dev_rec->conn_params.supervision_tout != BTM_BLE_CONN_PARAM_UNDEF) ?
- p_dev_rec->conn_params.supervision_tout : BTM_BLE_CONN_SUP_TOUT_DEF), /* conn_timeout */
+ p_dev_rec->conn_params.supervision_tout : BTM_BLE_CONN_TIMEOUT_DEF), /* conn_timeout */
0, /* UINT16 min_len */
0)) /* UINT16 max_len */
{
diff --git a/stack/l2cap/l2c_csm.c b/stack/l2cap/l2c_csm.c
index baad62480..fa261b211 100644
--- a/stack/l2cap/l2c_csm.c
+++ b/stack/l2cap/l2c_csm.c
@@ -1015,6 +1015,7 @@ static void l2c_csm_open (tL2C_CCB *p_ccb, UINT16 event, void *p_data)
#if BTM_PWR_MGR_INCLUDED == TRUE
{
tBTM_PM_PWR_MD settings;
+ memset((void*)&settings, 0, sizeof(settings));
settings.mode = BTM_PM_MD_ACTIVE;
BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr, &settings);
}
@@ -1038,6 +1039,7 @@ static void l2c_csm_open (tL2C_CCB *p_ccb, UINT16 event, void *p_data)
#if BTM_PWR_MGR_INCLUDED == TRUE
{
tBTM_PM_PWR_MD settings;
+ memset((void*)&settings, 0, sizeof(settings));
settings.mode = BTM_PM_MD_ACTIVE;
BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr, &settings);
}
diff --git a/stack/l2cap/l2c_utils.c b/stack/l2cap/l2c_utils.c
index bbcb3ea8a..db0218c03 100644
--- a/stack/l2cap/l2c_utils.c
+++ b/stack/l2cap/l2c_utils.c
@@ -3250,6 +3250,7 @@ BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb)
if ((p_buf = l2c_fcr_get_next_xmit_sdu_seg(p_ccb, 0)) != NULL)
{
+ l2cu_check_channel_congestion (p_ccb);
l2cu_set_acl_hci_header (p_buf, p_ccb);
return (p_buf);
}
@@ -3264,6 +3265,7 @@ BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb)
L2CAP_TRACE_ERROR("l2cu_get_buffer_to_send: No data to be sent");
return (NULL);
}
+ l2cu_check_channel_congestion (p_ccb);
l2cu_set_acl_hci_header (p_buf, p_ccb);
return (p_buf);
}
@@ -3391,7 +3393,7 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
/* If the CCB queue limit is subject to a quota, check for congestion */
/* if this channel has outgoing traffic */
- if ((p_ccb->p_rcb)&&(p_ccb->buff_quota != 0))
+ if (p_ccb->buff_quota != 0)
{
/* If this channel was congested */
if ( p_ccb->cong_sent )
@@ -3400,7 +3402,7 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
if (q_count <= (p_ccb->buff_quota / 2))
{
p_ccb->cong_sent = FALSE;
- if (p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb)
+ if (p_ccb->p_rcb && p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb)
{
L2CAP_TRACE_DEBUG ("L2CAP - Calling CongestionStatus_Cb (FALSE), CID: 0x%04x xmit_hold_q.count: %u buff_quota: %u",
p_ccb->local_cid, q_count, p_ccb->buff_quota);
@@ -3411,7 +3413,7 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
l2cb.is_cong_cback_context = FALSE;
}
#if (L2CAP_UCD_INCLUDED == TRUE)
- else if ( p_ccb->local_cid == L2CAP_CONNECTIONLESS_CID )
+ else if ( p_ccb->p_rcb && p_ccb->local_cid == L2CAP_CONNECTIONLESS_CID )
{
if ( p_ccb->p_rcb->ucd.cb_info.pL2CA_UCD_Congestion_Status_Cb )
{
@@ -3422,6 +3424,21 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
}
}
#endif
+#if (L2CAP_NUM_FIXED_CHNLS > 0)
+ else
+ {
+ UINT8 xx;
+ for (xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx ++)
+ {
+ if (p_ccb->p_lcb->p_fixed_ccbs[xx] == p_ccb)
+ {
+ if (l2cb.fixed_reg[xx].pL2CA_FixedCong_Cb != NULL)
+ (* l2cb.fixed_reg[xx].pL2CA_FixedCong_Cb)(p_ccb->p_lcb->remote_bd_addr, FALSE);
+ break;
+ }
+ }
+ }
+#endif
}
}
else
@@ -3430,7 +3447,7 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
if (q_count > p_ccb->buff_quota)
{
p_ccb->cong_sent = TRUE;
- if (p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb)
+ if (p_ccb->p_rcb && p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb)
{
L2CAP_TRACE_DEBUG ("L2CAP - Calling CongestionStatus_Cb (TRUE),CID:0x%04x,XmitQ:%u,Quota:%u",
p_ccb->local_cid, q_count, p_ccb->buff_quota);
@@ -3438,7 +3455,7 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
(*p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb)(p_ccb->local_cid, TRUE);
}
#if (L2CAP_UCD_INCLUDED == TRUE)
- else if ( p_ccb->local_cid == L2CAP_CONNECTIONLESS_CID )
+ else if ( p_ccb->p_rcb && p_ccb->local_cid == L2CAP_CONNECTIONLESS_CID )
{
if ( p_ccb->p_rcb->ucd.cb_info.pL2CA_UCD_Congestion_Status_Cb )
{
@@ -3449,6 +3466,21 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
}
}
#endif
+#if (L2CAP_NUM_FIXED_CHNLS > 0)
+ else
+ {
+ UINT8 xx;
+ for (xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx ++)
+ {
+ if (p_ccb->p_lcb->p_fixed_ccbs[xx] == p_ccb)
+ {
+ if (l2cb.fixed_reg[xx].pL2CA_FixedCong_Cb != NULL)
+ (* l2cb.fixed_reg[xx].pL2CA_FixedCong_Cb)(p_ccb->p_lcb->remote_bd_addr, TRUE);
+ break;
+ }
+ }
+ }
+#endif
}
}
}
diff --git a/stack/pan/pan_api.c b/stack/pan/pan_api.c
index d9bafbbee..6ba97b2b9 100644
--- a/stack/pan/pan_api.c
+++ b/stack/pan/pan_api.c
@@ -466,7 +466,7 @@ tPAN_RESULT PAN_Disconnect (UINT16 handle)
}
result = BNEP_Disconnect (pcb->handle);
- if (pcb->con_state == PAN_STATE_CONNECTED)
+ if (pcb->con_state != PAN_STATE_IDLE)
pan_cb.num_conns--;
if (pan_cb.pan_bridge_req_cb && pcb->src_uuid == UUID_SERVCLASS_NAP)
diff --git a/stack/sdp/sdp_api.c b/stack/sdp/sdp_api.c
index d72e1b262..9b3628c87 100644
--- a/stack/sdp/sdp_api.c
+++ b/stack/sdp/sdp_api.c
@@ -513,12 +513,13 @@ tSDP_DISC_REC *SDP_FindServiceInDb (tSDP_DISCOVERY_DB *p_db, UINT16 service_uuid
if ((SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE)
&& (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 2) ) {
- printf("SDP_FindServiceInDb - p_sattr value = 0x%x serviceuuid = 0x%x\r\n", p_sattr->attr_value.v.u16, service_uuid);
+ SDP_TRACE_DEBUG("SDP_FindServiceInDb - p_sattr value = 0x%x serviceuuid = 0x%x\r\n",
+ p_sattr->attr_value.v.u16, service_uuid);
if(service_uuid == UUID_SERVCLASS_HDP_PROFILE)
{
if( (p_sattr->attr_value.v.u16==UUID_SERVCLASS_HDP_SOURCE) || ( p_sattr->attr_value.v.u16==UUID_SERVCLASS_HDP_SINK))
{
- printf("SDP_FindServiceInDb found HDP source or sink\n" );
+ SDP_TRACE_DEBUG("SDP_FindServiceInDb found HDP source or sink\n" );
return (p_rec);
}
}
@@ -686,14 +687,14 @@ tSDP_DISC_REC *SDP_FindServiceUUIDInDb (tSDP_DISCOVERY_DB *p_db, tBT_UUID *p_uui
if (SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE)
{
- printf("uuid len=%d ", p_uuid->len);
+ SDP_TRACE_DEBUG("uuid len=%d ", p_uuid->len);
if (p_uuid->len == 2)
{
- printf("uuid=0x%x \n", p_uuid->uu.uuid16);
+ SDP_TRACE_DEBUG("uuid=0x%x \n", p_uuid->uu.uuid16);
}
else
{
- printf("\n");
+ SDP_TRACE_DEBUG("\n");
}
if (sdpu_compare_uuid_with_attr (p_uuid, p_sattr))
diff --git a/stack/smp/smp_l2c.c b/stack/smp/smp_l2c.c
index 02ec38eb6..3ba48aebb 100644
--- a/stack/smp/smp_l2c.c
+++ b/stack/smp/smp_l2c.c
@@ -58,6 +58,7 @@ void smp_l2cap_if_init (void)
fixed_reg.pL2CA_FixedConn_Cb = smp_connect_cback;
fixed_reg.pL2CA_FixedData_Cb = smp_data_ind;
+ fixed_reg.pL2CA_FixedCong_Cb = NULL; /* do not handle congestion on this channel */
fixed_reg.default_idle_tout = 60; /* set 60 seconds timeout, 0xffff default idle timeout */
/* Now, register with L2CAP */
diff --git a/stack/srvc/srvc_dis.c b/stack/srvc/srvc_dis.c
index 7c4df0d83..73be84b57 100644
--- a/stack/srvc/srvc_dis.c
+++ b/stack/srvc/srvc_dis.c
@@ -427,6 +427,9 @@ BOOLEAN DIS_ReadDISInfo(BD_ADDR peer_bda, tDIS_READ_CBACK *p_cback)
{
UINT16 conn_id;
+ /* Initialize the DIS client if it hasn't been initialized already. */
+ srvc_eng_init();
+
/* For now we only handle one at a time */
if (dis_cb.dis_read_uuid_idx != 0xff)
return(FALSE);
diff --git a/stack/srvc/srvc_eng.c b/stack/srvc/srvc_eng.c
index bf730aa7d..ec1128c07 100644
--- a/stack/srvc/srvc_eng.c
+++ b/stack/srvc/srvc_eng.c
@@ -41,6 +41,7 @@ static tGATT_CBACK srvc_gatt_cback =
NULL,
NULL,
srvc_eng_s_request_cback,
+ NULL,
NULL
} ;
/* type for action functions */