Is it possible to use build_vars in config_schema?

#1

I would like to build firmware with preconfigured Wifi provided on build time. It is possible to use build vars to achieve this? Following setup doesn’t work:

config_schema:
  - ["wifi.sta.enable", true]
  - ["wifi.sta.ssid", build_vars.WIFI_SSID]
  - ["wifi.sta.pass", build_vars.WIFI_PASS]
#2

Could you clarify please - are you trying to pass name/pass as a command line parameters for the mos build command?
My understanding is that you don’t like to hardcode the strings into the mos.yml file.

#3

Right. I would like to specify SSID and password in the commandline on build.

#4

Apparently that’s not possible at this moment.

The ugly workaround would be to temporarily replace mos.yml with the hardcoded credentials, then restore after build completes.

#5

OK. Thank you for the info.

#6

or modify the yml file with conditionals:

conds:

  • when: build_vars.WIFI == “provisioned”
    apply:
    config_schema:

    • [“wifi.sta.enable”, true]
    • [“wifi.ap.enable”, true]
    • [“wifi.sta.ssid”, “your ssid”]
    • [“wifi.sta.pass”, “your password”]
    • [“wifi.sta1.ssid”, “”]
    • [“wifi.sta1.pass”, “”]
    • [“wifi.sta2.ssid”, “”]
    • [“wifi.sta2.pass”, “”]
  • when: build_vars.WIFI == “notprovisioned”
    apply:
    config_schema:

    • [“wifi.sta.enable”, false]
    • [“wifi.ap.enable”, true]
    • [“wifi.sta.ssid”, “”]
    • [“wifi.sta.pass”, “”]
    • [“wifi.sta1.ssid”, “”]
    • [“wifi.sta1.pass”, “”]
    • [“wifi.sta2.ssid”, “”]
    • [“wifi.sta2.pass”, “”]

build_vars:
WIFI: provisioned

#7

@majorninth thanks, we are using them already, but config filewould be pretty long to include all possible SSIDs and passwords :wink: