Stopping and starting wifi STA and AP modes programmatically

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

  1. My goal is: [describe your goal]
    to be able to switch from ATS mode to AP mode and back again programmatically.

  2. My actions are: [describe your actions - code, commands, etc]
    Cfg.set(‘wifi.ap.enable’, true); // Enable AP mode
    Cfg.set(‘wifi.sta.enable’, false); // Disable STA mode
    let staDisconnect = ffi(‘bool mgos_wifi_dev_sta_disconnect(void)’);
    staDisconnect();

  3. The result I see is: [show the result - log, etc]
    conf9.json saved
    wifi is disconnected
    then it starts back up again.
    Note: connected and PUB/SUBing to AWS at the time.

  4. My expectation & question is: [describe your expectation and your question]
    I expect to be able to stop the STA mode and have AP mode enabled and running and also to be able to do the reverse.

I’m not sure your syntax is ok.

You were right about the syntax…too much bouncing around between mos cmd line, MJS, JavaScript/HTML and C RPC calls, obj and JSON.

ended up with this in MJS:
Cfg.set({wifi: {ap: {enable: true}}}); // Enable WiFi AP mode
Cfg.set({wifi: {sta: {enable: false}}}); // Disable STA mode
Sys.reboot(0);