-
Notifications
You must be signed in to change notification settings - Fork 7
/
appGlobals.h
163 lines (135 loc) · 5.03 KB
/
appGlobals.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
// Global IO_Extender declarations
//
// s60sc 2022
#pragma once
#include "globals.h"
#define ALLOW_SPACES false // set true to allow whitespace in configs.txt key values
#define USE_DS18B20 false // if true, requires additional libraries: OneWire and DallasTemperature
// web server ports
#define HTTP_PORT 80 // insecure app access
#define HTTPS_PORT 443 // secure app access
/*********************** Fixed defines leave as is ***********************/
/** Do not change anything below here unless you know what you are doing **/
//#define DEV_ONLY // leave commented out
#define STATIC_IP_OCTAL "161" // dev only
#define DEBUG_MEM false // leave as false
#define FLUSH_DELAY 0 // for debugging crashes
#define DBG_ON false // esp debug output
#define DOT_MAX 50
#define HOSTNAME_GRP 0
#define USE_IP6 false
#define APP_NAME "ESP_IO_Extender" // max 15 chars
#define APP_VER "1.6"
#define HTTP_CLIENTS 2 // http, ws
#define MAX_STREAMS 0
#define INDEX_PAGE_PATH DATA_DIR "/IO_EXT" HTML_EXT
#define FILE_NAME_LEN 64
#define IN_FILE_NAME_LEN 128
#define JSON_BUFF_LEN (1024 * 4)
#define MAX_CONFIGS 60 // > number of entries in configs.txt
#define GITHUB_PATH "/s60sc/ESP32-IO_Extender/main"
#define STORAGE LittleFS // One of LittleFS or SD_MMC
#define RAMSIZE (1024 * 8)
#define CHUNKSIZE (1024 * 4)
#define MIN_RAM 8 // min object size stored in ram instead of PSRAM default is 4096
#define MAX_RAM 4096 // max object size stored in ram instead of PSRAM default is 4096
#define TLS_HEAP (64 * 1024) // min free heap for TLS session
#define WARN_HEAP (32 * 1024) // low free heap warning
#define WARN_ALLOC (16 * 1024) // low free max allocatable free heap block
#define MAX_ALERT 1024
#define INCLUDE_FTP_HFS false // ftp.cpp (file upload)
#define INCLUDE_SMTP false // smtp.cpp (email)
#define INCLUDE_MQTT false // mqtt.cpp
#define INCLUDE_TGRAM false // telegram.cpp
#define INCLUDE_CERTS false // certificates.cpp (https and server certificate checking)
#define INCLUDE_UART true // uart.cpp (use another esp32 as IO extender)
#define INCLUDE_WEBDAV true // webDav.cpp (WebDAV protocol)
#define IS_IO_EXTENDER true // must be true for IO_Extender
#define EXTPIN 100
// to determine if newer data files need to be loaded
#define CFG_VER 3
#ifdef CONFIG_IDF_TARGET_ESP32S3
#define SERVER_STACK_SIZE (1024 * 8)
#define DS18B20_STACK_SIZE (1024 * 2)
#define STICK_STACK_SIZE (1024 * 4)
#else
#define SERVER_STACK_SIZE (1024 * 4)
#define DS18B20_STACK_SIZE (1024)
#define STICK_STACK_SIZE (1024 * 2)
#endif
#define BATT_STACK_SIZE (1024 * 2)
#define EMAIL_STACK_SIZE (1024 * 6)
#define FS_STACK_SIZE (1024 * 4)
#define LOG_STACK_SIZE (1024 * 3)
#define MIC_STACK_SIZE (1024 * 4)
#define MQTT_STACK_SIZE (1024 * 4)
#define PING_STACK_SIZE (1024 * 5)
#define SERVO_STACK_SIZE (1024)
#define SUSTAIN_STACK_SIZE (1024 * 4)
#define TGRAM_STACK_SIZE (1024 * 6)
#define TELEM_STACK_SIZE (1024 * 4)
#define UART_STACK_SIZE (1024 * 2)
// task priorities
#define HTTP_PRI 5
#define STICK_PRI 5
#define TGRAM_PRI 1
#define EMAIL_PRI 1
#define FTP_PRI 1
#define LOG_PRI 1
#define DS18B20_PRI 1
#define SERVO_PRI 1
#define UART_PRI 1
#define BATT_PRI 1
#define IDLEMON_PRI 5
/******************** Function declarations *******************/
// global app specific functions
void doIOExtPing();
void getPeripheralsRequest();
bool getPIRval();
float readTemperature(bool isCelsius);
void setCamPan(int panVal);
void setCamTilt(int tiltVal);
void setLamp(uint8_t lampVal);
void stepperDone();
/******************** Global app declarations *******************/
// status & control fields
extern const char* appConfig;
// buffers
extern byte* uartData;
// peripherals
// IO Extender use
extern bool useIOextender; // true to use IO Extender, otherwise false
extern bool useUART0;
extern int uartTxdPin;
extern int uartRxdPin;
// peripherals used
extern bool pirUse; // true to use PIR for motion detection
extern bool lampUse; // true to use lamp
extern bool lampAuto; // if true in conjunction with usePir & useLamp, switch on lamp when PIR activated
extern bool servoUse; // true to use pan / tilt servo control
extern bool voltUse; // true to report on ADC pin eg for for battery
// sensors
extern int pirPin; // if usePir is true
extern bool pirVal;
extern int lampPin; // if useLamp is true
// Pan / Tilt Servos
extern int servoPanPin; // if useServos is true
extern int servoTiltPin;
// ambient / module temperature reading
extern int ds18b20Pin; // if INCLUDE_DS18B20 true
// batt monitoring
extern int voltPin;
// configure for specific servo model, eg for SG90
extern int servoDelay;
extern int servoMinAngle; // degrees
extern int servoMaxAngle;
extern int servoMinPulseWidth; // usecs
extern int servoMaxPulseWidth;
// battery monitor
extern int voltDivider;
extern float voltLow;
extern int voltInterval;
// task handling
extern TaskHandle_t DS18B20handle;
extern TaskHandle_t servoHandle;
extern TaskHandle_t uartClientHandle;