diff --git a/pycardium/modules/modbluetooth_card10.c b/pycardium/modules/modbluetooth_card10.c index 9916eba602ca0e85bcb1bb39a7be1ed5a88c16f2..66f86ef8a75f333bbf7ca1270f257486c317cbb2 100644 --- a/pycardium/modules/modbluetooth_card10.c +++ b/pycardium/modules/modbluetooth_card10.c @@ -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++;