NAME

Protocol::IR::Proto::MWM - MWM protocol handler (Disney "Made With Magic")

VERSION

version 1.0

SYNOPSIS

use Protocol::IR::Converter;

my $converter = Protocol::IR::Converter->new();

# From a raw display-form value
my $code = $converter->import_code('MWM', '0x550808');

# From a data parameter (required)
my $code = $converter->import_code('MWM', { data => '0x550808' });

DESCRIPTION

The MWM protocol ("Made With Magic", used by Disney light-up products such as Glow With The Show) is 2400 bps serial over a 38 kHz carrier, with no header. Each byte is a 417 us start mark, 8 data bits (space = 1, mark = 0, LSB-first), and a 417 us stop space; up to 9 same-sign bits may merge into one measured run. Messages are 3 to 18 bytes (24-144 bits) and the byte count is implied by the message body: command frames carry a 4-bit payload length in the high nibble of the first byte (0x9x/0xFx), while show commands open with the 0x55 0xAA signature.

Because the decoded state bytes are exactly the transmitted bytes, the data value is the display form and matches Tasmota's Data field; no byte-order translation applies. Frames can reach 144 bits, which exceeds the native integer range, so data is always a Math::BigInt for this protocol.

The decode_timing decoder is strict: it validates the start/stop bits of every byte and enforces the payload-length check, so a genuinely truncated capture is rejected rather than silently misdecoded. A capture whose final byte's stop space merged into the omitted Tasmota footer is back-filled and accepted only when the reconstructed trailing byte passes the checksum.

METHODS

decode_raw

my $code = $class->decode_raw('0x550808');

Builds an Protocol::IR::Code from the raw display-form value. The frame length is implied by the value's width, rounded up to a whole number of bytes with the 3-byte protocol minimum.

decode_params

my $code = $class->decode_params(data => '0x550808');

Builds an Protocol::IR::Code from a single required data parameter. Dies without one.

decode_timing

my $code = $class->decode_timing(\@burst_pairs_us);

Decodes an arrayref of microsecond [mark_us, space_us] pairs. Returns an Protocol::IR::Code when the frame is a well-formed MWM message (valid start/stop bits, implied byte count, 24-144 bits), otherwise undef.

to_pronto

my $pronto = $class->to_pronto($ir_code);

Encodes an Protocol::IR::Code object as a Pronto Hex string at 38 kHz.

SUPPORT

Source code: https://github.com/bwarden/perl-protocol-ir

Bug reports and feature requests: https://github.com/bwarden/perl-protocol-ir/issues

AUTHOR

Brett T. Warden <bwarden@cpan.org>

COPYRIGHT AND LICENSE

Copyright (c) 2026 Brett T. Warden

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.