IoT Open Tech
Home
  • Platform
  • Modules
  • Devices
Guides
Changelog
Home
  • Platform
  • Modules
  • Devices
Guides
Changelog
  • Stories

    • My first look into Edge apps
      • My first look into Edge Apps
      • Setup and configuration
      • Logic implementation
      • The complete code
      • Publishing to the web
    • FunctionX status API
    • OpenWeather and IoT Open
    • Duplicate function data
    • Create a calculated function
    • ChirpStack to Lynx

Setup and configuration

What does the app need

I need some parameters to be set by the user for this app to work. First the user has to select the door that will start the timer, secondly the light to be controlled needs to be selected. The third parameter will be the time in seconds for the light to be on.

Set up a test environment

It is possible to run the app as a standalone program using the programs accompanying the edged package. With some extra parameters I can specify the executable file to run, and the config file to load for that application. I can trigger functions to be called to verify that all logic in the callbacks works as intended.

I create the config file with the parameters I wanted to use. It should look like the response from GET /api/v2/edge/app/configured/{installation_id}/{instance_id}.

I saved the config as config.json with this content:

{
  "id": 455,
  "app_id": 32,
  "installation_id": 23,
  "version": "1.0.0",
  "config": {
    "trigger_function": 2,
    "actuator_function": 12,
    "timeout": 5
  },
  "name": "My test run",
  "created": 1600676011,
  "updated": 1600676011
}

To run apps there is a wrapper program included in the edge daemon. This program can be run with the command edge-app. I used the following parameters to test my app:

edge-app -l app.lua -a config.json -r 1

This will run in the terminal. While the program is running the following RPC calls can be done to test the logic.

Write + enterDescription
destroyApp()Call onDestroy
createApp()Call onCreate
updateFunctions()Read the downloaded FunctionX data and call the onFunctionsUpdated callback

CTRL-C will cancel the execution and call the onExit callback.

Last updated:
Prev
My first look into Edge Apps
Next
Logic implementation