Move config to own file

This commit is contained in:
Christoph Hagen 2022-05-02 16:01:01 +02:00
parent eb982b3287
commit 94dd8f5e92
2 changed files with 95 additions and 50 deletions

94
include/config.h Normal file
View File

@ -0,0 +1,94 @@
#pragma once
#include <stdint.h>
#include <stddef.h>
/* Debug */
// The baud rate used for the debug serial interface
constexpr uint32_t serialBaudRate = 115200;
/* Keys */
// The size of the symmetric keys used for signing and verifying messages
constexpr size_t keySize = 32;
// The symmetric key used by the remote to sign unlock messages
constexpr const uint8_t remoteKey[keySize] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// The symmetric key used by this device to sign response messages
constexpr const uint8_t localKey[keySize] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* WiFi */
// The WiFi network to connect to
constexpr const char* wifiSSID = "MyWiFi";
// The WiFi password to connect to the above network
constexpr const char* wifiPassword = "00000000";
// The interval to reconnect to WiFi if the connection is broken
constexpr uint32_t wifiReconnectInterval = 10000;
/* Server */
// The remote server to connect to
constexpr const char* serverUrl = "christophhagen.de";
// The server port where the Sesame server is listening
constexpr const int serverPort = 443;
// The path on the server to connect the socket
constexpr const char* serverPath = "/sesame/listen";
// The authentication token for the device to connect to the server
constexpr const char* serverAccessKey = "0000000000000000000000000000000000000000000000000000000000000000";
/* Time */
// The url of the ntp server to get the current time
constexpr const char* ntpServerUrl = "pool.ntp.org";
// The offset (in seconds) to GMT time (i.e. the timezone)
constexpr int32_t timeOffsetToGMT = 3600;
// The daylight savings offset, if applicable
constexpr int32_t timeOffsetDaylightSavings = 3600;
/* Servo */
// Servo is Emax ES08MA II
// The time (in ms) to keep the door button pressed
constexpr uint32_t lockOpeningDuration = 1000;
// The timer to use to control the servo
constexpr int pwmTimer = 0;
// Pin wired up to the servo data line
constexpr int servoPin = 14;
// The Emax is a standard 50 Hz servo
constexpr int servoFrequency = 50;
// The microseconds to set the servo to for the pressed state
constexpr int servoPressedState = 1720;
// The microseconds to set the servo to for the released state
constexpr int servoReleasedState = 1520;

View File

@ -13,56 +13,7 @@
#include "message.h" #include "message.h"
#include "server.h" #include "server.h"
#include "servo.h" #include "servo.h"
#include "config.h"
// TODO:
// - Handle WiFi disconnect
// - Implement key sharing
// - Configure/diagnose over Bluetooth?
/* Settings */
constexpr uint32_t serialBaudRate = 115200;
constexpr size_t keySize = 32;
constexpr const uint8_t remoteKey[keySize] = { 1, 2, 3};
constexpr const uint8_t localKey[keySize] = { 1, 2, 3};
// The WiFi network to connect to
constexpr const char* wifiSSID = "MyNetwork";
constexpr const char* wifiPassword = "MyPassword";
constexpr uint32_t wifiReconnectInterval = 10000;
// The remote server to connect to
constexpr const char* serverUrl = "mydomain.com";
constexpr const int serverPort = 443;
constexpr const char* serverPath = "/sesame/listen";
constexpr const char* serverAccessKey = "MyAccessToken";
/* Time */
constexpr const char* ntpServerUrl = "pool.ntp.org";
constexpr int32_t timeOffsetToGMT = 3600;
constexpr int32_t timeOffsetDaylightSavings = 3600;
/* Servo */
// Servo is Emax ES08MA II
// The time (in ms) to keep the door button pressed
constexpr uint32_t lockOpeningDuration = 1500;
// The timer to use to control the servo
constexpr int pwmTimer = 0;
// Pin wired up to the servo data line
constexpr int servoPin = 14;
// The Emax is a standard 50 Hz servo
constexpr int servoFrequency = 50;
// The microseconds to set the servo to the pressed and released states
constexpr int servoPressedState = 1720;//1600;
constexpr int servoReleasedState = 1520;
/* Global variables */ /* Global variables */