esprfid / esp-rfid

ESP8266 RFID (RC522, PN532, Wiegand, RDM6300) Access Control system featuring WebSocket, JSON, NTP Client, Javascript, SPIFFS
MIT License
1.37k stars 424 forks source link

Fix activation logic for extra relays #620

Closed mcnewton closed 8 months ago

mcnewton commented 8 months ago

Existing code sets the activation flag, then finds out if it should be set or not. This means that for a relay configured as "continuous" it always lags behind by one activation. Swapping these over makes the relay work as expected each time it is activated.

Also simplifies the code slightly, there is no need to treat relay0 as special here; the previous code guarantees that it will already be ACCESS_GRANTED by the time it hits this loop.

matjack1 commented 8 months ago

Thanks! :)