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

Discovery of 128bit UUID services confusing

Hi

I am using sd_ble_gattc_primary_services_discover(conn_handle,0x0001,NULL) to discover primary services on a GATT server. After the first call to this function, I get 2 BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP, BLE_GATTC_EVT_CHAR_DISC_RSP and BLE_GATTC_EVT_DESC_DISC_RSP events:

  1. BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP with service count = 2, with 2 Standard BLE services listed and all handles linked
  2. BLE_GATTC_EVT_CHAR_DISC_RSP and BLE_GATTC_EVT_DESC_DISC_RSP events
  3. BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP with service count = 0 (I guess this means discovery is complete)

I know there are more 128 bit services, but why am I receiving the 2nd event with service count = 0. This tells my code that there are no more services, right? If I do another call to sd_ble_gattc_primary_services_discover(conn_handle,0x000c,NULL), but with the start handle set to the handle of the first 128 bit uuid in the list, it correctly returns with the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP response and some service info, but just the single event with its corresponding CHAR and DESC events...no second event with "service count = 0". So the first time I call it the response is different to the second time I call it.

So, why am I receiving the second event on the first api call, but not on any other there after?

I'm using the following

  • IC: nRF52840
  • Softdevice: S140 SDK: nRF5_SDK_13.0.0_04a0bfd
  • Example as base: ble_app_hrs_c
  • IDE: Eclipse + GCC

Thanks

Parents
  • Hi Tielman,

    I had the same problem, you need to add the SoftDevice the 128bit UUID and then ill reconize it as a 32 bit uuidd,in order to solve use this

    uint32_t err_code;

    err_code = sd_ble_uuid_vs_add(&quatServ128uuidd, &quatServ.type);
    
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_INFO("Failed to add the vendor-specific Quaternions service.\n");
        return 4002;
    }
    
    // Find the Quaternios service. Calls back to on_service_discovery_response() via ble_evt_dispatch().
    err_code = sd_ble_gattc_primary_services_discover(m_conn_handle[counter_conn-1],start_handle, NULL);
    

    where my uuids run as follow:

     /**@Brief 32-bit UUID from the Quaternios service*/
     static ble_uuid_t quatServ =
     {
       .uuid = 0x0000, // this number are the bit 12 and 13 from my 128-bit uuid
        .type = BLE_UUID_TYPE_BLE
      };
    
     /**@Brief 128-bit UUID Quaternios service */
      ble_uuid128_t  quatServ128uuidd= {
    	      {0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 
               0x00, 0x00, 0x00}
      };
    
  • Hi David

    Thanks for the answer. I am, however, already adding my 128bit UUIDs successfully. I can confirm this by doing a service discover and then seeing that the type is defined as a VENDER_SPECIFIC uuid.

    I edited my original post at the some moment you replied, so you might have missed some more detail.

    In summary, the first time a call service discovery, it responds with the ble services, characteristics and descriptors (not only services), followed by a service response with count = 0. Forcefully triggering another discovery after that works fine and does return the 128bit services, chars & descriptors, but this time it DOES NOT respond with the additional service event (with count = 0)

    PS. I noticed you declared your .type for your service as BLE_UUID_TYPE_BLE...should this not be BLE_UUID_TYPE_VENDOR_BEGIN for a 128bit UUID?

Reply
  • Hi David

    Thanks for the answer. I am, however, already adding my 128bit UUIDs successfully. I can confirm this by doing a service discover and then seeing that the type is defined as a VENDER_SPECIFIC uuid.

    I edited my original post at the some moment you replied, so you might have missed some more detail.

    In summary, the first time a call service discovery, it responds with the ble services, characteristics and descriptors (not only services), followed by a service response with count = 0. Forcefully triggering another discovery after that works fine and does return the 128bit services, chars & descriptors, but this time it DOES NOT respond with the additional service event (with count = 0)

    PS. I noticed you declared your .type for your service as BLE_UUID_TYPE_BLE...should this not be BLE_UUID_TYPE_VENDOR_BEGIN for a 128bit UUID?

Children
No Data
Related