#define LIMIT_OPENED_PIN 18 // A4: limit switch for open
#define LIMIT_CLOSED_PIN 19 // A5: limit switch for close
+#define AJAR_PIN 14 // input pin for reed relais (door ajar/shut)
+
#define MANUAL_OPEN_PIN 12 // keys for manual open and close
#define MANUAL_CLOSE_PIN 13 //
#define DEBOUNCE_DELAY 6250 // * 16us = 100ms
//**********//
+void init_ajar()
+{
+ pinMode(AJAR_PIN, INPUT); // set pin to input
+ digitalWrite(AJAR_PIN, HIGH); // turn on pullup resistors
+}
+
+boolean get_ajar_status() // shut = true, ajar = false
+{
+ if(digitalRead(AJAR_PIN))
+ return false;
+
+ return true;
+}
+
+//**********//
+
void init_manual()
{
pinMode(MANUAL_OPEN_PIN, INPUT); // set pin to input
Serial.print("opened");
else if(is_closed())
Serial.print("closed");
- Serial.println(", idle");
+ Serial.print(", idle");
+ if(get_ajar_status())
+ Serial.println(", shut");
+ else
+ Serial.println(", ajar");
return;
}
else if(current_state == ERROR) {
Serial.print("<->");
switch(current_state) {
- case IDLE: Serial.println(", idle"); break;
- case OPENING: Serial.println(", opening"); break;
- case CLOSING: Serial.println(", closing"); break;
- case WAIT: Serial.println(", waiting"); break;
- default: Serial.println(", <undefined state>"); break;
+ case IDLE: Serial.print(", idle"); break;
+ case OPENING: Serial.print(", opening"); break;
+ case CLOSING: Serial.print(", closing"); break;
+ case WAIT: Serial.print(", waiting"); break;
+ default: Serial.print(", <undefined state>"); break;
}
-
+ if(get_ajar_status())
+ Serial.println(", shut");
+ else
+ Serial.println(", ajar");
}
//**********//
void setup()
{
init_limits();
+ init_ajar();
init_stepper();
init_leds();
init_heartbeat();
def trackDoorStatusThread(uwscfg, status_tracker,connection_listener):
global door_sockhandle, door_socklock, threads_running
#socket.setdefaulttimeout(10.0) #affects all new Socket Connections (urllib as well)
- RE_STATUS = re.compile(r'Status: (\w+), idle',re.I)
+ RE_STATUS = re.compile(r'Status: (\w+), idle.*',re.I)
RE_REQUEST = re.compile(r'Request: (\w+) (?:(Card|Phone) )?(.+)',re.I)
RE_ERROR = re.compile(r'Error: (.+)',re.I)
while threads_running: