espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
12.93k stars 7.1k forks source link

Advertising Specific Services and Characteristics in BLE using ESP-IDF for ESP32 (IDFGH-12936) #13896

Open AhmedSalem636 opened 1 month ago

AhmedSalem636 commented 1 month ago

Answers checklist.

General issue report

Hi,

In my project. I am using ESP32 to communicate with a mobile-App over BLE. we are using two Services. Each has its own characteristics. So, we were thinking if it is possible to advertise only one of them without the other while still being able to interact with the hidden one knowing its Service and characteristics UUIDs.

here are the code snappets that are related to the services creation and advertising.

static const struct ble_gatt_svc_def Mygatt_svr_svcs[] = { { /* Service: Security test. / .type= BLE_GATT_SVC_TYPE_PRIMARY, .uuid = BLE_UUID128_DECLARE(Service_UUID), .characteristics = (struct ble_gatt_chr_def[]) { { / Characteristic: Static value. / .uuid = BLE_UUID128_DECLARE(WRITE_UUID), .access_cb = MyHandler, .flags = BLE_GATT_CHR_F_READ| BLE_GATT_CHR_F_WRITE, }, { 0, / No more characteristics in this service. */ } }, },

{ // service: OTA Service .type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &gatt_svr_svc_ota_uuid.u, .characteristics = (struct ble_gatt_chr_def[]){ { // characteristic: OTA control .uuid = &gatt_svr_chr_ota_control_uuid.u, .access_cb = gatt_svr_chr_ota_control_cb, .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_NOTIFY, .val_handle = &ota_control_val_handle, }, { // characteristic: OTA data .uuid = &gatt_svr_chr_ota_data_uuid.u, .access_cb = gatt_svr_chr_ota_data_cb, .flags = BLE_GATT_CHR_F_WRITE, .val_handle = &ota_data_val_handle, }, { 0, }}, },

{ 0, / No more services. / }, };

if CONFIG_EXAMPLE_EXTENDED_ADV

/**

AhmedSalem636 commented 4 days ago

anyone here can help? Thanks

rahult-github commented 3 days ago

Hi @AhmedSalem636 ,

So, we were thinking if it is possible to advertise only one of them without the other while still being able to interact with the hidden one knowing its Service and characteristics UUIDs.

Do you imply that only one service would be registered in the gatt server database ? i.e., when some central device attempts to perform gatt discovery, at that time only one service would show up ?

If yes, then there is no other way the central would be aware of any other service . gatt service discovery is the only way a device gets information about services present on remote side.