66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
/**
|
|
* Sesame-Device
|
|
* Christoph Hagen, 2022.
|
|
*
|
|
* The code for a simple door unlock mechanism where a servo pushes on an existing
|
|
* physical button.
|
|
*/
|
|
#include <Arduino.h>
|
|
|
|
#include "message.h"
|
|
#include "server.h"
|
|
#include "servo.h"
|
|
#include "controller.h"
|
|
#include "config.h"
|
|
|
|
SesameController controller(localWebServerPort, remoteDeviceCount);
|
|
|
|
void setup() {
|
|
Serial.begin(serialBaudRate);
|
|
Serial.setDebugOutput(true);
|
|
Serial.println("[INFO] Device started");
|
|
|
|
ServoConfiguration servoConfig {
|
|
.pwmTimer = pwmTimer,
|
|
.pwmFrequency = servoFrequency,
|
|
.pin = servoPin,
|
|
.openDuration = lockOpeningDuration,
|
|
.pressedValue = servoPressedState,
|
|
.releasedValue = servoReleasedState,
|
|
};
|
|
|
|
ServerConfiguration serverConfig {
|
|
.url = serverUrl,
|
|
.port = serverPort,
|
|
.path = serverPath,
|
|
.key = serverAccessKey,
|
|
.reconnectTime = 5000,
|
|
};
|
|
|
|
TimeConfiguration timeConfig {
|
|
.offsetToGMT = timeOffsetToGMT,
|
|
.offsetDaylightSavings = timeOffsetDaylightSavings,
|
|
.ntpServerUrl = ntpServerUrl,
|
|
.allowedTimeOffset = 60,
|
|
};
|
|
|
|
WifiConfiguration wifiConfig {
|
|
.ssid = wifiSSID,
|
|
.password = wifiPassword,
|
|
.networkName = networkName,
|
|
.reconnectInterval = wifiReconnectInterval,
|
|
};
|
|
|
|
KeyConfiguration keyConfig {
|
|
.remoteKey = remoteKey,
|
|
.localKey = localKey,
|
|
};
|
|
|
|
controller.configure(servoConfig, serverConfig, timeConfig, wifiConfig, keyConfig);
|
|
}
|
|
|
|
void loop() {
|
|
uint32_t time = millis();
|
|
|
|
controller.loop(time);
|
|
} |