NAME

Protocol::IR::Code - Intermediate representation of an IR remote control code

VERSION

version 0.08

SYNOPSIS

use Protocol::IR::Converter;

my $converter = Protocol::IR::Converter->new();
my $code = $converter->import_code('NEC', '0x10EF00FF');

print $code->protocol;    # NEC
print $code->address;     # 16
print $code->command;     # 0

my $hash = $code->to_irsend;   # Tasmota IRSend JSON payload

DESCRIPTION

Protocol::IR::Code is the unified intermediate representation used throughout the Protocol::IR::Code distribution. Every protocol handler decodes into an Protocol::IR::Code object and every format exports from one, so a signal can be moved between protocols and formats without loss of information.

The object is compatible with Tasmota's IRSend JSON payload structure: to_irsend returns a hash with Protocol, Bits, and Data keys. The data value is expressed so that it matches Tasmota's Data field for the protocol.

ATTRIBUTES

All attributes are read-write accessors, e.g. $code->alias('POWER'). They are created by the Protocol::IR::Converter registry and the protocol/format handlers; you normally do not construct Protocol::IR::Code objects directly.

METHODS

to_irsend

my $hash = $code->to_irsend;

Returns a hashref with Protocol, Bits, and (when known) Data keys, matching the structure of a Tasmota IRSend JSON payload.

FUNCTIONS

reverse_byte

my $reversed = Protocol::IR::Code::reverse_byte(0xE0);  # returns 0x07

Reverses the bits within an 8-bit byte. Used by "as_necx2_params" in Protocol::IR::Proto::SAMSUNG and "as_samsung_params" in Protocol::IR::Proto::NECX2 for cross-protocol conversion between SAMSUNG and NECX2, where the Samsung address/command bytes are the bit-reversal of the NECX2 device/function bytes.

This is an exported package function (not a method), callable as Protocol::IR::Code::reverse_byte($val).

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.

TRADEMARK NOTICE

This project exists solely to enable interoperability with independently purchased hardware. It is an independent community project: it is not supplied by, authorized by, affiliated with, or endorsed by The Walt Disney Company or any other rights holder. "Made With Magic", "Glow With The Show", and all related names and marks are trademarks of their respective owners, referenced here only to identify interoperable functionality.