-
-
Notifications
You must be signed in to change notification settings - Fork 230
/
Copy pathconfig.h
278 lines (228 loc) · 7.21 KB
/
config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
//-----------------------------------------------------------------------------
// 2024 Ahoy, https://www.mikrocontroller.net/topic/525778
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/4.0/deed
//-----------------------------------------------------------------------------
#ifndef __CONFIG_H__
#define __CONFIG_H__
// globally used
#define DEF_PIN_OFF 255
//-------------------------------------
// WIFI CONFIGURATION
//-------------------------------------
// Fallback WiFi Info
#define FB_WIFI_SSID ""
#define FB_WIFI_PWD ""
// Access Point Info
// In case there is no WiFi Network or Ahoy can not connect to it, it will act as an Access Point
#define WIFI_AP_SSID "AHOY-DTU"
#define WIFI_AP_PWD "esp_8266"
// If the next line is uncommented, Ahoy will stay in access point mode all the time
//#define AP_ONLY
#if defined(AP_ONLY)
#if defined(ENABLE_MQTT)
#undef ENABLE_MQTT
#endif
#endif
// timeout for automatic logoff (20 minutes)
#define LOGOUT_TIMEOUT (20 * 60)
//-------------------------------------
// MODULE SELECTOR - done by platform.ini
//-------------------------------------
// MqTT connection
//#define ENABLE_MQTT
// display plugin
//#define PLUGIN_DISPLAY
// history graph (WebUI)
//#define ENABLE_HISTORY
// inverter simulation
//#define ENABLE_SIMULATOR
// to enable the syslog logging (will disable web-serial)
//#define ENABLE_SYSLOG
//-------------------------------------
// CONFIGURATION - COMPILE TIME
//-------------------------------------
// ethernet
#if defined(ETHERNET)
#define ETH_SPI_HOST SPI2_HOST
#define ETH_SPI_CLOCK_MHZ 25
#ifndef DEF_ETH_IRQ_PIN
#define DEF_ETH_IRQ_PIN 4
#endif
#ifndef DEF_ETH_MISO_PIN
#define DEF_ETH_MISO_PIN 12
#endif
#ifndef DEF_ETH_MOSI_PIN
#define DEF_ETH_MOSI_PIN 13
#endif
#ifndef DEF_ETH_SCK_PIN
#define DEF_ETH_SCK_PIN 14
#endif
#ifndef DEF_ETH_CS_PIN
#define DEF_ETH_CS_PIN 15
#endif
#ifndef DEF_ETH_RST_PIN
#define DEF_ETH_RST_PIN DEF_PIN_OFF
#endif
#else /* defined(ETHERNET) */
// time in seconds how long the station info (ssid + pwd) will be tried
#define WIFI_TRY_CONNECT_TIME 30
// time during the ESP will act as access point on connection failure (to
// station) in seconds
#define WIFI_AP_ACTIVE_TIME 60
#endif /* defined(ETHERNET) */
// default device name
#define DEF_DEVICE_NAME "AHOY-DTU"
// default pinout (GPIO Number)
#if defined(ESP32)
// this is the default ESP32 (son-S) pinout on the WROOM modules for VSPI,
// for the ESP32-S3 there is no sane 'default', as it has full flexibility
// to map its two HW SPIs anywhere and PCBs differ materially,
// so it has to be selected in the Web UI
#ifndef DEF_NRF_CS_PIN
#define DEF_NRF_CS_PIN 5
#endif
#ifndef DEF_NRF_CE_PIN
#define DEF_NRF_CE_PIN 4
#endif
#ifndef DEF_NRF_IRQ_PIN
#define DEF_NRF_IRQ_PIN 16
#endif
#ifndef DEF_NRF_MISO_PIN
#define DEF_NRF_MISO_PIN 19
#endif
#ifndef DEF_NRF_MOSI_PIN
#define DEF_NRF_MOSI_PIN 23
#endif
#ifndef DEF_NRF_SCLK_PIN
#define DEF_NRF_SCLK_PIN 18
#endif
#if defined(ETHERNET) && !defined(SPI_HAL)
#ifndef DEF_CMT_SPI_HOST
#define DEF_CMT_SPI_HOST SPI3_HOST
#endif
#else
#ifndef DEF_CMT_SPI_HOST
#define DEF_CMT_SPI_HOST SPI2_HOST
#endif
#endif /* defined(ETHERNET) */
#ifndef DEF_CMT_SCLK
#define DEF_CMT_SCLK 12
#endif
#ifndef DEF_CMT_SDIO
#define DEF_CMT_SDIO 14
#endif
#ifndef DEF_CMT_CSB
#define DEF_CMT_CSB 27
#endif
#ifndef DEF_CMT_FCSB
#define DEF_CMT_FCSB 26
#endif
#ifndef DEF_CMT_IRQ
#define DEF_CMT_IRQ 34
#endif
#ifndef DEF_MOTION_SENSOR_PIN
#define DEF_MOTION_SENSOR_PIN DEF_PIN_OFF
#endif
#else // ESP8266
#ifndef DEF_NRF_CS_PIN
#define DEF_NRF_CS_PIN 15
#endif
#ifndef DEF_NRF_CE_PIN
#define DEF_NRF_CE_PIN 0
#endif
#ifndef DEF_NRF_IRQ_PIN
#define DEF_NRF_IRQ_PIN 2
#endif
// these are given to relay the correct values via API
// they cannot actually be moved for ESP82xx models
#ifndef DEF_NRF_MISO_PIN
#define DEF_NRF_MISO_PIN 12
#endif
#ifndef DEF_NRF_MOSI_PIN
#define DEF_NRF_MOSI_PIN 13
#endif
#ifndef DEF_NRF_SCLK_PIN
#define DEF_NRF_SCLK_PIN 14
#endif
#ifndef DEF_MOTION_SENSOR_PIN
#define DEF_MOTION_SENSOR_PIN A0
#endif
#endif
#ifndef DEF_LED0
#define DEF_LED0 DEF_PIN_OFF
#endif
#ifndef DEF_LED1
#define DEF_LED1 DEF_PIN_OFF
#endif
#ifndef DEF_LED2
#define DEF_LED2 DEF_PIN_OFF
#endif
#ifdef LED_ACTIVE_HIGH
#define LED_HIGH_ACTIVE true
#else
#define LED_HIGH_ACTIVE false
#endif
// number of packets hold in buffer
#define PACKET_BUFFER_SIZE 30
// number of configurable inverters
#if defined(ESP32)
#if defined(CONFIG_IDF_TARGET_ESP32S3)
#define MAX_NUM_INVERTERS 32
#else
#define MAX_NUM_INVERTERS 16
#endif
#else
#define MAX_NUM_INVERTERS 4
#endif
// default send interval
#define SEND_INTERVAL 15
// maximum human readable inverter name length
#define MAX_NAME_LENGTH 16
// maximum buffer length of packet received / sent to RF24 module
#define MAX_RF_PAYLOAD_SIZE 32
// maximum total payload buffers (must be greater than the number of received frame fragments)
#define MAX_PAYLOAD_ENTRIES 20
// number of seconds since last successful response, before inverter is marked inactive
#define INVERTER_INACT_THRES_SEC 5*60
// number of seconds since last successful response, before inverter is marked offline
#define INVERTER_OFF_THRES_SEC 15*60
// threshold of minimum power on which the inverter is marked as inactive
#define INACT_PWR_THRESH 0
// Timezone
#define TIMEZONE 1
// default NTP server uri
#define DEF_NTP_SERVER_NAME "pool.ntp.org"
// default NTP server port
#define DEF_NTP_PORT 123
// NTP refresh interval in ms (default 12h)
#define NTP_REFRESH_INTERVAL 12 * 3600 * 1000
// default mqtt interval
#define MQTT_INTERVAL 90
// default MQTT broker uri
#define DEF_MQTT_BROKER "\0"
// default MQTT port
#define DEF_MQTT_PORT 1883
// default MQTT user
#define DEF_MQTT_USER "\0"
// default MQTT pwd
#define DEF_MQTT_PWD "\0"
// default MQTT topic
#define DEF_MQTT_TOPIC "inverter"
// discovery prefix
#define MQTT_DISCOVERY_PREFIX "homeassistant"
// reconnect delay
#define MQTT_RECONNECT_DELAY 5000
// maximum custom link length
#define MAX_CUSTOM_LINK_LEN 100
#define MAX_CUSTOM_LINK_TEXT_LEN 32
// syslog settings
#ifdef ENABLE_SYSLOG
#define SYSLOG_HOST "<hostname-or-ip-address-of-syslog-server>"
#define SYSLOG_APP "ahoy"
#define SYSLOG_FACILITY FAC_USER
#define SYSLOG_PORT 514
#endif
#if __has_include("config_override.h")
#include "config_override.h"
#endif
#endif /*__CONFIG_H__*/