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

A library used on a terminal connected to the TWELITE parent device
MWings is a library used on a terminal connected to a TWELITE programmed with the parent/repeater application (App_Wings). It interprets the formatted strings output by App_Wings and provides the data received by the parent device to the terminal. It also constructs commands to App_Wings to control child devices.

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

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

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

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

1.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.1.2 - Class List

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

1.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

2 - TWELITE Wings API / MWings for Python

MWings for Modern Python
This is the TWELITE Wings API for modern Python.

2.1 - TWELITE Wings API / MWings for Python

Latest Version
This is the TWELITE Wings API for modern Python.

2.1.1 - mwings module

mwings

This is a top-level module that is often used directly.

src/mwings/__init__.py

Twelite

Interface for TWELITE

Inherits: threading.Thread

Twelite()

Twelite(port=None, rx_buffer_size=1024, timeout=100, tz=None, debugging=False)

Constructor. If a serial port is specified, it will be opened.

Parameters

NameTypeDescription
portoptional strSerial port name: disabled if None
rx_buffer_sizeintSize of the receive buffer in bytes
timeoutintTimeout between receiving packets (ms)
tzoptional tzinfoTimezone applied to received data: UTC if None
debuggingboolDebug output: enabled if True

Exceptions

  • IOError Serial port does not exist or is busy

close()

v1.0.10+

close()

Closes the serial port if it is open.

Parameters

None

Return value

None

add_listener()

@overload
add_listener(event, handler)
add_listener(event, handler)

Registers a receive handler.

Parameters

NameTypeDescription
eventcommon.PacketTypeIdentifier for the receive event
handlerCallable[[common.BarePacket], None]Handler for the receive event (raw data)
Callable[[common.SomeCallable], None]Handler for the receive event (parsed data)

Return value

None

on()

on(event)

Registers a receive handler (decorator version).

Parameters

NameTypeDescription
eventcommon.PacketTypeIdentifier for the receive event

Return value

TypeValueDescription
Callable[[common.SomeCallable], common.SomeCallable]-Decorated function

remove_all_listeners()

v1.0.9+

remove_all_listeners()

Removes all registered receive handlers.

Parameters

None

Return value

None

parse()

@overload
parse(character, use_lf=False)
parse(character, use_lf=False)
parse(character, use_lf=False)

Parses the given received data.

Parameters

NameTypeDescription
characterstrReceived data character: string of length 1
bytesReceived data character: bytes of length 1
intReceived data character: ASCII code
use_lfboolType of newline character: LF if True

Return value

TypeValueDescription
optional common.PacketTypecommon.PacketTypeParsed packet type
NoneNo parsed packet

Exceptions

  • RuntimeError Serial port is specified
  • ValueError Invalid character data detected

parse_line()

parse_line(line, use_lf=True)

Parses received data expressed as a single line string.

Parameters

NameTypeDescription
linestrReceived data string: a single line
use_lfboolType of newline character: LF if True

Return value

TypeValueDescription
optional common.PacketTypecommon.PacketTypeParsed packet type
NoneNo parsed packet

Exceptions

  • RuntimeError Serial port is specified

receive()

receive()

Parses data received on the serial port. Waits until the interpretation of one packet is complete.

Parameters

None

Return value

TypeValueDescription
common.PacketType-Parsed packet type

Exceptions

  • RuntimeError Serial port is not specified

run()

run()

Runs a subthread that performs reception. Overrides threading.Thread.run().

Parameters

None

Return value

None

send()

@overload
send(data)
send(data)

Sends commands from the serial port.

Parameters

NameTypeDescription
datacommon.SomeCommandVarious command data
common.BarePacketRaw command data

Return value

TypeValueDescription
boolTrueSuccess
FalseFailure

Exceptions

  • RuntimeError Serial port is not specified

set_timezone()

set_timezone(tz)

Sets the timezone applied to received data.

Parameters

NameTypeDescription
tztzinfoAny timezone: ZoneInfo
NoneUTC

Return value

None

start()

start()

Starts a subthread that performs reception. Overrides threading.Thread.start().

Parameters

None

Return value

None

Exceptions

  • RuntimeError Serial port is not specified

stop()

stop()

Stops the subthread that performs reception. Waits until handler calls for remaining received data are finished. This may take several seconds.

Parameters

None

Return value

None

Exceptions

  • RuntimeError Serial port is not specified

update()

update()

Parses data received on the serial port. Processes all data in the receive buffer and then immediately returns.

Parameters

None

Return value

TypeValueDescription
optional common.PacketTypecommon.PacketTypeParsed packet type
NoneNo parsed packet

Exceptions

  • RuntimeError Serial port is not specified

timezone

@property
update()

Return value

TypeValueDescription
tzinfo-Timezone applied to received data

2.1.1.1 - mwings.common Module

Stores data and procedures used throughout the library.

Contains data and procedures used throughout the library.

src/mwings/common.py

AccelEvent

Identifiers for accelerometer events

Inherits from: enum.IntEnum

  • DICE_1 Dice: 1
  • DICE_2 Dice: 2
  • DICE_3 Dice: 3
  • DICE_4 Dice: 4
  • DICE_5 Dice: 5
  • DICE_6 Dice: 6
  • SHAKE Shake
  • MOVE Move
  • NONE No event

AppPalNoticeBlinkSpeed

Identifiers for AppPal notification blink speed

Inherits from: enum.IntEnum

  • ALWAYS_ON Always on
  • SLOW Slow blinking
  • MEDIUM Moderate blinking
  • FAST Fast blinking

AppPalNoticeColor

Identifiers for AppPal notification colors

Inherits from: enum.IntEnum

  • RED Red
  • GREEN Green
  • BLUE Blue
  • YELLOW Yellow
  • PURPLE Purple
  • LIGHT_BLUE Light blue
  • WHITE White
  • WARM_WHITE Warm white

AppPalNoticeRGBWColor

Notification color expressed in RGBW format

Inherits from: pydantic.BaseModel

AppPalNoticeRGBWColor()

AppPalNoticeRGBWColor(*, red=0, green=0, blue=0, white=15)

Parameters

NameTypeDescription
redcommon.UInt8Red: 00xF
greencommon.UInt8Green: 00xF
bluecommon.UInt8Blue: 00xF
whitecommon.UInt8White: 00xF

You may pass a dictionary using ** unpacking.

u16()

u16()

Returns a 16-bit RGBW representation.

Parameters

None

Returns

TypeValueDescription
common.UInt16-16-bit RGBW representation

BarePacket

Raw packet data

Inherits from: pydantic.BaseModel

BarePacket()

BarePacket(payload, checksum=None, logical_and_command_id=None)

Parameters

NameTypeDescription
payloadbytesBinary payload data
checksumoptional common.UInt8LRC8: Automatically calculated if None
logical_and_command_idoptional tuple(common.UInt8, common.UInt8)Logical device ID and command ID

If the third argument is specified, the corresponding header in the payload is omitted.

i16_at()

i16_at(index)

Gets a signed 16-bit integer from the specified position.

Parameters

NameTypeDescription
indexintPosition in payload

Returns

TypeValueDescription
common.Int16-Numeric data

i32_at()

i32_at(index)

Gets a signed 32-bit integer from the specified position.

Parameters

NameTypeDescription
indexintPosition in payload

Returns

TypeValueDescription
common.Int32-Numeric data

i8_at()

i8_at(index)

Gets a signed 8-bit integer from the specified position.

Parameters

NameTypeDescription
indexintPosition in payload

Returns

TypeValueDescription
common.Int8-Numeric data

u16_at()

u16_at(index)

Gets an unsigned 16-bit integer from the specified position.

Parameters

NameTypeDescription
indexintPosition in payload

Returns

TypeValueDescription
common.UInt16-Numeric data

u32_at()

u32_at(index)

Gets an unsigned 32-bit integer from the specified position.

Parameters

NameTypeDescription
indexintPosition in payload

Returns

TypeValueDescription
common.UInt32-Numeric data

u8_at()

u8_at(index)

Gets an unsigned 8-bit integer from the specified position.

Parameters

NameTypeDescription
indexintPosition in payload

Returns

TypeValueDescription
common.UInt8-Numeric data

u8_from()

u8_from(index)

Gets a byte sequence starting from the specified index.

Parameters

NameTypeDescription
indexintStarting index in payload

Returns

TypeValueDescription
optional bytesbytesPartial byte sequence
NoneInvalid index

CommandBase

Abstract base class for commands

Inherits from: ABC, pydantic.BaseModel

CommandBase()

CommandBase(*, destination_logical_id=120)

Parameters

NameTypeDescription
destination_logical_idcommon.UInt8Logical device ID of destination

You may pass a dictionary using ** unpacking.

is_valid()

is_valid()

Checks if the command data is valid.

Parameters

None

Returns

TypeValueDescription
boolTrueValid
FalseInvalid

CommandSerializerBase

Static abstract base class for command serializers

Inherits from: ABC

serialize()

serialize(command)

Expands the given command into a raw byte sequence.

Parameters

NameTypeDescription
commandcommon.SomeCommandA command data object

Returns

TypeValueDescription
optional common.BarePacketcommon.BarePacketExpanded packet data
NoneInvalid command

CrossSectional[T]

Tuple-like class for storing cross-sectional data at a specific time point

Inherits from: common.FixedTuple[T]

CrossSectional[T]()

CrossSectional[T](length, elements)

Parameters

NameTypeDescription
Tcommon.TElement type
lengthintNumber of elements
elementsIterable[T]Element values

Exceptions

  • ValueError if the number of elements is invalid

DtypedDecimal

Abstract base class for numeric types that retain pandas dtype attribute

get_dtype()

get_dtype()

Retrieves the corresponding pandas dtype identifier.

Parameters

None

Returns

TypeValueDescription
str-dtype identifier

FixedList[T]

A class representing a fixed-length list

Inherits from: MutableSequence[T]

FixedList[T]()

FixedList[T](length, initial_elements)

Parameters

NameTypeDescription
Tcommon.TType of elements
lengthintNumber of elements
initial_elementsIterable[T]Initial elements

Exceptions

  • ValueError if the number of elements is invalid

insert()

insert(index, value)

Inserts an element at the specified index.

Parameters

NameTypeDescription
indexintIndex to insert
valuecommon.TElement to insert

Returns

None

Exceptions

  • IndexError if the index is invalid

FixedTuple[T]

Class representing a fixed-length tuple

Inherits from: Sequence[T]

FixedTuple[T]()

FixedTuple[T](length, elements)

Parameters

NameTypeDescription
Tcommon.TType of elements
lengthintNumber of elements
elementsIterable[T]Elements

Exceptions

  • ValueError if the number of elements is invalid

Float32

Class to store a 32-bit floating point value

Inherits from: float, common.DtypedDecimal

Float32()

Float32(value=None)

Parameters

NameTypeDescription
valueoptional floatInitial value

Exceptions

  • ValueError if the value is out of range

Float64

Class to store a 64-bit floating point value

Inherits from: float, common.DtypedDecimal

Float64()

Float64(value=None)

Parameters

NameTypeDescription
valueoptional floatInitial value

Exceptions

  • ValueError if the value is out of range

Int16

Class to store a 16-bit integer

Inherits from: int, common.DtypedDecimal

Int16()

Int16(value=None)

Parameters

NameTypeDescription
valueoptional intInitial value

Exceptions

  • ValueError if the value is out of range

hex()

hex()

Returns a hexadecimal string representation.

Python’s built-in hex() function does not accept int subclasses. This method provides a similar interface as float.hex().

Returns

TypeValueDescription
str-Hexadecimal string (lowercase)

Int32

Class to store a 32-bit integer

Inherits from: int, common.DtypedDecimal

Int32()

Int32(value=None)

Parameters

NameTypeDescription
valueoptional intInitial value

Exceptions

  • ValueError if the value is out of range

hex()

Same as in Int16

Int8

Class to store an 8-bit integer

Inherits from: int, common.DtypedDecimal

Int8()

Int8(value=None)

Parameters

NameTypeDescription
valueoptional intInitial value

Exceptions

  • ValueError if the value is out of range

hex()

Same as in Int16

MagnetState

Identifiers for magnet events

Inherits from: enum.IntEnum

  • NOT_DETECTED No magnet
  • N_POLE_IS_CLOSE N pole is close
  • S_POLE_IS_CLOSE S pole is close

PacketParserBase

Static abstract base class for packet parsers

Inherits from: ABC

is_valid()

is_valid(bare_packet)

Checks if the given bare packet is valid.

parse()

parse(bare_packet)

Parses the given bare packet.

PacketType

Identifiers for packet types

Inherits from: enum.StrEnum

(Keep enum entries as-is, only translated names if needed)

SomeCallable, SomeCommand, SomeParsedPacket, T, Timezone

Keep these type variable and constant definitions unchanged.

TimeSeries[T]

Tuple-like class for storing time-series data

Inherits from: common.FixedTuple[T]

TimeSeries[T]()

TimeSeries[T](length, elements)

Parameters

NameTypeDescription
Tcommon.TElement type
lengthintNumber of elements
elementsIterable[T]Element values

Exceptions

  • ValueError if the number of elements is invalid

UInt16, UInt32, UInt8

Same structure as Int16, Int32, Int8 respectively with class names and descriptions updated accordingly:

  • Class to store a 16/32/8-bit unsigned integer
  • hex() method same as above

2.1.1.2 - mwings.parsers Module

Parsers for interpreting packets and handling their data.
Parsers for interpreting packets and handling their data.

2.1.1.2.1 - mwings.parsers.app_twelite Module

Parsers for packets sent from the Standard App (App_TWELITE) and data structures to store their contents.

Parsers for packets sent from the Extremely simple! Standard App (App_Twelite) and data structures to handle the data.

src/mwings/parsers/app_twelite.py

PacketParser

A static class parser that interprets packets representing data sent from the Extremely simple! Standard App.

Inherits: common.PacketParserBase

is_valid()

is_valid(bare_packet)

Checks whether the given raw packet is valid.

Parameters

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
boolTrueValid, parsable
FalseInvalid, not parsable

parse()

parse(bare_packet)

Parses the given raw packet.

Parameters

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
optional ParsedPacketParsedPacket instanceParsed data
NoneParsing failed

ParsedPacket

A structure to store the result of parsing packets representing data sent from the Extremely simple! Standard App.

Inherits: common.ParsedPacketBase

ParsedPacket()

ParsedPacket(*, time_parsed=None, packet_type=PacketType.BARE, sequence_number=None, source_serial_id=0, source_logical_id=0, lqi=None, supply_voltage=None, destination_logical_id=120, relay_count=0, periodic=False, di_changed=<mwings.common.CrossSectional object>, di_state=<mwings.common.CrossSectional object>, ai_voltage=<mwings.common.CrossSectional object>)

Parameters

NameTypeDescription
time_parsedoptional AwareDatetimeParsing timestamp
packet_typecommon.PacketTypePacket type
sequence_numberoptional common.UInt16Sequence number
source_serial_idcommon.UInt32Source serial ID
source_logical_idcommon.UInt8Source logical device ID
lqioptional common.UInt8Radio communication quality
supply_voltageoptional common.UInt16Supply voltage (mV)
destination_logical_idcommon.UInt8Destination logical device ID
relay_countcommon.UInt8Relay count
periodicboolWhether periodic transmission
di_changedcommon.CrossSectional[bool](4)Digital interface change presence
di_statecommon.CrossSectional[bool](4)Digital interface state
ai_voltagecommon.CrossSectional[common.UInt16](4)Analog interface voltages

You can also pass a dictionary unpacked with **.

to_df()

to_df(include=None, exclude=None, verbose=True)

Converts parsed data to a pandas DataFrame.

Parameters

NameTypeDescription
includeoptional set[str]Set of columns (members) to include in the DataFrame
excludeoptional set[str]Set of columns (members) to exclude from the DataFrame
verboseboolWhether to include system information (only when other args are None)

