Check WiFi AP mode in C code

If you are asking a question, please follow this template:

  1. My goal is: [How to check System start in WiFi AP mode]
  2. My actions are: [I downloaded the mongoose-os-master.zip but why I could not locate the mgos_wifi.c and esp_wifi.c ??]
  3. The result I see is: []
  4. My expectation & question is:
    [
    mgos_wifi.c:458 WiFi mode: AP
    esp_wifi.c:118 WiFi mode: AP+STA
    ]

I honestly don’t understand neither point from 1 to 4.
If you want to set default AP mode or STA mode then in your mos.yml set that one to enable and the other to disable. If you want AP+STA, then keep both enabled.

  - ["wifi.sta.enable", true]
  - ["wifi.ap.enable", true]

If you want to know if the system is in one or other mode, there are a number of functions you can call, search the forum, it has been answered before. You can also call the usual config functions and get the wifi mode you are interested in:

result = mgos_sys_config_get_wifi_sta_enable();
result = mgos_sys_config_get_wifi_ap_enable();

If you want to set a mode, that will use the complementary functions:

mgos_sys_config_set_wifi_sta_enable(state);
mgos_sys_config_set_wifi_ap_enable(state);

If you want to control the mode at runtime, that is a bit more involved but it also has been answered before in the forum. Search and look at the wifi configuration solutions around, there are libraries you can use; sorry I can’t paste a link right now.

I should have explain better. I am using below in a ESP8266 board
libs:

When holding a button during RESET, the library would enable the AP mode.
I already tried, using “mgos_sys_config_get_wifi_ap_enable()” could not detect the AP mode being enabled.

In the “mgos_wifi.c” line 458
bool mgos_wifi_setup(struct mgos_config_wifi cfg)
{
if (trigger_ap || (cfg->ap.enable && sta_cfg == NULL)) {
struct mgos_config_wifi_ap ap_cfg;
memcpy(&ap_cfg, &cfg->ap, sizeof(ap_cfg));
ap_cfg.enable = true;
LOG(LL_INFO, (“WiFi mode: %s”, “AP”));
/
Disable STA if it was enabled. /
mgos_wifi_setup_sta(&dummy_sta_cfg);
result = mgos_wifi_setup_ap(&ap_cfg);
#ifdef MGOS_WIFI_ENABLE_AP_STA /
ifdef-ok */
}
}

I would like to determine the WiFi mode being setup in real time.

Maybe…
here
or here
you may find some help.
Or perhaps nliviu might guide you.

My issue at the moment is, the library already has the AP mode setup when/how to enable.
However, application level not knowing this is being enabled in AP mode.