summaryrefslogtreecommitdiffstats
path: root/stack
diff options
context:
space:
mode:
Diffstat (limited to 'stack')
-rw-r--r--stack/btm/btm_acl.c17
-rw-r--r--stack/btm/btm_ble_gap.c3
-rw-r--r--stack/btu/btu_init.c6
-rw-r--r--stack/gatt/gatt_auth.c5
-rw-r--r--stack/gatt/gatt_utils.c2
-rw-r--r--stack/include/bt_types.h1
-rw-r--r--stack/include/hcidefs.h3
-rw-r--r--stack/sdp/sdp_api.c13
-rw-r--r--stack/smp/smp_act.c15
9 files changed, 50 insertions, 15 deletions
diff --git a/stack/btm/btm_acl.c b/stack/btm/btm_acl.c
index e4dca3fb8..7f1ba27cb 100644
--- a/stack/btm/btm_acl.c
+++ b/stack/btm/btm_acl.c
@@ -1007,15 +1007,16 @@ void btm_read_remote_version_complete (UINT8 *p)
UINT16 handle;
int xx;
BTM_TRACE_DEBUG ("btm_read_remote_version_complete");
+
STREAM_TO_UINT8 (status, p);
- if (status == HCI_SUCCESS)
- {
- STREAM_TO_UINT16 (handle, p);
+ STREAM_TO_UINT16 (handle, p);
- /* Look up the connection by handle and copy features */
- for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_acl_cb++)
+ /* Look up the connection by handle and copy features */
+ for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_acl_cb++)
+ {
+ if ((p_acl_cb->in_use) && (p_acl_cb->hci_handle == handle))
{
- if ((p_acl_cb->in_use) && (p_acl_cb->hci_handle == handle))
+ if (status == HCI_SUCCESS)
{
STREAM_TO_UINT8 (p_acl_cb->lmp_version, p);
STREAM_TO_UINT16 (p_acl_cb->manufacturer, p);
@@ -1028,6 +1029,10 @@ void btm_read_remote_version_complete (UINT8 *p)
btm_read_remote_features (p_acl_cb->hci_handle);
break;
}
+
+ if (p_acl_cb->transport == BT_TRANSPORT_LE)
+ l2cble_notify_le_connection (p_acl_cb->remote_addr);
+ break;
}
}
}
diff --git a/stack/btm/btm_ble_gap.c b/stack/btm/btm_ble_gap.c
index 19ec9e75a..8c24e7da9 100644
--- a/stack/btm/btm_ble_gap.c
+++ b/stack/btm/btm_ble_gap.c
@@ -3215,8 +3215,7 @@ void btm_ble_read_remote_features_complete(UINT8 *p)
if ((p_acl_cb->in_use) && (p_acl_cb->hci_handle == handle))
{
STREAM_TO_ARRAY(p_acl_cb->peer_le_features, p, BD_FEATURES_LEN);
- /*notify link up here */
- l2cble_notify_le_connection (p_acl_cb->remote_addr);
+ btsnd_hcic_rmt_ver_req (p_acl_cb->hci_handle);
break;
}
}
diff --git a/stack/btu/btu_init.c b/stack/btu/btu_init.c
index 0888cb57e..250c1c43e 100644
--- a/stack/btu/btu_init.c
+++ b/stack/btu/btu_init.c
@@ -45,6 +45,10 @@
#endif
#endif
+// Increase BTU task thread priority to avoid pre-emption
+// of audio realated tasks.
+#define BTU_TASK_THREAD_PRIORITY -19
+
extern fixed_queue_t *btif_msg_queue;
// Communication queue from bta thread to bt_workqueue.
@@ -193,6 +197,8 @@ void BTU_StartUp(void)
if (bt_workqueue_thread == NULL)
goto error_exit;
+ thread_set_priority(bt_workqueue_thread, BTU_TASK_THREAD_PRIORITY);
+
// Continue startup on bt workqueue thread.
thread_post(bt_workqueue_thread, btu_task_start_up, NULL);
return;
diff --git a/stack/gatt/gatt_auth.c b/stack/gatt/gatt_auth.c
index ae5214592..89e2cc1cd 100644
--- a/stack/gatt/gatt_auth.c
+++ b/stack/gatt/gatt_auth.c
@@ -103,6 +103,11 @@ void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf)
UINT8 *p, *p_orig = (UINT8 *)(p_buf + 1) + p_buf->offset;
UINT32 counter;
+ if (p_buf->len < GATT_AUTH_SIGN_LEN + 4) {
+ GATT_TRACE_ERROR("%s: Data length %u less than expected %u",
+ __func__, p_buf->len, GATT_AUTH_SIGN_LEN + 4);
+ return;
+ }
cmd_len = p_buf->len - GATT_AUTH_SIGN_LEN + 4;
p = p_orig + cmd_len - 4;
STREAM_TO_UINT32(counter, p);
diff --git a/stack/gatt/gatt_utils.c b/stack/gatt/gatt_utils.c
index 5030c5328..907862ff1 100644
--- a/stack/gatt/gatt_utils.c
+++ b/stack/gatt/gatt_utils.c
@@ -1497,7 +1497,7 @@ UINT32 gatt_add_sdp_record (tBT_UUID *p_uuid, UINT16 start_hdl, UINT16 end_hdl)
case LEN_UUID_128:
UINT8_TO_BE_STREAM (p, (UUID_DESC_TYPE << 3) | SIZE_SIXTEEN_BYTES);
- ARRAY_TO_BE_STREAM (p, p_uuid->uu.uuid128, LEN_UUID_128);
+ ARRAY_TO_BE_STREAM_REVERSE (p, p_uuid->uu.uuid128, LEN_UUID_128);
SDP_AddAttribute (sdp_handle, ATTR_ID_SERVICE_CLASS_ID_LIST, DATA_ELE_SEQ_DESC_TYPE,
(UINT32) (p - buff), buff);
break;
diff --git a/stack/include/bt_types.h b/stack/include/bt_types.h
index 4ea447eca..453aa38a3 100644
--- a/stack/include/bt_types.h
+++ b/stack/include/bt_types.h
@@ -286,6 +286,7 @@ typedef struct
#define UINT16_TO_BE_STREAM(p, u16) {*(p)++ = (UINT8)((u16) >> 8); *(p)++ = (UINT8)(u16);}
#define UINT8_TO_BE_STREAM(p, u8) {*(p)++ = (UINT8)(u8);}
#define ARRAY_TO_BE_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[ijk];}
+#define ARRAY_TO_BE_STREAM_REVERSE(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[len - ijk - 1];}
#define BE_STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
#define BE_STREAM_TO_UINT16(u16, p) {u16 = (UINT16)(((UINT16)(*(p)) << 8) + (UINT16)(*((p) + 1))); (p) += 2;}
diff --git a/stack/include/hcidefs.h b/stack/include/hcidefs.h
index 41dc936c0..4cd34852a 100644
--- a/stack/include/hcidefs.h
+++ b/stack/include/hcidefs.h
@@ -24,6 +24,9 @@
#define HCI_PROTO_VERSION_2_0 0x03 /* Version for BT spec 2.0 */
#define HCI_PROTO_VERSION_2_1 0x04 /* Version for BT spec 2.1 [Lisbon] */
#define HCI_PROTO_VERSION_3_0 0x05 /* Version for BT spec 3.0 */
+#define HCI_PROTO_VERSION_4_0 0x06 /* Version for BT spec 4.0 */
+#define HCI_PROTO_VERSION_4_1 0x07 /* Version for BT spec 4.1 */
+#define HCI_PROTO_VERSION_4_2 0x08 /* Version for BT spec 4.2 */
#define HCI_PROTO_REVISION 0x000C /* Current implementation version */
/*
** Definitions for HCI groups
diff --git a/stack/sdp/sdp_api.c b/stack/sdp/sdp_api.c
index d96ace91d..720fad717 100644
--- a/stack/sdp/sdp_api.c
+++ b/stack/sdp/sdp_api.c
@@ -357,7 +357,8 @@ BOOLEAN SDP_FindServiceUUIDInRec(tSDP_DISC_REC *p_rec, tBT_UUID * p_uuid)
else if (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == LEN_UUID_128)
{
p_uuid->len = LEN_UUID_128;
- memcpy(p_uuid->uu.uuid128, p_sattr->attr_value.v.array, LEN_UUID_128);
+ for (uint8_t i = 0; i != LEN_UUID_128; ++i)
+ p_uuid->uu.uuid128[i] = p_sattr->attr_value.v.array[LEN_UUID_128-i-1];
}
else if (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == LEN_UUID_32)
{
@@ -443,8 +444,9 @@ BOOLEAN SDP_FindServiceUUIDInRec_128bit(tSDP_DISC_REC *p_rec, tBT_UUID * p_uuid)
/* only support 128 bits UUID for now */
if (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 16)
{
- p_uuid->len = 16;
- memcpy(p_uuid->uu.uuid128, p_sattr->attr_value.v.array, MAX_UUID_SIZE);
+ p_uuid->len = LEN_UUID_128;
+ for (uint8_t i = 0; i != LEN_UUID_128; ++i)
+ p_uuid->uu.uuid128[i] = p_sattr->attr_value.v.array[LEN_UUID_128-i-1];
}
return(TRUE);
}
@@ -457,8 +459,9 @@ BOOLEAN SDP_FindServiceUUIDInRec_128bit(tSDP_DISC_REC *p_rec, tBT_UUID * p_uuid)
/* only support 128 bits UUID for now */
&& (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) == 16))
{
- p_uuid->len = 16;
- memcpy(p_uuid->uu.uuid128, p_attr->attr_value.v.array, MAX_UUID_SIZE);
+ p_uuid->len = LEN_UUID_128;
+ for (uint8_t i = 0; i != LEN_UUID_128; ++i)
+ p_uuid->uu.uuid128[i] = p_attr->attr_value.v.array[LEN_UUID_128-i-1];
return(TRUE);
}
}
diff --git a/stack/smp/smp_act.c b/stack/smp/smp_act.c
index 462b02dce..8f758890c 100644
--- a/stack/smp/smp_act.c
+++ b/stack/smp/smp_act.c
@@ -51,6 +51,18 @@ const tSMP_ACT smp_distribute_act [] =
smp_set_derive_link_key
};
+static bool lmp_version_below(BD_ADDR bda, uint8_t version)
+{
+ tACL_CONN *acl = btm_bda_to_acl(bda, BT_TRANSPORT_LE);
+ if (acl == NULL || acl->lmp_version == 0)
+ {
+ SMP_TRACE_WARNING("%s cannot retrieve LMP version...", __func__);
+ return false;
+ }
+ SMP_TRACE_WARNING("%s LMP version %d < %d", __func__, acl->lmp_version, version);
+ return acl->lmp_version < version;
+}
+
/*******************************************************************************
** Function smp_update_key_mask
** Description This function updates the key mask for sending or receiving.
@@ -174,7 +186,8 @@ void smp_send_app_cback(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
if (!(p_cb->loc_auth_req & SMP_SC_SUPPORT_BIT)
|| interop_addr_match(INTEROP_DISABLE_LE_SECURE_CONNECTIONS,
- (const bt_bdaddr_t *)&p_cb->pairing_bda))
+ (const bt_bdaddr_t *)&p_cb->pairing_bda)
+ || lmp_version_below(p_cb->pairing_bda, HCI_PROTO_VERSION_4_2))
{
p_cb->loc_auth_req &= ~SMP_KP_SUPPORT_BIT;
p_cb->local_i_key &= ~SMP_SEC_KEY_TYPE_LK;