Variable packet length in the same program.
Closed this issue · 2 comments
gomond commented
Sebastian is it possible to read 2 different length packets? i.e. 32 bits and 40 bits.
As the Bed Remote that I am using uses 1 button to output a pairing packet of 40 bits and all of the others are 32.
It Is a Reverie bed.
> #include "RF433recv.h"
> #include <Arduino.h>
>
> #define PIN_RFINPUT 2
> // Specifying the interrupt number is optional, you can leave it to the
> // constructor to work it out.
> #define INT_RFINPUT 0
>
> void callback_anycode(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 callback_head_up(const BitVector *recorded) {
> Serial.print(F("Head Up pressed\n"));
> }
>
> void callback_head_down(const BitVector *recorded) {
> Serial.print(F("Head Down pressed\n"));
> }
>
> RF_manager rf(PIN_RFINPUT, INT_RFINPUT);
> // Second parameter is optional. Could also be:
> //RF_manager rf(PIN_RFINPUT);
>
> void setup() {
> pinMode(PIN_RFINPUT, INPUT);
> Serial.begin(115200);
>
>
> // 40 Bit registration
> // Data: 78 10 d6 be be
>
> rf.register_Receiver(
> RFMOD_TRIBIT_INVERTED, // mod
> 19468, // initseq
> 4968, // lo_prefix
> 5512, // hi_prefix
> 1018, // first_lo_ign
> 506, // lo_short
> 1018, // lo_long
> 0, // hi_short (0 => take lo_short)
> 0, // hi_long (0 => take lo_long)
> 968, // lo_last
> 19468, // sep
> 40 // nb_bits
> );
>
> rf.register_callback(callback_head_down, 500,
> new BitVector(40, 5, 0x78, 0x10, 0xd6, 0xbe, 0xbe));
>
> // 32 Bit registration
> // Data: 78 10 d7 bf
>
> rf.register_Receiver(
> RFMOD_TRIBIT_INVERTED, // mod
> 19468, // initseq
> 0, // lo_prefix
> 0, // hi_prefix
> 1020, // first_lo_ign
> 512, // lo_short
> 1020, // lo_long
> 0, // hi_short (0 => take lo_short)
> 0, // hi_long (0 => take lo_long)
> 968, // lo_last
> 19468, // sep
> 32 // nb_bits
> );
>
> rf.register_callback(callback_head_up, 500,
> new BitVector(32, 4, 0x78, 0x10, 0xd7, 0xbf));
>
>
> Serial.print(F("Waiting for signal\n"));
>
> rf.activate_interrupts_handler();
> }
>
> void loop() {
> rf.do_events();
> }
/**************************************************************************************/
this is what I am attempting but there are 18 buttons and I need to read them all.
Thank You
gomond commented
I apologise
I was programming with my brain switched off.
Worked it out.
Thanks.
sebmillet commented
ok good ;-)