Skip to content

Commit c5e46d6

Browse files
author
Simon Hewison
committed
get doorbot to handle lack of networking as fail-secure
previously, with no connectivity to a working acserver process, it would misinterpret network failures as a grant of access for any card, (and it would cache that card for 8 hours) acserver wasn't a problem.
1 parent 4cefe0d commit c5e46d6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/doorbot.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ void Doorbot::handleCardPresent(Card c) {
4343
case -1:
4444
denyAccess();
4545
break;
46+
case -99:
47+
networkingError();
48+
break;
4649
default:
4750
cache->set(c);
4851
grantAccess();
@@ -68,3 +71,18 @@ void Doorbot::denyAccess() {
6871
void Doorbot::grantAccess() {
6972
door.open();
7073
}
74+
75+
void Doorbot::networkingError() {
76+
// Captain, these lights are blinking out of sequence. What shall we do?
77+
// Get them to blink in sequence!
78+
// We have a networking error, so blink RED/BLUE/RED/BLUE to highlight some problem
79+
led.solid(RED);
80+
delay(ACCESS_DENIED_LED_ON_TIME/4);
81+
led.solid(BLUE);
82+
delay(ACCESS_DENIED_LED_ON_TIME/4);
83+
led.solid(RED);
84+
delay(ACCESS_DENIED_LED_ON_TIME/4);
85+
led.solid(BLUE);
86+
delay(ACCESS_DENIED_LED_ON_TIME/4);
87+
led.solid(BLACK);
88+
}

src/doorbot.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Doorbot : public Role {
2121
Doorbot(Door &, Watchdog &, PN532 &, RGB &l);
2222
void enableAnnouncer(uint16_t port);
2323
void run();
24+
void networkingError();
2425
protected:
2526
void handleCardPresent(Card c);
2627
void denyAccess();

0 commit comments

Comments
 (0)