Returns

TypeValueDescription
pd.DataFrame-Converted DataFrame

Exceptions

  • EnvironmentError if pandas is not installed

to_dict()

to_dict(include=None, exclude=None, verbose=True, spread=False, sort_keys=False)

Converts parsed data to a dictionary.

Parameters

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the dictionary
excludeoptional set[str]Set of keys (members) to exclude from the dictionary
verboseboolWhether to include system information (only when other args are None)
spreadboolWhether to split non-time-series list-like data
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
dict[str, Any]-Converted dictionary

to_json()

to_json(include=None, exclude=None, verbose=True, spread=False, indent=2, sort_keys=False)

Converts parsed data to JSON format.

Parameters

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the JSON
excludeoptional set[str]Set of keys (members) to exclude from the JSON
verboseboolWhether to include system information (only when other args are None)
spreadboolWhether to split non-time-series list-like data
indentoptional intNumber of spaces for indentation (None for no newline)
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
str-Converted JSON string

model_*()

2.1.1.2.2 - mwings.parsers.app_io Module

Parsers for packets sent from the remote control app and data structures to store their contents.

Parsers for packets sent from the remote control app and data structures to store their contents.

src/mwings/parsers/app_io.py

PacketParser

Static class for a parser that interprets packets representing data sent from the remote control app.

Inherits from: common.PacketParserBase

is_valid()

is_valid(bare_packet)

Checks whether the given raw packet is valid.

Arguments

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
boolTrueValid, parsable
FalseInvalid, not parsable

parse()

parse(bare_packet)

Parses the given raw packet.

Arguments

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
optional ParsedPacketData of type ParsedPacketParsed data
NoneParsing failed

ParsedPacket

Data structure to store the result of interpreting packets representing data sent from the remote control app.

Inherits from: common.ParsedPacketBase

ParsedPacket()

ParsedPacket(*, time_parsed=None, packet_type=PacketType.BARE, sequence_number=None, source_serial_id=0, source_logical_id=0, lqi=None, supply_voltage=None, relay_count=0, di_state=<mwings.common.CrossSectional object>, di_valid=<mwings.common.CrossSectional object>, di_interrupt=<mwings.common.CrossSectional object>)

Arguments

Properties inherited from the base class are also listed.

NameTypeDescription
time_parsedoptional AwareDatetimeParsing timestamp
packet_typecommon.PacketTypePacket type
sequence_numberoptional common.UInt16Sequence number
source_serial_idcommon.UInt32Source serial ID
source_logical_idcommon.UInt8Source logical device ID
lqioptional common.UInt8Radio communication quality
supply_voltageoptional common.UInt16Always None because ADC is not used
relay_countcommon.UInt8Number of relays
di_changedcommon.CrossSectional[bool](12)Digital interface change status
di_statecommon.CrossSectional[bool](12)Digital interface state
di_interruptcommon.CrossSectional[bool](12)Digital interface interrupt status

You can pass a dictionary unpacked with **.

to_df()

to_df(include=None, exclude=None, verbose=True)

Converts the parsed data to a pandas DataFrame.

Arguments

NameTypeDescription
includeoptional set[str]Set of columns (members) to include in the DataFrame
excludeoptional set[str]Set of columns (members) to exclude from the DataFrame
verboseboolInclude system information (only when other args are None)

Returns

TypeValueDescription
pd.DataFrame-Converted DataFrame

Exceptions

  • EnvironmentError if pandas is not installed

to_dict()

to_dict(include=None, exclude=None, verbose=True, spread=False, sort_keys=False)

Converts the parsed data to a dictionary.

Arguments

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the dictionary
excludeoptional set[str]Set of keys (members) to exclude from the dictionary
verboseboolInclude system information (only when other args are None)
spreadboolWhether to split non-time-series list-like data
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
dict[str, Any]-Converted dictionary

to_json()

to_json(include=None, exclude=None, verbose=True, spread=False, indent=2, sort_keys=False)

Converts the parsed data to JSON format.

Arguments

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the JSON
excludeoptional set[str]Set of keys (members) to exclude from the JSON
verboseboolInclude system information (only when other args are None)
spreadboolWhether to split non-time-series list-like data
indentoptional intNumber of spaces for indentation (None for no newline)
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
str-Converted JSON string

model_*()

2.1.1.2.3 - mwings.parsers.app_aria Module

Parsers for packets sent from App Aria and data structures to store their contents.

Parsers for packets sent from App Aria and data structures to store their contents.

src/mwings/parsers/app_aria.py

PacketParser

Static class parser that interprets packets representing data sent from the Aria app

Inherits: common.PacketParserBase

is_valid()

is_valid(bare_packet)

Checks whether the given raw packet is valid.

Arguments

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
boolTrueValid, parsable
FalseInvalid, not parsable

parse()

parse(bare_packet)

Parses the given raw packet.

Arguments

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
optional ParsedPacketData of type ParsedPacketParsed data
NoneParsing failed

ParsedPacket

Structure to store the result of interpreting packets representing data sent from the Aria app

Inherits: common.ParsedPacketBase

ParsedPacket()

ParsedPacket(*, time_parsed=None, packet_type=PacketType.BARE, sequence_number=None, source_serial_id=0, source_logical_id=0, lqi=None, supply_voltage=None, temp_100x=0, humid_100x=0, magnet_state=MagnetState.NOT_DETECTED, magnet_state_changed=False)

Arguments

Including inherited properties.

NameTypeDescription
time_parsedoptional AwareDatetimeParsing time
packet_typecommon.PacketTypePacket type
sequence_numberoptional common.UInt16Sequence number
source_serial_idcommon.UInt32Source serial ID
source_logical_idcommon.UInt8Source logical device ID
lqioptional common.UInt8Radio communication quality
supply_voltageoptional common.UInt16Supply voltage (mV)
router_serial_idcommon.UInt32Serial ID of the first relay device (0x80000000 if none) v1.0.13+
temp_100xcommon.Int16Temperature multiplied by 100 (°C)
humid_100xcommon.UInt16Relative humidity multiplied by 100
magnet_statecommon.MagnetStateMagnet state
magnet_state_changedboolWhether the magnet state has changed

You can also pass a dictionary unpacked with **.

to_df()

to_df(include=None, exclude=None, verbose=True)

Converts the parsed data to a pandas DataFrame format.

Arguments

NameTypeDescription
includeoptional set[str]Set of columns (members) to include in the DataFrame
excludeoptional set[str]Set of columns (members) to exclude from the DataFrame
verboseboolWhether to include system information (only if other arguments are None)

Returns

TypeValueDescription
pd.DataFrame-Converted DataFrame

Exceptions

  • EnvironmentError if pandas is not installed

to_dict()

to_dict(include=None, exclude=None, verbose=True, spread=False, sort_keys=False)

Converts the parsed data to a dictionary format.

Arguments

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the dictionary
excludeoptional set[str]Set of keys (members) to exclude from the dictionary
verboseboolWhether to include system information (only if other arguments are None)
spreadboolWhether to split non-time-series list-like data
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
dict[str, Any]-Converted dictionary

to_json()

to_json(include=None, exclude=None, verbose=True, spread=False, indent=2, sort_keys=False)

Converts the parsed data to JSON format.

Arguments

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the JSON
excludeoptional set[str]Set of keys (members) to exclude from the JSON
verboseboolWhether to include system information (only if other arguments are None)
spreadboolWhether to split non-time-series list-like data
indentoptional intNumber of spaces for indentation (None for no line breaks)
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
str-Converted JSON string

model_*()

2.1.1.2.4 - mwings.parsers.app_cue Module

Parsers for packets sent from the TWELITE CUE mode and data structures to store their contents.

Parsers for packets sent from the TWELITE CUE mode and data structures to store their contents.

src/mwings/parsers/app_cue.py

PacketParser

Static class for parsing packets representing data sent from the Cue app (TWELITE CUE mode).

Inherits from: common.PacketParserBase

is_valid()

is_valid(bare_packet)

Checks whether the given bare packet is valid.

Parameters

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
boolTrueValid and parsable
FalseInvalid and unparsable

parse()

parse(bare_packet)

Parses the given bare packet.

Parameters

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
optional ParsedPacketParsedPacket typed dataParsed data
NoneUnparsable

ParsedPacket

Structure to store the result of parsing packets representing data sent from the Cue app (TWELITE CUE mode).

Inherits from: common.ParsedPacketBase

ParsedPacket()

ParsedPacket(*, time_parsed=None, packet_type=PacketType.BARE, sequence_number=None, source_serial_id=0, source_logical_id=0, lqi=None, supply_voltage=None, sample_count=10, samples_x=<mwings.common.TimeSeries object>, samples_y=<mwings.common.TimeSeries object>, samples_z=<mwings.common.TimeSeries object>, has_accel_event=False, accel_event=AccelEvent.NONE, magnet_state=MagnetState.NOT_DETECTED, magnet_state_changed=False)

Parameters

Including properties inherited from the base class.

NameTypeDescription
time_parsedoptional AwareDatetimeParsing timestamp
packet_typecommon.PacketTypePacket type
sequence_numberoptional common.UInt16Sequence number
source_serial_idcommon.UInt32Source serial ID
source_logical_idcommon.UInt8Source logical device ID
lqioptional common.UInt8Radio communication quality
supply_voltageoptional common.UInt16Supply voltage (mV)
router_serial_idcommon.UInt32Serial ID of the first relay device (no relay is 0x80000000) v1.0.13+
sample_countcommon.UInt8Number of accelerometer samples per axis
samples_xcommon.TimeSeries[common.Int16]X-axis accelerometer samples
samples_ycommon.TimeSeries[common.Int16]Y-axis accelerometer samples
samples_zcommon.TimeSeries[common.Int16]Z-axis accelerometer samples
has_accel_eventboolPresence of accelerometer event
accel_eventcommon.AccelEventAccelerometer event
magnet_statecommon.MagnetStateMagnet state
magnet_state_changedboolWhether magnet state has changed

You can also pass a dictionary unpacked with **.

to_df()

to_df(include=None, exclude=None, verbose=True)

Converts the parsed data to a pandas DataFrame.

Parameters

NameTypeDescription
includeoptional set[str]Set of columns (members) to include in the DataFrame
excludeoptional set[str]Set of columns (members) to exclude from the DataFrame
verboseboolWhether to include system information (only when other arguments are None)

Returns

TypeValueDescription
pd.DataFrame-Converted DataFrame

Exceptions

  • EnvironmentError if pandas is not installed

to_dict()

to_dict(include=None, exclude=None, verbose=True, spread=False, sort_keys=False)

Converts the parsed data to a dictionary.

Parameters

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the dictionary
excludeoptional set[str]Set of keys (members) to exclude from the dictionary
verboseboolWhether to include system information (only when other arguments are None)
spreadboolWhether to split non-time-series list-like data
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
dict[str, Any]-Converted dictionary

to_json()

to_json(include=None, exclude=None, verbose=True, spread=False, indent=2, sort_keys=False)

Converts the parsed data to JSON format.

Parameters

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the JSON
excludeoptional set[str]Set of keys (members) to exclude from the JSON
verboseboolWhether to include system information (only when other arguments are None)
spreadboolWhether to split non-time-series list-like data
indentoptional intNumber of spaces for indentation (None for no newline)
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
str-Converted JSON string

model_*()

2.1.1.2.5 - mwings.parsers.app_cue_pal_event Module

Parsers for packets sent from TWELITE CUE in PAL event mode (Dice/Move mode) and data structures to store their contents.

Parsers for packets sent from TWELITE CUE in PAL event mode (Dice/Move mode) and data structures to store their contents.

src/mwings/parsers/app_cue_pal_event.py

PacketParser

Static class parser that interprets packets representing data sent from the CUE app (operation PAL mode: Dice/Move mode).

Inherits from: common.PacketParserBase

is_valid()

is_valid(bare_packet)

Checks whether the given raw packet is valid.

Arguments

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
boolTrueValid, parsable
FalseInvalid, not parsable

parse()

parse(bare_packet)

Parses the given raw packet.

Arguments

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
optional ParsedPacketData of type ParsedPacketParsed data
NoneParsing failed

ParsedPacket

Data structure to store the result of parsing packets representing data sent from the CUE app (operation PAL mode: Dice/Move mode).

Inherits from: common.ParsedPacketBase

ParsedPacket()

ParsedPacket(*, time_parsed=None, packet_type=PacketType.BARE, sequence_number=None, source_serial_id=0, source_logical_id=0, lqi=None, supply_voltage=None, ai1_voltage=0, accel_event=AccelEvent.NONE)

Arguments

Includes inherited properties as well.

NameTypeDescription
time_parsedoptional AwareDatetimeParsing timestamp
packet_typecommon.PacketTypePacket type
sequence_numberoptional common.UInt16Sequence number
source_serial_idcommon.UInt32Source serial ID
source_logical_idcommon.UInt8Source logical device ID
lqioptional common.UInt8Radio communication quality
supply_voltageoptional common.UInt16Supply voltage (mV)
router_serial_idcommon.UInt32Serial ID of the first relay device (no relay is 0x80000000) v1.0.13+
ai1_voltagecommon.UInt16Voltage of AI1 (mV)
accel_eventcommon.AccelEventAcceleration event

You can also pass a dictionary unpacked with **.

to_df()

to_df(include=None, exclude=None, verbose=True)

Converts the parsed data into a pandas DataFrame format.

Arguments

NameTypeDescription
includeoptional set[str]Set of columns (members) to include in the DataFrame
excludeoptional set[str]Set of columns (members) to exclude from the DataFrame
verboseboolInclude system information (only if other arguments are None)

Returns

TypeValueDescription
pd.DataFrame-Converted DataFrame

Exceptions

  • EnvironmentError if pandas is not installed

to_dict()

to_dict(include=None, exclude=None, verbose=True, spread=False, sort_keys=False)

Converts the parsed data into dictionary format.

Arguments

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the dictionary
excludeoptional set[str]Set of keys (members) to exclude from the dictionary
verboseboolInclude system information (only if other arguments are None)
spreadboolWhether to split non-time-series list-like data
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
dict[str, Any]-Converted dictionary

to_json()

to_json(include=None, exclude=None, verbose=True, spread=False, indent=2, sort_keys=False)

Converts the parsed data into JSON format.

Arguments

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the JSON
excludeoptional set[str]Set of keys (members) to exclude from the JSON
verboseboolInclude system information (only if other arguments are None)
spreadboolWhether to split non-time-series list-like data
indentoptional intNumber of spaces for indentation (None means no line breaks)
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
str-Converted JSON string

model_*()

2.1.1.2.6 - mwings.parsers.app_pal_openclose Module

Parsers for packets sent from PAL App (Open/Close PAL) and data structures to store their contents.

Parsers for packets sent from PAL App (Open/Close PAL) and data structures to store their contents.

src/mwings/parsers/app_pal_openclose.py

PacketParser

Static class parser that interprets packets representing data sent from PAL App (Open/Close PAL).

Inherits from: common.PacketParserBase

is_valid()

is_valid(bare_packet)

Checks whether the given raw packet is valid.

Parameters

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
boolTrueValid, parsable
FalseInvalid, not parsable

parse()

parse(bare_packet)

Parses the given raw packet.

Parameters

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
optional ParsedPacketData of type ParsedPacketParsed data
NoneParsing failed

ParsedPacket

Structure to store the result of parsing packets representing data sent from PAL App (Open/Close PAL).

Inherits from: common.ParsedPacketBase

ParsedPacket()

ParsedPacket(*, time_parsed=None, packet_type=PacketType.BARE, sequence_number=None, source_serial_id=0, source_logical_id=0, lqi=None, supply_voltage=None, ai1_voltage=0, magnet_state=MagnetState.NOT_DETECTED, magnet_state_changed=False)

Parameters

Properties inherited from the base class are also listed.

NameTypeDescription
time_parsedoptional AwareDatetimeParsing time
packet_typecommon.PacketTypePacket type
sequence_numberoptional common.UInt16Sequence number
source_serial_idcommon.UInt32Source serial ID
source_logical_idcommon.UInt8Source logical device ID
lqioptional common.UInt8Radio communication quality
supply_voltageoptional common.UInt16Supply voltage (mV)
router_serial_idcommon.UInt32Serial ID of the first relay device (0x80000000 if none) v1.0.13+
ai1_voltagecommon.UInt16Voltage of AI1 (mV)
magnet_statecommon.MagnetStateMagnet state
magnet_state_changedboolWhether the magnet state has changed

You can also pass a dictionary unpacked with **.

to_df()

to_df(include=None, exclude=None, verbose=True)

Converts the parsed data into a pandas DataFrame.

Parameters

NameTypeDescription
includeoptional set[str]Set of columns (members) to include in DataFrame
excludeoptional set[str]Set of columns (members) to exclude from DataFrame
verboseboolWhether to include system information (only when other args are None)

Returns

TypeValueDescription
pd.DataFrame-Converted DataFrame

Exceptions

  • EnvironmentError if pandas is not installed

to_dict()

to_dict(include=None, exclude=None, verbose=True, spread=False, sort_keys=False)

Converts the parsed data into a dictionary.

Parameters

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the dictionary
excludeoptional set[str]Set of keys (members) to exclude from the dictionary
verboseboolWhether to include system information (only when other args are None)
spreadboolWhether to split non-time-series list-like data
sort_keysboolWhether to sort by keys

Returns

TypeValueDescription
dict[str, Any]-Converted dictionary

to_json()

to_json(include=None, exclude=None, verbose=True, spread=False, indent=2, sort_keys=False)

Converts the parsed data into JSON format.

Parameters

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in JSON
excludeoptional set[str]Set of keys (members) to exclude from JSON
verboseboolWhether to include system information (only when other args are None)
spreadboolWhether to split non-time-series list-like data
indentoptional intNumber of spaces for indentation (None for no newline)
sort_keysboolWhether to sort by keys

Returns

TypeValueDescription
str-Converted JSON string

model_*()

2.1.1.2.7 - mwings.parsers.app_pal_amb Module

Parsers for packets sent from PAL App (Environmental PAL) and data structures to store their contents.

Parsers for packets sent from PAL App (Environmental PAL) and data structures to store their contents.

src/mwings/parsers/app_pal_amb.py

PacketParser

A static class parser that interprets packets representing data sent from PAL App (Environmental PAL).

Inherits from: common.PacketParserBase

is_valid()

is_valid(bare_packet)

Checks whether the given raw packet is valid.

Parameters

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
boolTrueValid, parsable
FalseInvalid, unparsable

parse()

parse(bare_packet)

Parses the given raw packet.

Parameters

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
optional ParsedPacketParsedPacket instanceParsed data
NoneUnparsable

ParsedPacket

A structure to store the result of parsing packets representing data sent from PAL App (Environmental PAL).

Inherits from: common.ParsedPacketBase

ParsedPacket()

ParsedPacket(*, time_parsed=None, packet_type=PacketType.BARE, sequence_number=None, source_serial_id=0, source_logical_id=0, lqi=None, supply_voltage=None, ai1_voltage=0, temp_100x=0, humid_100x=0, illuminance=0)

Parameters

Including properties inherited from the base class.

NameTypeDescription
time_parsedoptional AwareDatetimeParsing timestamp
packet_typecommon.PacketTypePacket type
sequence_numberoptional common.UInt16Sequence number
source_serial_idcommon.UInt32Source serial ID
source_logical_idcommon.UInt8Source logical device ID
lqioptional common.UInt8Radio communication quality
supply_voltageoptional common.UInt16Supply voltage (mV)
router_serial_idcommon.UInt32Serial ID of first relay device (0x80000000 if none) v1.0.13+
ai1_voltagecommon.UInt16Voltage of AI1 (mV)
temp_100xcommon.Int16Temperature multiplied by 100 (°C)
humid_100xcommon.UInt16Relative humidity multiplied by 100
illuminancecommon.UInt32Illuminance (lx)

You can also pass a dictionary unpacked with **.

to_df()

to_df(include=None, exclude=None, verbose=True)

Converts the parsed data into a pandas DataFrame.

Parameters

NameTypeDescription
includeoptional set[str]Set of columns (members) to include in the DataFrame
excludeoptional set[str]Set of columns (members) to exclude from the DataFrame
verboseboolWhether to include system information (only if other args are None)

Returns

TypeDescription
pd.DataFrameConverted DataFrame

Exceptions

  • EnvironmentError if pandas is not installed

to_dict()

to_dict(include=None, exclude=None, verbose=True, spread=False, sort_keys=False)

Converts the parsed data into a dictionary.

Parameters

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the dictionary
excludeoptional set[str]Set of keys (members) to exclude from the dictionary
verboseboolWhether to include system information (only if other args are None)
spreadboolWhether to split non-time-series list-like data
sort_keysboolWhether to sort keys

Returns

TypeDescription
dict[str, Any]Converted dictionary

to_json()

to_json(include=None, exclude=None, verbose=True, spread=False, indent=2, sort_keys=False)

Converts the parsed data into a JSON string.

Parameters

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the JSON
excludeoptional set[str]Set of keys (members) to exclude from the JSON
verboseboolWhether to include system information (only if other args are None)
spreadboolWhether to split non-time-series list-like data
indentoptional intNumber of indentation spaces (None for no newlines)
sort_keysboolWhether to sort keys

Returns

TypeDescription
strConverted JSON string

model_*()

2.1.1.2.8 - mwings.parsers.app_pal_mot Module

Parsers for packets sent from PAL App (Motion PAL) or CUE App in Motion PAL Mode (accelerometer measurement).

Parsers for packets sent from PAL App (Motion PAL) or CUE App in Motion PAL Mode (accelerometer measurement), and data structures to store the parsed information.

src/mwings/parsers/app_pal_mot.py

PacketParser

A static class parser that interprets packets representing data sent from PAL App (Motion PAL) or CUE App (Motion PAL Mode: accelerometer measurement).

Inherits: common.PacketParserBase

is_valid()

is_valid(bare_packet)

Checks whether the given bare packet is valid.

Arguments

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
boolTrueValid, parsable
FalseInvalid, not parsable

parse()

parse(bare_packet)

Parses the given bare packet.

Arguments

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
optional ParsedPacketParsedPacket instanceParsed data
NoneParsing failed

ParsedPacket

A data structure to store the result of parsing packets sent from PAL App (Motion PAL) or CUE App (Motion PAL Mode: accelerometer measurement).

Inherits: common.ParsedPacketBase

ParsedPacket()

ParsedPacket(*, time_parsed=None, packet_type=PacketType.BARE, sequence_number=None, source_serial_id=0, source_logical_id=0, lqi=None, supply_voltage=None, ai1_voltage=0, sample_count=16, samples_x=<mwings.common.TimeSeries object>, samples_y=<mwings.common.TimeSeries object>, samples_z=<mwings.common.TimeSeries object>, sampling_frequency=25)

Arguments

Including properties inherited from the base class.

NameTypeDescription
time_parsedoptional AwareDatetimeParsing timestamp
packet_typecommon.PacketTypePacket type
sequence_numberoptional common.UInt16Sequence number
source_serial_idcommon.UInt32Source serial ID
source_logical_idcommon.UInt8Source logical device ID
lqioptional common.UInt8Radio communication quality
supply_voltageoptional common.UInt16Supply voltage (mV)
router_serial_idcommon.UInt32Serial ID of the first relay device (0x80000000 if none) v1.0.13+
ai1_voltagecommon.UInt16Voltage of AI1 (mV)
sample_countcommon.UInt8Number of acceleration samples per axis
samples_xcommon.TimeSeries[common.Int16]Acceleration samples on X axis
samples_ycommon.TimeSeries[common.Int16]Acceleration samples on Y axis
samples_zcommon.TimeSeries[common.Int16]Acceleration samples on Z axis
sampling_frequencycommon.UInt16Acceleration sampling frequency

