Struct mgos_config_wifi_ap issues

Hi all,

I’m hoping to get some help resolving an issue I’m finding with the struct mgos_config_wifi_ap.

I’m attempting to programmatically turn AP and STA on and off at different stages of my program depending on the system state. I followed an example I saw here and have come across some strangeness with the struct mgos_config_wifi_ap.

Looking at the mongoose os docs, the mgos_wifi.h library says the mgos_config_wifi_ap should look like:

struct mgos_config_wifi_ap {
  int enable;
  char *ssid;
  char *pass;
  int hidden;
  int channel;
  int max_connections;
  char *ip;
  char *netmask;
  char *gw;
  char *dhcp_start;
  char *dhcp_end;
  int trigger_on_gpio;
  int disable_after;
  int keep_enabled;
};

But when (from VS code) I follow the source of the struct I find in mgos_config.h a struct that looks like this:

struct mgos_config_wifi_ap {
  const char * ssid;
  const char * pass;
  int channel;
  const char * dhcp_end;
};

Stranger yet is when I follow the source of mgos_wifi.h and I see that there are definitions all over the place that are showing up as errors due to missing struct parameters. But it all seems to compile.

I’m guessing I’m looking in the wrong place for the mgos_config_wifi_ap struct, but I’ve looked everywhere I can think of and can’t find any source that has the extra parameters shown in mgos_wifi.h

At the end of the day I just want to be able to programmatically turn off AP when STA has connected, but it would be great to learn to fish.

Thanks.

mgos_wifi.h is a little outdated regarding the documentation. The actual structure of mgos_config_wifi_ap and mgos_config_wifi_sta is defined by the config_schema in mos.yml.

The generated C structures can be found in build/gen/mgos_config.h:
esp8266:

struct mgos_config_wifi_ap {
  int enable;
  const char * ssid;
  const char * pass;
  int hidden;
  int channel;
  int max_connections;
  const char * ip;
  const char * netmask;
  const char * gw;
  const char * dhcp_start;
  const char * dhcp_end;
  int trigger_on_gpio;
  int disable_after;
  const char * hostname;
  int keep_enabled;
};

esp32:

struct mgos_config_wifi_ap {
  int enable;
  const char * ssid;
  const char * pass;
  int hidden;
  int channel;
  int max_connections;
  const char * ip;
  const char * netmask;
  const char * gw;
  const char * dhcp_start;
  const char * dhcp_end;
  int trigger_on_gpio;
  int disable_after;
  const char * hostname;
  int keep_enabled;
  int bandwidth_20mhz;
  const char * protocol;
};

The additional fields for esp32 are added here

PS. I don’t use VS code, just plane cli.