Settings and Resources

Application Settings

Apps can uniquely configure ZentriOS with ZentriOS variables using the Settings API. In some cases, an app may even need to switch between several different variable configurations.

To simplify the process, the ZentriOS SDK provides a system for storing variable configurations in files. The format is a list of variables with their settings, following the same syntax described in the ZentriOS variables documentation. For example:

# mDNS settings
mdns.enabled  1
mdns.name  http_server

# HTTP Server settings
http.server.enabled  1
http.server.cors_origin  *

The syntax is the same as for a set command for the variable, without the preceding set. If a line in the file starts with a # character, the contents of the line is ignored and assumed to be a comment.

The settings file is stored with the application source, for example with the filename settings.ini.

The location of settings file(s) is specified in the application .mk file, in the value of the $(NAME)_APP_SETTINGS parameter, e.g.

$(NAME)_APP_SETTINGS := settings.ini

Settings file(s) are bundled with the ZentriOS app and downloaded to the device.

To load the ZentriOS variable configuration stored in a settings file, call the API zn_load_app_settings, for example:

 if(zn_load_app_settings("settings.ini") != ZOS_SUCCESS)
    {
        ZOS_LOG("Failed to load settings");
        return;
    }

The settings.ini configuration is referred to by its original filename.

You can edit the settings file in a text editor.

Alternatively, the ZentriOS SDK provides a GUI dialog for editing settings files. To open it, right click on the ZentriOS project, and in the context menu choose ZentriOS/Modify Project Settings.

Then choose the Application Settings tab.

Disabling Settings

When debugging a Zap, it may be convenient to set test variable values via the user console before running the Zap. To prevent the Zap executing the zn_load_app_settings() call and overriding test settings, use the variable zap.debug.ignore_settings.

Application Resources

ZentriOS apps may require file resources such as web pages, security certificates, help files, etc. These resource files must be downloaded to the device when the application is programmed.

To manage resources, use a manifest.json file. The manifest.json is in JSON format. In the manifest "files" object, there is an array of file specifications, each of which has the following parameters:

You can also specify other ZentriOS file properties, such as:

For details of these properties, see ZentriOS File System.

For example:

{
   "files": [
      {
         "local_path": "resources/display_stream.html", 
         "name": "display_stream.html"
      }
   ]
}

The location of manifest file is specified in the application .mk file, in the value of the $(NAME)_RESOURCE_MANIFEST parameter, e.g.

$(NAME)_APP_MANIFEST := resources\manifest.json

During the SDK download step, files specified in the manifest are automatically downloaded to the file system on the device.

Here's an example of a more complex manifest file from the Moray 3D Demo App:

   "files": [
      {
         "flags": 0, 
         "local_path": "resources/moray3d.html", 
         "name": "moray3d.html", 
         "remote_path": "moray3d.html", 
         "type": 254, 
         "version": 134217728
      }, 
      {
         "flags": 0, 
         "local_path": "resources/js/morayAccel.min.js.gz", 
         "name": "morayAccel.min.js.gz", 
         "remote_path": "js/morayAccel.min.js.gz", 
         "type": 254, 
         "version": 134217728
      }, 
      {
         "flags": 0, 
         "local_path": "resources/js/morayModel.min.js.gz", 
         "name": "morayModel.min.js.gz", 
         "remote_path": "js/morayModel.min.js.gz", 
         "type": 254, 
         "version": 134217728
      }, 
      {
         "flags": 0, 
         "local_path": "resources/js/three.min.js.gz", 
         "name": "three.min.js.gz", 
         "remote_path": "js/three.min.js.gz", 
         "type": 254, 
         "version": 134217728
      }, 
      {
         "flags": 0, 
         "local_path": "resources/js/three.renderer.projector.min.js.gz", 
         "name": "three.renderer.projector.min.js.gz", 
         "remote_path": "js/three.renderer.projector.min.js.gz", 
         "type": 254, 
         "version": 134217728
      }
   ], 
   "search_paths": [
      "", 
      "apps/demo/moray3d/resources", 
      "."
   ]
}

You can edit the resources file in a text editor.

Alternatively, the ZentriOS SDK provides a GUI dialog for editing resources files. To open it, right click on the ZentriOS project, and in the context menu choose ZentriOS/Modify Project Settings. See the screen grab above in Application Settings section.

Then choose the Application Resources tab.