Skip to content

Commit 6c00b45

Browse files
nimble/host: store client supported features value
This adds support for storing client supported features for clients with a trusted relationship. Fixes Host qualification test case GATT/SR/GAS/BV-04-C
1 parent 4c78896 commit 6c00b45

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

nimble/host/src/ble_gatts.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,8 @@ int
16121612
ble_gatts_peer_cl_sup_feat_get(uint16_t conn_handle, uint8_t *out_supported_feat, uint8_t len)
16131613
{
16141614
struct ble_hs_conn *conn;
1615+
struct ble_store_key_cl_sup_feat feat_key;
1616+
struct ble_store_value_cl_sup_feat feat_val;
16151617
int rc = 0;
16161618

16171619
if (out_supported_feat == NULL) {
@@ -1629,8 +1631,16 @@ ble_gatts_peer_cl_sup_feat_get(uint16_t conn_handle, uint8_t *out_supported_feat
16291631
len = BLE_GATT_CHR_CLI_SUP_FEAT_SZ;
16301632
}
16311633

1632-
memcpy(out_supported_feat, conn->bhc_gatt_svr.peer_cl_sup_feat,
1633-
sizeof(uint8_t) * len);
1634+
if (conn->bhc_sec_state.bonded) {
1635+
feat_key.peer_addr = conn->bhc_peer_addr;
1636+
feat_key.idx = 0;
1637+
ble_store_read_peer_cl_sup_feat(&feat_key, &feat_val);
1638+
memcpy(out_supported_feat, feat_val.peer_cl_sup_feat,
1639+
sizeof(uint8_t) * len);
1640+
} else {
1641+
memcpy(out_supported_feat, conn->bhc_gatt_svr.peer_cl_sup_feat,
1642+
sizeof(uint8_t) * len);
1643+
}
16341644

16351645
done:
16361646
ble_hs_unlock();
@@ -1641,6 +1651,7 @@ int
16411651
ble_gatts_peer_cl_sup_feat_update(uint16_t conn_handle, struct os_mbuf *om)
16421652
{
16431653
struct ble_hs_conn *conn;
1654+
struct ble_store_value_cl_sup_feat store_feat;
16441655
uint8_t feat[BLE_GATT_CHR_CLI_SUP_FEAT_SZ] = {};
16451656
uint16_t len;
16461657
int rc = 0;
@@ -1686,6 +1697,14 @@ ble_gatts_peer_cl_sup_feat_update(uint16_t conn_handle, struct os_mbuf *om)
16861697

16871698
memcpy(conn->bhc_gatt_svr.peer_cl_sup_feat, feat, BLE_GATT_CHR_CLI_SUP_FEAT_SZ);
16881699

1700+
if (conn->bhc_sec_state.bonded) {
1701+
store_feat.peer_addr = conn->bhc_peer_addr;
1702+
memcpy(store_feat.peer_cl_sup_feat,
1703+
feat,
1704+
BLE_GATT_CHR_CLI_SUP_FEAT_SZ);
1705+
ble_store_write_peer_cl_sup_feat(&store_feat);
1706+
}
1707+
16891708
done:
16901709
ble_hs_unlock();
16911710
return rc;

0 commit comments

Comments
 (0)