You can also pass a dictionary unpacked with **.

to_df()

to_df(include=None, exclude=None, verbose=True)

Converts the parsed data into a pandas DataFrame.

Arguments

NameTypeDescription
includeoptional set[str]Set of columns (members) to include in the DataFrame
excludeoptional set[str]Set of columns (members) to exclude from the DataFrame
verboseboolWhether to include system information (only effective if other arguments are None)

Returns

TypeDescription
pd.DataFrameConverted DataFrame

Exceptions

  • EnvironmentError if pandas is not installed

to_dict()

to_dict(include=None, exclude=None, verbose=True, spread=False, sort_keys=False)

Converts the parsed data into a dictionary.

Arguments

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the dictionary
excludeoptional set[str]Set of keys (members) to exclude from the dictionary
verboseboolWhether to include system information (only effective if other arguments are None)
spreadboolWhether to split non-time-series list-like data
sort_keysboolWhether to sort keys

Returns

TypeDescription
dict[str, Any]Converted dictionary

to_json()

to_json(include=None, exclude=None, verbose=True, spread=False, indent=2, sort_keys=False)

Converts the parsed data into JSON format.

Arguments

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the JSON
excludeoptional set[str]Set of keys (members) to exclude from the JSON
verboseboolWhether to include system information (only effective if other arguments are None)
spreadboolWhether to split non-time-series list-like data
indentoptional intNumber of spaces for indentation (None for no newlines)
sort_keysboolWhether to sort keys

Returns

TypeDescription
strConverted JSON string

model_*()

2.1.1.2.9 - mwings.parsers.app_uart_ascii Module

Parsers for packets sent from the serial communication app (format mode: simplified).

Parsers for packets sent from the serial communication app (format mode: simplified) and data structures to store their contents.

src/mwings/parsers/app_uart_ascii.py

PacketParser

Static class parser that interprets packets representing data sent from the serial communication app (format mode: simplified).

Inherits: common.PacketParserBase

is_valid()

is_valid(bare_packet)

Checks whether the given bare packet is valid.

Parameters

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
boolTrueValid, can be parsed
FalseInvalid, cannot be parsed

parse()

parse(bare_packet)

Parses the given bare packet.

Parameters

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
optional ParsedPacketAn instance of ParsedPacketParsed data
NoneCannot parse

ParsedPacket

Structure to hold the results of parsing packets representing data sent from the serial communication app (format mode: simplified).

Inherits: common.ParsedPacketBase

ParsedPacket()

ParsedPacket(*, time_parsed=None, packet_type=PacketType.BARE, sequence_number=None, source_serial_id=0, source_logical_id=0, lqi=None, supply_voltage=None, command_id=0, data=b'')

Parameters

Including inherited properties.

NameTypeDescription
time_parsedoptional AwareDatetimeParsing timestamp
packet_typecommon.PacketTypePacket type
sequence_numberoptional common.UInt16Not obtainable, always None
source_serial_idcommon.UInt32Source serial ID
source_logical_idcommon.UInt8Source logical device ID
lqioptional common.UInt8Not obtainable, always None
supply_voltageoptional common.UInt16Not obtainable, always None
command_idcommon.UInt8Command ID
databytesData

You can also pass a dictionary unpacked with **.

to_df()

to_df(include=None, exclude=None, verbose=True)

Converts parsed data into a pandas DataFrame.

Parameters

NameTypeDescription
includeoptional set[str]Set of columns (members) to include in the DataFrame
excludeoptional set[str]Set of columns (members) to exclude from the DataFrame
verboseboolWhether to include system information (only if other args are None)

Returns

TypeValueDescription
pd.DataFrame-Converted DataFrame

Exceptions

  • EnvironmentError if pandas is not installed

to_dict()

to_dict(include=None, exclude=None, verbose=True, spread=False, sort_keys=False)

Converts parsed data into a dictionary.

Parameters

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the dictionary
excludeoptional set[str]Set of keys (members) to exclude from the dictionary
verboseboolWhether to include system information (only if other args are None)
spreadboolWhether to split non-time-series list-like data
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
dict[str, Any]-Converted dictionary

to_json()

to_json(include=None, exclude=None, verbose=True, spread=False, indent=2, sort_keys=False)

Converts parsed data into JSON format.

Parameters

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in JSON
excludeoptional set[str]Set of keys (members) to exclude from JSON
verboseboolWhether to include system information (only if other args are None)
spreadboolWhether to split non-time-series list-like data
indentoptional intNumber of indentation spaces (None for no newlines)
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
str-Converted JSON string

model_*()

2.1.1.2.10 - mwings.parsers.app_uart_ascii_extended Module

Parsers for packets sent from the serial communication app (format mode: extended).

Parsers for packets sent from the serial communication app (format mode: extended) and data structures to store their contents.

src/mwings/parsers/app_uart_ascii_extended.py

PacketParser

Static class parser for interpreting packets representing data sent from the serial communication app (format mode: extended).

Inherits from: common.PacketParserBase

is_valid()

is_valid(bare_packet)

Checks whether the given bare packet is valid.

Parameters

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
boolTrueValid, parsable
FalseInvalid, not parsable

parse()

parse(bare_packet)

Parses the given bare packet.

Parameters

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
optional ParsedPacketInstance of ParsedPacketParsed data
NoneParsing failed

ParsedPacket

Data structure to store the results of parsing packets representing data sent from the serial communication app (format mode: extended).

Inherits from: common.ParsedPacketBase

ParsedPacket()

ParsedPacket(*, time_parsed=None, packet_type=PacketType.BARE, sequence_number=None, source_serial_id=0, source_logical_id=0, lqi=None, supply_voltage=None, destination_serial_id=120, command_id=0, data=b'')

Parameters

Including inherited properties.

NameTypeDescription
time_parsedoptional AwareDatetimeParsing timestamp
packet_typecommon.PacketTypePacket type
sequence_numberoptional common.UInt16Not available, always None
source_serial_idcommon.UInt32Sender’s serial ID
source_logical_idcommon.UInt8Sender’s logical device ID
lqicommon.UInt8Radio signal quality
supply_voltageoptional common.UInt16Not available, always None
destination_serial_idcommon.UInt32Receiver’s serial ID
command_idcommon.UInt8Command ID
databytesData

You can also pass a dictionary unpacked with **.

to_df()

to_df(include=None, exclude=None, verbose=True)

Converts the parsed data into a pandas DataFrame.

Parameters

NameTypeDescription
includeoptional set[str]Set of columns (members) to include in the DataFrame
excludeoptional set[str]Set of columns (members) to exclude from the DataFrame
verboseboolWhether to include system information (only when other arguments are None)

Returns

TypeDescription
pd.DataFrameConverted DataFrame

Exceptions

  • EnvironmentError if pandas is not installed

to_dict()

to_dict(include=None, exclude=None, verbose=True, spread=False, sort_keys=False)

Converts the parsed data into a dictionary.

Parameters

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the dictionary
excludeoptional set[str]Set of keys (members) to exclude from the dictionary
verboseboolWhether to include system information (only when other arguments are None)
spreadboolWhether to split list-like data that is not time series
sort_keysboolWhether to sort keys

Returns

TypeDescription
dict[str, Any]Converted dictionary

to_json()

to_json(include=None, exclude=None, verbose=True, spread=False, indent=2, sort_keys=False)

Converts the parsed data into JSON format.

Parameters

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the JSON
excludeoptional set[str]Set of keys (members) to exclude from the JSON
verboseboolWhether to include system information (only when other arguments are None)
spreadboolWhether to split list-like data that is not time series
indentoptional intNumber of spaces for indentation (None for no line breaks)
sort_keysboolWhether to sort keys

Returns

TypeDescription
strConverted JSON string

model_*()

2.1.1.2.11 - mwings.parsers.act Module

Parsers for packets sent from act and data structures to store their contents.

Parsers for packets sent from act and data structures to store their contents.

src/mwings/parsers/act.py

PacketParser

Static class to parse packets sent from act

Inherits: common.PacketParserBase

is_valid()

is_valid(bare_packet)

Checks whether the given bare packet is valid.

Arguments

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
boolTrueValid, parsable
FalseInvalid, not parsable

parse()

parse(bare_packet)

Parses the given bare packet.

Arguments

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
optional ParsedPacketParsedPacket instanceParsed data
NoneParsing failed

ParsedPacket

Structure to store the result of parsing packets sent from act

Inherits: common.ParsedPacketBase

ParsedPacket()

ParsedPacket(*, time_parsed=None, packet_type=PacketType.BARE, sequence_number=None, source_serial_id=0, source_logical_id=0, lqi=None, supply_voltage=None, command_id=0, data=b'')

Arguments

Includes properties inherited from the base class.

NameTypeDescription
time_parsedoptional AwareDatetimeParsing timestamp
packet_typecommon.PacketTypePacket type
sequence_numberoptional common.UInt16Not available, always None
source_serial_idcommon.UInt32Source serial ID
source_logical_idcommon.UInt8Source logical device ID
lqioptional common.UInt8Radio communication quality
supply_voltageoptional common.UInt16Not available, always None
command_idcommon.UInt8Command ID
databytesData

You can also pass a dictionary unpacked with **.

to_df()

to_df(include=None, exclude=None, verbose=True)

Converts parsed data into a pandas DataFrame.

Arguments

NameTypeDescription
includeoptional set[str]Set of columns (members) to include in the DataFrame
excludeoptional set[str]Set of columns (members) to exclude from the DataFrame
verboseboolWhether to include system information (only effective if other args are None)

Returns

TypeValueDescription
pd.DataFrame-Converted DataFrame

Exceptions

  • EnvironmentError if pandas is not available

to_dict()

to_dict(include=None, exclude=None, verbose=True, spread=False, sort_keys=False)

Converts parsed data into a dictionary.

Arguments

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the dictionary
excludeoptional set[str]Set of keys (members) to exclude from the dictionary
verboseboolWhether to include system information (only effective if other args are None)
spreadboolWhether to split non-time-series list-like data
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
dict[str, Any]-Converted dictionary

to_json()

to_json(include=None, exclude=None, verbose=True, spread=False, indent=2, sort_keys=False)

Converts parsed data into JSON format.

Arguments

NameTypeDescription
includeoptional set[str]Set of keys (members) to include in the JSON
excludeoptional set[str]Set of keys (members) to exclude from the JSON
verboseboolWhether to include system information (only effective if other args are None)
spreadboolWhether to split non-time-series list-like data
indentoptional intNumber of indent spaces (None for no line breaks)
sort_keysboolWhether to sort keys

Returns

TypeValueDescription
str-Converted JSON string

model_*()

2.1.1.3 - mwings.serializers Module

Serializers to generate commands and data structures to handle them.
Serializers to generate commands and data structures to handle them.

2.1.1.3.1 - mwings.serializers.app_twelite Module

mwings.serializers.app_twelite

Serializers to generate commands representing packets for the Extremely Simple! Standard App, and data structures to handle them.

src/mwings/serializers/app_twelite.py

CommandSerializer

Static class to generate commands representing packets for the Extremely Simple! Standard App

Inherits: common.CommandSerializerBase

serialize()

serialize(command)

Expands the given command into a raw byte sequence.

Arguments

NameTypeDescription
commandCommandCommand data

Returns

TypeValueDescription
optional common.BarePacketcommon.BarePacketExpanded data
NoneInvalid command data

Command

Structure to store data used to generate commands representing packets for the Extremely Simple! Standard App

Inherits: common.CommandBase

Command()

Command(*, destination_logical_id=120, di_to_change=<mwings.common.FixedList object>, di_state=<mwings.common.FixedList object>, pwm_to_change=<mwings.common.FixedList object>, pwm_duty=<mwings.common.FixedList object>)

Arguments

NameTypeDescription
destination_logical_idcommon.UInt8Destination logical device ID
di_to_changecommon.FixedList[bool](4)Digital interfaces to change
di_statecommon.FixedList[bool](4)Digital interface states after change
pwm_to_changecommon.FixedList[bool](4)PWM interfaces to change
pwm_dutycommon.FixedList[int](4)PWM interface duty after change

You can also pass a dictionary unpacked with **.

is_valid()

is_valid()

Checks whether the command data is valid.

Arguments

None

Returns

TypeValueDescription
boolTrueValid
FalseInvalid

model_*()

2.1.1.3.2 - mwings.serializers.app_io Module

mwings.serializers.app_io

Serializers that generate commands representing packets to be sent to the remote control app, and the data structures to handle them.

src/mwings/serializers/app_io.py

CommandSerializer

Static class that serializes commands representing packets to be sent to the remote control app

Inherits from: common.CommandSerializerBase

serialize()

serialize(command)

Expands the given command into a raw packet byte sequence.

Parameters

NameTypeDescription
commandCommandCommand data

Returns

TypeValueDescription
optional common.BarePacketcommon.BarePacketExpanded data
NoneInvalid command data

Command

Data structure to hold data used to generate commands representing packets to be sent to the remote control app

Inherits from: common.CommandBase

Command()

Command(*, destination_logical_id=120, di_to_change=<mwings.common.FixedList object>, di_state=<mwings.common.FixedList object>)

Parameters

NameTypeDescription
destination_logical_idcommon.UInt8Destination logical device ID
di_to_changecommon.FixedList[bool](12)Digital interfaces to change
di_statecommon.FixedList[bool](12)State of digital interfaces after change

You can also pass a dictionary unpacked with **.

is_valid()

is_valid()

Checks whether the command data is valid.

Parameters

None

Returns

TypeValueDescription
boolTrueValid
FalseInvalid

model_*()

2.1.1.3.3 - mwings.serializers.app_pal_notice Module

mwings.serializers.app_pal_notice

Serializers that generate commands representing packets to be sent to the PAL App (Notification PAL), and the data structures to handle them.

src/mwings/serializers/app_pal_notice.py

CommandSerializer

A static class serializer that generates commands representing packets to be sent to the PAL App (Notification PAL).

Inherits: common.CommandSerializerBase

serialize()

serialize(command)

Expands the given command into a raw packet byte sequence.

Arguments

NameTypeDescription
commandCommandCommand data

Returns

TypeValueDescription
optional common.BarePacketcommon.BarePacketExpanded data
NoneInvalid command data

Command

A structure to store parameters used when generating commands representing packets to be sent to the PAL App (Notification PAL).

Inherits: common.CommandBase

Command()

Command(*, destination_logical_id=120, color=AppPalNoticeColor.WHITE, blink_speed=AppPalNoticeBlinkSpeed.ALWAYS_ON, brightness=8, duration_in_sec=5)

Arguments

NameTypeDescription
destination_logical_idcommon.UInt8Destination logical device ID
colorcommon.AppPalNoticeColorLighting color name
blink_speedcommon.AppPalNoticeBlinkSpeedBlinking speed
brightnesscommon.UInt8Brightness
duration_in_seccommon.UInt8Total lighting (blinking) duration in seconds

You can pass a dictionary unpacked with **.

is_valid()

is_valid()

Checks whether the command data is valid.

Arguments

None

Returns

TypeValueDescription
boolTrueValid
FalseInvalid

model_*()

2.1.1.3.4 - mwings.serializers.app_pal_notice_detailed Module

mwings.serializers.app_pal_notice_detailed

Serializers that generate commands representing detailed packets to be sent to the PAL App (Notification PAL), and the data structures to handle them.

src/mwings/serializers/app_pal_notice_detailed.py

CommandSerializer

Static class serializer that generates commands representing detailed packets to be sent to the PAL App (Notification PAL).

Inherits from: common.CommandSerializerBase

serialize()

serialize(command)

Expands the given command into a raw packet byte sequence.

Parameters

NameTypeDescription
commandCommandCommand data

Returns

TypeValueDescription
optional common.BarePacketcommon.BarePacketExpanded data
NoneInvalid command data

Command

Data structure for storing data used to generate commands representing detailed packets to be sent to the PAL App (Notification PAL).

Inherits from: common.CommandBase

Command()

Command(*, destination_logical_id=120, color=AppPalNoticeRGBWColor(red=0, green=0, blue=0, white=15), blink_duty_percentage=100, blink_period_in_sec=1.0, duration_in_sec=1)

Parameters

NameTypeDescription
destination_logical_idcommon.UInt8Destination logical device ID
colorcommon.AppPalNoticeRGBWColorRGBW color for illumination
blink_duty_percentagecommon.UInt8Percentage of on-time during blinking
blink_period_in_seccommon.Float64Blink period in seconds
duration_in_seccommon.UInt8Total duration of illumination (blinking)

You can also pass a dictionary unpacked with **.

is_valid()

is_valid()

Checks whether the command data is valid.

Parameters

None

Returns

TypeValueDescription
boolTrueValid
FalseInvalid

model_*()

2.1.1.3.5 - mwings.serializers.app_pal_notice_event Module

mwings.serializers.app_pal_notice_event

Serializers that generate commands representing event packets to be sent to the PAL App (Notification PAL), and the data structures to handle them.

src/mwings/serializers/app_pal_notice_event.py

CommandSerializer

Static class serializer that generates commands representing event data packets sent to the PAL App (Notification PAL)

Inherits from: common.CommandSerializerBase

serialize()

serialize(command)

Expands the given command into a raw packet byte sequence.

Arguments

NameTypeDescription
commandCommandCommand data

Returns

TypeValueDescription
optional common.BarePacketcommon.BarePacketExpanded data
NoneInvalid command data

Command

Structure to hold data used when generating commands representing event data packets sent to the PAL App (Notification PAL)

Inherits from: common.CommandBase

Command()

Command(*, destination_logical_id=120, event_id=0)

Arguments

NameTypeDescription
destination_logical_idcommon.UInt8Destination logical device ID
event_idcommon.UInt8Event ID

You can also pass a dictionary unpacked with **.

is_valid()

is_valid()

Checks whether the command data is valid.

Arguments

None

Returns

TypeValueDescription
boolTrueValid
FalseInvalid

model_*()

2.1.1.3.6 - mwings.serializers.app_uart_ascii Module

mwings.serializers.app_uart_ascii

Serializers that generate commands representing packets to be sent to the serial communication app (format mode: simplified), and the data structures to handle them.

src/mwings/serializers/app_uart_ascii.py

CommandSerializer

Static class serializer that generates commands representing packets to be sent to the serial communication app (format mode: simplified)

Inherits from: common.CommandSerializerBase

serialize()

serialize(command)

Expands the given command into a raw packet byte sequence.

Arguments

NameTypeDescription
commandCommandCommand data

Returns

TypeValueDescription
optional common.BarePacketcommon.BarePacketExpanded data
NoneInvalid command data

Command

Structure to store data used to generate commands representing packets to be sent to the serial communication app (format mode: simplified)

Inherits from: common.CommandBase

Command()

Command(*, destination_logical_id=120, command_id=0, data)

Arguments

NameTypeDescription
destination_logical_idcommon.UInt8Destination logical device ID
command_idcommon.UInt8Command ID
databytesData

You can pass a dictionary unpacked with **.

is_valid()

is_valid()

Checks whether the command data is valid.

Arguments

None

Returns

TypeValueDescription
boolTrueValid
FalseInvalid

model_*()

2.1.1.4 - mwings.utils Module

mwings.utils

Contains general-purpose utility functions.

src/mwings/utils.py

ask_user()

ask_user(prompt, regex, on_error, ex_verifier=None, max_attempts=None)

Gets input from the user via the console.

Arguments

NameTypeDescription
promptstrMessage displayed in the prompt
regexstrRegular expression to validate user input
on_errorstrMessage displayed when user input is invalid
ex_verifieroptional Callable[[str], bool]Function to further validate input string beyond regex
max_attemptsoptional intNumber of retry attempts. None means unlimited

Returns

TypeValueDescription
str-Validated user input string

ask_user_for_port()

ask_user_for_port()

Prompts the user to select a port to use.

Arguments

None

Returns

TypeValueDescription
str-Selected port name

byte_count_from()

byte_count_from(character_count)

Converts the length of a byte sequence represented as an ASCII string to the length of its binary representation.

Arguments

NameTypeDescription
character_countintLength of the ASCII representation of the byte sequence

Returns

TypeValueDescription
int-Length of the byte sequence in binary form

character_from()

character_from(hexvalue)

Converts a number from 0x0 to 0xF to its hexadecimal character representation.

Arguments

NameTypeDescription
hexvalueintNumber

Returns

TypeValueDescription
int-ASCII code of character

find_ascii()

find_ascii(port, data, timeout, debugging=False)

Waits to receive the specified ASCII string.

Arguments

NameTypeDescription
portserial.SerialSerial port
datastrASCII string
timeoutintTimeout (seconds)
debuggingboolDebug output

Returns

TypeValueDescription
boolTrueReception confirmed
boolFalseReception not confirmed

find_binary()

find_binary(port, data, timeout, debugging=False)

Waits to receive the specified byte sequence.

Arguments

NameTypeDescription
portserial.SerialSerial port
datastrByte sequence
with_terminalboolWhether to use terminal data
terminalintData to treat as terminal
timeoutintTimeout (seconds)
debuggingboolDebug output

Returns

TypeValueDescription
boolTrueReception confirmed
boolFalseReception not confirmed

flush_rx_buffer()

flush_rx_buffer(port)

Clears the receive buffer.

Arguments

NameTypeDescription
portserial.SerialSerial port

Returns

None

flush_tx_buffer()

flush_tx_buffer(port)

Clears the transmit buffer.

Arguments

NameTypeDescription
portserial.SerialSerial port

Returns

None

get_ports()

get_ports()

Retrieves a list of available serial ports.

Arguments

None

Returns

TypeValueDescription
list[str]-List of port names

hex_from()

hex_from(character)

Converts an ASCII character representing a hexadecimal digit to its numeric value. The result is undefined for characters other than 0-9 and A-F.

Arguments

NameTypeDescription
characterintASCII code of the character

Returns

TypeValueDescription
int-Numeric value

is_initialized()

is_initialized(port)

Checks whether the serial port is initialized.

Arguments

NameTypeDescription
portserial.SerialSerial port

Returns

TypeValueDescription
boolTrueInitialized
FalseNot initialized

is_readable()

is_readable(port)

Checks whether data can be read from the serial port.

Arguments

NameTypeDescription
portserial.SerialSerial port

Returns

TypeValueDescription
boolTrueData available in receive buffer
FalseNot readable

is_there_some_ports()

is_there_some_ports()

Checks whether any serial ports are available.

Arguments

None

Returns

TypeValueDescription
boolTrueSerial ports exist
FalseNone available

is_writable()

is_writable(port)

Checks whether data can be written to the serial port.

Arguments

NameTypeDescription
portserial.SerialSerial port

Returns

TypeValueDescription
boolTrueWritable
FalseNot writable

lrc8()

lrc8(data)

Calculates the 8-bit LRC.

Arguments

NameTypeDescription
databytesByte sequence to calculate

Returns

TypeValueDescription
int-LRC8 value

millis()

millis()

Gets the current system time in milliseconds.

Arguments

None

Returns

TypeValueDescription
int-System time (ms)

open_on_system()

open_on_system(path)

Opens the specified file path with the system’s default application.

Arguments

NameTypeDescription
pathPathFile path

Returns

None

write_binary()

write_binary(port, data)

Sends a byte sequence to the serial port.

Arguments

NameTypeDescription
portserial.SerialSerial port
dataintData to send
bytesSequence of data to send

Returns

None

write_in_ascii()

write_in_ascii(port, data)

Sends an ASCII representation of a byte sequence to the serial port.

Arguments

NameTypeDescription
portserial.SerialSerial port
dataintCharacter to send
bytesString to send

Returns

None