Page 1 of 1

ble mesh: combine node and provisioner

Posted: Fri Jul 08, 2022 7:53 am
by luca.cbt
Hi everyone,

I would like to create a device on ESP32 that can dynamically switch between provisioner role and a simple to-be-provisioned node (depending on various external working conditions).

I tried combining the code from the sensor cli/srv example, activating both CONFIG_BLE_MESH_NODE and CONFIG_BLE_MESH_PROVISIONER flags (and also the other related flags), but, after flashing the device, the code panics and reboots continuously.

I also tried merging the fast provisioning example server and client. The merged application works as client, but not as provisioner (it can only provision the first client, then it stops working).

So, I'm wondering: is it possible to create an application that implements both node and provisioner roles?
And how?

Thanks,
Luca

Re: ble mesh: combine node and provisioner

Posted: Mon Oct 17, 2022 5:58 am
by jiabuda
hi,we are develop a project like you said, have you already solve the problem?

i try to enable provisioner and node in menuconfig, but encounter panic and the board restart.

Re: ble mesh: combine node and provisioner

Posted: Tue Dec 26, 2023 3:56 am
by gzk_will
the same problem.

Re: ble mesh: combine node and provisioner

Posted: Wed Dec 27, 2023 12:05 pm
by busadhruv
anyone having a solution then let me know

Re: ble mesh: combine node and provisioner

Posted: Thu Oct 31, 2024 7:18 am
by snutw_
Ok I see many people needing a solution for this - and so do I join them...

Well, it impresses me that luca.cbt was able to provision one device with a merged code...
Interesting how did he managed to reach that? (even as it would still be not sufficient also for me)

And in any case (for the next people looking here for further help), I can hint at teh other thread started by him:
https://esp32.com/viewtopic.php?f=13&t= ... 44#p100344

Seems since so many people have trouble with this issue, then it could be really reasonable to include such example in the IDF.
It seems that even knowledgeable people like chegewara seem to have been still checking some of these features not a long time ago

Re: ble mesh: combine node and provisioner

Posted: Tue Nov 05, 2024 8:00 am
by chegewara
Ok I see many people needing a solution for this - and so do I join them...

Well, it impresses me that luca.cbt was able to provision one device with a merged code...
Interesting how did he managed to reach that? (even as it would still be not sufficient also for me)

And in any case (for the next people looking here for further help), I can hint at teh other thread started by him:
https://esp32.com/viewtopic.php?f=13&t= ... 44#p100344

Seems since so many people have trouble with this issue, then it could be really reasonable to include such example in the IDF.
It seems that even knowledgeable people like chegewara seem to have been still checking some of these features not a long time ago
Thank you for kind words, but i am not that "knowledgable" as you may think. I am just hard working with some topics, like ble, ble mesh or usb, and it takes me hundreds hours to learn stuff. Then, when i have some knowledge and i see other people struggling with problems like this, i am trying to see if its possible to make it works and this way i am learning new stuff. I am just thinking about this as an exercise.

As to some questions in this topic i can try answer, based on my limited knowledge:
- yes, it should be possible to switch between provisioner and node, as you can run both, provisioner and node, in the same time

Some time ago i started working on ble mesh library, which is currently on hold, but it should be fairly easy to test provisioner + node:
https://github.com/chegewara/esp32-ble- ... nouncement

Why i started to work on it?
- because i think that ble mesh is cool feature and it is worth to learn it and to have it in my portfolio
Why is it on hold?
- for few reasons; lack of time, i am focusing on other stuff like USB and esp32-p4, my brain is not in good shape lately and it takes me much more time to do some codding etc

Re: ble mesh: combine node and provisioner

Posted: Tue Nov 05, 2024 1:47 pm
by snutw_
Thank you for kind words, but i am not that "knowledgable" as you may think. I am just hard working with some topics, like ble, ble mesh or usb, and it takes me hundreds hours to learn stuff. Then, when i have some knowledge and i see other people struggling with problems like this, i am trying to see if its possible to make it works and this way i am learning new stuff. I am just thinking about this as an exercise.
Well it is not entirely ESP's fault, because the Bluetooth SIG organization did in it's technology specification a division between clients and servers...
So well my not very patient boss wants me to go for Bluetooth without a mesh so we could sell the product sooner.. Even though I dunno if switching to regular BLE will indeed simplify this matter. Since I am not sure if there it is simpler, or it also has such a division designed to keep having to separate softwares.
Anyway nice to know you are also from Poland. :) Even though I've recently relocated south-east.

Re: ble mesh: combine node and provisioner

Posted: Wed Nov 13, 2024 3:02 pm
by snutw_
Ok it is not that hard to combine a node and a provisioner in single software. I mean from the fast provisioning example you can take all the files and simply run one or the other role (server or client) depending on a condition that is deciding if this particular device now should be a provisioner or a provisioned node. Not an elegant solution, but it's and easy and fast starting point.
(and add the options of sdkconfig)

Re: ble mesh: combine node and provisioner

Posted: Tue Nov 26, 2024 2:50 pm
by snutw_
- yes, it should be possible to switch between provisioner and node, as you can run both, provisioner and node, in the same time
So you say, that it sould be possible to run both a provisioner and a node in the same time.
Well I have started with the fast provisioning BLE Mesh example from the IDF.
After merging client and server in the same software it connects indeed.
But there is a problem when a node reconnetcs. It is a rather typical situation as many devices just want to deep sleep, and after waking up to connect again.
The provisioner keeps printing "Device has already been provisioned". It comes from idf/components/bt/esp_ble_mesh/core/prov_pvnr.c.
So I tried in sdkconfig to store BLE Mesh settings (BLE_MESH_SETTINGS), but hm it does not help. But looks at least like some settings do get saved and loaded judging by the LOG messages that are printed.
For me it is suspicious that while the provisioner after restard reads its models connected to the CID.
But the node is not reading any saved models.
Now it seems like after initialization, both provisioner and the node give no more BLE Mesh console output, even though calls to esp_ble_mesh_client_model_send_msg or esp_ble_mesh_server_model_send_msg return ESP_OK.
Before initialization ends the node has -120 error at ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT. Well these negative BLE Mesh error codes are confusing, as they are not corresponding to the normal Espressif codes. Another thread on this forum with a question for explanation did not get any answer.
Are these codes from components/lwip/lwip/src/include/lwip/errno.h?
Is it ok to have client running concurrently with provisioner and server with a node?
I do have a proper partition ble_mesh. Hm maybe its similar to what other people complain: that their settings are also not stored:
https://github.com/espressif/esp-idf/issues/8942
You can maintain a humble attitude, but I see that you have joined ESP team in fixing the IDF. :)
https://github.com/espressif/esp-idf/issues/12871

edit:
Ok, loading settings works, they even exchange some opcodes after the reboot, but not the messages I give them to send. :(

Re: ble mesh: combine node and provisioner

Posted: Thu Dec 05, 2024 3:22 pm
by snutw_
Ah it was not that terribly hard. :) Quite crucial to working it out was to learn about a requirement to clean the already saved network in the device before proceeding further.
And the node (not provisisoner) needed to call example_handle_config_app_key_add_evt function from the example's code after loading the network settings from memory.