Skip to content
Snippets Groups Projects
Commit 6ff37ded authored by schneider's avatar schneider
Browse files

change(mp-ble): Cleanup cccd section

parent bee7c425
No related branches found
No related tags found
1 merge request!446Initial MicroPython BLE support (GATTS)
......@@ -449,17 +449,16 @@ int mp_bluetooth_gatts_register_service(
flags & (MP_BLUETOOTH_CHARACTERISTIC_FLAG_INDICATE)) {
/* CCCD */
currentHandle++;
uint8_t initCcc[2] = {};
// TODO: activate notification/indications by default
// Not according to spec
uint8_t cccd_buf[2] = {};
// TODO: Handle CCC data.
// Until then: activate notification/indications by default.
if (flags & MP_BLUETOOTH_CHARACTERISTIC_FLAG_NOTIFY) {
initCcc[0] |= 0x01;
cccd_buf[0] |= 0x01;
}
if (flags & MP_BLUETOOTH_CHARACTERISTIC_FLAG_INDICATE) {
initCcc[0] |= 0x02;
cccd_buf[0] |= 0x02;
}
// TODO: Handle CCC data
uint8_t ccc_uuid[] = { 0x02, 0x29 };
uint8_t flags = MP_BLUETOOTH_CHARACTERISTIC_FLAG_READ |
MP_BLUETOOTH_CHARACTERISTIC_FLAG_WRITE;
......@@ -468,16 +467,25 @@ int mp_bluetooth_gatts_register_service(
ccc_uuid,
sizeof(ccc_uuid),
flags,
initCcc,
sizeof(initCcc),
sizeof(initCcc)
cccd_buf,
sizeof(cccd_buf),
sizeof(cccd_buf)
);
epic_ble_atts_set_attr(
currentHandle, initCcc, sizeof(initCcc)
currentHandle, cccd_buf, sizeof(cccd_buf)
);
//mp_bluetooth_gatts_db_create_entry(GATTS_DB, handles[handle_index] + 1, MP_BLUETOOTH_CCCB_LEN);
//gatts_status_create_entry(GATTS_STATUS, handles[handle_index] + 1);
//int ret = mp_bluetooth_gatts_db_write(GATTS_DB, handles[handle_index] + 1, cccb_buf, sizeof(cccb_buf));
mp_bluetooth_gatts_db_create_entry(
GATTS_DB, currentHandle, sizeof(cccd_buf)
);
int ret = mp_bluetooth_gatts_db_write(
GATTS_DB,
currentHandle,
cccd_buf,
sizeof(cccd_buf)
);
if (ret) {
return ret;
}
}
handle_index++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment