Situation

A parameter is to be added to an existing profile using an ASCII configuration file containing a Lua script.

Solution

The problem when adding a list parameter to an existing configuration list is that it is necessary to know the number of already existing list entries if another parameter references to this parameter. If the number is unknown or the ASCII configuration is to be applied to different routers with a differing number of list entries, this can be solved using a Lua script to determine the number of existing list entries. We use the example of the Configuration Guide Dual Connection Check with Ping and Triggering an Action to show how to do this. This example uses an ASCII configuration file to add a timer and an event that uses this timer. To use this timer, the event must know the number of it.

Refer to the Lua 5.3 Reference Manual for more information about Lua.

Preparation of the ASCII configuration file

We’ve prepared the following ASCII configuration file for adding the timer and event of above example. Copy and paste it to your text editor or download it using the link below.

The ASCII configuration file will add a timer to an already existing list of timers using the function [last]. Then, an action will be added that uses this timer as a triggering event.

ASCII configuration file
events.timer.timer.add
events.timer.timer[last].active=1
events.timer.timer[last].description=Timer for dual ping check with Lua
events.timer.timer[last].type=interval
events.timer.timer[last].interval_hh=00
events.timer.timer[last].interval_mm=10

events.event_config.event.add
events.event_config.event[last].active=1
events.event_config.event[last].description=Dual ping check with Lua
events.event_config.event[last].event_type=ev_timer
-----LUA-----
cli("events.event_config.event[last].event_timer_name=timer"..cli("events.timer.timer.size").."")
-----LUA-----
events.event_config.event[last].event_action_type=act_ascii
events.event_config.event[last].event_action_ascii=CG_m3_lua_connection_check_script.txt

administration.profiles.activate

A short Lua script is used to determine the size of the timer list and use it to compose the timer name of the added timer. The double dots (..) connect the first string (events.event_config.event[last].event_timer_name=timer) with the result returned from (events.timer.timer.size) and a last, empty string to form the whole command:

Lua script from ASCII configuration file
-----LUA-----
cli("events.event_config.event[last].event_timer_name=timer"..cli("events.timer.timer.size").."")
-----LUA-----

Router configuration

It is prerequisite that you have access to the web interface of the router.

  1. Open web interface of the router using a browser:

    • 192.168.1.1

    • User name: insys (default)

    • Password: icom (default)

  2. In the AdministrationProfiles menu, go to the Import profile or ASCII configuration file section, click on Browse…​ and select the ASCII configuration file that you have downloaded above.

  3. Click on Import profile.

  4. Click on the Apply ASCII configuration icon behind the ASCII configuration file under ASCII configurations (text execute). [1]

  5. Change to the EventsTimer menu to see the timer that has been added at the end of the list.

  6. Change to the EventsEvents menu to see the event that has been added at the end of the list and open this event for editing () to see that above timer is used to trigger the event.


1. This will add the timer and the event to your profile.