Skip to content

Commit

Permalink
require two sequential matching light/lock status
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWieland committed Jan 2, 2024
1 parent c91d0dc commit 39d4c31
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/static_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

void readStaticCode(byte rxSP1StaticCode[SECPLUS1_CODE_LEN], uint8_t &door, uint8_t &light, uint8_t &lock){
static uint8_t prevDoor;
static uint8_t prevLight;
static uint8_t prevLock;

uint8_t obs = 0; // experiement to figure out what key 0x39 is for
uint8_t key = 0;
Expand Down Expand Up @@ -67,7 +69,16 @@ void readStaticCode(byte rxSP1StaticCode[SECPLUS1_CODE_LEN], uint8_t &door, uint

// light & lock
if(key == 0x3A){
if(prevLight != bitRead(val,2)){
prevLight = bitRead(val,2);
return;
}
light = bitRead(val,2);

if(prevLock != bitRead(val,3)){
prevLock = bitRead(val,3);
return;
}
lock = !bitRead(val,3);
}

Expand Down

1 comment on commit 39d4c31

@PaulWieland
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #46

Please sign in to comment.