Meaning of "o" or "b" and "i"

["foo", "o", {title: "my app settings"}]
["foo.enable", "b", true, {title: "Enable foo"}]

I have questions about the meaning of “o” or “b” and sometime “i” on the above code, usually they are written in the mos.yml file.
what are they? and how many letter are they? how & when to use them?

- ["", "i", 5, {title: "GPIO pin a sensor is attached to"}]

i’m assuming " i " mean intger, what does 5 mean ?

The config_schema section of the mos.yml provides a way to define configuration options for the device and override options defined elsewehre (e.g. in alibrary).

 - ["app", "o", {title: "My app settings"}]                                # "o"=object
 - ["", "s", "My app name", {title: "Application's name"}]         # "s"=string
 - ["app.led_pin", "i", 2, {title: "LED pin. Default GPIO2"}]              # "i"=int
 - ["app.led_enable", "b", true, {title: "LED enable. Default true"}]      # "b"=bool
 - ["app.interval", "d", 123.45, {title: "A double value"}]                # "d"=double
 - ["app.uint_val", "ui", 12345678, {title: "An unsigned integer value"}]  # "ui"=unsigned int
 - ["i2c.enable", true]                                                    # overrides i2c.enable from the i2c library

During the build process, each object defined in the config_schema will be compiled in a C structure (the boolean type is translated to int with values 0 for false and 1 for true):

struct mgos_config_app {
  const char * name;
  int led_pin;
  int led_enable;
  double interval;
  unsigned int uint_val;

The default values can be changed at runtime running, e.g

mos config-set app.led_enable=false
mos config-set"New app"

These settings can be used in your code to do an action according to their values:

  if((mgos_sys_config_get_app_led_pin() > 0) && mgos_sys_config_get_app_led_enable()){
    // toggle the led

Thank you Mr. Nliviu for the fast reply :blush:, make sense now,

Thanks again, I really appreciate it

how can we do like this but not get override by mos.yml

In runtime user may change the config then we want to keep user change in flash memory.
I will put some method for initial that config in production. like…

void initSystemConfig () { // This is factory default setup function will get call by developer only!!!
if(mgos_config_app.version!=1) {
mgos_config_app.version = 1; // 1 mean already initial or restore to factory setting
mgos_config_app.interval = 2; // default factory setting

  then save mgos_config_app where ?? how ??


So after mgos_config_app has been initial it will get last save from user only to used during runtime.
How can I do it?

Configuration API.

It doesn’t work like that.
You have to user getters and setters:mgos_sys_config_get_app_version() and mgos_sys_config_set_app_version(value)

ok I get it. when user make change then we perform

mgos_sys_config_save(&mgos_sys_config, false, NULL);

and this will keep in file system some where can’t rollback to conf0.json it and also retained after OTA as well am I correct ?

mgos_sys_config_save saves the settings in conf9.json.
The conf0.json is not used anymore to store the defaults. They are harcoded in build/gen/mgos_config.c during the build process.
After OTA update confX.json are copied over in the new fs partion from the old one.

Is there are anymore type ?

I forgot the float value:

- ["app.float_val", "f", 123.45, {title: "A float value"}]                # "f"=float

The list is here.