This is the multi-page printable view of this section. Click here to print...

Return to the regular view of this page

As of 2025-07-24

TWELITE Wings API / MWings for 32-bit Arduinos

MWings for 32-bit Arduino boards
TWELITE Wings API for 32-bit Arduino boards.

1 - TWELITE Wings API / MWings for 32-bit Arduinos

Latest Version
TWELITE Wings API for 32-bit Arduino boards.

1.1 - List of Data Types and Procedures

List of MWings-specific data types and procedures for 32-bit Arduino boards
This is a list of MWings-specific data types and procedures. Click here for a list of classes.

Structures

BarePacket

Stores raw data extracted from the packet received by the parent device from a child device.

MWings_Common.h

Data

TypeNameDescription
uint8_t*u8PayloadPayload data converted to binary (excluding :, checksum, and CRLF)
uint16_tu16PayloadSizeByte size of the above data
uint8_tu8ChecksumChecksum of the above data

Procedures

Type and NameDescription
uint8_t* u8From(int)Gets payload data from the specified position onward
uint8_t u8At(int)Gets the payload data at the specified position as an 8-bit unsigned integer
int8_t i8At(int)Gets the payload data at the specified position as an 8-bit signed integer
uint16_t u16At(int)Gets the payload data at the specified position as a 16-bit unsigned integer
int16_t i16At(int)Gets the payload data at the specified position as a 16-bit signed integer
uint32_t u32At(int)Gets the payload data at the specified position as a 32-bit unsigned integer
int32_t i32At(int)Gets the payload data at the specified position as a 32-bit signed integer

mwings::ParsedPacketBase

Abstract structure that stores parsed data received by the parent device from a child device.

MWings_Common.h

Data

TypeNameDescription
uint32_tu32SourceSerialIdSerial ID of the sender
uint8_tu8SourceLogicalIdLogical device ID of the sender
uint16_tu16SequenceNumberSequence number
uint8_tu8LqiLQI
uint16_tu16SupplyVoltageSupply voltage (mV)

ParsedAppTwelitePacket

Derived from mwings::ParsedPacketBase

Structure that stores data received by the parent device from a child device running the “Super Easy! Standard App”.

AppTwelitePacketParser.h

Data

TypeNameDescription
uint8_tu8DestinationLogicalIdLogical device ID of the recipient
uint8_tu8RelayCountNumber of relays
boolbPeriodictrue if the packet is a periodic transmission
bool[4]bDiChangedtrue if DI1–4 changed
bool[4]bDiStatetrue if DI1–4 are in Low state
uint16_t[4]u16AiVoltageInput voltage of AI1–4 (mV)

ParsedAppIoPacket

Derived from mwings::ParsedPacketBase

Structure that stores data received by the parent device from a child device running the Remote App.

AppIoPacketParser.h

Data

TypeNameDescription
uint8_tu8RelayCountNumber of relays
bool[12]bDiStatetrue if each DI is in Low state
bool[12]bDiValidtrue if each DI is valid
bool[12]bDiInterrupttrue if each DI has changed by interrupt

ParsedAppAriaPacket

Derived from mwings::ParsedPacketBase

Structure that stores data received by the parent device from a child device running the Aria App (TWELITE ARIA mode).

AppAriaPacketParser.h

Data

TypeNameDescription
uint32_tu32RouterSerialIdSerial ID of the first relay device
0x80000000 if not relayed (v1.2.2+)
int16_ti16Temp100xTemperature ×100 (Celsius)
uint16_tu16Humid100xRelative humidity ×100 (%)
uint8_tu8MagnetStateMagnet Event ID
boolbMagnetStateChangedtrue if magnet sensor state changed
Magnet Event ID
IDDescription
0x00No magnet nearby
0x01North pole is nearby
0x02South pole is nearby

ParsedAppCuePacket

Derived from mwings::ParsedPacketBase

Structure that stores data received by the parent device from a child device running the Cue App (TWELITE CUE mode).

AppCuePacketParser.h

Data

TypeNameDescription
uint32_tu32RouterSerialIdSerial ID of the first relay device
0x80000000 if not relayed (v1.2.2+)
int16_t[10]i16SamplesXX-axis acceleration samples (mG)
int16_t[10]i16SamplesYY-axis acceleration samples (mG)
int16_t[10]i16SamplesZZ-axis acceleration samples (mG)
uint8_tu8SampleCountNumber of samples
boolbHasAccelEventtrue if there is an acceleration event
uint8_tu8AccelEventAcceleration Event ID
uint8_tu8MagnetStateMagnet Event ID
boolbMagnetStateChangedtrue if magnet sensor state changed
Acceleration Event ID
IDDescription
0x01~0x06Dice
0x08Shake
0x10Move
Magnet Event ID
IDDescription
0x00No magnet nearby
0x01North pole is nearby
0x02South pole is nearby

ParsedAppPalAmbPacket

Derived from mwings::ParsedPacketBase

Structure that stores data received by the parent device from a child device running the Pal App (environment sensor Pal).

AppPalAmbPacketParser.h

Data

TypeNameDescription
uint32_tu32RouterSerialIdSerial ID of the first relay device
0x80000000 if not relayed (v1.2.2+)
uint16_tu16Ai1VoltageAI1 input voltage (mV)
int16_ti16Temp100xTemperature ×100 (Celsius)
uint16_tu16Humid100xRelative humidity ×100 (%)
uint32_tu32IlluminanceIlluminance (lux)

ParsedAppPalMotPacket

Derived from mwings::ParsedPacketBase

Structure that stores data received by the parent device from a child device running the Pal App (motion sensor Pal).

AppPalMotPacketParser.h

Data

TypeNameDescription
uint32_tu32RouterSerialIdSerial ID of the first relay device
0x80000000 if not relayed (v1.2.2+)
uint16_tu16Ai1VoltageAI1 input voltage (mV)
int16_t[16]i16SamplesXX-axis acceleration samples (mG)
int16_t[16]i16SamplesYY-axis acceleration samples (mG)
int16_t[16]i16SamplesZZ-axis acceleration samples (mG)
uint8_tu8SampleCountNumber of samples
uint16_tu16SamplingFrequencySampling frequency (Hz)

ParsedAppPalOpenClosePacket

Derived from mwings::ParsedPacketBase

Structure that stores data received by the parent device from a child device running the Pal App (open/close sensor Pal).

AppPalOpenClosePacketParser.h

Data

TypeNameDescription
uint32_tu32RouterSerialIdSerial ID of the first relay device
0x80000000 if not relayed (v1.2.2+)
uint16_tu16Ai1VoltageAI1 input voltage (mV)
uint8_tu8MagnetStateMagnet Event ID
boolbMagnetStateChangedtrue if magnet sensor state changed
Magnet Event ID
IDDescription
0x00No magnet nearby
0x01North pole is nearby
0x02South pole is nearby

ParsedAppUartAsciiPacket

Derived from mwings::ParsedPacketBase

Structure that stores data received by the parent device from a child device running the serial communication app (A mode, simple format).

AppUartAsciiPacketParser.h

Data

TypeNameDescription
uint8_tu8CommandIdCommand type (response ID)
uint8_t*u8DataData
uint16_tu16DataSizeData length

ParsedAppUartAsciiExtendedPacket

Derived from mwings::ParsedPacketBase

Structure that stores data received by the parent device from a child device running the serial communication app (A mode, extended format).

AppUartAsciiExtendedPacketParser.h

Data

TypeNameDescription
uint32_tu32DestinationSerialIdDestination serial ID
uint8_tu8CommandIdCommand type (response ID)
uint8_t*u8DataData
uint16_tu16DataSizeData length

ParsedActPacket

Derived from mwings::ParsedPacketBase

Structure that stores data received by the parent device from a child device running the act app.

ActPacketParser.h

Data

TypeNameDescription
uint8_tu8CommandIdCommand type (response ID)
uint8_t*u8DataData
uint16_tu16DataSizeData length

mwings::CommandBase

Abstract structure that stores command data sent from the parent device to a child device.

MWings_Common.h

Data

TypeNameDescription
uint8_tu8DestinationLogicalIdDestination logical device ID

Procedures

Type and NameDescription
bool isValid()Returns true if the data is valid (pure virtual function)

AppTweliteCommand

Derived from mwings::CommandBase

Structure that stores command data sent from the parent device to a child device running the “Super Easy! Standard App”.

AppTweliteCommandSerializer.h

Data

TypeNameDescription
bool[4]bDiToChangetrue to change the state of each DO1-4
bool[4]bDiStatetrue to set each DO1-4 to Low state
bool[4]bPwmToChangetrue to change the state of each PWM1-4
uint16_t[4]u16PwmDutyDuty ratio of each PWM1-4 (0-1024)

AppIoCommand

Derived from mwings::CommandBase

Structure that stores command data sent from the parent device to a child device running the Remote App.

AppIoCommandSerializer.h

Data

TypeNameDescription
bool[12]bDiToChangetrue to change the state of each O1-12
bool[12]bDiStatetrue to set each O1-12 to Low state

AppPalNoticeCommand

Derived from mwings::CommandBase

Structure that stores command data sent from the parent device to a child device running the Pal App (Notifier Pal).

AppPalNoticeCommandSerializer.h

Data

TypeNameDescription
AppPalNoticeColoreColorLighting color
AppPalNoticeBlinkSpeedeBlinkSpeedBlinking speed
uint8_tu8BrightnessBrightness (0-15)
uint16_tu16DurationInSecLighting duration (seconds)

AppPalNoticeDetailedCommand

Derived from mwings::CommandBase

Structure that stores command data sent from the parent device to a child device running the Pal App (Notifier Pal) — detailed format.

AppPalNoticeDetailedCommandSerializer.h

Data

TypeNameDescription
AppPalNoticeRGBWColorsRGBWColorLighting color (RGBW)
uint8_tu8BlinkDutyPercentageLighting time ratio (%)
floatfBlinkPeriodInSecBlinking period (seconds)
uint16_tu16DurationInSecLighting duration (seconds)

AppPalNoticeEventCommand

Derived from mwings::CommandBase

Structure that stores command data (detailed format) sent from the parent device to a child device running the Pal App (Notifier Pal).

AppPalNoticeEventCommandSerializer.h

Data

TypeNameDescription
uint8_tu8EventIdEvent ID (0x00-0x10)

AppUartAsciiCommand

Derived from mwings::CommandBase

Structure that stores command data (simple format) sent from the parent device to a child device running the serial communication app (A mode).

AppUartAsciiCommand.h

Data

TypeNameDescription
uint8_tu8CommandIdCommand type (response ID)
uint8_t*u8DataData
uint16_tu16DataSizeData length

AppPalNoticeRGBWColor

Structure that defines the lighting color (RGBW) used in AppPalNoticeDetailedCommand.

AppPalNoticeDetailedCommandSerializer.h

Data

TypeNameDescription
uint8_tredR (0-15)
uint8_tgreenG (0-15)
uint8_tblueB (0-15)
uint8_twhiteW (0-15)

Procedures

Type and NameDescription
bool isValid()Returns true if the data is valid
uint16_t u16()Returns a 16-bit unsigned integer with RGBW packed in order from LSB, 4 bits each

Enumerations

AppPalNoticeColor

enum class based on uint8_t ?

Enumeration that defines the lighting color used in AppPalNoticeCommand.

AppPalNoticeCommandSerializer.h

