Skip to content

Commit 16a0789

Browse files
committed
Merge branch 'feat/added_change_to_ble_spp_client_v5.0' into 'release/v5.0'
feat(nimble): Allow BLE SPP Client to subscribe to the server (v5.0) See merge request espressif/esp-idf!37459
2 parents 3b60206 + 62ac09e commit 16a0789

File tree

1 file changed

+16
-0
lines changed
  • examples/bluetooth/nimble/ble_spp/spp_client/main

1 file changed

+16
-0
lines changed

examples/bluetooth/nimble/ble_spp/spp_client/main/main.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,27 @@ static void
6767
ble_spp_client_set_handle(const struct peer *peer)
6868
{
6969
const struct peer_chr *chr;
70+
const struct peer_dsc *dsc;
71+
uint8_t value[2];
7072
chr = peer_chr_find_uuid(peer,
7173
BLE_UUID16_DECLARE(GATT_SPP_SVC_UUID),
7274
BLE_UUID16_DECLARE(GATT_SPP_CHR_UUID));
7375
attribute_handle[peer->conn_handle] = chr->chr.val_handle;
76+
MODLOG_DFLT(INFO, "attribute_handle %x\n", attribute_handle[peer->conn_handle]);
7477

78+
dsc = peer_dsc_find_uuid(peer,
79+
BLE_UUID16_DECLARE(GATT_SPP_SVC_UUID),
80+
BLE_UUID16_DECLARE(GATT_SPP_CHR_UUID),
81+
BLE_UUID16_DECLARE(BLE_GATT_DSC_CLT_CFG_UUID16));
82+
if (dsc == NULL) {
83+
MODLOG_DFLT(ERROR, "Error: Peer lacks a CCCD for the subscribable characteristic\n");
84+
return;
85+
}
86+
87+
value[0] = 1;
88+
value[1] = 0;
89+
ble_gattc_write_flat(peer->conn_handle, dsc->dsc.handle,
90+
value, sizeof(value), NULL, NULL);
7591
}
7692

7793

0 commit comments

Comments
 (0)