Provision Manager and Mesh coexistence incompatibility

rsimpsonbusa
Posts: 131
Joined: Tue May 17, 2016 8:12 pm

Provision Manager and Mesh coexistence incompatibility

Postby rsimpsonbusa » Mon May 15, 2023 11:59 pm

Hi all.

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 :shock: 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();
I could not "undo" the esp_netif_create_default_wifi_sta() since there is no specific "destroy/uncreate" wifi_sta (maybe use the void esp_netif_destroy_default_wifi(void *esp_netif)? If so can anybody tell me how to get the current *esp_netif?

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.

rsimpsonbusa
Posts: 131
Joined: Tue May 17, 2016 8:12 pm

Re: Provision Manager and Mesh coexistence incompatibility

Postby rsimpsonbusa » Wed May 17, 2023 5:42 pm

I finally figured it out !!!!

Who is online

Users browsing this forum: No registered users and 67 guests