Does anybody know a way to have the Provision Manager routines (BLE interface) and a Mesh routines coexist in the same App?
Idea is that when NOT PROVISIONED we go thru the usual provision steps (BLE) chose whatever Access Point one wants, save as usual to NVS then REBOOT or just continue, as is usual, with whatever app you want.
What I expected:
1._ On boot call the Prov manger to check if it is provisioned, if not go thru the process and return.
2._ Just go ahead setting up the mesh and starting it.
What is happening:
In my case I have really weird crashes, error messages from the mesh manager and finally if it starts working at all, it will behave very erratically allowing connections just to dump them, crash in the mbed section and other stuff.
What i have done:
I did make a routine ONLY to check if provisioned, with minimal setups for the provisioning manager. Similar crash and other issues..
Then I did a manual process by enabling and disabling certain code in the app, instead of the "automatic/usual"
1._ Erase NVS/Prov so as to force a new provisioning(Erase Flash or whatever means). Reboot.
2._ System detects no provisioning. Provisioning goes as expected.
3._ Disable the routine that calls the prov manager, compile and re-flash Reboot
4._ System now skipping the provisioning calls and goes directly to the mesh process.
The mesh connects without a single warning, error or crash.
But if I skip 3, it returns saying it is provisioned(yes) and as per usual de_initing the prov manager etc, but the mesh app goes ballistic.
Seems to be that the prov manager required steps (esp-netif, event group, event handler, etc) are not undone by the wifi_prov_mgr_deinit() call. So I helped him by undoing all the wifi calls like event handler, got ip and all that stuff
Code: Select all
ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_PROV_EVENT, ESP_EVENT_ANY_ID, &event_handler));
ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler));
ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler));
esp_event_loop_delete_default();
esp_wifi_deinit();
Anyway its a mess , I will have to use an internal logic where the App will know that it is or not provisioned so as to call or not call the provisioning code. I thought that I just should call the provision_manager which will do its stuff, you are or not provisioned, deinit_prov and go on with your app, but not working for me.
Thanks for any help.