Skip to content

IRSend: support protocols >64 bits (e.g. Fujitsu AC 128-bit) #2014

Description

@falkenhawk

Problem

IRSend with the comma format (FUJITSU_AC,128,0x1463001010FE0930800100000000202F) fails with:

Error:IR:IRSend currently only protocol with up to 64bits are supported

This blocks all AC/HVAC protocols that require >64-bit packets (Fujitsu AC uses 128-bit).

Root cause

In drv_ir_new.cpp, IR_Send_Cmd() parses the hex data into a uint64_t via strtoll(), which naturally caps at 64 bits. For larger protocols, it returns CMD_RES_BAD_ARGUMENT.

The underlying IRRemoteESP8266 library already supports these protocols — IRsend has a byte-array overload:

bool send(const decode_type_t type, const uint8_t *state, const uint16_t nbytes);

Suggested fix

In the bits > 64 branch, instead of returning an error, parse the hex string into a byte array and call the byte-array overload:

if (bits <= 64) {
    uint64_t data = strtoll(_data, &p, 16);
    int repeats = strtol(p + 1, NULL, 10);
    pIRsend->send(protocol, data, bits, repeats);
} else {
    const char *hex = _data;
    if (hex[0] == '0' && (hex[1] == 'x' || hex[1] == 'X')) hex += 2;
    uint16_t nbytes = (bits + 7) / 8;
    uint8_t buf[32];
    for (uint16_t i = 0; i < nbytes && i < sizeof(buf); i++) {
        char h[3] = { hex[i * 2], hex[i * 2 + 1], '\0' };
        buf[i] = (uint8_t)strtol(h, NULL, 16);
    }
    pIRsend->send(protocol, buf, nbytes);
}

The same approach would also unblock IRAC implementation in the future.

Environment

  • Chip: BK7238
  • Firmware: OpenBeken with ENABLE_DRIVER_IRREMOTEESP
  • Protocol: FUJITSU_AC (128-bit state packets, 56-bit power-off)
  • IR receive/decode works perfectly (note: when it works. sometimes it breaks, increasing buffer to 500 helps but sometimes it still stops decoding incoming data) — only sending is blocked by the 64-bit limit

Workaround

Currently none. The only alternatives are using separate ESP hardware with Tasmota/ESPHome for IR sending, or patching the firmware manually.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions