mwings::MWings Class
mwings::MWings
class.Twelite
object used in sketches is an instance of the mwings::MWings
class.mwings::MWings
class in your sketch. Please use the automatically initialized Twelite
object.Constructor
MWings()
Constructor. Initializes internal variables.
MWings()
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);
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
HardwareSerial& | serial | Port communicating with TWELITE | ||
int | indicatorPin | Pin connected to status LED | 🆗 | Can be omitted with -1 |
int | resetPin | TWELITE’s RST pin | 🆗 | Can be omitted with -1 |
int | programPin | TWELITE’s PRG pin | 🆗 | Can be omitted with -1 |
uint8_t | channel | Frequency channel | 🆗 | Default is 18 |
uint32_t | appId | Application ID | 🆗 | Default is 0x67720102 |
uint8_t | retryCount | Number of retries | 🆗 | 0-9 |
uint8_t | txPower | Transmission power | 🆗 | 0-3 |
int | rxBufferSize | Size of packet reception buffer | 🆗 | Binary-based |
int | timeout | Timeout for each packet | 🆗 | Until reception completion |
uint32_t | encryptKey | Encryption key | 🆗 | Disabled if 0 , available from v1.2.3+ |
HardwareSerial* | debugSerial | Debug output port | 🆗 |
Return Value
Type | Value | Description | Remarks |
---|---|---|---|
bool | true | Success | |
false | Error |
end()
Initializes all internal variables.
inline void end()
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();
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))
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
void (*)(BarePacket&) | callback | Event handler |
BarePacket
, see Data and Procedures.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))
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
void (*)(ParsedAppTwelitePacket&) | callback | Event handler |
ParsedAppTwelitePacket
, see Data and Procedures.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))
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
void (*)(ParsedAppIoPacket&) | callback | Event handler |
ParsedAppIoPacket
, see Data and Procedures.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))
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
void (*)(ParsedAppAriaPacket&) | callback | Event handler |
ParsedAppAriaPacket
, see Data and Procedures.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))
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
void (*)(ParsedAppCuePacket&) | callback | Event handler |
ParsedAppCuePacket
, see Data and Procedures.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))
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
void (*)(ParsedAppPalOpenClosePacket&) | callback | Event handler |
ParsedAppPalOpenClosePacket
, see Data and Procedures.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))
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
void (*)(ParsedAppPalAmbPacket&) | callback | Event handler |
ParsedAppPalAmbPacket
, see Data and Procedures.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))
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
void (*)(ParsedAppPalMotPacket&) | callback | Event handler |
ParsedAppPalMotPacket
, see Data and Procedures.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))
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
void (*)(ParsedAppUartAsciiPacket&) | callback | Event handler |
ParsedAppUartAsciiPacket
, see Data and Procedures.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))
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
void (*)(ParsedAppUartAsciiExtendedPacket&) | callback | Event handler |
ParsedAppUartAsciiExtendedPacket
, see Data and Procedures.Return Value
None
on()
<ParsedActPacket
>
Registers a handler to process data sent from act child devices.
inline void on(void (*callback)(const ParsedActPacket& packet))
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
void (*)(ParsedActPacket&) | callback | Event handler |
ParsedActPacket
, see Data and Procedures.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)
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
uint8_t* | payload | Payload | Between : and LRC | |
int | payloadSize | Payload size | ||
uint8_t | checksum | Checksum | LRC of the payload |
Return Value
Type | Value | Description | Remarks |
---|---|---|---|
bool | true | Success | |
false | Error |
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)
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
uint8_t* | payload | Payload | Between : and LRC | |
int | payloadSize | Payload size |
Return Value
Type | Value | Description | Remarks |
---|---|---|---|
bool | true | Success | |
false | Error |
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)
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
uint8_t | logicalId | Destination logical device ID | ||
uint8_t | commandId | Command type | ||
uint8_t* | payload | Payload | Between : and LRC | |
int | payloadSize | Payload size | ||
uint8_t | checksum | Checksum | LRC of the payload |
Return Value
Type | Value | Description | Remarks |
---|---|---|---|
bool | true | Success | |
false | Error |
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)
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
uint8_t | logicalId | Destination logical device ID | ||
uint8_t | commandId | Command type | ||
uint8_t* | payload | Payload | Between : and LRC | |
int | payloadSize | Payload size |
Return Value
Type | Value | Description | Remarks |
---|---|---|---|
bool | true | Success | |
false | Error |
send()
<AppTweliteCommand
>
Super easy! Sends a command to operate standard app terminals to the parent device.
inline bool send(AppTweliteCommand& command)
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
AppTweliteCommand | command | Command data |
AppTweliteCommand
, see Data and Procedures.Return Value
Type | Value | Description | Remarks |
---|---|---|---|
bool | true | Success | |
false | Error |
send()
<AppIoCommand
>
Sends a command to operate remote control app terminals to the parent device.
inline bool send(AppIoCommand& command)
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
AppIoCommand | command | Command data |
AppIoCommand
, see Data and Procedures.Return Value
Type | Value | Description | Remarks |
---|---|---|---|
bool | true | Success | |
false | Error |
send()
<AppPalNoticeCommand
>
Sends a command to operate PAL app (notification PAL) terminals to the parent device.
inline bool send(AppPalNoticeCommand& command)
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
AppPalNoticeCommand | command | Command data |
AppPalNoticeCommand
, see Data and Procedures.Return Value
Type | Value | Description | Remarks |
---|---|---|---|
bool | true | Success | |
false | Error |
send()
<AppPalNoticeDetailedCommand
>
Sends a command (detailed format) to operate PAL app (notification PAL) terminals to the parent device.
inline bool send(AppPalNoticeDetailedCommand& command)
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
AppPalNoticeDetailedCommand | command | Command data |
AppPalNoticeDetailedCommand
, see Data and Procedures.Return Value
Type | Value | Description | Remarks |
---|---|---|---|
bool | true | Success | |
false | Error |
send()
<AppPalNoticeEventCommand
>
Sends a command (event) to operate PAL app (notification PAL) terminals to the parent device.
inline bool send(AppPalNoticeEventCommand& command)
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
AppPalNoticeEventCommand | command | Command data |
AppPalNoticeEventCommand
, see Data and Procedures.Return Value
Type | Value | Description | Remarks |
---|---|---|---|
bool | true | Success | |
false | Error |
send()
<AppPalUartAsciiCommand
>
Sends a command (simple format) to operate serial communication app (A mode) terminals to the parent device.
inline bool send(AppPalUartAsciiCommand& command)
Arguments
Type | Name | Description | Optional | Remarks |
---|---|---|---|---|
AppPalUartAsciiCommand | command | Command data |
AppPalUartAsciiCommand
, see Data and Procedures.Return Value
Type | Value | Description | Remarks |
---|---|---|---|
bool | true | Success | |
false | Error |