mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-30 13:50:03 +00:00
Backport fixes for BLE 5.4 PTS Related Features and Fixes
This commit is contained in:
@@ -936,7 +936,7 @@ struct ble_gatt_cpfd {
|
||||
uint16_t unit;
|
||||
|
||||
/** The name space of the description. */
|
||||
uint8_t namespace;
|
||||
uint8_t name_space;
|
||||
|
||||
/** The description of this characteristic. Depends on name space. */
|
||||
uint16_t description;
|
||||
|
||||
@@ -75,6 +75,7 @@ static const struct ble_gatt_svc_def ble_svc_htp_defs[] = {
|
||||
0,
|
||||
}
|
||||
},
|
||||
.cpfd = NULL,
|
||||
}, {
|
||||
0, /* No more characteristics in this service. */
|
||||
}
|
||||
|
||||
@@ -6338,8 +6338,10 @@ ble_gap_ext_connect(uint8_t own_addr_type, const ble_addr_t *peer_addr,
|
||||
ble_conn_reattempt.own_addr_type = own_addr_type;
|
||||
|
||||
if (peer_addr != NULL) {
|
||||
ble_conn_reattempt.peer_addr_present = 1;
|
||||
memcpy(&ble_conn_reattempt.peer_addr, peer_addr, sizeof(ble_addr_t));
|
||||
} else {
|
||||
ble_conn_reattempt.peer_addr_present = 0;
|
||||
memset(&ble_conn_reattempt.peer_addr, 0, sizeof(ble_addr_t));
|
||||
}
|
||||
|
||||
|
||||
+32
-29
@@ -767,33 +767,6 @@ ble_gatts_clt_cfg_find(struct ble_gatts_clt_cfg_list *ble_gatts_clt_cfgs,
|
||||
}
|
||||
|
||||
#else
|
||||
static int
|
||||
ble_gatts_cpfd_is_sane(const struct ble_gatt_cpfd *cpfd)
|
||||
{
|
||||
/** As per Assigned Numbers Specification (2023-09-07) */
|
||||
if ((cpfd->format < 0x01) || (cpfd->format > 0x1C)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((cpfd->unit < 0x2700) ||
|
||||
((cpfd->unit > 0x2707) && (cpfd->unit < 0x2710)) ||
|
||||
(cpfd->unit == 0x271F) ||
|
||||
((cpfd->unit > 0x2735) && (cpfd->unit < 0x2740)) ||
|
||||
((cpfd->unit > 0x2757) && (cpfd->unit < 0x2760)) ||
|
||||
((cpfd->unit > 0x2768) && (cpfd->unit < 0x2780)) ||
|
||||
((cpfd->unit > 0x2787) && (cpfd->unit < 0x27A0)) ||
|
||||
(cpfd->unit == 0x27BB) ||
|
||||
(cpfd->unit > 0x27C8)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((cpfd->namespace == BLE_GATT_CHR_NAMESPACE_BT_SIG) && (cpfd->description > 0x0110)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
ble_gatts_clt_cfg_find_idx(struct ble_gatts_clt_cfg *cfgs,
|
||||
uint16_t chr_val_handle)
|
||||
@@ -826,6 +799,33 @@ ble_gatts_clt_cfg_find(struct ble_gatts_clt_cfg *cfgs,
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
ble_gatts_cpfd_is_sane(const struct ble_gatt_cpfd *cpfd)
|
||||
{
|
||||
/** As per Assigned Numbers Specification (2023-09-07) */
|
||||
if ((cpfd->format < 0x01) || (cpfd->format > 0x1C)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((cpfd->unit < 0x2700) ||
|
||||
((cpfd->unit > 0x2707) && (cpfd->unit < 0x2710)) ||
|
||||
(cpfd->unit == 0x271F) ||
|
||||
((cpfd->unit > 0x2735) && (cpfd->unit < 0x2740)) ||
|
||||
((cpfd->unit > 0x2757) && (cpfd->unit < 0x2760)) ||
|
||||
((cpfd->unit > 0x2768) && (cpfd->unit < 0x2780)) ||
|
||||
((cpfd->unit > 0x2787) && (cpfd->unit < 0x27A0)) ||
|
||||
(cpfd->unit == 0x27BB) ||
|
||||
(cpfd->unit > 0x27C8)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((cpfd->name_space == BLE_GATT_CHR_NAMESPACE_BT_SIG) && (cpfd->description > 0x0110)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
ble_gatts_subscribe_event(uint16_t conn_handle, uint16_t attr_handle,
|
||||
uint8_t reason,
|
||||
@@ -1066,7 +1066,7 @@ ble_gatts_cpfd_access(uint16_t conn_handle, uint16_t attr_handle,
|
||||
rc += os_mbuf_append(*om, &(cpfd->format), sizeof(cpfd->format));
|
||||
rc += os_mbuf_append(*om, &(cpfd->exponent), sizeof(cpfd->exponent));
|
||||
rc += os_mbuf_append(*om, &(cpfd->unit), sizeof(cpfd->unit));
|
||||
rc += os_mbuf_append(*om, &(cpfd->namespace), sizeof(cpfd->namespace));
|
||||
rc += os_mbuf_append(*om, &(cpfd->name_space), sizeof(cpfd->name_space));
|
||||
rc += os_mbuf_append(*om, &(cpfd->description), sizeof(cpfd->description));
|
||||
|
||||
return ((rc == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES);
|
||||
@@ -2088,7 +2088,11 @@ ble_gatts_chr_updated(uint16_t chr_val_handle)
|
||||
* Consider using a "foreach" function to walk the connection list.
|
||||
*/
|
||||
conn = ble_hs_conn_find_by_idx(i);
|
||||
#if MYNEWT_VAL(BLE_DYNAMIC_SERVICE)
|
||||
if (conn == NULL) {
|
||||
#else
|
||||
if (conn == NULL || conn->bhc_gatt_svr.clt_cfgs == NULL) {
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2201,7 +2205,6 @@ ble_gatts_peer_cl_sup_feat_update(uint16_t conn_handle, struct os_mbuf *om)
|
||||
uint16_t len;
|
||||
int rc = 0;
|
||||
int i;
|
||||
int rfu_mask = 7;
|
||||
|
||||
BLE_HS_LOG(DEBUG, "");
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ ble_l2cap_coc_rx_fn(struct ble_l2cap_chan *chan)
|
||||
BLE_HS_LOG(ERROR, "Payload larger than expected (%d>%d)\n",
|
||||
om_total, sdu_len + 2);
|
||||
/* Disconnect peer with invalid behaviour */
|
||||
rx_sdu = NULL;
|
||||
rx->sdu = NULL;
|
||||
rx->data_offset = 0;
|
||||
ble_l2cap_disconnect(chan);
|
||||
return BLE_HS_EBADDATA;
|
||||
|
||||
@@ -432,7 +432,6 @@ int ble_sm_init(void);
|
||||
struct ble_l2cap_chan *ble_sm_create_chan(uint16_t handle);
|
||||
void *ble_sm_cmd_get(uint8_t opcode, size_t len, struct os_mbuf **txom);
|
||||
int ble_sm_tx(uint16_t conn_handle, struct os_mbuf *txom);
|
||||
int ble_sm_alg_aes_cmac(const uint8_t *key, const uint8_t *in, size_t len, uint8_t *out);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -2069,6 +2069,7 @@ struct ble_hci_ev_le_subev_periodic_adv_resp_rep {
|
||||
#define BLE_HCI_VER_BCS_5_1 (10)
|
||||
#define BLE_HCI_VER_BCS_5_2 (11)
|
||||
#define BLE_HCI_VER_BCS_5_3 (12)
|
||||
#define BLE_HCI_VER_BCS_5_4 (13)
|
||||
|
||||
#define BLE_LMP_VER_BCS_1_0b (0)
|
||||
#define BLE_LMP_VER_BCS_1_1 (1)
|
||||
@@ -2083,6 +2084,7 @@ struct ble_hci_ev_le_subev_periodic_adv_resp_rep {
|
||||
#define BLE_LMP_VER_BCS_5_1 (10)
|
||||
#define BLE_LMP_VER_BCS_5_2 (11)
|
||||
#define BLE_LMP_VER_BCS_5_3 (12)
|
||||
#define BLE_LMP_VER_BCS_5_4 (13)
|
||||
|
||||
/* selected HCI and LMP version */
|
||||
#if MYNEWT_VAL(BLE_VERSION) == 50
|
||||
@@ -2094,6 +2096,9 @@ struct ble_hci_ev_le_subev_periodic_adv_resp_rep {
|
||||
#elif MYNEWT_VAL(BLE_VERSION) == 52
|
||||
#define BLE_HCI_VER_BCS BLE_HCI_VER_BCS_5_2
|
||||
#define BLE_LMP_VER_BCS BLE_LMP_VER_BCS_5_2
|
||||
#elif MYNEWT_VAL(BLE_VERSION) == 54
|
||||
#define BLE_HCI_VER_BCS BLE_HCI_VER_BCS_5_4
|
||||
#define BLE_LMP_VER_BCS BLE_LMP_VER_BCS_5_4
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user