Skip to main content
Version: 2.14.4 - 2.14.0

Common

This category contains functions that are used for all the devices.

api.ledControl(state)

Turns ON or OFF the on board LED.

tip

It can be also used for debugging purposes.

api.delayms(ms)

Pauses the execution for ms milliseconds.

api.randInt(min, max)

Generates random number within given range.

warning

Available only for LoRaWAN devices (function uses it's module to generate random number)

api.getUniqueNumber()

Generates unique number.

info

Function increases uint32_t variable by one every time this function is called then it returns it's value. It's in range (in range from 0 to 2^32)*

api.getBatteryVoltage()

Retrieves the current voltage level of the battery in mV.

api.getTick()

Returns current number of milliseconds since startup.

info

Counts up to 2^32 and then restarts from 0. By default it's using RTC derived tick which is incremented during sleep, but it's possible to explicitly select systick, which is not.

api.dumpArray(str)

Prints contents of variable as hexadecimal string (dumps array into console).

api.float(operation, form, arg1, arg2)

Performs operation with given floating point data.

danger

Only available if it's allowed by the firmware.

api.setVar(index, ...)

Saves a persistent variable value.

info

Can be used between different wake up iterations.

api.getVar(index)

Returns persistent variable value.

info

Can be used between different wake up iterations.

api.wakeUpAt(day, hour, minute, second)

Schedules the next wake up event of the device to provided day of month, hour, minute and second.

info

The provided wake up date is therefore absolute and not relative as in api.wakeUpIn().

api.wakeUpIn(day, hour, minute, second)

Schedules the next wake up event of the device after specified time interval.

info

The provided wake up date is therefore relative and not absolute as in api.wakeUpAt().

note

The input arguments are not limited, but the total period specified must not exceed 31 days. (e.g. hour = 40, days = 2 gives a period of 3 days and 16 hours).

api.getTimeDate()

Returns current date and time set on this device.

info

The time can be synchronized over LoRa, or when uploading LUA script using LUA scripting interface.

api.getTimeDate(timezone)

  • timezone (integer, optional) - Return time zone shift: 1 - ON, 0 - OFF

api.setTimeDate(...)

Set date and time on this device, or calculate the difference and synchronize the date and time.

api.voltageSourceState(state)

Controls voltage source.

danger

Only for variants with voltage source. The adjustable voltage option is only available for variant with adjustable voltage source.

api.stdin(option, ...)

Reads stdin (standard input) data or control button (get status, wait for button).

note

This function is using serial line, therefore use of this function in an interactive console (GUI) is not possible.

api.stdout(out)

Writes to stdout (standard output) without adding line termination.

tip

Can be useful when implementing raw serial protocols.

api.bsprintf(binData, format)

Formats binary stream data according to various format specifiers, including support for characters, integers, short and long integers, floats, and doubles.

api.setVerbosity(num)

Controls the number of messages printed to the serial line.

api.exec(command, ...)

Executes a system command or Lua fragment.

info

Additionally uploaded Configuration API extension, according to https://ieeexplore.ieee.org/document/8733437.

api.table(operation, ...)

Interface to create and manipulate memory-efficient tables and maps.

tip

Check multimode script or sendOnce script for example usage.

api.aes(operation, data, iv, key)

Encrypts or decrypts provided payload using a key and IV with AES-CTR.

tip

See this section for more information and examples.