|
| 1 | +//// |
| 2 | +//// Copyright (c) 2021 Alexander Mohr |
| 3 | +//// Licensed under the terms of the GNU General Public License v3.0 |
| 4 | +//// |
1 | 5 | //
|
2 |
| -// Copyright (c) 2021 Alexander Mohr |
3 |
| -// Licensed under the terms of the GNU General Public License v3.0 |
4 |
| -// |
5 |
| - |
6 | 6 | #ifndef WIFIMANAGERCONFIG_HPP_
|
7 | 7 | #define WIFIMANAGERCONFIG_HPP_
|
8 | 8 |
|
9 |
| -// disable formatter, cstdin must be included first |
10 |
| -// formatter:off |
11 |
| -#include <cstdint> |
12 |
| -// formatter:on |
13 |
| -#include <hardware/pins.h> |
14 |
| -#include <pins_arduino.h> |
15 |
| - |
16 |
| -static constexpr uint8_t MIN_AP_PASSWORD_SIZE = 8; |
17 |
| -static constexpr uint8_t SSID_MAX_LEN = 32; |
18 |
| -static constexpr uint8_t PASS_MAX_LEN = 64; |
19 |
| - |
20 |
| -static constexpr uint16_t MQTT_DEFAULT_PORT = 1883; |
21 |
| -static constexpr uint8_t MQTT_SERVER_NAME_MAX_SIZE = 32; |
22 |
| -static constexpr uint8_t MQTT_PORT_STR_MAX_SIZE = 16; |
23 |
| -static constexpr uint16_t MQTT_TOPIC_MAX_SIZE = 64; |
24 |
| -static constexpr uint8_t MQTT_USERNAME_MAX_SIZE = 32; |
25 |
| -static constexpr uint8_t MQTT_PASSWORD_MAX_SIZE = 32; |
26 |
| - |
27 |
| -static constexpr uint8_t UPDATE_MIN_USERNAME_LEN = 1; |
28 |
| -static constexpr uint8_t UPDATE_MAX_USERNAME_LEN = 32; |
29 |
| -static constexpr uint8_t UPDATE_MIN_PW_LEN = 1; |
30 |
| -static constexpr uint8_t UPDATE_MAX_PW_LEN = 64; |
31 |
| - |
32 |
| -static constexpr uint8_t HOST_NAME_MAX_LEN = 32; |
33 |
| - |
34 |
| -static constexpr int8_t DEFAULT_MOTOR_GROUND = D6; |
35 |
| -static constexpr int8_t DEFAULT_MOTOR_VIN = D5; |
36 |
| - |
37 |
| -static constexpr int8_t DEFAULT_TEMP_VIN = D7; |
38 |
| -// On devboard defaults are D8 and D7 |
39 |
| -// PIN_D7 13 |
40 |
| -// PIN_D8 15 |
41 |
| -static constexpr int8_t DEFAULT_WINDOW_GROUND = -1; |
42 |
| -static constexpr int8_t DEFAULT_WINDOW_VIN = -1; |
43 |
| - |
44 |
| -static constexpr const char* DEFAULT_HOST_NAME = "OpenHeat"; |
45 |
| - |
46 |
| -static constexpr const char* DEFAULT_USER = "admin"; |
47 |
| -static constexpr const char* DEFAULT_PW = "letmein"; |
48 |
| - |
49 |
| -typedef struct { |
50 |
| - char ssid[SSID_MAX_LEN]; |
51 |
| - char password[PASS_MAX_LEN]; |
52 |
| -} WiFiCredentials; |
53 |
| - |
54 |
| -typedef struct MQTTSettings { |
55 |
| - char Server[MQTT_SERVER_NAME_MAX_SIZE]{}; |
56 |
| - unsigned short Port = MQTT_DEFAULT_PORT; |
57 |
| - char Topic[MQTT_TOPIC_MAX_SIZE]{}; |
58 |
| - char Username[MQTT_USERNAME_MAX_SIZE]{}; |
59 |
| - char Password[MQTT_PASSWORD_MAX_SIZE]{}; |
60 |
| -} MQTTSettings; |
61 |
| - |
62 |
| -typedef struct UpdateSettings { |
63 |
| - char Username[UPDATE_MAX_USERNAME_LEN]{}; |
64 |
| - char Password[UPDATE_MAX_PW_LEN]{}; |
65 |
| -} UpdateSettings; |
66 |
| - |
67 |
| -// pins are signed to indicate unused with < 0 |
68 |
| -typedef struct PinSettings { |
| 9 | +namespace open_heat::config { |
| 10 | +// |
| 11 | +//// disable formatter, cstdin must be included first |
| 12 | +//// formatter:off |
| 13 | +//#include <cstdint> |
| 14 | +//// formatter:on |
| 15 | +//#include <hardware/pins.h> |
| 16 | +//#include <pins_arduino.h> |
| 17 | +// |
| 18 | +// static constexpr uint8_t MIN_AP_PASSWORD_SIZE = 8; |
| 19 | +// static constexpr uint8_t SSID_MAX_LEN = 32; |
| 20 | +// static constexpr uint8_t PASS_MAX_LEN = 64; |
| 21 | +// |
| 22 | +// static constexpr uint16_t MQTT_DEFAULT_PORT = 1883; |
| 23 | +// static constexpr uint8_t MQTT_SERVER_NAME_MAX_SIZE = 32; |
| 24 | +// static constexpr uint8_t MQTT_PORT_STR_MAX_SIZE = 16; |
| 25 | +// static constexpr uint16_t MQTT_TOPIC_MAX_SIZE = 64; |
| 26 | +// static constexpr uint8_t MQTT_USERNAME_MAX_SIZE = 32; |
| 27 | +// static constexpr uint8_t MQTT_PASSWORD_MAX_SIZE = 32; |
| 28 | +// |
| 29 | +// static constexpr uint8_t UPDATE_MIN_USERNAME_LEN = 1; |
| 30 | +// static constexpr uint8_t UPDATE_MAX_USERNAME_LEN = 32; |
| 31 | +// static constexpr uint8_t UPDATE_MIN_PW_LEN = 1; |
| 32 | +// static constexpr uint8_t UPDATE_MAX_PW_LEN = 64; |
| 33 | +// |
| 34 | +// static constexpr uint8_t HOST_NAME_MAX_LEN = 32; |
| 35 | +// |
| 36 | +// static constexpr int8_t DEFAULT_MOTOR_GROUND = D6; |
| 37 | +// static constexpr int8_t DEFAULT_MOTOR_VIN = D5; |
| 38 | +// |
| 39 | +// static constexpr int8_t DEFAULT_TEMP_VIN = D7; |
| 40 | +//// On devboard defaults are D8 and D7 |
| 41 | +//// PIN_D7 13 |
| 42 | +//// PIN_D8 15 |
| 43 | +// static constexpr int8_t DEFAULT_WINDOW_GROUND = -1; |
| 44 | +// static constexpr int8_t DEFAULT_WINDOW_VIN = -1; |
| 45 | +// |
| 46 | +// static constexpr const char* DEFAULT_HOST_NAME = "OpenHeat"; |
| 47 | +// |
| 48 | +// static constexpr const char* DEFAULT_USER = "admin"; |
| 49 | +// static constexpr const char* DEFAULT_PW = "letmein"; |
| 50 | +// |
| 51 | +// typedef struct { |
| 52 | +// char ssid[SSID_MAX_LEN]; |
| 53 | +// char password[PASS_MAX_LEN]; |
| 54 | +// } WiFiCredentials; |
| 55 | +// |
| 56 | +// typedef struct MQTTSettings { |
| 57 | +// char Server[MQTT_SERVER_NAME_MAX_SIZE]{}; |
| 58 | +// unsigned short Port = MQTT_DEFAULT_PORT; |
| 59 | +// char Topic[MQTT_TOPIC_MAX_SIZE]{}; |
| 60 | +// char Username[MQTT_USERNAME_MAX_SIZE]{}; |
| 61 | +// char Password[MQTT_PASSWORD_MAX_SIZE]{}; |
| 62 | +// } MQTTSettings; |
| 63 | +// |
| 64 | +// typedef struct UpdateSettings { |
| 65 | +// char Username[UPDATE_MAX_USERNAME_LEN]{}; |
| 66 | +// char Password[UPDATE_MAX_PW_LEN]{}; |
| 67 | +// } UpdateSettings; |
| 68 | +// |
| 69 | +//// pins are signed to indicate unused with < 0 |
| 70 | +using PinSettings = struct PinSettings { |
69 | 71 | int8_t Ground{};
|
70 | 72 | int8_t Vin{};
|
71 |
| -} PinSettings; |
72 |
| - |
73 |
| -enum OperationMode { HEAT, OFF, FULL_OPEN, UNKNOWN }; |
74 |
| -enum TemperatureSensor { BME, BMP }; |
75 |
| - |
76 |
| -typedef struct Config { |
77 |
| - WiFiCredentials WifiCredentials{"", ""}; |
78 |
| - MQTTSettings MQTT{}; |
79 |
| - UpdateSettings Update{}; |
80 |
| - char Hostname[HOST_NAME_MAX_LEN]{}; |
81 |
| - float SetTemperature{18}; |
82 |
| - OperationMode Mode{OFF}; |
83 |
| - PinSettings MotorPins{DEFAULT_MOTOR_GROUND, DEFAULT_MOTOR_VIN}; |
84 |
| - PinSettings WindowPins{}; |
85 |
| - int8_t TempVin{DEFAULT_TEMP_VIN}; |
86 |
| - TemperatureSensor TempSensor{TemperatureSensor::BME}; |
87 |
| - |
88 |
| -} Config; |
89 |
| - |
| 73 | +}; |
| 74 | + |
| 75 | +enum class OperationMode { HEAT, OFF, FULL_OPEN, UNKNOWN }; |
| 76 | +enum class TemperatureSensor { BME, BMP }; |
| 77 | +constexpr const char* MOTOR_VIN = "MotorVIN"; |
| 78 | +constexpr const char* MOTOR_GROUND = "MotorGROUND"; |
| 79 | +constexpr const char* TEMP_VIN = "TempVIN"; |
| 80 | +constexpr const char* TEMP_SENSOR_TYPE = "TempSensorType"; |
| 81 | +constexpr const char* TEMP_SET = "TempSet"; |
| 82 | +constexpr const char* TEMP_MODE = "TempMode"; |
| 83 | +// |
| 84 | +// typedef struct Config { |
| 85 | +// WiFiCredentials WifiCredentials{"", ""}; |
| 86 | +// MQTTSettings MQTT{}; |
| 87 | +// UpdateSettings Update{}; |
| 88 | +// char Hostname[HOST_NAME_MAX_LEN]{}; |
| 89 | +// float SetTemperature{18}; |
| 90 | +// OperationMode Mode{OFF}; |
| 91 | +// PinSettings MotorPins{DEFAULT_MOTOR_GROUND, DEFAULT_MOTOR_VIN}; |
| 92 | +// PinSettings WindowPins{}; |
| 93 | +// int8_t TempVin{DEFAULT_TEMP_VIN}; |
| 94 | +// TemperatureSensor TempSensor{TemperatureSensor::BME}; |
| 95 | +// |
| 96 | +//} Config; |
| 97 | +// |
| 98 | +} // namespace open_heat::config |
90 | 99 | #endif // WIFIMANAGERCONFIG_HPP_
|
0 commit comments