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

Unable to find the name of the BLE peripheral and how to discover all services from a connected BLE peripheral.

Hi,

I am creating a wrapper that uses nrf-ble-driver-sd_api_v6-mt-4_1_1.dll. I had burn the dongle with fw: connectivity_4.1.1_usb_with_s140_6.1.1.hex.

I am trying to create a central app by following and modifying the heart_rate_collector example.

There are 2 questions that i need help currently.

Question 1:

Why is it that i am unable to find the name of some of the ble peripheral by follow the heart_rate_collector example but i am able to find the names using nRF connect application?

I am using the code:

//search for advertising names
    err_code = adv_report_parse(BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME,
                                &adv_data,
                                &dev_name);

and

// Look for the short local name if it was not found as complete
        err_code = adv_report_parse(BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME,
                                    &adv_data,
                                    &dev_name);

Question 2:

Upon using the peer address to connect, how can i discover all of the peripheral services?

From the code:

static uint32_t service_discovery_start()
{
    uint32_t   err_code;
    uint16_t   start_handle = 0x01;
    ble_uuid_t srvc_uuid;

    printf("Discovering primary services\n");
    fflush(stdout);

    srvc_uuid.type = BLE_UUID_TYPE_BLE;
    srvc_uuid.uuid = BLE_UUID_HEART_RATE_SERVICE;

    // Initiate procedure to find the primary BLE_UUID_HEART_RATE_SERVICE.
    err_code = sd_ble_gattc_primary_services_discover(m_adapter,
                                                      m_connection_handle, start_handle,
                                                      &srvc_uuid);

So by changing the uuid, i can discover individual services. Is it possible to find all of the ble peripheral services instead of looking for it 1 by 1?

If the uuid is a vendor specific uuid, how can i find them?

Thanks for helping.

Regards,

LC

Parents Reply Children
  • Hi Terje,

    Thanks for the link. It's very useful.

    I am able to find the different services now.

    Just another question, do you know how to get the custom characteristic uuid?

    Currently, after finding the custom service uuid, i had add it to sd_ble_uuid_vs_add() and i had a return uuid type of 0x2.

    But i am not sure how to use that type or i don't have to do anything with it?

    And on characteristic respond, i get the uuid = 0 and if i were to call sd_ble_gattc_read(), i am unable to find the uuid also.

    Any advice on this?

    Thanks for helping.

    Regards,

    LC

  • Hi,

    UUIDs are stored internally as a combination of "type" and a 16 bit UUID. The type refers to a "base UUID", which is all but 16 bits of the full 128 bit UUID. This follows the same pattern as Bluetooth SIG 16 bit UUIDs, which all are really 128 bit UUIDs which are a combination of a specially assigned base UUID adn the 16 bits from the 16 bit UUID. You can read more about the system with base UUIDs in Bluetooth low energy SErvices, a beginner's tutorial. You can also convert between the ble_uuid_t data type (16 bit UUID + base UUID index) and a 16 byte array representation of the full 128 bit UUID using the functions sd_ble_uuid_encode() and sd_ble_uuid_decode().

    What to do with the UUID depends on what is your use case. You can for instance recognize a service or characteristic based on the UUID. What to do really depends on the answer to the question "What is the purpose of your application?"

    Regarding sd_ble_gattc_read(), there is no direct connection there to the UUIDs. When using the discover functions for services and characteristics, you will get discovery events that provides "handles" in addition to the UUIDs, Services, characteristics and descriptors are all entries in the GATT table, and the handle is an unique identifier for selecting one such entry. I am a bit confused as to what you are trying to do there, but usually one would store the handle in a data structure used for keeping track of a given service. We have numerous examples of this in our SDK, just have a look at any of the BLE central examples.

    Regards,
    Terje

Related