IdentifierValueDescription
AppPalNoticeColor::RED0Red
AppPalNoticeColor::GREEN1Green
AppPalNoticeColor::BLUE2Blue
AppPalNoticeColor::YELLOW3Yellow
AppPalNoticeColor::PURPLE4Purple
AppPalNoticeColor::LIGHT_BLUE5Light blue
AppPalNoticeColor::WHITE6White
AppPalNoticeColor::WARM_WHITE7Warm white

AppPalNoticeBlinkSpeed

enum class based on uint8_t

Enumeration that defines the blinking speed used in AppPalNoticeCommand.

AppPalNoticeCommandSerializer.h

IdentifierValueDescription
AppPalNoticeBlinkSpeed::ALWAYS_ON0Always on
AppPalNoticeBlinkSpeed::SLOW1Slow blinking
AppPalNoticeBlinkSpeed::MEDIUM2Medium blinking
AppPalNoticeBlinkSpeed::FAST3Fast blinking

Other Data Types

Procedures

GetAppTweliteSerializedCommandPayloadSize()

constexpr function ?

Returns the payload size (in bytes) of the serialized fixed-length data for AppTweliteCommand.

AppTweliteCommandSerializer.h

Type and NameDescription
int GetAppTweliteSerializedCommandPayloadSize()Returns the number of bytes

GetAppAppPalNoticeSerializedCommandPayloadSize()

constexpr function

Returns the payload size (in bytes) of the serialized fixed-length data for AppPalNoticeCommand.

AppPalNoticeCommandSerializer.h

Type and NameDescription
int GetAppPalNoticeSerializedCommandPayloadSize()Returns the number of bytes

GetAppAppPalNoticeDetailedSerializedCommandPayloadSize()

constexpr function

Returns the payload size (in bytes) of the serialized fixed-length data for AppPalNoticeDetailedCommand.

AppPalNoticeDetailedCommandSerializer.h

Type and NameDescription
int GetAppPalNoticeDetailedSerializedCommandPayloadSize()Returns the number of bytes

GetAppAppPalNoticeEventSerializedCommandPayloadSize()

constexpr function

Returns the payload size (in bytes) of the serialized fixed-length data for AppPalNoticeEventCommand.

AppPalNoticeEventCommandSerializer.h

Type and NameDescription
int GetAppPalNoticeEventSerializedCommandPayloadSize()Returns the number of bytes

1.2 - Class List

List of MWings classes for 32-bit Arduino boards
This is a list of classes.

1.2.1 - mwings::MWings Class

The main MWings class for 32-bit Arduino boards
This is an explanation of the mwings::MWings class.

Constructor

MWings()

Constructor. Initializes internal variables.

MWings()

MWings.h

Arguments

None

Destructor

~MWings()

Destructor. Releases allocated buffers.

~MWings()

Public Member Functions

begin()

Initializes TWELITE and starts it with the specified settings.

    bool begin(HardwareSerial& serial,
                   const int indicatorPin = -1,
                   const int resetPin = -1,
                   const int programPin = -1,
                   const uint8_t channel = 18,
                   const uint32_t appId = 0x67720102,
                   const uint8_t retryCount = 2,
                   const uint8_t txPower = 3,
                   const int rxBufferSize = 1024,
                   const int timeout = 100,
                   const uint32_t encryptKey = 0,
                   HardwareSerial* debugSerial = nullptr);

MWings.cpp

Arguments

TypeNameDescriptionOptionalRemarks
HardwareSerial&serialPort communicating with TWELITE
intindicatorPinPin connected to status LED🆗Can be omitted with -1
intresetPinTWELITE’s RST pin🆗Can be omitted with -1
intprogramPinTWELITE’s PRG pin🆗Can be omitted with -1
uint8_tchannelFrequency channel🆗Default is 18
uint32_tappIdApplication ID🆗Default is 0x67720102
uint8_tretryCountNumber of retries🆗0-9
uint8_ttxPowerTransmission power🆗0-3
intrxBufferSizeSize of packet reception buffer🆗Binary-based
inttimeoutTimeout for each packet🆗Until reception completion
uint32_tencryptKeyEncryption key🆗Disabled if 0, available from v1.2.3+
HardwareSerial*debugSerialDebug output port🆗

Return Value

TypeValueDescriptionRemarks
booltrueSuccess
falseError

end()

Initializes all internal variables.

inline void end()

MWings.h

Arguments

None

Return Value

None

update()

Reads the serial receive buffer and parses the ModBus ASCII format data sent from the parent device.

void update();

MWings.h

Arguments

None

Return Value

None

on() <BarePacket>

Registers a handler to process data sent from all child devices.

inline void on(void (*callback)(const BarePacket& packet))

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
void (*)(BarePacket&)callbackEvent handler

Return Value

None

on() <ParsedAppTwelitePacket>

Super easy! Registers a handler to process data sent from standard app child devices.

inline void on(void (*callback)(const ParsedAppTwelitePacket& packet))

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
void (*)(ParsedAppTwelitePacket&)callbackEvent handler

Return Value

None

on() <ParsedAppIoPacket>

Registers a handler to process data sent from remote control app child devices.

inline void on(void (*callback)(const ParsedAppIoPacket& packet))

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
void (*)(ParsedAppIoPacket&)callbackEvent handler

Return Value

None

on() <ParsedAppAriaPacket>

Registers a handler to process data sent from ARIA app (TWELITE ARIA mode) child devices.

inline void on(void (*callback)(const ParsedAppAriaPacket& packet))

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
void (*)(ParsedAppAriaPacket&)callbackEvent handler

Return Value

None

on() <ParsedAppCuePacket>

Registers a handler to process data sent from CUE app (TWELITE CUE mode) child devices.

inline void on(void (*callback)(const ParsedAppCuePacket& packet))

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
void (*)(ParsedAppCuePacket&)callbackEvent handler

Return Value

None

on() <ParsedAppPalOpenClosePacket>

Registers a handler to process data sent from PAL app (open/close sensor PAL) child devices.

inline void on(void (*callback)(const ParsedAppPalOpenClosePacket& packet))

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
void (*)(ParsedAppPalOpenClosePacket&)callbackEvent handler

Return Value

None

on() <ParsedAppPalAmbPacket>

Registers a handler to process data sent from PAL app (environment sensor PAL) child devices.

inline void on(void (*callback)(const ParsedAppPalAmbPacket& packet))

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
void (*)(ParsedAppPalAmbPacket&)callbackEvent handler

Return Value

None

on() <ParsedAppPalMotPacket>

Registers a handler to process data sent from PAL app (motion sensor PAL) child devices.

inline void on(void (*callback)(const ParsedAppPalMotPacket& packet))

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
void (*)(ParsedAppPalMotPacket&)callbackEvent handler

Return Value

None

on() <ParsedAppUartAsciiPacket>

Registers a handler to process data (simple format) sent from serial communication app (A mode) child devices.

inline void on(void (*callback)(const ParsedAppUartAsciiPacket& packet))

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
void (*)(ParsedAppUartAsciiPacket&)callbackEvent handler

Return Value

None

on() <ParsedAppUartAsciiExtendedPacket>

Registers a handler to process data (extended format) sent from serial communication app (A mode) child devices.

inline void on(void (*callback)(const ParsedAppUartAsciiExtendedPacket& packet))

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
void (*)(ParsedAppUartAsciiExtendedPacket&)callbackEvent handler

Return Value

None

on() <ParsedActPacket>

Registers a handler to process data sent from act child devices.

inline void on(void (*callback)(const ParsedActPacket& packet))

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
void (*)(ParsedActPacket&)callbackEvent handler

Return Value

None

send() <uint8_t*, int, uint8_t>

