Compare commits

..

No commits in common. "1bcbd3b8e3feafdbfb0c5d984971526b2547b0d1" and "156e095d4df06fcb15f2cb79f4d9cd819ed3eff8" have entirely different histories.

16 changed files with 28 additions and 88 deletions

View File

@ -39,11 +39,3 @@
### 20.03.2022 ### 20.03.2022
+ settings API implemented and tested + settings API implemented and tested
+ TODO: factory reset + TODO: factory reset
### 10.04.2022
+ Toni:
+ Reed Contact -> Door closed?
+ Tracking in->out
+ Stats
+ Sensors

View File

@ -5,14 +5,9 @@ Adress 0x21
### 1.1 Wiring ### 1.1 Wiring
* Red: 3.3V * Red: 3.3V
* Black GND * Black GND
* Green SDA -> D2 * Green SDA -> D3
* Grey SCL -> D1 * Grey SCL -> D4
## 2.0 LCD ## 2.0 LCD
The LCD display is driven on the same i2c bus as the keypad. The LCD display is driven on the same i2c bus as the keypad.
nterface Definition
BYTE BIT
7 (MSB) 6 5 4 3 2 1 0 (LSB)
I2C slave address L H L L A2 A1 A0 R/W
I/O data bus P7 P6 P5 P4 P3 P2 P1 P0

2
data/s/bundle.357e7.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
data/s/bundle.45d14.css Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>doorlock_pwa</title><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-capable" content="yes"><link rel="apple-touch-icon" href="/assets/icons/apple-touch-icon.png"><link rel="manifest" href="/manifest.json"><meta name="theme-color" content="#673ab8"><style>*{box-sizing:border-box}html{font-family:Helvetica,sans-serif;font-size:16px}body,html{height:100%}body{background-color:#fff;margin:0;padding:0;width:100%}</style><link href="/bundle.3bf6c.css" rel="stylesheet" media="only x" onload="this.media='all'"><noscript><link rel="stylesheet" href="/bundle.3bf6c.css"></noscript></head><body><script defer="defer" src="/bundle.4bdf3.js"></script><script nomodule="" src="/polyfills.914a6.js"></script></body></html> <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>doorlock_pwa</title><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-capable" content="yes"><link rel="apple-touch-icon" href="/assets/icons/apple-touch-icon.png"><link rel="manifest" href="/manifest.json"><meta name="theme-color" content="#673ab8"><style>*{box-sizing:border-box}html{font-family:Helvetica,sans-serif;font-size:16px}body,html{height:100%}body{background-color:#fff;margin:0;padding:0;width:100%}</style><link href="/bundle.45d14.css" rel="stylesheet" media="only x" onload="this.media='all'"><noscript><link rel="stylesheet" href="/bundle.45d14.css"></noscript></head><body><script defer="defer" src="/bundle.357e7.js"></script><script nomodule="" src="/polyfills.058fb.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
#include "Config.h" #include "Config.h"
Config::Config(const char* filepath): _filepath(filepath) Config::Config()
{ {
if (!LittleFS.begin()) if (!LittleFS.begin())
{ {
@ -12,13 +12,10 @@ Config::~Config()
{ {
free(buffer); free(buffer);
} }
bool Config::setFilePath(const char* filepath){
this->_filepath = filepath;
return loadBin();
}
bool Config::loadBin() bool Config::loadBin()
{ {
File config_file = LittleFS.open(_filepath, "r"); File config_file = LittleFS.open("/settings", "r");
//if (buffer == nullptr) // Allocate only once //if (buffer == nullptr) // Allocate only once
// buffer = (uint8_t *)malloc(CONFIG_SIZE); // buffer = (uint8_t *)malloc(CONFIG_SIZE);
if (config_file.available()) if (config_file.available())
@ -26,6 +23,7 @@ bool Config::loadBin()
config_file.read(buffer, CONFIG_SIZE); config_file.read(buffer, CONFIG_SIZE);
buffer[OFFSET_SSID + 0x1F] = 0x00; // ensure ssid and password are terminated with a null character buffer[OFFSET_SSID + 0x1F] = 0x00; // ensure ssid and password are terminated with a null character
buffer[OFFSET_PASS + 0x1F] = 0x00; buffer[OFFSET_PASS + 0x1F] = 0x00;
} }
config_file.close(); config_file.close();
return true; return true;
@ -33,7 +31,7 @@ bool Config::loadBin()
bool Config::saveBin() bool Config::saveBin()
{ {
File config_file = LittleFS.open(_filepath, "w"); File config_file = LittleFS.open("/settings", "w");
config_file.write(buffer, CONFIG_SIZE); config_file.write(buffer, CONFIG_SIZE);
delay(100); delay(100);
config_file.close(); config_file.close();

View File

@ -16,7 +16,7 @@ private:
uint8_t *buffer = (uint8_t *)malloc(CONFIG_SIZE); uint8_t *buffer = (uint8_t *)malloc(CONFIG_SIZE);
public: public:
Config(const char* filepath); Config();
~Config(); ~Config();
const char *SSID = (char *)(buffer + OFFSET_SSID); const char *SSID = (char *)(buffer + OFFSET_SSID);
const char *PASS = (char *)(buffer + OFFSET_PASS); const char *PASS = (char *)(buffer + OFFSET_PASS);
@ -26,8 +26,7 @@ public:
uint8_t &mode = *(buffer + OFFSET_MODE); uint8_t &mode = *(buffer + OFFSET_MODE);
uint8_t &fail_timeout = *(buffer+OFFSET_FAIL_TIMEOUT); uint8_t &fail_timeout = *(buffer+OFFSET_FAIL_TIMEOUT);
uint8_t &hold_time = *(buffer+OFFSET_HOLD_TIME); uint8_t &hold_time = *(buffer+OFFSET_HOLD_TIME);
const char* _filepath;
bool setFilePath(const char* filepath);
bool loadConfig(); bool loadConfig();
bool loadBin(); bool loadBin();
bool saveBin(); bool saveBin();

View File

@ -1,6 +1,8 @@
#include "Keyboard.h" #include "Keyboard.h"
//#define DEBUG
#define PIN_WIRE_SDA D3
#define PIN_WIRE_SCL D4
Keyboard::Keyboard(uint8_t _debounce) Keyboard::Keyboard(uint8_t _debounce)
{ {
this->keybind.insert({ this->keybind.insert({
@ -21,7 +23,7 @@ Keyboard::Keyboard(uint8_t _debounce)
} }
void Keyboard::begin(TwoWire *databus) void Keyboard::begin(TwoWire *databus)
{ {
pcf8574 = new PCF8574(databus, 0x21); pcf8574 = new PCF8574(databus, 0x21, PIN_WIRE_SDA, PIN_WIRE_SCL);
pcf8574->pinMode(0, OUTPUT); pcf8574->pinMode(0, OUTPUT);
for (int i = 1; i < 8; i++) for (int i = 1; i < 8; i++)
{ {

View File

@ -1,26 +0,0 @@
#include "Relais.h"
Relais::Relais(uint8_t pin)
{
pinMode(pin, OUTPUT);
digitalWrite(_pin, 1);
_pin = pin;
}
void Relais::cylce()
{
if (!_state)
return;
if (millis() > _call_time)
{
digitalWrite(_pin, 1);
_state = false;
Serial.println("Relay released.");
}
}
void Relais::activate(uint8_t seconds)
{
Serial.println("Relay activated for "+String(seconds)+" Seconds.");
digitalWrite(_pin, 0);
_state = true;
_call_time = millis() + seconds * 1000;
}

View File

@ -1,16 +0,0 @@
#pragma once
#include <Arduino.h>
#include <Wire.h>
class Relais
{
public:
Relais(uint8_t pin);
void cylce();
void activate(uint8_t seconds);
private:
unsigned long _call_time = 0;
bool _state = false;
uint8_t _pin;
};

View File

@ -1,8 +1,8 @@
#include "Rfid.h" #include "Rfid.h"
#define SS_PIN D8 #define SS_PIN D8
#define RST_PIN D0 #define RST_PIN D1
#define RFID_TIMEOUT 3000 #define RFID_TIMEOUT 3000
Rfid::Rfid(/* args */) : _mfrc522(SS_PIN, RST_PIN) Rfid::Rfid(/* args */) : _mfrc522(SS_PIN)
{ {
} }
@ -33,12 +33,11 @@ void Rfid::scan()
{ {
_status = 1; _status = 1;
#ifdef DEBUG #ifdef DEBUG
_mfrc522.PICC_DumpToSerial(&(_mfrc522.uid)); Serial.print(this->_rfid);
#endif #endif
this->_lastRfid = this->_rfid; this->_lastRfid = this->_rfid;
this->_lastRfidScan = millis(); this->_lastRfidScan = millis();
} }
} }
} }

View File

@ -8,18 +8,17 @@
#include "WebConsole.h" #include "WebConsole.h"
#include "UserDb.h" #include "UserDb.h"
#include "Config.h" #include "Config.h"
#include "Relais.h"
// File config // File config
Config config("/settings"); Config config;
userdb::UserDb userdatabase("/userdb.csv"); userdb::UserDb userdatabase("userdb.csv");
webconsole::WebConsole web; webconsole::WebConsole web;
// Rfid // Rfid
Rfid rfid; Rfid rfid;
// i2C Bus // i2C Bus
#define PIN_WIRE_SDA D1 #define PIN_WIRE_SDA D3
#define PIN_WIRE_SCL D2 #define PIN_WIRE_SCL D4
Relais relay(D4);
Keyboard keyboard(200); Keyboard keyboard(200);
Interface iface; Interface iface;
void setup() void setup()
@ -39,7 +38,6 @@ void setup()
void loop() void loop()
{ {
relay.cylce();
rfid.scan(); rfid.scan();
web.serve(); web.serve();
keyboard.scanAsync(); keyboard.scanAsync();
@ -76,7 +74,6 @@ void loop()
{ {
iface.greetUser(login_user.first_name + " " + login_user.last_name); iface.greetUser(login_user.first_name + " " + login_user.last_name);
Serial.println("Logon from User " + login_user.toString()); Serial.println("Logon from User " + login_user.toString());
relay.activate(config.hold_time);
} }
iface.render(); iface.render();
} }