Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IrReceive Data is HEX, IrSend needs Integer #1290

Closed
MatzeJoerling opened this issue Dec 1, 2017 · 7 comments
Closed

IrReceive Data is HEX, IrSend needs Integer #1290

MatzeJoerling opened this issue Dec 1, 2017 · 7 comments

Comments

@MatzeJoerling
Copy link

Hi,
it needs some time to get it, Receive sends IR data to mqtt/console in HEX format.
I tried to send that same data out, but failed.
then i realized that i have to convert it form HEX to DEC (unsigned integer).
Any idea why? Can irSend accept HEX as dataformat and send it out?
Makes IR handling much easier in my nodered.

regards M.

@arendst
Copy link
Owner

arendst commented Dec 2, 2017

But for now you managed to convert from hex to decimal in node-red.

Due to legacy compatibility a change to hex/hex kr decimal/decimal would be a problem.

@MatzeJoerling
Copy link
Author

hi,
must not be a change, could not irsend send it in dec and hex depends on parameter or # prefix.

regards M.

@arendst
Copy link
Owner

arendst commented Dec 2, 2017

Yes that would be the solution if users not already expected to send a number like 1234 as being hexadecimal.

Unlucky choices made in the past are hard to fix.

@sammy2360
Copy link

so if this is legacy compatibility affecting IR and RF i take it its not the libraries used for IR and RF but deeper into the arduino core?

@arendst
Copy link
Owner

arendst commented Dec 5, 2017

No it's tasmota legacy.

@sammy2360
Copy link

sammy2360 commented Dec 5, 2017

im just looking at the xdrv_snfbridge.ino file in particular this section

  if (dataBuf[0] == '#') {
      dataBuf++;
      data_len--;
      radix = 16;
    }

    if (data_len) {
      code = strtol(dataBuf, &p, radix);
      if (code) {
        if (CMND_RFCODE == command_code) {
          sonoff_bridge_last_send_code = code;
          SonoffBridgeSendCode(code);
        } else {
          if (1 == payload) {
            code = pgm_read_byte(kDefaultRfCode + set_index) << 8 | pgm_read_byte(kDefaultRfCode + set_index +1);
          }
          uint8_t msb = code >> 8;
          uint8_t lsb = code & 0xFF;
          if ((code > 0) && (code < 0x7FFF) && (msb != 0x55) && (lsb != 0x55)) {  // Check for End of Text codes
            Settings.rf_code[0][set_index] = msb;
            Settings.rf_code[0][set_index +1] = lsb;
          }
        }
      }
    }

just trying to work out how to add a cmnd RF_CODE# for example, so that the sending of a hex value can be triggered from the topic of mqtt rather than the payload. so the topic would be cmnd/sonoffBridge/RfCode# and payload 8263CA. one problem that may occur is using a # in mqtt may be dodgy.

@arendst
Copy link
Owner

arendst commented Apr 2, 2018

I'll change the way IRSend is processing the Data input field.

Starting with version 5.12.0i it will accept both decimal like 1234567 and hexadecimal like 0x12345A. So the change is that it now supports the standard C notation for hexadecimal being 0x.

This means that the default mode is decimal with optional hexadecimal when prefixed with 0x or 0X.

arendst added a commit that referenced this issue Apr 2, 2018
5.12.0i
 * Add hexadecimal Data entry to command IrSend using 0x
notation (#1290, #2314)
@arendst arendst closed this as completed Apr 2, 2018
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.12.0i
 * Add hexadecimal Data entry to command IrSend using 0x
notation (arendst#1290, arendst#2314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants