Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE Mesh Stack Overrides Custom BLE Advertising Parameters (IDFGH-14437) #15217

Open
3 tasks done
lebrislo opened this issue Jan 15, 2025 · 5 comments
Open
3 tasks done
Assignees
Labels
Status: Opened Issue is new Type: Bug bugs in IDF

Comments

@lebrislo
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.4

Espressif SoC revision.

ESP32

Operating System used.

Linux

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

None

Development Kit.

ESP32-MINI-1

Power Supply used.

USB

What is the expected behavior?

When using the ESP BLE Mesh stack along with BLE GATT advertising, I encounter an issue where my custom BLE advertising data is overridden by the BLE Mesh stack after the advertising duration ends. Specifically:

  • I configure BLE advertising parameters to include my vendor-specific service UUID in the complete list of service UUIDs.

  • Advertising works as expected for the specified duration (e.g., 19 seconds).

  • After the BLE advertising duration ends, only the BLE Mesh Proxy Service UUID (0x1828) is advertised, and my vendor-specific UUID is no longer included.

This behavior prevents the coexistence of BLE Mesh Proxy and custom BLE GATT advertising.

The BLE advertising should continue periodically with the configured parameters, including both the BLE Mesh Proxy Service UUID (0x1828) and my vendor-specific service UUID.

What is the actual behavior?

After the BLE advertising duration ends, the ESP BLE Mesh stack takes control of the advertising process and only advertises the Mesh Proxy Service UUID (0x1828). My vendor-specific UUID is no longer included.

Steps to reproduce.

  1. Initialize the ESP BLE Mesh stack.
  2. Configure BLE advertising parameters as shown below:
static esp_ble_mesh_ble_adv_param_t g_bleMeshAdvParam = {
    .interval       = 0x20,
    .adv_type       = ADV_TYPE_IND,
    .own_addr_type  = BLE_ADDR_TYPE_PUBLIC,
    .peer_addr_type = BLE_ADDR_TYPE_PUBLIC,
    .peer_addr      = {0},
    .duration       = 19000,
    .period         = 20000,
    .count          = ESP_BLE_MESH_BLE_ADV_INFINITE,
    .priority       = ESP_BLE_MESH_BLE_ADV_PRIO_HIGH,
};
  1. Start BLE advertising with the above parameters.

  2. Observe the advertising data using a BLE scanner app (e.g., nRF Connect).

Debug Logs.

No response

More Information.

Is there a supported way to include custom vendor-specific UUIDs alongside the Mesh Proxy Service UUID in the BLE advertising data?

If not, can you suggest an alternative approach or API updates to allow coexistence of BLE Mesh and custom BLE GATT advertising?

Thank you for your support!

@lebrislo lebrislo added the Type: Bug bugs in IDF label Jan 15, 2025
@github-actions github-actions bot changed the title BLE Mesh Stack Overrides Custom BLE Advertising Parameters BLE Mesh Stack Overrides Custom BLE Advertising Parameters (IDFGH-14437) Jan 15, 2025
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jan 15, 2025
@forx157
Copy link
Collaborator

forx157 commented Jan 17, 2025

Hi, @lebrislo

Do you mean mesh proxy adveritising data to carry your UUID information? This shouldn't be the case, your UUID information should be included in your own broadcast message!

@lebrislo
Copy link
Author

Thanks for your reply,

No, I was talking about the BLE advertising the complete list of service uuid. With esp-idf we configure this list by setting esp_ble_adv_data_t.p_service_uuid like in the gatt_server example :

static uint8_t adv_service_uuid128[32] = {
    0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x34, 0x12, 0x00, 0x00,
};

// The length of adv data must be less than 31 bytes
//static uint8_t test_manufacturer[TEST_MANUFACTURER_DATA_LEN] =  {0x12, 0x23, 0x45, 0x56};
//adv data
static esp_ble_adv_data_t adv_data = {
    .set_scan_rsp = false,
    .include_name = true,
    .include_txpower = false,
    .min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
    .max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
    .appearance = 0x00,
    .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
    .p_manufacturer_data =  NULL, //&test_manufacturer[0],
    .service_data_len = 0,
    .p_service_data = NULL,
    .service_uuid_len = sizeof(adv_service_uuid128), // <-- HERE
    .p_service_uuid = adv_service_uuid128, // <-- HERE
    .flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
};

If I don't init esp_ble_mesh stack, my device advertises the services0x1234 (what I'm expecting). But, when I init the esp_ble_mesh stack and since my device is a proxy, the device now advertise only the mesh proxy service 0x1828.

Regarding to the documentation, there's a way to make esp_ble_gatt and esp_ble_mesh advertising coexist. That's what I setup with esp_ble_mesh_start_ble_advertising :

static esp_ble_mesh_ble_adv_param_t g_bleMeshAdvParam = {
    .interval       = 0x20,
    .adv_type       = ADV_TYPE_DIRECT_IND_HIGH,
    .own_addr_type  = BLE_ADDR_TYPE_PUBLIC,
    .peer_addr_type = BLE_ADDR_TYPE_PUBLIC,
    .peer_addr      = {0},
    .duration       = 2000,
    .period         = 4000,
    .count          = ESP_BLE_MESH_BLE_ADV_INFINITE,
    .priority       = ESP_BLE_MESH_BLE_ADV_PRIO_HIGH,
};

static esp_ble_mesh_ble_adv_data_t g_bleMeshAdvData = {
    .adv_data_len      = 0,
    .scan_rsp_data_len = 0,
};

err = esp_ble_mesh_start_ble_advertising(&g_bleMeshAdvParam, &g_bleMeshAdvData);
    if (err != ESP_OK)
    {
        ESP_LOGE(TAG, "Failed to start BLE advertising: %d", err);
        goto error;
    }

This works partially since my esp_ble_gatt adv_data is advertised during the first period but after that it's no more advertised and only the proxy service is advertised. See screenshots below :

BLE GATT ADVETISING
Image
MESH PROXY ADVETISING
Image

So here's my question :

  • Is it a bug that the device only advertise for the first period ?

  • Is there another way the insert my service uuid at the end of the complete list of service uuid (just after the proxy mesh service, for example) ?

  • If it's not the right way to achieve what I'm expecting, can you explain me the right way to do it ?

Thank you !

@forx157
Copy link
Collaborator

forx157 commented Jan 20, 2025

Hi, @lebrislo

Why did you set adv data len and scan response len to 0?

How did you set the service uuid information when using ble mesh?

@lebrislo
Copy link
Author

Hi,

Why did you set adv data len and scan response len to 0?

Because it doesn't change anything, if I change it to the following code I get the same result :

g_bleMeshAdvData.adv_data_len = sizeof(g_serviceUuidList);
memcpy(g_bleMeshAdvData.adv_data, g_serviceUuidList, sizeof(g_serviceUuidList));
g_bleMeshAdvData.scan_rsp_data_len = sizeof(g_serviceUuidList);
memcpy(g_bleMeshAdvData.scan_rsp_data, g_serviceUuidList, sizeof(g_serviceUuidList));

err = esp_ble_mesh_start_ble_advertising(&g_bleMeshAdvParam, &g_bleMeshAdvData);
if (err != ESP_OK)
{
  ESP_LOGE(TAG, "Failed to start BLE advertising: %d", err);
  goto error;
}

How did you set the service uuid information when using ble mesh?

Just how I explain to you above. I set it into the esp_ble_adv_data_t along with the others advertising parameters :

static esp_ble_adv_data_t g_advertisingData = {
    .set_scan_rsp        = false,
    .include_name        = true,
    .include_txpower     = true,
    .min_interval        = ADV_INT_MIN,
    .max_interval        = ADV_INT_MAX,
    .manufacturer_len    = 0,
    .p_manufacturer_data = NULL,
    .service_data_len    = 0,
    .p_service_data      = NULL,
    .service_uuid_len    = sizeof(g_serviceUuidList),
    .p_service_uuid      = g_serviceUuidList,
    .flag                = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
};

static esp_ble_adv_data_t g_scanResponseData = {
    .set_scan_rsp        = true,
    .include_name        = true,
    .include_txpower     = true,
    .min_interval        = ADV_INT_MIN,
    .max_interval        = ADV_INT_MAX,
    .manufacturer_len    = 0,
    .p_manufacturer_data = NULL,
    .service_data_len    = 0,
    .p_service_data      = NULL,
    .service_uuid_len    = 0,
    .p_service_uuid      = NULL,
    .flag                = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
};

static esp_ble_adv_params_t g_advertisingParams = {
    .adv_int_min       = ADV_INT_MIN,
    .adv_int_max       = ADV_INT_MAX,
    .adv_type          = ADV_TYPE_IND,
    .own_addr_type     = BLE_ADDR_TYPE_PUBLIC,
    .channel_map       = ADV_CHNL_ALL,
    .adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
};

static esp_ble_mesh_ble_adv_param_t g_bleMeshAdvParam = {
    .interval       = 0x20,
    .adv_type       = ADV_TYPE_DIRECT_IND_HIGH,
    .own_addr_type  = BLE_ADDR_TYPE_PUBLIC,
    .peer_addr_type = BLE_ADDR_TYPE_PUBLIC,
    .peer_addr      = {0},
    .duration       = 2000,
    .period         = 4000,
    .count          = ESP_BLE_MESH_BLE_ADV_INFINITE,
    .priority       = ESP_BLE_MESH_BLE_ADV_PRIO_HIGH,
};

err = esp_ble_gap_config_adv_data(&g_advertisingData);
err = esp_ble_gap_config_adv_data(&g_scanResponseData);
err = esp_ble_mesh_start_ble_advertising(&g_bleMeshAdvParam, &g_bleMeshAdvData);
err = esp_ble_gap_start_advertising(&g_advertisingParams);

@forx157
Copy link
Collaborator

forx157 commented Jan 22, 2025

Hi, @lebrislo

Sorry for the late reply.

After my testing and confirmation, it is not possible to broadcast your own private service uuid when using ble mesh to coexist with ble adv, you can submit a feature request in github and we will support it in the future and sync the information to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants