Fix RFrecv exceptions 0 and/or 6 (#17285)

This commit is contained in:
Theo Arends 2022-12-09 17:35:57 +01:00
parent 1098ec2098
commit 423945233c
1 changed files with 12 additions and 12 deletions

View File

@ -57,21 +57,21 @@
/* Protocol description format /* Protocol description format
* *
* { * {
* Pulse length, * Pulse length,
* *
* PreambleFactor, * PreambleFactor,
* Preamble {high,low}, * Preamble {high,low},
* *
* HeaderFactor, * HeaderFactor,
* Header {high,low}, * Header {high,low},
* *
* "0" bit {high,low}, * "0" bit {high,low},
* "1" bit {high,low}, * "1" bit {high,low},
* *
* Inverted Signal, * Inverted Signal,
* Guard time * Guard time
* } * }
* *
* Pulse length: pulse duration (Te) in microseconds, * Pulse length: pulse duration (Te) in microseconds,
* for example 350 * for example 350
* PreambleFactor: Number of high and low states to send * PreambleFactor: Number of high and low states to send
@ -80,7 +80,7 @@
* Preamble: Pulse shape which defines a preamble bit. * Preamble: Pulse shape which defines a preamble bit.
* Sent ceil(PreambleFactor/2) times. * Sent ceil(PreambleFactor/2) times.
* For example, {1, 2} with factor 3 would send * For example, {1, 2} with factor 3 would send
* _ _ * _ _
* | |__| |__ (each horizontal bar has a duration of Te, * | |__| |__ (each horizontal bar has a duration of Te,
* vertical bars are ignored) * vertical bars are ignored)
* HeaderFactor: Number of times to send the header pulse. * HeaderFactor: Number of times to send the header pulse.
@ -88,22 +88,22 @@
* {1, 31} means one pulse of duration 1 Te high and 31 Te low * {1, 31} means one pulse of duration 1 Te high and 31 Te low
* _ * _
* | |_______________________________ (don't count the vertical bars) * | |_______________________________ (don't count the vertical bars)
* *
* "0" bit: pulse shape defining a data bit, which is a logical "0" * "0" bit: pulse shape defining a data bit, which is a logical "0"
* {1, 3} means 1 pulse duration Te high level and 3 low * {1, 3} means 1 pulse duration Te high level and 3 low
* _ * _
* | |___ * | |___
* *
* "1" bit: pulse shape that defines the data bit, which is a logical "1" * "1" bit: pulse shape that defines the data bit, which is a logical "1"
* {3, 1} means 3 pulses with a duration of Te high level and 1 low * {3, 1} means 3 pulses with a duration of Te high level and 1 low
* ___ * ___
* | |_ * | |_
* *
* (note: to form the state bit Z (Tri-State bit), two codes are combined) * (note: to form the state bit Z (Tri-State bit), two codes are combined)
* *
* Inverted Signal: Signal inversion - if true the signal is inverted * Inverted Signal: Signal inversion - if true the signal is inverted
* replacing high to low in a transmitted / received packet * replacing high to low in a transmitted / received packet
* Guard time: Separation time between two retries. It will be followed by the * Guard time: Separation time between two retries. It will be followed by the
* next preamble of the next packet. In number of Te. * next preamble of the next packet. In number of Te.
* e.g. 39 pulses of duration Te low level * e.g. 39 pulses of duration Te low level
*/ */
@ -758,7 +758,7 @@ bool RECEIVE_ATTR RCSwitch::receiveProtocol(const int p, unsigned int changeCoun
unsigned int sdelay = 0; unsigned int sdelay = 0;
if (syncLengthInPulses > 0) { if (syncLengthInPulses > 0) {
sdelay = RCSwitch::timings[FirstTiming] / syncLengthInPulses; sdelay = RCSwitch::timings[FirstTiming] / syncLengthInPulses;
} else { } else if (pro.PreambleFactor > 0) {
sdelay = RCSwitch::timings[FirstTiming-2] / pro.PreambleFactor; sdelay = RCSwitch::timings[FirstTiming-2] / pro.PreambleFactor;
} }
const unsigned int delay = sdelay; const unsigned int delay = sdelay;