sebmillet / rf433send

GNU Lesser General Public License v3.0
9 stars 3 forks source link

How to get the "data[] byte" to 5 characters #3

Closed RedSalsicha closed 3 months ago

RedSalsicha commented 3 months ago

Hi

Firstly, I would like to congratulate you on the excellent libraries and the excellent work, which is of great help.

However, I've been struggling for a few days trying to send the code for a control that "RF433any > 01_main" returned the code below:

Data: 4a 0c 00 91 01

-----CODE START-----
// [WRITE THE DEVICE NAME HERE]
rf.register_Receiver(
  RFMOD_TRIBIT_INVERTED, // mod
  5210, // initseq
  0, // lo_prefix
  0, // hi_prefix
  510, // first_lo_ign
  510, // lo_short
  995, // lo_long
  0, // hi_short (0 => take lo_short)
  0, // hi_long  (0 => take lo_long)
  281, // lo_last
  5210, // sep
  40  // nb_bits
);
-----CODE END-----

However, when trying to use it in "RF433 > 01_send" with the code below:

tx_whatever = rfsend_builder(
    RfSendEncoding::TRIBIT_INVERTED,
    PIN_RFOUT,
    RFSEND_DEFAULT_CONVENTION,  // Do we want to invert 0 and 1 bits? No.
    4,       // Number of sendings
    nullptr, // No callback to keep/stop sending (if you want to send
             // SO LONG AS a button is pressed, the function reading the
             // button state is to be put here).
    5210,    // initseq
    0,       // lo_prefix
    0,       // hi_prefix
    510,       // first_lo_ign
    510,    // lo_short
    995,    // lo_long
    0,       // hi_short
    0,       // hi_long
    281,       // lo_last
    5210,    // sep
    40       // nb_bits
);

}

byte data[] = { 0x03, 0x14, 0x15, 0x93 };

I get the following error:

rf433send.cpp:166: assertion failed, aborted.

I believe it could be something like "byte data[] = { 0x03, 0x14, 0x15, 0x93 };" because the data obtained is actually 5 bytes long, if this is really the problem, how can I get this correct data with 5 bytes long?

sebmillet commented 3 months ago

Hello

you are right, it comes from a mismatch between the code length and the data size you provide to be sent. The code length says 40 bits = 5 bytes to hold it. This means, you have to provide 5 bytes whenever you call the send method.

To fix, you have to add a byte to the code list, that is:

you replace byte data[] = { 0x03, 0x14, 0x15, 0x93 };

with (for example) byte data[] = { 0x9a, 0x03, 0x14, 0x15, 0x93 };

Regards, Sébastien Millet

RedSalsicha commented 3 months ago

Perfect.

I took the DATA information I got from RF433any, which was "Data: 4a 0c 00 91 01" and added the 0x to the beginning and it worked:

byte data[] = { 0x4a, 0x0c, 0x00, 0x91, 0x01 };

Thanks.