MCPcopy Create free account
hub / github.com/DanielOgorchock/ST_Anything / receiveProtocol3

Method receiveProtocol3

Arduino/libraries/RCSwitch/RCSwitch.cpp:716–754  ·  view source on GitHub ↗

Protocol 3 is used by BL35P02. * */

Source from the content-addressed store, hash-verified

714 *
715 */
716bool RCSwitch::receiveProtocol3(unsigned int changeCount){
717
718 unsigned long code = 0;
719 unsigned long delay = RCSwitch::timings[0] / PROTOCOL3_SYNC_FACTOR;
720 unsigned long delayTolerance = delay * RCSwitch::nReceiveTolerance * 0.01;
721
722 for (int i = 1; i<changeCount ; i=i+2) {
723
724 if (RCSwitch::timings[i] > delay*PROTOCOL3_0_HIGH_CYCLES - delayTolerance
725 && RCSwitch::timings[i] < delay*PROTOCOL3_0_HIGH_CYCLES + delayTolerance
726 && RCSwitch::timings[i+1] > delay*PROTOCOL3_0_LOW_CYCLES - delayTolerance
727 && RCSwitch::timings[i+1] < delay*PROTOCOL3_0_LOW_CYCLES + delayTolerance) {
728 code = code << 1;
729 } else if (RCSwitch::timings[i] > delay*PROTOCOL3_1_HIGH_CYCLES - delayTolerance
730 && RCSwitch::timings[i] < delay*PROTOCOL3_1_HIGH_CYCLES + delayTolerance
731 && RCSwitch::timings[i+1] > delay*PROTOCOL3_1_LOW_CYCLES - delayTolerance
732 && RCSwitch::timings[i+1] < delay*PROTOCOL3_1_LOW_CYCLES + delayTolerance) {
733 code+=1;
734 code = code << 1;
735 } else {
736 // Failed
737 i = changeCount;
738 code = 0;
739 }
740 }
741 code = code >> 1;
742 if (changeCount > 6) { // ignore < 4bit values as there are no devices sending 4bit values => noise
743 RCSwitch::nReceivedValue = code;
744 RCSwitch::nReceivedBitlength = changeCount / 2;
745 RCSwitch::nReceivedDelay = delay;
746 RCSwitch::nReceivedProtocol = 3;
747 }
748
749 if (code == 0){
750 return false;
751 }else if (code != 0){
752 return true;
753 }
754}
755
756void RCSwitch::handleInterrupt() {
757

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected