Skip to content

Define new protocol in RF_Protocols.h

Portisch edited this page Nov 6, 2018 · 5 revisions

Let's take the example from decode 0xB1 sniffed data.

These are the Parameters needed to be defined:

/*
 * high low factor
 */
typedef struct
{
	uint8_t HIGH;
	uint8_t LOW;
} HIGH_LOW;

/*
 * typedef for timing protocols
 */
typedef struct TIMING_PROTOCOL_DATA
{
	// high and low factor for the sync pulse
	HIGH_LOW SYNC;
	// sync bit count
	uint8_t SYNC_BIT_COUNT;
	// pulse time
	uint16_t PULSE_TIME;
	// high and low factor for bit 0
	HIGH_LOW BIT0;
	// high and low factor for bit 1
	HIGH_LOW BIT1;
	// bit count for this protocol
	uint8_t BIT_COUNT;
	// decode tolerance in % of the PULSE_TIME
	uint8_t TOLERANCE;
	// delay in microseconds between the repeats
	uint8_t REPEAT_DELAY;
	// protocol with inverse pulses
	uint8_t INVERSE;
} TIMING_PROTOCOL_DATA;

Find the pulse time

First the pulse time needs to be found.
We do have these 4 buckets:

Bucket 0 length: 960µs
Bucket 1 length: 440µs
Bucket 2 length: 3010µs
Bucket 3 length: 7280µs

With a tolerance (jitter) of the raw signal the pulse time could maybe be 500µs:

PULSE_TIME = 500

SYNC

As a sync bit is high Bucket 2 length: 3010µs followed by low Bucket 3 length: 7280µs the result we be:

SYNC.HIGH = 6
SYNC.LOW = 15

This is calculated by:

SYNC.HIGH = (Bucket 2) / PULSE_TIME ~ 6
SYNC.LOW = (Bucket 3) / PULSE_TIME ~ 15

BIT0

As a bit 0 is high Bucket 1 length: 440µs followed by low Bucket 0 length: 960µs the result we be:

BIT0.HIGH = 1
BIT0.LOW = 2

This is calculated by:

BIT0.HIGH = (Bucket 1) / PULSE_TIME ~ 1
BIT0.LOW = (Bucket 2) / PULSE_TIME ~ 2

BIT1

As a bit 1 is high Bucket 0 length: 960µs followed by low Bucket 1 length: 440µs the result we be:

BIT1.HIGH = 2
BIT1.LOW = 1

This is calculated by:

BIT1.HIGH = (Bucket 0) / PULSE_TIME ~ 2
BIT1.LOW = (Bucket 1) / PULSE_TIME ~ 1

SYNC_BIT_COUNT

This may vary by the used protocol.
Default:

SYNC_BIT_COUNT = 0

BIT_COUNT

By the decoded data the bit count would be 24 bits.
This may vary by the used protocol.

BIT_COUNT = 24

TOLERANCE

Use this tolerance to fine tune the decoding of bit 0 and bit 1 buckets.
Default:

TOLERANCE = 60

REPEAT_DELAY

Use the repeat delay to insert a pause between the repeat of each transfer.
The value should be insert in milliseconds.
Default:

REPEAT_DELAY = 0

INVERSE

With this boolean you are able to invert the RF signal.
A not inverted signal is defined by a high bucket followed by a low bucket.
A inverted signal is defined by a low bucket followed by a high bucket.
Default:

INVERSE = false
Clone this wiki locally