| OpenHAP::TLV(3p) | Perl Library Manual | OpenHAP::TLV(3p) |
NAME
OpenHAP::TLV - TLV8 encoding/decoding for HAP protocol
SYNOPSIS
use OpenHAP::TLV;
# Encode
my $encoded = OpenHAP::TLV::encode(
0x06 => pack('C', 1), # State
0x00 => pack('C', 0), # Method
);
# Decode
my %decoded = OpenHAP::TLV::decode($encoded);
DESCRIPTION
This module implements TLV8 (Type-Length-Value with 8-bit fields) encoding and decoding as specified in the HomeKit Accessory Protocol.
FUNCTIONS
encode(%items)
Encodes a hash of type => value pairs into TLV8 format. Values longer than 255 bytes are automatically split into chunks.
decode($data)
Decodes TLV8 data into a hash of type => value pairs. Automatically concatenates chunks with the same type.
Returns the empty list if the buffer is malformed: a truncated record header, or a length field pointing past the end of the buffer.
SEE ALSO
spec/HAP-TLV8.md
| 2026-07-27 | OpenBSD |