9H1LO:
I have an routine which takes an unsigned char and sends it as an IR command.i am trying to receive this over mqtt using:
unsigned char code[100];
void callback(char* topic, byte* payload, unsigned int length) {
int i = 0;
for(i=0; i<length; i++) {
code = payload*;*
* }*
sendHexCodetoIR(code, sizeof(code) / sizeof(code[0]), 38);
it seems to receive it over mqtt but "code" doesn't seem to actually contain what i send by mqtt
if i set example:
unsigned char test[] = {0xA6,0xAC,0x00,0x02,0x40,0xA0,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x54};
it works fine
your guidance onto the right track would be much appreciated
[/quote]
What kind of "IR code" do you plan to use? Infrared commands are usually "pulses" (i.e. on times) of a 40 khz carrier, with specific ON and OFF times to denote binary 1 and 0. Additionally, there is usually a header which signifies the beginning of an IR command (as well as being a "dummy" signal so that the IR receiver can adjust it's AGC).
A typical IR signal looks like this:
The faint lines inside each "pulse" denote the IR LED pulsing on ans off at 40 khz.
So, to send an 8 bit character, you would send a header, then the appropriate 1 or 0 bits afterwards. You may want to also send along a checksum or a CRC so that the receiving end can tell if the received signal is valid.
**
