Hi,
I am developing a system consisting of a BLE peripheral and central with a custom service (SDK 17, S140, PCA10056).
For the peripheral, I am using a modified version from the Nordic Playground Bluetooth Course. I upgraded it to work in SDK 17 and I tested it using nRF Connect, where I have no issues reading the characteristic, enabling notifications and writing to it after bonding using LESC and MITM OFF settings.
For the central, I started from the HRS example, and now I have both devices bonding and transferring data using a notification, but I am confused with some changes I had to make to the central to make it work:
- The custom service on the peripheral uses BLE_UUID_TYPE_VENDOR_BEGIN and a 128-bit uuid. However, I must initialize the central service to look for a BLE_UUID_TYPE_BLE; if I select BLE_UUID_TYPE_VENDOR_BEGIN instead, I get error messages:
<error> nrf_ble_gq: SD GATT procedure (2) failed on connection handle 0 with error: 0x00000007.
<debug> ble_cus_c: Battery Service discovery failure at peer.
And in ble_cus_on_db_disc_evt(), I get p_evt->evt_type = BLE_DB_DISCOVERY_ERROR, although instantly after I get BLE_DB_DISCOVERY_AVAILABLE. I never get the complete event after this though, which I do if I don't use vendor-specific.
Should I keep using BLE_UUID_TYPE_BLE in this case? Why does it work for a vendor-specific ID?uint32_t ble_cus_c_init(ble_cus_c_t * p_ble_cus_c, ble_cus_c_init_t * p_ble_cus_c_init) { VERIFY_PARAM_NOT_NULL(p_ble_cus_c); VERIFY_PARAM_NOT_NULL(p_ble_cus_c_init); ble_uuid_t cus_uuid; cus_uuid.type = BLE_UUID_TYPE_BLE; cus_uuid.uuid = BLE_UUID_CUSTOM_SERVICE; p_ble_cus_c->conn_handle = BLE_CONN_HANDLE_INVALID; p_ble_cus_c->peer_cus_db.bl_cccd_handle = BLE_GATT_HANDLE_INVALID; p_ble_cus_c->peer_cus_db.bl_handle = BLE_GATT_HANDLE_INVALID; p_ble_cus_c->evt_handler = p_ble_cus_c_init->evt_handler; p_ble_cus_c->error_handler = p_ble_cus_c_init->error_handler; p_ble_cus_c->p_gatt_queue = p_ble_cus_c_init->p_gatt_queue; return ble_db_discovery_evt_register(&cus_uuid); }
- Even if I use the above workaround, I receive a characteristic with uuid=0x0000. Because of this, I can't check if the IDs match. The only way I can proceed at this time is to ignore this error and assume that this is the characteristic I am searching for given that there is one characteristic per service. However, this is not ideal, as I would like to have multiple characteristics per service. Why does this happen?
Please see attached code. Thanks for your help.