crankyoldgit / IRremoteESP8266

Infrared remote library for ESP8266/ESP32: send and receive infrared signals with multiple protocols. Based on: https://github.com/shirriff/Arduino-IRremote/
GNU Lesser General Public License v2.1
2.84k stars 810 forks source link

help with irsend AC commands convert String to unsigned char array #2051

Closed jayantdyfo closed 6 months ago

jayantdyfo commented 6 months ago

Hi,

I am getting IR data via MQTT and saving it as String. In most AC irsend commands the data / state variable is const unsigned char []. Please let me know of a method to do this

what I am currently doing is

String str = doc["hex"]; String protocol = doc["protocol"];

eg if I want to send Fujitsu_AC protocol

  uint64_t hex = strtoul(string2char(str), NULL, 0);
  unsigned char hex_array[sizeof(hex)];
  memcpy(hex_array, &hex, sizeof(hex));

  irsend.sendFujitsuAC(hex_array, kFujitsuAcBits,kFujitsuAcMinRepeat);

When I use IRdump V3 to check the received code and protocol I get UNKNOWN and a random hex

while I am sending following in my mqtt message { "hex" = "0x1463001010FE0930810103000000202B", "protocol" = "FUJITSU_AC" } Quick help would be appreciated.

crankyoldgit commented 6 months ago

That is certainly not how you convert a very long hex string into an array. Try looking in the IRMQTTServer source code for how it does it

This is not a library problem, this a "how you write code" problem.