Microtronics AppLog Entries

Description

Make rapidM2M's device logic a little bit more look like all these ...uino platforms

OVERVIEW

Abstract:

The predefined texts for the AppLog event codes and parameters described in this section are used by the libraries provided by Microtronics. They are grouped by topic.

It is also recommended to use these predefined AppLog messages in your own library and applications if suitable to simplify the interpretation of log messages across several different applications.

Usage example:
applog(MT_BACKUPSUPPLY, MT_BACKUPSUPPLY_BATTERY_ACTIVE);

Shutdown Handling

Constants_for_Shutdown_Handling:
Event CodeParameterExplanation
ConstantPlain textConstantPlain text
MT_BACKUPSUPPLYMT.BackupSupplyMT_BACKUPSUPPLY_BATTERY_ACTIVESwitched to buffer batterySupply switched to the rechargeable buffer battery
MT_BACKUPSUPPLYMT.BackupSupplyMT_BACKUPSUPPLY_EXT_SUPPLY_ACTSupply voltage available againSupply switched back to the ext. supply voltage input (VIN)
MT_BACKUPSUPPLYMT.BackupSupplyMT_BACKUPSUPPLY_OUTAGE_EXPIREDOutage timeout expiredTime expired for which a short-term supply voltage failure is ignored
MT_SHUTDOWNMT.ShutdownCommand to shut down the system issued by the Device Logic

Software Update

Constants_for_Software_Update:
Event CodeParameterExplanation
ConstantPlain textConstantPlain text
MT_APPUPDATEDMT.AppUpdatedMT_APPUPDATED_VERSIONINFOFrom V%d to V%dThe DLO has been updated from version x to version y.
%d ... previously installed version (x)
%d ... currently installed version (y)
MT_APPCHANGEDMT.AppChangedMT_APPCHANGED_VERSIONINFOFrom %s, V%d to %s, V%dThe DLO was replaced by another DLO.
%s ... pipAppId of previously installed DLO
%d ... version of previously installed DLO
%s ... pipAppId of currently installed DLO
%d ... version of currently installed DLO
MT_MODFWUPDATEDMT.ModFwUpdatedMT_MODFWUPDATED_VERSIONINFO%s: from %s to %sThe firmware of one of the modules in the device has been updated.
%s ... designation of the module (e.g. IO controller)
%s ... previously installed FW version
%s ... currently installed FW version

µino DLO Pawn

Description

Make rapidM2M's device logic a little bit more look like all these ...uino platforms

MEM

memcpy(dst, dstofs, src, srcofs, bytes, _dstCells=sizeof dst, _srcCells=sizeof src)

copy bytes from one buffer to the other

Throws assertion if extents of dst or src are exceeded.
dst[] : u8 - destination buffer
dstofs : s32 - offset into dst
src[] : u8 - source buffer
srcofs : s32 - offset into src
bytes : s32 - number of bytes to copy
returns : void
memcmp(src1, src1ofs, src2, src2ofs, bytes, _src1cells=sizeof src1, _src2cells=sizeof src2)

compare two buffers byte by byte

Throws assertion if extents of src1 or src2 are exceeded.
src1[] : u8 - buffer #1
src1ofs : s32 - offset into src1
src2[] : u8 - buffer #2
src2ofs : s32 - offset into src2
bytes : s32 - number of bytes to compare
returns : s32
0 - src1 equals to src2
<0 - src1 < src2
>0 - src1 > src2
memtostr(str, mem, memofs, bytes, _strCells=sizeof str, _memCells=sizeof mem)

convert a byte buffer into hex string

Throws assertion if bytes exceeds extents of str or mem.
str : astr - output string buffer
mem[] : u8 - binary source data
memofs : s32 - offset where to start reading from mem
bytes : s32 - number of bytes to stringify from mem
MEMTOSTR_SPACES - flag to delimit bytes with spaces
MEMTOSTR_UPPERCASE - flag to use A..F instead of a..f
returns : void
memset(dst, dstofs, srcval, bytes=S32_MAX, _dstcells=sizeof dst)
The writing range is silently clamped to the extents of dst.
dst[] : u8 - destination buffer
dstofs : s32 - offset into dst
srcval : u8 - value to write into each element of dst
bytes : s32 - number of bytes to write, or fill all if not given
returns : void
bufset(buf, bufofs=0, srcval=0, count=S32_MAX, _bufcells=sizeof buf)
The writing range is silently clamped to extents of buf.
buf[] : s32 - destination buffer
bufofs : s32 - offset into buf
srcval : u8 - value to write into each element of buf
count : s32 - number of elements to write, or fill all if not given
returns : void
TmemValue

type of value for mempeek() and mempoke()

Tu8 - unsigned 8bit
Tu16 - unsigned 16bit, little endian
Tu16be - unsigned 16bit, big endian
Tu32 - unsigned 32bit, little endian
Tu32be - unsigned 32bit, big endian
Ts8 - signed 8bit
Ts16 - signed 16bit, little endian
Ts16be - signed 16bit, big endian
Ts32 - signed 32bit, little endian
Ts32be - signed 32bit, big endian
Tf32 - float 32bit, little endian
Tf32be - float 32bit, big endian
mempoke(mem, memofs, valtype, val)

write a value into a memory buffer

mem[] : u8 - memory buffer
memofs : s32 - offset into memory buffer where to write to
valtype : TmemValue
val : s32 - integer value to write
mempeek(mem, memofs, valtype)

read value from a memory buffer

mem[] : u8 - memory buffer
memofs : s32 - offset into memory buffer where to read from
valtype : TmemValue
returns : s32 - value read as integer
mempokef32(mem, memofs, valtype, val)

write a value into a memory buffer

mem[] : u8 - memory buffer
memofs : s32 - offset into memory buffer where to write to
valtype : TmemValue
val : f32 - float value to write
mempeekf32(mem, memofs, valtype)

read a value from a memory buffer

mem[] : u8 - memory buffer
memofs : s32 - offset into memory buffer where to read from
valtype : TmemValue
returns : f32 - value read as float

TIMERS

setInterval(cb, ms)
Repeatedly execute a callback in a given interval.
  • setInterval() and setTimeout() share the same group of typ. 7 system timers (e.g. limited to typ. 7 concurrent calls)
  • setInterval( ..., 1000) uses an extra group of typ. >30 further system timers (e.g. additional typ. 30 concurrent calls)
  • Automatically clears the timer, if the given callback has already been used for another timer. Therefore, it is not necessary to call clearInterval() before reinitialising.
  • cb : TonTimer - Callback to be executed
    ms : s32 - Milliseconds to wait between executions
    returns : Terror
    OK - if successful
    ERROR - if one of the following errors occurs
  • Out of timers (maximum number reached)
  • Callback invalid
  • Internal error
  • < OK - if another error occurs, see Terror
    clearInterval(cb)
    Undo a setInterval. The call is silently ignored, if the given interval has not been setup.
    cb : TonTimer - Same as used with setInterval
    setImmediate(cb)
    Execute a callback as soon as possible, similar to setTimeout( ..., 0)
  • May fail on older runtime released before 2019.
  • Automatically clears the timer, if the given callback has already been used for another timer. Therefore, it is not necessary to call clearTimeout() before reinitialising.
  • cb : TonTimer - Callback to be executed
    returns : Terror
    OK - if successful
    ERROR - if one of the following errors occurs
  • Out of timers (maximum number reached)
  • Callback invalid
  • Internal error
  • < OK - if another error occurs, see Terror
    setTimeout(cb, ms)
    Execute a callback just once after some delay.
    Upon expiration, the timer object is free'd automatically before calling <cb>
  • setInterval() and setTimeout() share the same group of typ. 7 system timers (e.g. limited to typ. 7 concurrent calls)
  • Automatically clears the timer, if the given callback has already been used for another timer. Therefore, it is not necessary to call clearTimeout() before reinitialising.
  • cb : TonTimer - Callback to be executed
    ms : s32 - Milliseconds to wait, should be >0
    Use setImmediate() for ms==0.
    returns : Terror
    OK - if successful
    ERROR - if one of the following errors occurs
  • Out of timers (maximum number reached)
  • Callback invalid
  • Internal error
  • < OK - if another error occurs, see Terror
    clearTimeout(cb)
    Undo a setTimeout. The call is silently ignored, if the given timeout has not been setup or already expired.
    cb : TonTimer - Same as used with setTimeout
    TonTimer()
    Execute this function (without any parameters or result).
    warmupElapsed(&lastStamp, interval_s, warmup_s)

    check if next full mulitple of interval, shifted by warmup time, reached

    Typ. used to trigger warmup phase N seconds before a capture.
    momentElapsed, debounceElapsed
    lastStamp : Tstamp32 - static buffer provided by the app; declare as
    static t_;
    interval_s : s32 - interval between moments [s]
    warmup_s : s32 - timeshift [s] before moment reached; must be 1 ... interval_s-1
    returns : bool - true if start of warmup reached
    Example:
    #define CAPTURE_INTERVAL_S 60 #define WARMUP_TIME_S 10 #callback onTimerTick() { static tw_, tc_; if( warmupElapsed( tw_, CAPTURE_INTERVAL_S, WARMUP_TIME_S)) { sensorOn(); // turn on sensor supply to start measurment } if( momentElapsed( tc_, CAPTURE_INTERVAL_S)) { sensorRead(); // capture sensor value sensorOff(); // turn off sensor supply DDE_xxx_write(); // record sensor values } }
    momentElapsed(&lastStamp, interval_s, fireonce=0)

    check if next full mulitple of moment-interval reached

    Typ. used to trigger capture and recording of instantaneous values which apply to a single point of time. Their stamp refers to "now".
    warmupElapsed, periodElapsed, debounceElapsed
    lastStamp : Tstamp32 - static buffer provided by the app; declare as
    static t_;
    interval_s : s32 - interval between moments [s]
    fireonce : bool - triggers immediately upon the very first call, even if now() is not a full multiple of the interval.
    returns : bool - true if moment reached
    Example:
    #histdata9 instvalues vm s32
    #callback onTimerTick() { // === capture AND record value static t_; if( momentElapsed( t_, 60)) { new buf[DDE_instvalues]; buf.vm= captureValue(); DDE_instvalues_write( t_, buf); } }
    periodElapsed(&lastStamp, duration_s, fireonce=0)

    check if next full mulitple of period-interval reached

    Use this with a single histdata container only - do not combine with multiple histdata, alerts or applog containers!
    Typ. used to trigger recording of some avg/min/max/ values which apply to a time range (with several captures taken).
    While recording is done immediately after the period's end, the recording's stamp refers to the period's start.
    momentElapsed, debounceElapsed, cycleElapsed
    lastStamp : Tstamp32 - static buffer provided by the app; declare as
    static t_;
    duration_s : s32 - length of a period [s]
    fireonce : bool - triggers immediately upon the very first call, even if now() is not a full multiple of the interval.
    returns : bool - true if period's end reached
    Example:
    #histdata0 avgvalues vp s32
    #callback onTimerTick() { // === capture value (oversampling) static sum_=0; static cnt_=0; sum_= sum_ + captureValue(); cnt_++; // === record value static t_; if( periodElapsed( t_, 60)) { new buf[DDE_avgvalues]; buf.vp= sum_ / cnt_; // build avg sum_= 0; cnt_= 0; // then reset aggregator DDE_avgvalues_write( t_, buf); } }
    cycleElapsed(&timer, cycleTime_s, immediate=false)

    Trigger an action every cycleTime_s seconds. The cycle starts with the first call (and NOT /w full multiple of cycleTime_s).

    periodElapsed
    timer : Tstamp32 - static buffer provided by the app; declare as
    static t_; Contains 0 for reset, or date/time when activity will be triggered next.
    cycleTime_s : s32 - [s] number of seconds for one cycle; must be >0;
    immediate : bool - true triggers activity immediately upon very first call.
    returns : bool - true when action is triggered
    To reset the cycle timer, simply set it to 0.
    Example:
    static cycleTimer_; #callback onButtonPressed(pressed) { if(pressed) cycleTimer_= 0; // restart cycle timer } #callback loop() { if( cycleElapsed( cycleTimer_, 15)) { // if button is pressed, it will take longer than just 15s! #log( "just another 15s are over"); } } init() { watchButton( onButtonPressed); setInterval( loop, 1000); } ...
    debounceElapsed(&timer, debounceTime_s, changedSignal)

    Trigger an action after value changed and becomes stable for some time

    1. When changes signaled, then
    2. Wait until no changes are signaled for some time, then
    3. Trigger an action by returning true once
    Typ. used to smooth values which bounce shortly when changing from one stable state to another.This can help to reduce write operations which in fact saves energy and transmission efforts.
    timer : Tstamp32 - static buffer provided by the app; declare as
    static t_;
    debounceTime_s : s32 - [s] time to wait after
    last change signaled until action triggered
    changedSignal : bool - signal that underlying value has changed
    returns : bool - true when action is triggered
    Example:
    #config0 status up dlo-volatile val s32
    #callback appLoop() { // capture value new v= captureBouncingValue(); // detect changes static status[DDE_status]; new chgd= changed( status_.val, v); // wait for value to become stable before sending it to the backend static tdebounce_; if ( debounceElapsed( tdebounce_, 15, chgd)) DDE_status_write( status_) }
    throttleElapsed warmupElapsed momentElapsed periodElapsed
    throttleElapsed(&timer, throttleTime_s, changedSignal)

    Trigger a delayed action after the first change in value

    1. When changes signaled, then
    2. Wait some time ignoring any further changes, then
    3. Trigger an action by returning true once
    Typ. used together with lazy volatile #configX containers (configx_volatile) to reduce number of FLASH writes.This helps to save energy and extends FLASH life-time without restricting data avaibility.
    timer : Tstamp32 - static buffer provided by the app; declare as
    static t_;
    throttleTime_s : s32 - [s] time to wait after
    first change signaled until action triggered
    changedSignal : bool - signal that underlying value has changed
    returns : bool - true when action triggered
    Example:
    #config0 status up dlo-volatile=lazy val s32
    #callback appLoop() { // capture value new v= captureValue(); // detect changes static status[DDE_status]; new chgd= changed( status_.val, v); // upon changes: send data to backend if (chgd) DDE_status_write( status_); // 60s after first change: persist recent data to flash static tthrottle_; if ( debounceElapsed( tthrottle_, 60, chgd)) DDE_status_persist(); }
    debounceElapsed warmupElapsed momentElapsed periodElapsed
    stampToISOString(utc)

    convert UTC stamp into ISO 8601 string "yyyy-mm-ddThh:nn:ssZ"

    utc : Tstamp32
    returns : string
    rM2M_TimerAdd rM2M_TimerRemove rM2M_TimerAddExt rM2M_TimerRemoveExt

    DATE & TIME

    date_time:

    See StdLib for further features such as

  • rM2M_GetTime
  • rM2M_GetDate
  • rM2M_GetTimezoneOffset
  • rM2M_DoW
  • Tstamp32
  • Tstamp32

    seconds since 31.12.1999 0:00

    Due to it's s32 storage, values will
  • go negative in the year 2065
  • wrap around in the year 2130
  • now()
    Get current (absolute) date and time in [seconds]
    returns : Tstamp32
    new stamp= now();
    nowTicks()
    Get current (absolute) date and time in [1/256s ticks]
    returns : s32 - ticks since 31.12.1999 0:00
    This is a 31bit value which wraps around every 97days
    nowMs()
    Get current (absolute) date and time in [1ms]
    returns : s32 - milliseconds since 31.12.1999 0:00
    This is a 31bit value which wraps around every 24days

    DIGITAL PINs

    M22X:

    pinMode(const pin, const mode=RM2M_GPIO_DISABLED)

    Sets the pin mode for a GPIO.

    Changing the pinMode() may have an impact on neighbour pins due to groupwise level-shifter disable/enable.
  • Default after boot is DISABLED
  • Any digitalWrite() switches implicitly to OUTPUT
  • Any digitalRead() switches implicitly to INPUT
  • pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    mode : s32 - Signal direction to be used for the GPIO:
    undefined - Disable pin to minify power consumption → TrM2M_GPIO_DIR.RM2M_GPIO_DISABLED
    OUTPUT - Set pin to output → TrM2M_GPIO_DIR.RM2M_GPIO_OUTPUT
    INPUT - Set pin to input → TrM2M_GPIO_DIR.RM2M_GPIO_INPUT
    It is recommended to use this function instead of rM2M_GpioDir()
    digitalWrite(const pin, const value)

    Sets the output level of a GPIO.

    Forces pinMode to OUTPUT and sets the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    value : TpinValue - Specification of the level to be issued.
    It is recommended to use this function instead of rM2M_GpioSet()
    digitalRead(const pin)

    Reads the signal level of a GPIO.

    Forces pinMode to INPUT before reading the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    returns : TpinValue - Current level of the pin
    It is recommended to use this function instead of rM2M_GpioGet()
    digitalPeek(const pin)

    Reads the signal level of a GPIO.

    If the pinMode has not yet been initialized (e.g. using pinMode(), digitalWrite(), digitalRead() or a previous call of digitalPeek()) the pinMode is set to "INPUT" before reading the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    returns : TpinValue - Current level of the pin
    Tpin

    Number of GPIO pin, ranging from 0 (= first GPIO of the device) to PIN_COUNT-1

    PIN_COUNT -

    total number of pins; depends on current device hardware

    TpinValue: s32

    Signal levels of the GPIOs

    0 - "low" signal level
    1 - "high" signal level
    any other - digitalWrite() only: set pin to "high"

    M23X:

    pinMode(const pin, const mode=RM2M_GPIO_DISABLED)

    Sets the pin mode for a GPIO.

    Changing the pinMode() may have an impact on neighbour pins due to groupwise level-shifter disable/enable.
  • Default after boot is DISABLED
  • Any digitalWrite() switches implicitly to OUTPUT
  • Any digitalRead() switches implicitly to INPUT
  • pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    mode : s32 - Signal direction to be used for the GPIO:
    undefined - Disable pin to minify power consumption → TrM2M_GPIO_DIR.RM2M_GPIO_DISABLED
    OUTPUT - Set pin to output → TrM2M_GPIO_DIR.RM2M_GPIO_OUTPUT
    INPUT - Set pin to input → TrM2M_GPIO_DIR.RM2M_GPIO_INPUT
    It is recommended to use this function instead of rM2M_GpioDir()
    digitalWrite(const pin, const value)

    Sets the output level of a GPIO.

    Forces pinMode to OUTPUT and sets the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    value : TpinValue - Specification of the level to be issued.
    It is recommended to use this function instead of rM2M_GpioSet()
    digitalRead(const pin)

    Reads the signal level of a GPIO.

    Forces pinMode to INPUT before reading the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    returns : TpinValue - Current level of the pin
    It is recommended to use this function instead of rM2M_GpioGet()
    digitalPeek(const pin)

    Reads the signal level of a GPIO.

    If the pinMode has not yet been initialized (e.g. using pinMode(), digitalWrite(), digitalRead() or a previous call of digitalPeek()) the pinMode is set to "INPUT" before reading the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    returns : TpinValue - Current level of the pin
    Tpin

    Number of GPIO pin, ranging from 0 (= first GPIO of the device) to PIN_COUNT-1

    PIN_COUNT -

    total number of pins; depends on current device hardware

    TpinValue: s32

    Signal levels of the GPIOs

    0 - "low" signal level
    1 - "high" signal level
    any other - digitalWrite() only: set pin to "high"

    M3IOTBOX:

    pinMode(const pin, const mode=RM2M_GPIO_DISABLED)

    Sets the pin mode for a GPIO.

    Changing the pinMode() may have an impact on neighbour pins due to groupwise level-shifter disable/enable.
  • Default after boot is DISABLED
  • Any digitalWrite() switches implicitly to OUTPUT
  • Any digitalRead() switches implicitly to INPUT
  • pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    mode : s32 - Signal direction to be used for the GPIO:
    undefined - Disable pin to minify power consumption → TrM2M_GPIO_DIR.RM2M_GPIO_DISABLED
    OUTPUT - Set pin to output → TrM2M_GPIO_DIR.RM2M_GPIO_OUTPUT
    INPUT - Set pin to input → TrM2M_GPIO_DIR.RM2M_GPIO_INPUT
    It is recommended to use this function instead of rM2M_GpioDir()
    digitalWrite(const pin, const value)

    Sets the output level of a GPIO.

    Forces pinMode to OUTPUT and sets the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    value : TpinValue - Specification of the level to be issued.
    It is recommended to use this function instead of rM2M_GpioSet()
    digitalRead(const pin)

    Reads the signal level of a GPIO.

    Forces pinMode to INPUT before reading the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    returns : TpinValue - Current level of the pin
    It is recommended to use this function instead of rM2M_GpioGet()
    digitalPeek(const pin)

    Reads the signal level of a GPIO.

    If the pinMode has not yet been initialized (e.g. using pinMode(), digitalWrite(), digitalRead() or a previous call of digitalPeek()) the pinMode is set to "INPUT" before reading the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    returns : TpinValue - Current level of the pin
    Tpin

    Number of GPIO pin, ranging from 0 (= first GPIO of the device) to PIN_COUNT-1

    PIN_COUNT -

    total number of pins; depends on current device hardware

    TpinValue: s32

    Signal levels of the GPIOs

    0 - "low" signal level
    1 - "high" signal level
    any other - digitalWrite() only: set pin to "high"

    T32X:

    pinMode(const pin, const mode=RM2M_GPIO_DISABLED)

    Sets the pin mode for a GPIO.

    Changing the pinMode() may have an impact on neighbour pins due to groupwise level-shifter disable/enable.
  • Default after boot is DISABLED
  • Any digitalWrite() switches implicitly to OUTPUT
  • Any digitalRead() switches implicitly to INPUT
  • pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    mode : s32 - Signal direction to be used for the GPIO:
    undefined - Disable pin to minify power consumption → TrM2M_GPIO_DIR.RM2M_GPIO_DISABLED
    OUTPUT - Set pin to output → TrM2M_GPIO_DIR.RM2M_GPIO_OUTPUT
    INPUT - Set pin to input → TrM2M_GPIO_DIR.RM2M_GPIO_INPUT
    It is recommended to use this function instead of rM2M_GpioDir()
    digitalWrite(const pin, const value)

    Sets the output level of a GPIO.

    Forces pinMode to OUTPUT and sets the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    value : TpinValue - Specification of the level to be issued.
    It is recommended to use this function instead of rM2M_GpioSet()
    digitalRead(const pin)

    Reads the signal level of a GPIO.

    Forces pinMode to INPUT before reading the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    returns : TpinValue - Current level of the pin
    It is recommended to use this function instead of rM2M_GpioGet()
    digitalPeek(const pin)

    Reads the signal level of a GPIO.

    If the pinMode has not yet been initialized (e.g. using pinMode(), digitalWrite(), digitalRead() or a previous call of digitalPeek()) the pinMode is set to "INPUT" before reading the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    returns : TpinValue - Current level of the pin
    Tpin

    Number of GPIO pin, ranging from 0 (= first GPIO of the device) to PIN_COUNT-1

    PIN_COUNT -

    total number of pins; depends on current device hardware

    TpinValue: s32

    Signal levels of the GPIOs

    0 - "low" signal level
    1 - "high" signal level
    any other - digitalWrite() only: set pin to "high"

    NRF91:

    pinMode(const pin, const mode=RM2M_GPIO_DISABLED)

    Sets the pin mode for a GPIO.

    Changing the pinMode() may have an impact on neighbour pins due to groupwise level-shifter disable/enable.
  • Default after boot is DISABLED
  • Any digitalWrite() switches implicitly to OUTPUT
  • Any digitalRead() switches implicitly to INPUT
  • pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    mode : s32 - Signal direction to be used for the GPIO:
    undefined - Disable pin to minify power consumption → TrM2M_GPIO_DIR.RM2M_GPIO_DISABLED
    OUTPUT - Set pin to output → TrM2M_GPIO_DIR.RM2M_GPIO_OUTPUT
    INPUT - Set pin to input → TrM2M_GPIO_DIR.RM2M_GPIO_INPUT
    It is recommended to use this function instead of rM2M_GpioDir()
    digitalWrite(const pin, const value)

    Sets the output level of a GPIO.

    Forces pinMode to OUTPUT and sets the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    value : TpinValue - Specification of the level to be issued.
    It is recommended to use this function instead of rM2M_GpioSet()
    digitalRead(const pin)

    Reads the signal level of a GPIO.

    Forces pinMode to INPUT before reading the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    returns : TpinValue - Current level of the pin
    It is recommended to use this function instead of rM2M_GpioGet()
    digitalPeek(const pin)

    Reads the signal level of a GPIO.

    If the pinMode has not yet been initialized (e.g. using pinMode(), digitalWrite(), digitalRead() or a previous call of digitalPeek()) the pinMode is set to "INPUT" before reading the pin. See pinMode() for potential complications.
    pin : Tpin - Number of the GPIO, starting with 0 for the first GPIO of the device.
    returns : TpinValue - Current level of the pin
    Tpin

    Number of GPIO pin, ranging from 0 (= first GPIO of the device) to PIN_COUNT-1

    PIN_COUNT -

    total number of pins; depends on current device hardware

    TpinValue: s32

    Signal levels of the GPIOs

    0 - "low" signal level
    1 - "high" signal level
    any other - digitalWrite() only: set pin to "high"

    DIGITAL PINs /w INTERRUPT

    watchPin()
    Not available, use setWatch()
    setWatch(wpin, wmode, cb=-1)
    Applies automatically clearWatch() if wpin is already watched.
    wpin : s32 - ranging from 0 up to WATCH_COUNT-1
    wmode : WATCH_RISING|WATCH_FALLING
    cb : TonWatch - optional; when omitted setWatch behaves similar to clearWatch()
    It is not possible to trigger on both edges at the same time, but there is an alternative solution for this affair - see code snippet below.
    // --- // watch on both edges // --- #callback onPin( pinHi) { // watch for next pin change setWatch( 0, pinHi ? WATCH_FALLING : WATCH_RISING, onPin); // do somehting depending on current pin state #log( pinHi ? "risen" : "fallen"); } main() { // start watching pin changes // - needs decision to start with either falling or rising edge setWatch( 0, WATCH_FALLING, onPin); }
    WATCH_COUNT -

    total number of watchable pins

    clearWatch(wpin)

    The call is ignored if no watch has been set yet.

    wpin : s32 - ranging from 0 up to WATCH_COUNT -1
    TonWatch(pinHi)
    pinHi : s32 - Current state of pin (0=low, 1=high)

    UPLINK

    watchUplinkConfigs(const cb)
    cb : TonUplinkConfig
    TonUplinkConfig(cfg)
    cfg : s32 - Index (0 based) of config just received from uplink.
    0...9

    UPLINK - REGISTRY

    registryWrite(reg, key, num)

    write numeric value to registry

    Intelligent write - e.g. executes only if value really changes.
    Use this function instead of rM2M_RegSetValue() to minify stress for FLASH memory.
    reg : TrM2M_RegId - accepts only:
    rM2M_REG_APP_FLASH
    rM2M_REG_APP_OTP
    rM2M_REG_APP_STATE
    key : astr - name of registry entry
    num : s32|f32 - numeric value to write
    returns : TrM2M_RegError
    rM2M_RegSetValue
    registryWriteString(reg, key, str)

    write string value to registry

    Intelligent write - e.g. executes only if value really changes.
    Use this function instead of rM2M_RegSetString() to minify stress for FLASH memory.
    reg : TrM2M_RegId - accepts only:
    rM2M_REG_APP_FLASH
    rM2M_REG_APP_OTP
    rM2M_REG_APP_STATE
    key : astr - name of registry entry
    str : astr - string value to write
    returns : TrM2M_RegError
    rM2M_RegSetString
    registryWrite_PIP()

    report installed application, version and build stamp to registry

    Sets these registry values of RM2M_REG_APP_OTP:

  • pipAppId:astr - value of APM_PIP_ID taken from project settings field "PIP ID"; fallback to "not-set-yet-{{APM_ID}}"
  • pipAppVer:s32 - [1+] value of APM_VERSION which is the current tag version (e.g. APP head version)
  • pipAppBuild:astr - value of APM_BUILD_STAMP, "yyyy-mm-dd hh:nn:ss"
  • All APM_xxx constants are to be found in "dlo/~auto.dde"

    Best practice is to call this function once during each application boot which is done implicitly by salve().
    TRegWifiSecurity: s32 -
    WIFI_SEC_AUTO - autodetect WIFI security
    WIFI_SEC_WPA_PSK - → TWIFI_SEC
    WIFI_SEC_OPEN - → TWIFI_SEC
    WIFI_SEC_WEP - → TWIFI_SEC
    WIFI_SEC_802_1X - → TWIFI_SEC
    registryWrite_WIFI(ssid, pwd, ?sec, ?ipcfg, ?region)

    setup WiFi interface configuration and authentication

    Sets these registry values of RM2M_REG_APP_FLASH:
  • .wifiSSID:astr
  • .wifiPwd:astr
  • .wifiIpCfg:astr (optional)
  • .wifiRegion:astr (optional)
  • When using the ~uplink library, this function is implicitely called by uplinkSetItf_Wifi().
    ssid : astr
    pwd : astr
    sec : TRegWifiSecurity - optional; defaults to WIFI_SEC_AUTO
    ipcfg : astr - optional; setup the interface either for DHCP or static IP:
  • use DHCP for ip configuration (default)
    "DHCP"
  • use static ip configuration
    // STATIC;<IP>;<MASK>;<GATEWAY>;<DNS> "STATIC;192.168.1.10;255.255.255.0;192.168.1.1;192.168.1.1"
  • region : astr - optional; setup .wifiRegion
    "EUROPE" - default if not set
    "ALL"
    "NORTH_AMERICA"
    "ASIA"
    Internally, the security type is added as prefix-string to the .wifiSSID parameter
  • "WPA_PSK;xxx"
  • "802_1X;xxx"
  • "OPEN;xxx"
  • "WEP;xxx"
  • registryWrite_LAN(ipcfg)

    setup LAN interface configuration

    Sets these registry values of RM2M_REG_APP_FLASH:
  • .ethIpCfg:astr
  • When using the ~uplink library, this function is implicitely called by uplinkSetItf_Lan().
    ipcfg : astr - setup the interface either for DHCP or static IP:
  • use DHCP for ip configuration (default)
    "DHCP"
  • use static ip configuration
    // STATIC;<IP>;<MASK>;<GATEWAY>;<DNS> "STATIC;192.168.1.10;255.255.255.0;192.168.1.1;192.168.1.1"
  • MATH

    changed(&ref, val, mindiff=1)

    check if val changed (by at least mindiff)

    static myref_= S32_MIN; // preset with some out-of-scope value to grant inital trigger of changed if (changed( myref_, readMeasurement())) { #log("changed to %d", myref); }
    ref : s32 - global/static reference value to detect changes of val; automatically updated if val changes.
    val : s32 - current value to check for changes
    mindiff : s32 - >0, optional; absolute difference required to raise changed signal
    returns : bool - true if val differs from ref
    random(range=0)

    get random number

    Uses rand() function if firmware/hardware supports it, or emulates the random value otherwise.
    range : s32 - optional; [1...S32_MAX]
    returns : s32 - random value, either
  • [S32_MIN ... S32_MAX] when range not set, or
  • [0 ... range] otherwise
  • rand
    indexOf(list[], key, startIdx=0, takeEndIfNotFound=false)

    get index of first key inside list

    key : s32 - value to look for
    list[] : s32 - list of values to look in
    startIdx : s32 - index of first item to check; <0 = counting from behind end of list; -1 represents the last item of the list.
    takeEndIfNotFound : bool - default=false, see @return
    returns : s32 - item index inside list[] where key is found
    first.

    if key not found the result is -1, or the number of list items if takeEndIfNotFound=true

    lastIndexOf
    lastIndexOf(list[], key, startIdx=-1, takeEndIfNotFound=false)

    get index of

    last key inside list
    key : s32 - value to look for
    list[] : s32 - list of values to look in
    startIdx : s32 - index of first item to check; <0 = counting from behind end of list; -1 represents the last item of the list.
    takeEndIfNotFound : bool - default=false, see @return
    returns : s32 - item index inside list[] where key is found
    last.

    if key not found the result is -1, or the number of list items if takeEndIfNotFound=true

    indexOf

    STRINGS

    s32ToStr(val, decimals)

    convert fix comma number into string

    val : s32 - numeric input value
    decimals : s32 - [9..-9] digit-shift for the fix-comma value. Examples:
    #log( s32ToStr(1234,1)); // → "123.4" #log( s32ToStr(1234,6); // → "0.001234" #log( s32ToStr(1234,-1); // → "12340"
    returns : astr
    u32ToStr(val, decimals)

    convert fix comma number into string

    Although the actual data type of "val" is s32, this function interprets the data type as u32 when "val" is converted to a string.
    val : s32 - numeric input value
    decimals : s32 - [9..-9] digit-shift for the fix-comma value. Examples:
    #log( u32ToStr(1234,1)); // → "123.4" #log( u32ToStr(1234,6); // → "0.001234" #log( u32ToStr(1234,-1); // → "12340"
    returns : astr
    s32ToNamurStr(val, decimals=0)

    convert number into string with NAMUR tokens

    Inspired by NAMUR NE43.

    val : s32 - numeric input value or NAMUR like constant such as S32_OL,...
    decimals : s32 - optional; states the digit-shift if val contains a fix-comma value (similar to s32ToStr())

    Example: s32ToNamurStr(1234,1) → "123.4"

    returns : astr - stringified number or one of the following string-tokens:
  • "OL" - S32_OL
  • "SC" - S32_SC
  • "OF" - S32_OF
  • "UF" - S32_UF
  • "NaN" - S32_NAN
  • s16ToNamurStr(val, decimals=0)

    convert number into string with NAMUR tokens

    Inspired by NAMUR NE43.

    val : s32 - numeric input value or NAMUR like constant such as S16_OL,...
    decimals : s32 - optional; states the digit-shift if val contains a fix-comma value (similar to s32ToStr())

    Example: s16ToNamurStr(1234,1) → "123.4"

    returns : astr - stringified number or one of the following string-tokens:
  • "OL" - S16_OL
  • "SC" - S16_SC
  • "OF" - S16_OF
  • "UF" - S16_UF
  • "NaN" - S16_NAN
  • s8ToNamurStr(val, decimals=0)

    convert number into string with NAMUR tokens

    Inspired by NAMUR NE43.

    val : s32 - numeric input value or NAMUR like constant such as S8_OL,...
    decimals : s32 - optional; states the digit-shift if val contains a fix-comma value (similar to s32ToStr())

    Example: s8ToNamurStr(123,1) → "12.3"

    returns : astr - stringified number or one of the following string-tokens:
  • "OL" - S8_OL
  • "SC" - S8_SC
  • "OF" - S8_OF
  • "UF" - S8_UF
  • "NaN" - S8_NAN
  • u32ToNamurStr(val, decimals=0)

    convert unsigned number into string with NAMUR tokens

    Inspired by NAMUR NE43.

    Although the actual data type of "val" is s32, this function interprets the data type as u32 when "val" is converted to a string.
    val : s32 - numeric input value or NAMUR like constant such as U32_OL,...
    decimals : s32 - optional; states the digit-shift if val contains a fix-comma value (similar to u32ToStr())

    Example: u32ToNamurStr(1234,1) → "123.4"

    returns : astr - stringified number or one of the following string-tokens:
  • "OL" - U32_OL
  • "SC" - U32_SC
  • "OF" - U32_OF
  • "UF" - U32_UF
  • "NaN" - U32_NAN
  • u16ToNamurStr(val, decimals=0)

    convert unsigned number into string with NAMUR tokens

    Inspired by NAMUR NE43.

    val : s32 - numeric input value or NAMUR like constant such as U16_OL,...
    decimals : s32 - optional; states the digit-shift if val contains a fix-comma value (similar to s32ToStr())

    Example: u16ToNamurStr(1234,1) → "123.4"

    returns : astr - stringified number or one of the following string-tokens:
  • "OL" - U16_OL
  • "SC" - U16_SC
  • "OF" - U16_OF
  • "UF" - U16_UF
  • "NaN" - U16_NAN
  • u8ToNamurStr(val, decimals=0)

    convert unsigned number into string with NAMUR tokens

    Inspired by NAMUR NE43.

    val : s32 - numeric input value or NAMUR like constant such as U8_OL,...
    decimals : s32 - optional; states the digit-shift if val contains a fix-comma value (similar to s32ToStr())

    Example: u8ToNamurStr(123,1) → "12.3"

    returns : astr - stringified number or one of the following string-tokens:
  • "OL" - U8_OL
  • "SC" - U8_SC
  • "OF" - U8_OF
  • "UF" - U8_UF
  • "NaN" - U8_NAN
  • COMMON

    noop()

    do nothing! - typ. used to avoid "036: empty statement" errors

    TRUE()

    returns always true; typ. used to avoid "206: redundant test" warnings

    COLORS

    Trgb: s32

    32bit color, 0x00RRGGBB

    CO_DEFAULT = -1 - return to automatic control by firmware
    CO_OFF = 0x000000 - same as CO_BLACK
    CO_BLACK = 0x000000 - same as CO_OFF
    CO_DKGRAY = 0x404040
    CO_GRAY = 0x808080
    CO_LTGRAY = 0xc0c0c0
    CO_WHITE = 0xffffff
    CO_RED = 0xff0000
    CO_GREEN = 0x00ff00
    CO_BLUE = 0x0000ff
    CO_YELLOW = 0xffff00
    CO_CYAN = 0x00ffff
    CO_MAGENTA = 0xff00ff
    CO_ORANGE = 0xff6000
    CO_DKRED = 0x600000
    CO_DKGREEN = 0x006000
    CO_DKBLUE = 0x000080
    CO_DKYELLOW = 0x606000
    CO_DKCYAN = 0x006060
    CO_DKMAGENTA = 0x600060
    CO_DKORANGE = 0x602000

    RUNTIME

    Tperf

    used by perfStop() to accumulate long-term stats

    perfStart()

    start performance measurement

    Each perfStart() requires a perfStop() to follow, before another perfStart() is allowed (no concurrency!).
    returns : void
    perfStop() for an example
    perfStop(prefix, perf)

    finish performance measurement andprint results to console if changed

    prefix : astr - some text to identify the program location
    perf : Tperf - buffer to hold recent stats for change detection
    returns : void
    Example
    foo() { perfStart(); // ... // application code // ... static perf_[Tperf]; perfStop( "foo ", perf_); }

    CONSOLE

    CONSOLE_BUFFER_BYTES -

    overrides default console buffer size (4k)

    Requires salve() to be called
    // increase to 6000 bytes #define CONSOLE_BUFFER_BYTES 6000
    // turn off extra console buffer #define CONSOLE_BUFFER_BYTES 0
    main() { salve(...); }
    salve(onAppInit, flags=0)

    prepare device for application start

    1. Increase console buffer (to 4k by default, see CONSOLE_BUFFER_BYTES to change this)
    2. Print a boot message to the console
    3. Report installed application - registryWrite_PIP()
    4. Start extended debug interface if rmStudio is detected
    Calling salve() should be the very first command inside main().
    Remove any setbuf() - it's already called by salve().
    onAppInit : function() - execute when we are ready to proceed with application initialization
    flags : s32
    SALVE_NOHELLO - disable boot message
    SALVE_NOXDBG - disable extended debug interface even if there is rmStudio detected
    SALVE_FORCEXDBG - enable extended debug interface even if there is NO rmStudio detected
    returns : void
    Example
    #callback init() { // app's boot code... } main() { salve( init); // this should be the first (and only) line in main() }
    setbuf

    SYSTEM

    getTemperature()

    read internal temperature sensor

    Available on ALL deviceprofiles (IoTBox, BLEGW, easyIoT, easyV3,...) with these restrictions
    • T32x - returns the value captured at previous call
      • cyclic call of getTemperature() at short inverval <15s recommended
      • very first call (after boot) always returns a safe fallback of 20°C
    • M22x, M23x, ... all devices w/o internal sensor - return just simulated random values, starting at 20°C (an adequate warning appears in the compiler output)
    returns : s32 - [0,1°C] or S32_OL if internal sensor fails (an error message appears in the console output)
    IoTbox_GetSysValues
    BLEGW_GetSysValues
    EasyV3_GetSysValues
    T32_TempGet

    LED

    M22X:

    setLed(rgb, mode=LED_STATIC, count=0)

    control the (onboard) system LED(s)

    Colors behave slightly different depending on the underlying hardware's capabilities:
  • M22x, M23x: They have just an unconnected open-drain output titled "Status LED", on which you have to connect some LED by your own. Any color != 0 drags this output pin against GND.
  • NRF91: Has one dedicated pin (P0.28) for this function, on which you have to connect some LED by your own. Any color != 0 sets this output pin to "High".
  • easyV3, easyIoT: They have 2 integrated LEDs - red and green. Any red color turns on the red LED, any green color turns on the green LED.
  • IoT-Box: Has full RGB support on it's integrated LED.
  • T32x: Has basic RGB support w/o dimming capability, i.e. any color value >0 turns the appropriate LED color on.
  • BLE-Gateway: There is no LED available, use the integrated display instead.
  • Note that this function controls on M22x, M23x and NRF91 just an unconnected digital output. You need to connect some LED by your own.
    rgb : Trgb -
    0xRRGGBB - 24bit color code
    CO_BLACK - black, e.g. turn off
    CO_DEFAULT - give LED control back to firmware (former CO_AUTOMATIC)
    mode : s32 - optional;
    LED_STATIC - default
    LED_BLINK
    LED_FLICKER
    LED_FLASH
    LED_FLASH_ONCE - flash just once w/o giving the count parameter
    LED_BLINK_ONCE - blink just once w/o giving the count parameter
    count : s32 - optional;
    0 - forever (default)
    others - duration; ignored with LED_STATIC
    Examples
    setLed( rrggbb); // turn LED to color rrggbb setLed( CO_BLACK); // turn LED off setLed( rrggbb, LED_BLINK, 5); // blink LED 5 times setLed( rrggbb, LED_FLASH); // flash LED forever setLed( rrggbb, LED_FLASH_ONCE); // same as setLed( RGB, LED_FLASH, 1) setLed( -1); // give back LED to firmware

    M23X:

    setLed(rgb, mode=LED_STATIC, count=0)

    control the (onboard) system LED(s)

    Colors behave slightly different depending on the underlying hardware's capabilities:
  • M22x, M23x: They have just an unconnected open-drain output titled "Status LED", on which you have to connect some LED by your own. Any color != 0 drags this output pin against GND.
  • NRF91: Has one dedicated pin (P0.28) for this function, on which you have to connect some LED by your own. Any color != 0 sets this output pin to "High".
  • easyV3, easyIoT: They have 2 integrated LEDs - red and green. Any red color turns on the red LED, any green color turns on the green LED.
  • IoT-Box: Has full RGB support on it's integrated LED.
  • T32x: Has basic RGB support w/o dimming capability, i.e. any color value >0 turns the appropriate LED color on.
  • BLE-Gateway: There is no LED available, use the integrated display instead.
  • Note that this function controls on M22x, M23x and NRF91 just an unconnected digital output. You need to connect some LED by your own.
    rgb : Trgb -
    0xRRGGBB - 24bit color code
    CO_BLACK - black, e.g. turn off
    CO_DEFAULT - give LED control back to firmware (former CO_AUTOMATIC)
    mode : s32 - optional;
    LED_STATIC - default
    LED_BLINK
    LED_FLICKER
    LED_FLASH
    LED_FLASH_ONCE - flash just once w/o giving the count parameter
    LED_BLINK_ONCE - blink just once w/o giving the count parameter
    count : s32 - optional;
    0 - forever (default)
    others - duration; ignored with LED_STATIC
    Examples
    setLed( rrggbb); // turn LED to color rrggbb setLed( CO_BLACK); // turn LED off setLed( rrggbb, LED_BLINK, 5); // blink LED 5 times setLed( rrggbb, LED_FLASH); // flash LED forever setLed( rrggbb, LED_FLASH_ONCE); // same as setLed( RGB, LED_FLASH, 1) setLed( -1); // give back LED to firmware

    M2BLEGW:

    setLed()
    Function not available on this module.
    Use the display to signal information to the user.
    Display_SetValues()

    M2EASYIOT:

    setLed(rgb, mode=LED_STATIC, count=0)

    control the (onboard) system LED(s)

    Colors behave slightly different depending on the underlying hardware's capabilities:
  • M22x, M23x: They have just an unconnected open-drain output titled "Status LED", on which you have to connect some LED by your own. Any color != 0 drags this output pin against GND.
  • NRF91: Has one dedicated pin (P0.28) for this function, on which you have to connect some LED by your own. Any color != 0 sets this output pin to "High".
  • easyV3, easyIoT: They have 2 integrated LEDs - red and green. Any red color turns on the red LED, any green color turns on the green LED.
  • IoT-Box: Has full RGB support on it's integrated LED.
  • T32x: Has basic RGB support w/o dimming capability, i.e. any color value >0 turns the appropriate LED color on.
  • BLE-Gateway: There is no LED available, use the integrated display instead.
  • Note that this function controls on M22x, M23x and NRF91 just an unconnected digital output. You need to connect some LED by your own.
    rgb : Trgb -
    0xRRGGBB - 24bit color code
    CO_BLACK - black, e.g. turn off
    CO_DEFAULT - give LED control back to firmware (former CO_AUTOMATIC)
    mode : s32 - optional;
    LED_STATIC - default
    LED_BLINK
    LED_FLICKER
    LED_FLASH
    LED_FLASH_ONCE - flash just once w/o giving the count parameter
    LED_BLINK_ONCE - blink just once w/o giving the count parameter
    count : s32 - optional;
    0 - forever (default)
    others - duration; ignored with LED_STATIC
    Examples
    setLed( rrggbb); // turn LED to color rrggbb setLed( CO_BLACK); // turn LED off setLed( rrggbb, LED_BLINK, 5); // blink LED 5 times setLed( rrggbb, LED_FLASH); // flash LED forever setLed( rrggbb, LED_FLASH_ONCE); // same as setLed( RGB, LED_FLASH, 1) setLed( -1); // give back LED to firmware

    M2EASYV3:

    setLed(rgb, mode=LED_STATIC, count=0)

    control the (onboard) system LED(s)

    Colors behave slightly different depending on the underlying hardware's capabilities:
  • M22x, M23x: They have just an unconnected open-drain output titled "Status LED", on which you have to connect some LED by your own. Any color != 0 drags this output pin against GND.
  • NRF91: Has one dedicated pin (P0.28) for this function, on which you have to connect some LED by your own. Any color != 0 sets this output pin to "High".
  • easyV3, easyIoT: They have 2 integrated LEDs - red and green. Any red color turns on the red LED, any green color turns on the green LED.
  • IoT-Box: Has full RGB support on it's integrated LED.
  • T32x: Has basic RGB support w/o dimming capability, i.e. any color value >0 turns the appropriate LED color on.
  • BLE-Gateway: There is no LED available, use the integrated display instead.
  • Note that this function controls on M22x, M23x and NRF91 just an unconnected digital output. You need to connect some LED by your own.
    rgb : Trgb -
    0xRRGGBB - 24bit color code
    CO_BLACK - black, e.g. turn off
    CO_DEFAULT - give LED control back to firmware (former CO_AUTOMATIC)
    mode : s32 - optional;
    LED_STATIC - default
    LED_BLINK
    LED_FLICKER
    LED_FLASH
    LED_FLASH_ONCE - flash just once w/o giving the count parameter
    LED_BLINK_ONCE - blink just once w/o giving the count parameter
    count : s32 - optional;
    0 - forever (default)
    others - duration; ignored with LED_STATIC
    Examples
    setLed( rrggbb); // turn LED to color rrggbb setLed( CO_BLACK); // turn LED off setLed( rrggbb, LED_BLINK, 5); // blink LED 5 times setLed( rrggbb, LED_FLASH); // flash LED forever setLed( rrggbb, LED_FLASH_ONCE); // same as setLed( RGB, LED_FLASH, 1) setLed( -1); // give back LED to firmware

    M3IOTBOX:

    setLed(rgb, mode=LED_STATIC, count=0)

    control the (onboard) system LED(s)

    Colors behave slightly different depending on the underlying hardware's capabilities:
  • M22x, M23x: They have just an unconnected open-drain output titled "Status LED", on which you have to connect some LED by your own. Any color != 0 drags this output pin against GND.
  • NRF91: Has one dedicated pin (P0.28) for this function, on which you have to connect some LED by your own. Any color != 0 sets this output pin to "High".
  • easyV3, easyIoT: They have 2 integrated LEDs - red and green. Any red color turns on the red LED, any green color turns on the green LED.
  • IoT-Box: Has full RGB support on it's integrated LED.
  • T32x: Has basic RGB support w/o dimming capability, i.e. any color value >0 turns the appropriate LED color on.
  • BLE-Gateway: There is no LED available, use the integrated display instead.
  • Note that this function controls on M22x, M23x and NRF91 just an unconnected digital output. You need to connect some LED by your own.
    rgb : Trgb -
    0xRRGGBB - 24bit color code
    CO_BLACK - black, e.g. turn off
    CO_DEFAULT - give LED control back to firmware (former CO_AUTOMATIC)
    mode : s32 - optional;
    LED_STATIC - default
    LED_BLINK
    LED_FLICKER
    LED_FLASH
    LED_FLASH_ONCE - flash just once w/o giving the count parameter
    LED_BLINK_ONCE - blink just once w/o giving the count parameter
    count : s32 - optional;
    0 - forever (default)
    others - duration; ignored with LED_STATIC
    Examples
    setLed( rrggbb); // turn LED to color rrggbb setLed( CO_BLACK); // turn LED off setLed( rrggbb, LED_BLINK, 5); // blink LED 5 times setLed( rrggbb, LED_FLASH); // flash LED forever setLed( rrggbb, LED_FLASH_ONCE); // same as setLed( RGB, LED_FLASH, 1) setLed( -1); // give back LED to firmware

    NRF91:

    setLed(rgb, mode=LED_STATIC, count=0)

    control the (onboard) system LED(s)

    Colors behave slightly different depending on the underlying hardware's capabilities:
  • M22x, M23x: They have just an unconnected open-drain output titled "Status LED", on which you have to connect some LED by your own. Any color != 0 drags this output pin against GND.
  • NRF91: Has one dedicated pin (P0.28) for this function, on which you have to connect some LED by your own. Any color != 0 sets this output pin to "High".
  • easyV3, easyIoT: They have 2 integrated LEDs - red and green. Any red color turns on the red LED, any green color turns on the green LED.
  • IoT-Box: Has full RGB support on it's integrated LED.
  • T32x: Has basic RGB support w/o dimming capability, i.e. any color value >0 turns the appropriate LED color on.
  • BLE-Gateway: There is no LED available, use the integrated display instead.
  • Note that this function controls on M22x, M23x and NRF91 just an unconnected digital output. You need to connect some LED by your own.
    rgb : Trgb -
    0xRRGGBB - 24bit color code
    CO_BLACK - black, e.g. turn off
    CO_DEFAULT - give LED control back to firmware (former CO_AUTOMATIC)
    mode : s32 - optional;
    LED_STATIC - default
    LED_BLINK
    LED_FLICKER
    LED_FLASH
    LED_FLASH_ONCE - flash just once w/o giving the count parameter
    LED_BLINK_ONCE - blink just once w/o giving the count parameter
    count : s32 - optional;
    0 - forever (default)
    others - duration; ignored with LED_STATIC
    Examples
    setLed( rrggbb); // turn LED to color rrggbb setLed( CO_BLACK); // turn LED off setLed( rrggbb, LED_BLINK, 5); // blink LED 5 times setLed( rrggbb, LED_FLASH); // flash LED forever setLed( rrggbb, LED_FLASH_ONCE); // same as setLed( RGB, LED_FLASH, 1) setLed( -1); // give back LED to firmware

    T32X:

    setLed(rgb, mode=LED_STATIC, count=0)

    control the (onboard) system LED(s)

    Colors behave slightly different depending on the underlying hardware's capabilities:
  • M22x, M23x: They have just an unconnected open-drain output titled "Status LED", on which you have to connect some LED by your own. Any color != 0 drags this output pin against GND.
  • NRF91: Has one dedicated pin (P0.28) for this function, on which you have to connect some LED by your own. Any color != 0 sets this output pin to "High".
  • easyV3, easyIoT: They have 2 integrated LEDs - red and green. Any red color turns on the red LED, any green color turns on the green LED.
  • IoT-Box: Has full RGB support on it's integrated LED.
  • T32x: Has basic RGB support w/o dimming capability, i.e. any color value >0 turns the appropriate LED color on.
  • BLE-Gateway: There is no LED available, use the integrated display instead.
  • Note that this function controls on M22x, M23x and NRF91 just an unconnected digital output. You need to connect some LED by your own.
    rgb : Trgb -
    0xRRGGBB - 24bit color code
    CO_BLACK - black, e.g. turn off
    CO_DEFAULT - give LED control back to firmware (former CO_AUTOMATIC)
    mode : s32 - optional;
    LED_STATIC - default
    LED_BLINK
    LED_FLICKER
    LED_FLASH
    LED_FLASH_ONCE - flash just once w/o giving the count parameter
    LED_BLINK_ONCE - blink just once w/o giving the count parameter
    count : s32 - optional;
    0 - forever (default)
    others - duration; ignored with LED_STATIC
    Examples
    setLed( rrggbb); // turn LED to color rrggbb setLed( CO_BLACK); // turn LED off setLed( rrggbb, LED_BLINK, 5); // blink LED 5 times setLed( rrggbb, LED_FLASH); // flash LED forever setLed( rrggbb, LED_FLASH_ONCE); // same as setLed( RGB, LED_FLASH, 1) setLed( -1); // give back LED to firmware

    BUTTON

    M22X:

    watchButton()
    Function not available on this module.
    Some peripherals library such as POC base starter may help.

    M23X:

    watchButton()
    Function not available on this module.
    Some peripherals library such as POC base starter may help.

    M2BLEGW:

    watchButton(cb=-1)
  • Supported by APM_DPID_m2easyv3, ..._m2easyiot, ..._m3iotbox, ..._t32x, ..._nrf91
  • NOT supported by APM_DPID_m22x, ..._m23x
  • // install button watcher #callback onButton( pressed){...} watchButton( onButton);
    // remove button watcher - give back button control to firmware watchButton();
    // totally disable button watchButton( BUTTON_DISABLE);
    cb : TonButton
    TonButton - install watcher callback
    BUTTON_DISABLE - totally disable button (wheather application nur firmware uses it)
    none - remove button watcher and handover control to firmware (e.g. BUTTON_DEFAULT)
    Switch_Init Switch_Close
    TonButton(pressed)
    pressed : s32
    0 - button has been released
    1 - button has been pressed
    T32x plattforms may issue an initial TonButton(pressed=false) without a physical button release behind.To filter this unwanted event, add the code below:
    #callback onButton( pressed) { // filter out unwanted initial pressed=0 events for APM_DPID_T32X static isPressed_=0; if (!changed(isPressed_, pressed)) return; ... your application's button pressed/released code ... }

    M2EASYIOT:

    watchButton(cb=-1)
  • Supported by APM_DPID_m2easyv3, ..._m2easyiot, ..._m3iotbox, ..._t32x, ..._nrf91
  • NOT supported by APM_DPID_m22x, ..._m23x
  • // install button watcher #callback onButton( pressed){...} watchButton( onButton);
    // remove button watcher - give back button control to firmware watchButton();
    // totally disable button watchButton( BUTTON_DISABLE);
    cb : TonButton
    TonButton - install watcher callback
    BUTTON_DISABLE - totally disable button (wheather application nur firmware uses it)
    none - remove button watcher and handover control to firmware (e.g. BUTTON_DEFAULT)
    Switch_Init Switch_Close
    TonButton(pressed)
    pressed : s32
    0 - button has been released
    1 - button has been pressed
    T32x plattforms may issue an initial TonButton(pressed=false) without a physical button release behind.To filter this unwanted event, add the code below:
    #callback onButton( pressed) { // filter out unwanted initial pressed=0 events for APM_DPID_T32X static isPressed_=0; if (!changed(isPressed_, pressed)) return; ... your application's button pressed/released code ... }

    M2EASYV3:

    watchButton(cb=-1)
  • Supported by APM_DPID_m2easyv3, ..._m2easyiot, ..._m3iotbox, ..._t32x, ..._nrf91
  • NOT supported by APM_DPID_m22x, ..._m23x
  • // install button watcher #callback onButton( pressed){...} watchButton( onButton);
    // remove button watcher - give back button control to firmware watchButton();
    // totally disable button watchButton( BUTTON_DISABLE);
    cb : TonButton
    TonButton - install watcher callback
    BUTTON_DISABLE - totally disable button (wheather application nur firmware uses it)
    none - remove button watcher and handover control to firmware (e.g. BUTTON_DEFAULT)
    Switch_Init Switch_Close
    TonButton(pressed)
    pressed : s32
    0 - button has been released
    1 - button has been pressed
    T32x plattforms may issue an initial TonButton(pressed=false) without a physical button release behind.To filter this unwanted event, add the code below:
    #callback onButton( pressed) { // filter out unwanted initial pressed=0 events for APM_DPID_T32X static isPressed_=0; if (!changed(isPressed_, pressed)) return; ... your application's button pressed/released code ... }

    M3IOTBOX:

    watchButton(cb=-1)
  • Supported by APM_DPID_m2easyv3, ..._m2easyiot, ..._m3iotbox, ..._t32x, ..._nrf91
  • NOT supported by APM_DPID_m22x, ..._m23x
  • // install button watcher #callback onButton( pressed){...} watchButton( onButton);
    // remove button watcher - give back button control to firmware watchButton();
    // totally disable button watchButton( BUTTON_DISABLE);
    cb : TonButton
    TonButton - install watcher callback
    BUTTON_DISABLE - totally disable button (wheather application nur firmware uses it)
    none - remove button watcher and handover control to firmware (e.g. BUTTON_DEFAULT)
    Switch_Init Switch_Close
    TonButton(pressed)
    pressed : s32
    0 - button has been released
    1 - button has been pressed
    T32x plattforms may issue an initial TonButton(pressed=false) without a physical button release behind.To filter this unwanted event, add the code below:
    #callback onButton( pressed) { // filter out unwanted initial pressed=0 events for APM_DPID_T32X static isPressed_=0; if (!changed(isPressed_, pressed)) return; ... your application's button pressed/released code ... }

    NRF91:

    watchButton(cb=-1)
  • Supported by APM_DPID_m2easyv3, ..._m2easyiot, ..._m3iotbox, ..._t32x, ..._nrf91
  • NOT supported by APM_DPID_m22x, ..._m23x
  • // install button watcher #callback onButton( pressed){...} watchButton( onButton);
    // remove button watcher - give back button control to firmware watchButton();
    // totally disable button watchButton( BUTTON_DISABLE);
    cb : TonButton
    TonButton - install watcher callback
    BUTTON_DISABLE - totally disable button (wheather application nur firmware uses it)
    none - remove button watcher and handover control to firmware (e.g. BUTTON_DEFAULT)
    Switch_Init Switch_Close
    TonButton(pressed)
    pressed : s32
    0 - button has been released
    1 - button has been pressed
    T32x plattforms may issue an initial TonButton(pressed=false) without a physical button release behind.To filter this unwanted event, add the code below:
    #callback onButton( pressed) { // filter out unwanted initial pressed=0 events for APM_DPID_T32X static isPressed_=0; if (!changed(isPressed_, pressed)) return; ... your application's button pressed/released code ... }

    T32X:

    watchButton(cb=-1)
  • Supported by APM_DPID_m2easyv3, ..._m2easyiot, ..._m3iotbox, ..._t32x, ..._nrf91
  • NOT supported by APM_DPID_m22x, ..._m23x
  • // install button watcher #callback onButton( pressed){...} watchButton( onButton);
    // remove button watcher - give back button control to firmware watchButton();
    // totally disable button watchButton( BUTTON_DISABLE);
    cb : TonButton
    TonButton - install watcher callback
    BUTTON_DISABLE - totally disable button (wheather application nur firmware uses it)
    none - remove button watcher and handover control to firmware (e.g. BUTTON_DEFAULT)
    Switch_Init Switch_Close
    TonButton(pressed)
    pressed : s32
    0 - button has been released
    1 - button has been pressed
    T32x plattforms may issue an initial TonButton(pressed=false) without a physical button release behind.To filter this unwanted event, add the code below:
    #callback onButton( pressed) { // filter out unwanted initial pressed=0 events for APM_DPID_T32X static isPressed_=0; if (!changed(isPressed_, pressed)) return; ... your application's button pressed/released code ... }