Sends an arbitrary command (ModBus ASCII format) to the parent device.

inline bool send(const uint8_t* const payload,
                     const int payloadSize,
                     const uint8_t checksum)

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
uint8_t*payloadPayloadBetween : and LRC
intpayloadSizePayload size
uint8_tchecksumChecksumLRC of the payload

Return Value

TypeValueDescriptionRemarks
booltrueSuccess
falseError

send() <uint8_t*, int>

Sends an arbitrary command (ModBus ASCII format) to the parent device (checksum automatically added).

inline bool send(const uint8_t* const payload,
                     const int payloadSize)

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
uint8_t*payloadPayloadBetween : and LRC
intpayloadSizePayload size

Return Value

TypeValueDescriptionRemarks
booltrueSuccess
falseError

send() <uint8_t, uint8_t, uint8_t* int, uint8_t>

Sends an arbitrary command (ModBus ASCII format) to the parent device.

inline bool send(const uint8_t logicalId,
                     const uint8_t commandId,
                     const uint8_t* const payload,
                     const int payloadSize,
                     const uint8_t checksum)

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
uint8_tlogicalIdDestination logical device ID
uint8_tcommandIdCommand type
uint8_t*payloadPayloadBetween : and LRC
intpayloadSizePayload size
uint8_tchecksumChecksumLRC of the payload

Return Value

TypeValueDescriptionRemarks
booltrueSuccess
falseError

send() <uint8_t, uint8_t, uint8_t* int>

Sends an arbitrary command (ModBus ASCII format) to the parent device (checksum automatically added).

inline bool send(const uint8_t logicalId,
                     const uint8_t commandId,
                     const uint8_t* const payload,
                     const int payloadSize)

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
uint8_tlogicalIdDestination logical device ID
uint8_tcommandIdCommand type
uint8_t*payloadPayloadBetween : and LRC
intpayloadSizePayload size

Return Value

TypeValueDescriptionRemarks
booltrueSuccess
falseError

send() <AppTweliteCommand>

Super easy! Sends a command to operate standard app terminals to the parent device.

inline bool send(AppTweliteCommand& command)

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
AppTweliteCommandcommandCommand data

Return Value

TypeValueDescriptionRemarks
booltrueSuccess
falseError

send() <AppIoCommand>

Sends a command to operate remote control app terminals to the parent device.

inline bool send(AppIoCommand& command)

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
AppIoCommandcommandCommand data

Return Value

TypeValueDescriptionRemarks
booltrueSuccess
falseError

send() <AppPalNoticeCommand>

Sends a command to operate PAL app (notification PAL) terminals to the parent device.

inline bool send(AppPalNoticeCommand& command)

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
AppPalNoticeCommandcommandCommand data

Return Value

TypeValueDescriptionRemarks
booltrueSuccess
falseError

send() <AppPalNoticeDetailedCommand>

Sends a command (detailed format) to operate PAL app (notification PAL) terminals to the parent device.

inline bool send(AppPalNoticeDetailedCommand& command)

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
AppPalNoticeDetailedCommandcommandCommand data

Return Value

TypeValueDescriptionRemarks
booltrueSuccess
falseError

send() <AppPalNoticeEventCommand>

Sends a command (event) to operate PAL app (notification PAL) terminals to the parent device.

inline bool send(AppPalNoticeEventCommand& command)

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
AppPalNoticeEventCommandcommandCommand data

Return Value

TypeValueDescriptionRemarks
booltrueSuccess
falseError

send() <AppPalUartAsciiCommand>

Sends a command (simple format) to operate serial communication app (A mode) terminals to the parent device.

inline bool send(AppPalUartAsciiCommand& command)

MWings.h

Arguments

TypeNameDescriptionOptionalRemarks
AppPalUartAsciiCommandcommandCommand data

Return Value

TypeValueDescriptionRemarks
booltrueSuccess
falseError