NAME

Protocol::IR::Proto::NEC48 - 48-NEC1 protocol handler (48-bit NEC family base)

VERSION

version 1.0

SYNOPSIS

use Protocol::IR::Converter;

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

# From a raw 48-bit value or from parameters
my $code = $converter->import_code('48-NEC1', '0x4DB2DE2100FF');
my $code = $converter->import_code('48-NEC1',
    { address => 77, subaddress => 178, command => 222 });

DESCRIPTION

The 48-bit NEC family transmits 48-bit frames at 38 kHz: six bytes -- address (device), subaddress, command, the command's one's complement, an extended E byte, and E's one's complement -- each sent LSB-first, preceded by a 9024/4512 us header and followed by a stop mark. A single frame carries all six bytes; the repeat is a whole-frame retransmission invisible to the single-frame decoders here.

The data value matches Tasmota's DataLSB field: address in bits 40-47, subaddress in bits 32-39, command in bits 24-31, its complement in bits 16-23, E in bits 8-15, and E's complement in bits 0-7. The display form (Tasmota Data) is the per-byte bit reversal; see decode_byte_order.

IRDB distinguishes two single-frame formats, like the 32-bit NEC family:

  • 48-NEC1 (this class) -- short header+gap repeat.

  • 48-NEC2 (Protocol::IR::Proto::NEC482) -- identical single-frame timing; only the repeat differs (it re-transmits the whole frame).

The E byte is not part of the IRDB CSV rows, so codes built from device/subdevice/function parameters send it cleared.

When a subaddress is omitted (-1), it is masked to 0xFF exactly as the type-script sibling does; IRDB rows always carry an explicit subdevice.

METHODS

decode_raw

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

Builds an Protocol::IR::Code from the raw 48-bit accumulated value.

decode_byte_order

my $code = $class->decode_byte_order($raw, $lsb);

Decodes from either byte order: $lsb true reads the accumulated (DataLSB) form, false reads the display (Data) form reached by reversing the bits within each byte.

decode_params

my $code = $class->decode_params(address => 77, subaddress => 178, command => 222);

Builds an Protocol::IR::Code from discrete parameters. Accepts address or device, subaddress or subdevice, and command or function.

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 header, 48 data bits, and stop bit match the 48-bit NEC timing signature, 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.