sebmillet / RF433any

GNU Lesser General Public License v3.0
39 stars 4 forks source link

Can't receive any information using RF433recv #11

Closed mmz1785 closed 10 months ago

mmz1785 commented 1 year ago

I used RF433any to get the timing information, and then used RF433 recv to receive information, but I couldn't receive it anyway. Moreover, the timing information output by the same button is different. This is the timing information for the output.

// rf.register_Receiver( // RFMOD_TRIBIT, // mod // 12091, // initseq // 0, // lo_prefix // 0, // hi_prefix // 0, // first_lo_ign // 426, // lo_short // 1249, // lo_long // 0, // hi_short (0 => take lo_short) // 0, // hi_long (0 => take lo_long) // 425, // lo_last // 12091, // sep // 24 // nb_bits // );

This is the sniffed information

Signal duration: 428218 us N LOW, HIGH -----BEGIN RF433 LOW HIGH SEQUENCE----- , 12096 000 1328, 380 001 464, 1164 002 1316, 392 003 1324, 396 004 1296, 408 005 1308, 404 006 1308, 408 007 1296, 416 008 452, 1180 009 448, 1184 010 452, 1180 011 452, 1184 012 444, 1184 013 448, 1184 014 1300, 412 015 1300, 416 016 440, 1192 017 440, 1188 018 444, 1188 019 440, 1192 020 440, 1196 021 432, 1196 022 1288, 424 023 428, 1204 024 432, 12128 025 1292, 420 026 444, 1188 027 1296, 416 028 1292, 420 029 1284, 428 030 1284, 424 031 1284, 424 032 1280, 440 033 424, 1208 034 428, 1208 035 428, 1204 036 428, 1208 037 428, 1208 038 416, 1216 039 1272, 432 040 1268, 448 041 420, 1216 042 416, 1212 043 420, 1204 044 424, 1212 045 424, 1208 046 424, 1212 047 1268, 440 048 420, 1212 049 416,195720 050 36, 1800 051 68, 3048 052 32, 3048 053 44, 900 054 56, 948 055 64, 1468 056 68, 3156 057 28, 1108 058 128, 364 059 52, 556 060 108, 488 061 40, 152 062 100, 908 063 32, 80 064 16, 824 065 200, 480 066 48, 44 067 52, 32 068 12, 24 069 128, 36 070 48, 588 071 88, 136 072 16, 1348 073 52, 232 074 400, 936 075 44, 96 076 88, 432 077 140, 68 078 436, 64 079 36, 144 080 124, 484 081 96, 1036 082 72, 416 083 60, 496 084 68, 436 085 48, 1024 086 216, 692 087 84, 432 088 20, 472 089 128, 136 090 116, 20 091 16, 28 092 16, 476 093 56, 68 094 68, 12 095 72, 160 096 24, 1620 097 32, 676 098 276, 200 099 264, 264 100 52, 72 101 116, 12 102 68, 8 103 56, 48 104 260, 156 105 252, 76 106 12, 68 107 164, 28 108 236, 920 109 48, 396 110 160, 64 111 412, 80 112 392, 64 113 20, 64 114 136, 772 115 144, 852 116 204, 56 117 104, 392 118 148, 120 119 92, 76 120 208, 396 121 156, 196 122 52, 108 123 68, 236 124 172, 32 125 580, 148 126 280, 68 127 332, 28 128 124, 216 129 448, 124 130 228, 100 131 128, 152 132 92, 48 133 124, 140 134 192, 92 135 100, 148 136 80, 104 137 140, 28 138 220, 156 139 508, 84 140 212, 48 141 8, 112 142 412, 244 143 260, 148 144 268, 56 145 140, 24 146 356, 364 147 324, 96 148 92, 36 149 72, 84 150 376, 96 151 16, 24 152 416, 116 153 36, 508 154 112, 56 155 100, 124 156 676, 120 157 96, 96 158 116, 144 159 480, 304 160 324, 56 161 12, 128 162 312, 216 163 76, 28 164 680, 128 165 116, 96 166 144, 36 167 456, 84 168 384, 128 169 412, 136 170 32, 56 171 248, 20 172 132, 8 173 332, 100 174 904, 132 175 48, 20 176 288, 128 177 220, 44 178 84, 212 179 692, 268 180 204, 48 181 16, 200 182 368, 248 183 260, 232 184 244, 80 185 132, 24 186 768, 100 187 172, 128 188 576, 168 189 92, 8 190 72, 16 191 592, 220 192 800, 280 193 60, 52 194 240, 16 195 36, 8 196 308, 44 197 808, 64 198 56, 96 199 100, 84 200 2960, 116 201 468, 316 202 832, 132 203 904, 36 204 540, 12 205 380, 96 206 576, 16 207 284, 96 208 468, 8 209 436, 88 210 392, 84 211 1444, 48 212 820, 24 213 72, 188 214 836, 144 215 836, 224 216 800, 24 217 944, 32 218 456, 40 219 492, 124 220 120, 8 221 720, 72 222 916, 80 223 192, 72 224 564, 240 225 200, 128 226 484, 96 227 1448, 120 228 332, 80 229 8, 164 230 748, 108 231 4872, 92 232 912, 116 233 844, 132 234 892, 84 235 1916, 36 236 292, 40 237 612, 144 238 868, 68 239 1924, 48 240 1940, 64 241 944, 32 242 1964, 56 243 2876, 140 244 1916, 28 245 7984, 44 246 1944, 80 247 888, 84 248 1816, 0 249 3136, 108 -----END RF433 LOW HIGH SEQUENCE----- Waiting for signal...

ask for your help

sebmillet commented 1 year ago

Hello

the timing shown by the snif correspondons to the timings used to create the receiver: 12000 us of separator, then 24 short/long or long/short sequences followed by a short (it is the lo_last) followed by a separator of 12000 us.

What do you mean "Moreover, the timing information output by the same button is different."?

In SIMULATED mode, I sent the sniffed timings to the receiver as you wrote it and it worked, received code is: code received: 24 bits: [bf 03 02]

Did you register a callback function when or after creating the receiver?

Regards, Sébastien Millet

mmz1785 commented 1 year ago

Thanks for your reply, I registered the callback function. But it has never been successful.

mmz1785 commented 1 year ago

Decodes fine with rf433any. I put the sequence information output by rf433any into rf433recv. No information will be received.

sebmillet commented 1 year ago

Hello

Could you send me the whole code?

There are required steps, that you can see in example codes like (among others) in 01_generic.ino.

Are all these criteria met?

Regards, Sébastien Millet

mmz1785 commented 1 year ago

this is my code

#include "RF433recv.h"
#include <Arduino.h>

#define PIN_RFINPUT 25

#define ASSERT_OUTPUT_TO_SERIAL

void callback_generic(const BitVector *recorded)
{
    Serial.print(F("Code received: "));
    char *printed_code = recorded->to_str();

    if (printed_code)
    {
        Serial.print(recorded->get_nb_bits());
        Serial.print(F(" bits: ["));
        Serial.print(printed_code);
        Serial.print(F("]\n"));

        free(printed_code);
    }
}

void callback1(const BitVector *recorded)
{
    Serial.print(F("111Waiting for signal\n"));
    Serial.print(F("1> "));
    callback_generic(recorded);
}

RF_manager rf(PIN_RFINPUT);

void setup()
{
    pinMode(PIN_RFINPUT, INPUT);
    Serial.begin(115200);
    rf.register_Receiver(
        RFMOD_TRIBIT, // mod
        12000,        // initseq
        0,            // lo_prefix
        0,            // hi_prefix
        0,            // first_lo_ign
        431,          // lo_short
        1236,         // lo_long
        0,            // hi_short (0 => take lo_short)
        0,            // hi_long  (0 => take lo_long)
        430,          // lo_last
        12091,        // sep
        24,            // nb_bits
        callback1,
        0
    );

    rf.register_callback(callback1, 1000);

    rf.set_opt_wait_free_433(false);
    rf.activate_interrupts_handler();
}

void loop()
{
    rf.do_events();
}
mmz1785 commented 1 year ago

I use RF433any lib without any problem

[19:24:24.566]收←◆Decoded: yes, err: 0, code: T, rep: 1, bits: 24, data: bf 03 02
         I=12099, LS=437, LL=1240, HS=0, HL=0, S=12099, U=0, V=0, Y=0, Z=424
Decoded: yes, err: 0, code: T, rep: 1, bits: 24, data: bf 03 02
         I=0, LS=437, LL=1240, HS=0, HL=0, S=65535, U=0, V=0, Y=0, Z=419

[19:24:25.800]收←◆Decoded: yes, err: 0, code: T, rep: 1, bits: 24, data: bf 03 03
         I=12111, LS=430, LL=1244, HS=0, HL=0, S=12111, U=0, V=0, Y=0, Z=432
Decoded: yes, err: 0, code: T, rep: 1, bits: 24, data: bf 03 03
         I=0, LS=430, LL=1244, HS=0, HL=0, S=65535, U=0, V=0, Y=0, Z=405

[19:24:26.643]收←◆Decoded: yes, err: 0, code: T, rep: 1, bits: 24, data: bf 03 04
         I=12099, LS=444, LL=1235, HS=0, HL=0, S=12099, U=0, V=0, Y=0, Z=428
Decoded: yes, err: 0, code: T, rep: 1, bits: 24, data: bf 03 04
         I=0, LS=444, LL=1235, HS=0, HL=0, S=65535, U=0, V=0, Y=0, Z=420

[19:24:27.487]收←◆Decoded: yes, err: 0, code: T, rep: 1, bits: 24, data: bf 03 01
         I=12087, LS=432, LL=1244, HS=0, HL=0, S=12087, U=0, V=0, Y=0, Z=441
Decoded: yes, err: 0, code: T, rep: 1, bits: 24, data: bf 03 01
         I=0, LS=432, LL=1244, HS=0, HL=0, S=12153, U=0, V=0, Y=0, Z=416
Decoded: yes, err: 0, code: T, rep: 1, bits: 24, data: bf 03 01
         I=0, LS=432, LL=1244, HS=0, HL=0, S=65535, U=0, V=0, Y=0, Z=410

By the way, I am using an ESP32 device

sebmillet commented 1 year ago

Hello

I tested your code (along with a signal-emitter device nearby with proper timings) and output is:

-----BEGIN ARDUINO OUTPUT----- 111Waiting for signal 1> Code received: 24 bits: [1f 03 14] 111Waiting for signal 1> Code received: 24 bits: [1f 03 14] 111Waiting for signal 1> Code received: 24 bits: [1f 03 14] 111Waiting for signal 1> Code received: 24 bits: [1f 03 14] 111Waiting for signal 1> Code received: 24 bits: [1f 03 14] 111Waiting for signal 1> Code received: 24 bits: [1f 03 14] 111Waiting for signal 1> Code received: 24 bits: [1f 03 14] 111Waiting for signal 1> Code received: 24 bits: [1f 03 14] -----END ARDUINO OUTPUT-----

I did it on an Arduino nano. Of course I had to update the RF_INPUT value but that's all I changed.

So maybe using an ESP32 leads to "something" specific that does not work? What I'd do going forward:

1) You register the callback function twice, I'd register it only once (I tested it and it works, still, as is logical). I left the registration in the call to register_Receiver (but it really doesn't matter where you register the callback).

2) You may add a 'tic' print out to make sure that during execution the code still runs (no crash) and the output to serial still works. I used the below (tested successfully, again, on Arduino Nano):

void loop() { static unsigned long last_t = 0;

rf.do_events();
unsigned long t = millis();
if (t - last_t >= 1000) {
    Serial.print(F("tic\n"));
    last_t = t;
}

}

This'll add a "tic" line every second.

If it does not help I have other ideas, but more complicated to test. The main difference I see between RF433any and RF433recv is that RF433recv makes use of PROGMEM-recorded arrays, of which partial content is copied on-the-fly, as needed, to regular memory. This is necessary because the decoding uses state-automats that are huge and saving it in real memory would consume too much memory (at least on an Arduino). I know nothing about ESP32 but maybe this mechanism is defeated out there? Just thinking loudly... The code is found in the PROGMEM assertions (arrays declaration and initialization) and later, all the calls to pgm_read_byte.

Let me know if your code 'tics' as expected.

Regards, Sébastien Millet

mmz1785 commented 1 year ago
[18:58:31.512]收←◆tic

[18:58:32.512]收←◆tic

[18:58:33.512]收←◆tic

[18:58:34.511]收←◆tic

[18:58:35.512]收←◆tic

[18:58:36.512]收←◆tic

[18:58:37.512]收←◆tic

The software is working normally, but it still cannot decode normally

sebmillet commented 10 months ago

hello

my conclusion is that ESP32 has some specific logic not fully compatible with the library. To fix it, only way I see would be to test with an ESP32... not planned yet.

Regards