BLE and BLE Mesh coexistence?

bluefan
Posts: 3
Joined: Tue Sep 22, 2020 8:58 am

BLE and BLE Mesh coexistence?

Postby bluefan » Tue Sep 22, 2020 10:52 am

Dear forum,

I am trying to program a device that will be both a standard BLE client (scan devices, connect to them, read/write GATT attributes, disconnect) as well as a BLE Mesh node/relay that can control other devices in the network. I'm still studying the BLE Mesh architecture, it's a pretty steep learning curve and confusing, but as far as I understand so far that would require the device to be a relay + node + proxy.

My question is: Can the ESP32 BLE operate in both of these modes at the same time?
If so, are there any examples for this sort of device?


I already have the simple BLE working (thanks for the great examples espressif team!), can connect to BLE devices as needed. So far I just tried adding bits of the onoff_client example code, called the init after initing normal BLE, which kind of killed the scanning functionality:

Code: Select all

E (287166) BT_BTM: BTM_BleScan scan already active
W (287167) BT_APPL:  bta_dm_ble_scan start scan failed. status=0x6

Thanks,

bluefan

iotdeveloperfw
Posts: 10
Joined: Tue Sep 22, 2020 4:53 pm

Re: BLE and BLE Mesh coexistence?

Postby iotdeveloperfw » Tue Sep 22, 2020 4:58 pm

I have the same doubt, please Espresiff staff could you answer the question?

esp_liu
Posts: 35
Joined: Wed Nov 28, 2018 4:12 am

Re: BLE and BLE Mesh coexistence?

Postby esp_liu » Wed Sep 23, 2020 2:49 am

bluefan wrote:
Tue Sep 22, 2020 10:52 am
Dear forum,

I am trying to program a device that will be both a standard BLE client (scan devices, connect to them, read/write GATT attributes, disconnect) as well as a BLE Mesh node/relay that can control other devices in the network. I'm still studying the BLE Mesh architecture, it's a pretty steep learning curve and confusing, but as far as I understand so far that would require the device to be a relay + node + proxy.

My question is: Can the ESP32 BLE operate in both of these modes at the same time?
If so, are there any examples for this sort of device?


I already have the simple BLE working (thanks for the great examples espressif team!), can connect to BLE devices as needed. So far I just tried adding bits of the onoff_client example code, called the init after initing normal BLE, which kind of killed the scanning functionality:

Code: Select all

E (287166) BT_BTM: BTM_BleScan scan already active
W (287167) BT_APPL:  bta_dm_ble_scan start scan failed. status=0x6

Thanks,

bluefan
Hi,

If BLE Mesh device is enabled, e.g. calling esp_ble_mesh_node_prov_enable() successfully, then the BLE advertising and scan will be both enabled by the mesh stack. And in this case, if the application tries to invoke the ESP BLE related functions, for example, start advertising or scanning, this will have impact on the mesh stack, and probably some error log will be output like the above ones.

And if the normal BLE advertising packets need to be notified to the application layer when mesh is enabled, some specific event needs to be added to the mesh event group, i.e. an event used for receiving the other BLE advertising packets.

Thanks.

bluefan
Posts: 3
Joined: Tue Sep 22, 2020 8:58 am

Re: BLE and BLE Mesh coexistence?

Postby bluefan » Wed Sep 23, 2020 6:11 am

Thanks for the replies.

So, if I understand the replies correctly, then it's not possible without serious modifications to the underlying stack, since the two frameworks essentially 'steal' one anothers events?

Thanks,

bluefan

esp_liu
Posts: 35
Joined: Wed Nov 28, 2018 4:12 am

Re: BLE and BLE Mesh coexistence?

Postby esp_liu » Wed Sep 23, 2020 9:14 am

bluefan wrote:
Wed Sep 23, 2020 6:11 am
Thanks for the replies.

So, if I understand the replies correctly, then it's not possible without serious modifications to the underlying stack, since the two frameworks essentially 'steal' one anothers events?

Thanks,

bluefan
For BLE scan, currently yes. Because when mesh is enabled, the other scanned BLE advertising packets will be ignored, unless specific modifications are made for notifying them to the application. Later we may add some events for this kind of requirements.

For BLE advertising, currently we added a option in the menuconfig to support advertisng normal BLE packets when mesh is enabled.
The option is "Support sending normal BLE advertising packets".

Thanks.

bluefan
Posts: 3
Joined: Tue Sep 22, 2020 8:58 am

Re: BLE and BLE Mesh coexistence?

Postby bluefan » Fri Sep 25, 2020 1:02 pm

Thanks for the information.

I'm still kind of getting my head around BLE and BLE Mesh.

If I would be OK without the BLE scan feature and fed it addresses directly, could they coexist? I'm guessing that no, but I'm hoping :)

flow75
Posts: 1
Joined: Sat Oct 16, 2021 1:47 pm

Re: BLE and BLE Mesh coexistence?

Postby flow75 » Sat Oct 16, 2021 2:01 pm

Hi guys,

I see this topic is already 1 year old, but I also stumbled over that problem and I saw there is now a solution.

There aren't any examples yet and stuff is not documented, but now it's working to register a callback to the mesh stack and receive the "normal" BLE advertising packages in user code:


In menuconfig it must be selected
BLE Mesh and BLE coexistence support,
especially the BLE_MESH_SUPPORT_BLE_SCAN option.

Code: Select all

#include "scan.h" //bt_mesh_start_ble_scan
#include "esp_ble_mesh_ble_api.h"

//create user callback:
static void ble_mesh_scan_cb(esp_ble_mesh_ble_cb_event_t event,
                             esp_ble_mesh_ble_cb_param_t *param){
										   
ESP_LOGI(MESH_SCAN_CB_TAG, "event  =%x\n"event);    																					  										   										   
}

//register user callback:
esp_ble_mesh_register_ble_callback(ble_mesh_scan_cb);


//start receiving advertising packages with my callback:
struct bt_mesh_ble_scan_param sparam;
sparam.duration = GATTC_SCAN_DURATION_SEC; //this has no effect.. not implemented in scan.h..
bt_mesh_start_ble_scan(&sparam);



Officially this was implemented in ESP-IDP 4.3-beta:
https://newreleases.io/project/github/e ... v4.3-beta3

But in 4.2 (updated) it also works well.

BR,

Who is online

Users browsing this forum: No registered users and 256 guests