Search code examples
bluetooth-lowenergyesp32gattbluetooth-gattesp-idf

What is the difference between GATT Service UUID (esp_gatt_srvc_id_t) vs ADV DATA Service UUID (esp_ble_adv_data_t) in ESP 32 GATT SERVER?


I am new to ESP32 and Bluetooth programming. I just try to understand the GATT server operation in ESP32 using the sample code provided in the ESP IDF.

Here is the link : https://github.com/espressif/esp-idf/blob/master/examples/bluetooth/bluedroid/ble/gatt_server/

To my knowledge, there will be UUID's for service and UUIS's for each Characteristics of the services. But I can able to find two different service UUID's one in esp_gatt_srvc_id_t and other in esp_ble_adv_data_t .

The esp_gatt_srvc_id_t used in esp_ble_gatts_create_service() and esp_ble_adv_data_t used in esp_ble_gap_config_adv_data(&adv_data) APIs.

Can someone help me to understand, what is the difference between both and what is the specific use case of each of this. Is both mandatory required for the connection and what is the use of esp_ble_adv_data_t since we are using esp_gatt_srvc_id_t uuid for connection?

Thanks.


Solution

  • GATT service is the service that represents some service of your device. Device may have more than one GATT service and each service may have some characteristics - this is what you are working with when device is connected by GATT. This UUID will be seen after connecting to device and reading its attributes. Required for GATT comunication.

    Advertising service UUID is the UUID that device will advertise. Usualy it is the primary service's UUID so client/central can easy find your devices by checking this UUID in BLE advertisement packets. But this UUID can be different to indicate something for clients. Or devic emay advertise few UUIDs to indicate that it supports few different services. This UUID will be seen during BLE discovering. This is not required option. Device may or may not advertise any UUIDs.

    Also there is something known as SOL service UUID. Such UUID may include some data so device may indicate its status by changing this data and clients may get it without connecting to device. So this can be used by non-connectable BLE devices.