Manage WiFi connectivity using SDK

Hello

I have a question about managing WiFi connectivity. First of all, I found this question:  RE: Connect wifi and control wifi connection using code in da16200 , but it wasn't entirely helpful.

Namely, as I see it, the wlanInit() function performs initialization and connects to WiFi. If I’m not mistaken, the same function also enables the chip's Soft AP mode. However, I need the connection to WiFi / activation of Soft AP mode to happen in a different place — specifically, after my part of the code starts executing (the my_function(); shown in the image below).

Inside my function, there's an if-else condition that determines whether to connect to the network or activate Soft AP mode. However, when I move the wlanInit() function to another place, the program never reaches my_function; it gets stuck where the original wlanInit() function was located.

How can I manage the WiFi connection / enable Soft AP mode so that it happens within my my_function instead?

Thanks for your help.