- My goal is: Have more than 3 SSID defined in the wifi.sta nodes
- My actions are: add a new object to wifi.sta3
- The result I see is: Not working
- My expectation & question is: Is it possible to have more than 3 defined stations in the wifi config mode?, is yes, is there a max number of sta to be defined?
The wifi library supports only 3 station configurations. It’s easy to extend to more then that.
Thanks @nliviu. Do you know where I can find a good tutorial about MOS and compiling libraries local in order to modify the libraries?
I tried last week on my own with no success
Cheers
FBP
You need to install docker, set the local origin of the library in mos.yml
and run mos build --local --platform xxx
Ex:
- origin: ../libs/lib1
My directory layout is something like this
app-dir
app1
app2
libs
lib1
lib2
Thanks @nliviu, I have found:
#define NUM_STA_CFG 3
In mgos_wifi.c and changed to 5, plus added to the mos.yml:
- ["wifi.sta3", "wifi.sta", {title: "WiFi Station Config 3"}]
- ["wifi.sta3.enable", false]
- ["wifi.sta4", "wifi.sta", {title: "WiFi Station Config 4"}]
- ["wifi.sta4.enable", false]
The only local lib reference in the main mos.yml is:
- origin: ../libs/wifi
But it still scans until #3 (sta2), is there any other part where the max # of STA is defined?
Yes, there are some other changes necessary. Just read the code
Found it, for anyone else needing to extend the number of STA
File: mgos_wifi_c.h:
Define the number of STA:
#define NUM_STA_CFG 5
Extend case use to the number of STA:
static const struct mgos_config_wifi_sta *mgos_wifi_get_sta_cfg(
const struct mgos_config_wifi *cfg, int idx) {
if (cfg == NULL) return NULL;
switch (idx) {
case 0:
return &cfg->sta;
case 1:
return &cfg->sta1;
case 2:
return &cfg->sta2;
case 3:
return &cfg->sta3;
case 4:
return &cfg->sta4;
}
return NULL;
}
Great work. I suggest you submit that as a PR to the cesanta team.
ps, easiest way to submit a small PR is browse to the file on github (ie https://github.com/mongoose-os-libs/wifi/blob/master/src/mgos_wifi.c) and click the edit icon. You can edit in the browser and submit a PR all in 2 minutes flat. Much easier than the old fork the library, clone, change it, commit, go back to github and create a PR.
And if you do that, helps to modify the doc page https://mongoose-os.com/docs/mongoose-os/api/net/wifi.md with your note on the NUM_STA_CFG variable limit of 3, but you can change that if building locally.