This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

custom service/client init Order

hi, In my device(nr51), have multi service and one client. when i initial the client first ,then to setup service. this follow is O.K. But, if i initial the service, and setup client . get a error when sd_ble_gattc_primary_services_discover(Attribute Not Found Error Code)

We do(deal with) it in order?

service: (sd_ble_uuid_vs_add,sd_ble_gatts_service_add and sd_ble_gatts_characteristic_add)

client: (sd_ble_uuid_vs_add,sd_ble_gattc_primary_services_discover,sd_ble_gattc_characteristics_discover and sd_ble_gattc_descriptors_discover)

  • It isn't easy to say this for sure without seeing your code, but you should make sure that you handle the UUID types correctly. You must store the type that is returned by uuid_vs_add(), and make sure that you set the ble_uuid_t-s correctly before doing discovery calls. The not-found error you're seeing could be caused by a wrong UUID used.

    If you still have trouble, could you edit your question, and show the complete code you're using?

  • hi, thank you for your reply. i create a sample to Verification for this issue. that work correctly ,so i will check my code again.

  • hi, i maybe descriptor error question about this issue. the service and client is custom uuid ,(service custom uuid,A; client custom uuid,B) so when i init the client first, the ble use the correct uuid(B) to find . on the hand, if i first use service init ,then setup client( sd_ble_gattc_primary_services_discover) to found . it Still use service uuid(A) not client uuid(B) to find, so that will get the Attribute Not Found Error Code. so i think sd_ble_gattc_primary_services_discover function which is use first add uuid to search.

  • Great that you've gotten it working, but your answer more or less confirms my suspicion. When you set up your ble_uuid_t, you must make sure to not use the BLE_UUID_VENDOR_BEGIN define, but instead use the type returned by sd_ble_uuid_vs_add(). Take a look at nAN-36 for details on how custom UUIDs should be handled: https://www.nordicsemi.com/eng/content/download/34055/573345/file/nAN-36.zip