Common
api.ledControl(state)
- Overview
- Arguments
- Example
Turns ON or OFF the on board LED. It can be also used for debugging purposes.
- state (integer) - sets LED state (1=ON, 0=OFF)
--turns on blue LED
api.ledControl(1)
api.delayms(ms,mode)
- Overview
- Arguments
- Example #1
- Example #2
- Example #3
Pause the execution for ms milliseconds.
- ms (integer) - The number of milliseconds to delay (in range from 0 to 2147483647)
- mode (integer)(optional) - use sleep in longer intervals:
- 1 - if the interval ms is longer than 10 ms, sleep
- 2 - sleep for defined amount of milliseconds
api.delayms(1000) --delay one second
api.ledControl(1) -- turn on blue LED
api.delayms(1000) -- wait 1 second
api.ledControl(0) -- turn off blue LED
api.delayms(1000,2) -- sleep for one second, then continue in the process
api.randInt(min, max)
- Overview
- Arguments
- Return
- Example
Generate random number within given range.
Available only for LoRaWAN devices (function uses it's module to generate random number)
- min (integer) - beginning number of the interval (in range from 0 to 2147483647)
- max (integer) - end number of the interval (in range from 0 to 2147483647)
- number (Integer)
-- generates random number within interval from 5 to 20
ran=api.randInt(5, 20)
api.getUniqueNumber()
- Overview
- Return
- Example
Calling this 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)*
- num (integer) - Unique number (in range from 0 to 2^32)*
--get an unique number
num = api.getUniqueNumber()
api.getBatteryVoltage()
- Overview
- Return
- Example
Get curent battery voltage in mV.
- voltage (Integer)
--get battery voltage value in mV
mv = api.getBatteryVoltage()
api.getTick(int)
- Overview
- Arguments
- Return
- Example
Returns current number of milliseconds since startup. 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 isn't.
- int (integer) (optional)
- 2 to use RTC derived tick and return value in seconds
- 1 to use RTC derived tick and return value in ms (default)
- 0 to use systick (value in ms)
- int (integer) (optional) (if first argument is 0)
- 1 - reset systick value to 0
- 0 - do not reset the systick (default)
- tick (integer) - Value according to argument (in seconds / milliseconds)
--get a timestamp, can be used for timing
timestamp = api.getTick()
-- to show the amount of milliseconds you can use print() function
print(timestamp)
api.dumpArray(str, opt)
- Overview
- Arguments
- Example
Prints contents of variable as hexadecimal string (dumps array into console)
- str (string) - variable to print
- opt (string)(optional) - optional argument defining type of print
- "normal" - printing method used by default
- "raw" - prints only the raw values
--print string "123ef" as hexadecimal
api.dumpArray("123ef")
-- output
-- 00 : 31 32 33 65 66
--print string "123ef" as hexadecimal raw
api.dumpArray("123ef","raw")
-- output
-- 31 32 33 65 66