Remove Button and LED.

Now we provide the encryption key as RFID code.
parent e6896a4d
......@@ -3,8 +3,6 @@
#include <SoftwareSerial.h>
#include <SimpleGSM.h>
#include <LinkedList.h>
#include <Button.h>
#include <LED.h>
#include <SPI.h>
#include <SD.h>
......@@ -17,18 +15,14 @@ const byte GSM_TRANSMITTER_LINE_PIN = 3;
const byte GSM_POWER_PIN = 7;
const byte DOOR_SENSOR_PIN = A3;
const byte PIR_SENSOR_PIN = A1;
const byte BUTTON_PIN = 4;
const byte SIREN_PIN = A0;
const byte LED_PIN = A2;
const unsigned long DELAY_TIME_OF_PIR_SENSOR_CALIBRATION = 40000; // 40 seconds
const unsigned long DELAY_TIME_OF_CRITICAL_SECTION = 15000; // 15 seconds
const unsigned long DELAY_TIME_OF_CALL_RINGING_DURATION = 10000; // 10 seconds
const unsigned long DELAY_TIME_WHILE_ENABLING_ALARM = 120000; // 2 minutes
const unsigned long DELAY_TIME_BEFORE_READING_SERIAL = 2000; // 2 seconds
const unsigned long DELAY_TIME_OF_CRITICAL_SECTION = 15000; // 15 seconds
const unsigned long DELAY_TIME_OF_RINGING_SIREN = 900000; // 15 minutes
const unsigned long DELAY_TIME_OF_LCD_MESSAGE = 2000; // 2 seconds
const unsigned long DELAY_TIME_OF_LED_BLINKING = 2000; // 2 seconds
const unsigned long DELAY_TIME_OF_CALL_RINGING_DURATION = 10000; // 10 seconds
const byte NOTIFICATIONS_PER_USER = 3;
......@@ -127,32 +121,6 @@ getSystemGsm ()
return *object;
}
LED &
getSystemLed ()
{
static LED * object = NULL;
if (object == NULL)
{
object = new LED (LED_PIN);
}
return *object;
}
Button &
getSystemButton ()
{
static Button * object = NULL;
if (object == NULL)
{
object = new Button (BUTTON_PIN);
}
return *object;
}
LinkedList <String> &
getSystemRfids ()
{
......@@ -373,10 +341,7 @@ systemError (const __FlashStringHelper * string)
{
printStringWithoutDelay(string);
while (true)
{
getSystemLed().blink(DELAY_TIME_OF_LED_BLINKING);
}
while (true) ;
}
void
......@@ -532,7 +497,7 @@ rfidTagHandled (String & rfidCode)
return false;
}
void
bool
readSystemRfids()
{
getSystemRfids().clear();
......@@ -547,14 +512,14 @@ readSystemRfids()
}
file.close();
return true;
}
else
{
systemError(F("Error in RFIDs"));
}
return false;
}
void
bool
readSystemMobiles()
{
getSystemMobiles().clear();
......@@ -569,11 +534,11 @@ readSystemMobiles()
}
file.close();
return true;
}
else
{
systemError(F("Error in Mobiles"));
}
return false;
}
bool
......@@ -614,26 +579,10 @@ notifyUsers ()
}
}
void
waitUntilButtonIsPressed ()
{
while (!getSystemButton().uniquePress()) continue;
}
void
readEncryptionKey ()
{
const long baudRate = 9600;
Serial.begin(baudRate);
while (! Serial.available ()) continue;
delay(DELAY_TIME_BEFORE_READING_SERIAL);
encryptionKey = Serial.readStringUntil('\n');
Serial.end();
while (!rfidTagHandled(encryptionKey)) ;
}
String
......@@ -677,53 +626,59 @@ setup ()
{
initializeSiren();
getSystemLed().on();
initializeLcd();
readEncryptionKey();
printString(F("Init door sensor"));
waitUntilButtonIsPressed();
initializeDoorSensor();
getSystemLed().off();
printString(F("Init PIR sensor"));
initializeLcd();
initializePirSensor();
printString(F("Init SD card"));
printString(F("Init GSM"));
if (!initializeSdCard())
if (!initializeGsm())
{
systemError (F("SD init failed"));
systemError (F("GSM failed"));
}
printString(F("SD init OK"));
printString(F("GSM OK"));
printString(F("Reading RFIDs"));
printString(F("Init SD card"));
readSystemRfids();
if (!initializeSdCard())
{
systemError (F("SD card failed"));
}
printString(F("Reading Mobiles"));
printString(F("SD card OK"));
readSystemMobiles();
printString(F("Read RFIDs"));
printString(F("Init door sensor"));
if (!readSystemRfids())
{
systemError(F("RFIDs failed"));
}
initializeDoorSensor();
printString(F("RFIDs OK"));
printString(F("Init GSM"));
printString(F("Read mobiles"));
if (!initializeGsm())
if (!readSystemMobiles())
{
systemError (F("Init GSM failed"));
systemError(F("Mobiles failed"));
}
printString(F("Init GSM OK"));
printString(F("Init PIR sensor"));
initializePirSensor();
printString(F("Mobiles OK"));
printString(F("Init RFID"));
initializeRfid();
printString(F("Read key"));
readEncryptionKey();
}
void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment