diff --git a/.gitignore b/.gitignore
index 8a9fb2f..89cc49c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,3 @@
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
-.vs/
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 69aa100..c66a10b 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -13,8 +13,6 @@
"type_traits": "cpp",
"utility": "cpp",
"*.d": "cpp",
- "*.html": "cpp",
- "*.tcc": "cpp",
- "regex": "cpp"
+ "*.html": "cpp"
}
}
\ No newline at end of file
diff --git a/src/espmega_iot_core.cpp b/src/espmega_iot_core.cpp
index d6253ac..5384855 100644
--- a/src/espmega_iot_core.cpp
+++ b/src/espmega_iot_core.cpp
@@ -18,9 +18,11 @@ bool standalone = true;
char MQTT_BASE_TOPIC[20];
uint8_t base_topic_length = 0;
char STATE_REQUEST_TOPIC[40];
-bool MQTT_USE_AUTH = false;
-char MQTT_USERNAME[32];
-char MQTT_PASSWORD[32];
+// #define MQTT_USE_AUTH
+#ifdef MQTT_USE_AUTH
+const char MQTT_USERNAME[] = "username";
+const char MQTT_PASSWORD[] = "password";
+#endif
uint8_t utc_offset = 7;
float current_room_temp = 0;
float current_room_humid = 0;
@@ -47,6 +49,12 @@ const int PWM_CYCLE_VALUES[PWM_CYCLE_VALUES_COUNT] = {50, 125, 255};
char PWM_SET_STATE_TOPIC[70];
char PWM_SET_VALUE_TOPIC[70];
+// Infrared Transciever
+#define IR_RECIEVE_PIN 35
+#define IR_SEND_PIN 17
+#define MARK_EXCESS_MICROS 20
+#define RAW_BUFFER_LENGTH 750
+
// LCD
int lcd_current_page = 1;
int lcd_pwmAdj_id = 0;
@@ -61,6 +69,8 @@ Fan Speed 0: Auto, 1: High, 2: Mid, 3: Low
uint8_t ac_mode = 0;
uint8_t ac_fan_speed = 0;
uint8_t ac_temperature = 25;
+#define AC_MAX_TEMPERATURE 30
+#define AC_MIN_TEMPERATURE 18
char AC_SET_MODE_TOPIC[75];
char AC_SET_FAN_TOPIC[75];
char AC_SET_TEMPERATURE_TOPIC[75];
@@ -71,22 +81,19 @@ char AC_ROOM_TEMPERATURE_TOPIC[75];
char AC_HUMIDITY_TOPIC[75];
// EEPROM ADDRESS
-#define EEPROM_ADDRESS_AC_MODE 0 // 01bytes
-#define EEPROM_ADDRESS_AC_TEMPERATURE 1 // 01bytes
-#define EEPROM_ADDRESS_AC_FAN_SPEED 2 // 01bytes
-#define EEPROM_ADDRESS_PWM_STATE 3 // 16bytes, thru 18
-#define EEPROM_ADDRESS_PWM_VALUE 19 // 32bytes, thru 50
-#define EEPROM_ADDRESS_HOSTNAME 65 // 15bytes, thru 79
-#define EEPROM_ADDRESS_TOPIC 80 // 20bytes, thru 99
-#define EEPROM_ADDRESS_IP 100 // 04bytes, thru 103
-#define EEPROM_ADDRESS_SUBNET 104 // 04bytes, thru 107
-#define EEPROM_ADDRESS_GATEWAY 108 // 04bytes, thru 111
-#define EEPROM_ADDRESS_DNS 112 // 04bytes, thru 115
-#define EEPROM_ADDRESS_MQTT_SERVER 116 // 04bytes, thru 119
-#define EEPROM_ADDRESS_MQTT_PORT 120 // 02bytes, thru 121
-#define EEPROM_ADDRESS_MQTT_USERNAME 122 // 32bytes, thru 153
-#define EEPROM_ADDRESS_MQTT_PASSWORD 154 // 32bytes, thru 185
-#define EEPROM_ADDRESS_MQTT_USEAUTH 186 // 1bytes
+#define EEPROM_ADDRESS_AC_MODE 0 // 01bytes
+#define EEPROM_ADDRESS_AC_TEMPERATURE 1 // 01bytes
+#define EEPROM_ADDRESS_AC_FAN_SPEED 2 // 01bytes
+#define EEPROM_ADDRESS_PWM_STATE 3 // 16bytes, thru 18
+#define EEPROM_ADDRESS_PWM_VALUE 19 // 32bytes, thru 50
+#define EEPROM_ADDRESS_HOSTNAME 65 // 15bytes, thru 79
+#define EEPROM_ADDRESS_TOPIC 80 // 20bytes, thru 99
+#define EEPROM_ADDRESS_IP 100 // 04bytes, thru 103
+#define EEPROM_ADDRESS_SUBNET 104 // 04bytes, thru 107
+#define EEPROM_ADDRESS_GATEWAY 108 // 04bytes, thru 111
+#define EEPROM_ADDRESS_DNS 112 // 04bytes, thru 115
+#define EEPROM_ADDRESS_MQTT_SERVER 116 // 04bytes, thru 119
+#define EEPROM_ADDRESS_MQTT_PORT 120 // 02bytes, thru 121
char PWM_STATE_TOPIC[75];
char PWM_VALUE_TOPIC[75];
@@ -123,7 +130,6 @@ void setup()
lcd_send_stop_bit();
lcd_init();
lcd_begin();
- check_boot_reset();
#ifdef ENABLE_EXTERNAL_LCD
Serial2.print("rest");
Serial2.write(0xFF);
@@ -138,8 +144,6 @@ void setup()
lcd_send_command("boot_state.txt=\"Network Initializing . . .\"");
network_begin();
lcd_send_command("boot_state.txt=\"IoT Core Initializing . . .\"");
- mqtt_client.setSocketTimeout(1000);
- eth.setTimeout(1);
mqtt_connect();
lcd_send_command("boot_state.txt=\"Threads Initializing . . .\"");
thread_initialization();
@@ -207,9 +211,6 @@ void eeprom_retrieve_init()
MQTT_SERVER = eeprom_ip_retrieve(EEPROM_ADDRESS_MQTT_SERVER);
eeprom_hostname_retrieve();
eeprom_mqtt_port_retrieve();
- eeprom_mqtt_useauth_retrieve();
- eeprom_mqtt_username_retrieve();
- eeprom_mqtt_password_retrieve();
mqtt_client.setServer(MQTT_SERVER, MQTT_PORT);
eeprom_basetopic_retrieve();
base_topic_length = strlen(MQTT_BASE_TOPIC) + 1;
@@ -248,81 +249,13 @@ void ota_begin()
otaserver.on("/", HTTP_GET, []()
{
otaserver.sendHeader("Connection", "close");
- String otabuffer = ota_part1;
- otabuffer+=ota_part2_1+"Hostname"+ota_part2_2+String(HOSTNAME)+ota_part2_3;
- otabuffer+=ota_part2_1+"IP Address"+ota_part2_2+IP.toString()+ota_part2_3;
- otabuffer+=ota_part2_1+"MAC Address"+ota_part2_2+ETH.macAddress()+ota_part2_3;
- otabuffer+=ota_part2_1+"Device"+ota_part2_2+ESPMEGA_REV+ota_part2_3;
- otabuffer+=ota_part2_1+"BMS Server"+ota_part2_2+MQTT_SERVER.toString()+ota_part2_3;
- otabuffer+=ota_part2_1+"BMS Endpoint"+ota_part2_2+String(MQTT_BASE_TOPIC)+ota_part2_3;
- otabuffer+=ota_part2_1+"Centrally Managed"+ota_part2_2;
+ String otabuffer = ota_part1+HOSTNAME+ota_part2+IP.toString()+ota_part3+ETH.macAddress()+ota_part4+ESPMEGA_REV+ota_part5+MQTT_SERVER.toString()+ota_part6+String(MQTT_BASE_TOPIC)+ota_part7;
if(standalone)
otabuffer+=String("No");
else
otabuffer+=String("Yes");
- otabuffer+=ota_part2_3+ota_part3;
+ otabuffer+=ota_part8;
otaserver.send(200, "text/html", otabuffer); });
- otaserver.on("/config", HTTP_GET, []()
- {
- otaserver.sendHeader("Connection", "close");
- String configbuffer = config_part1;
- configbuffer+=config_txt_part1+"IP Address"+config_txt_part2+"text"+config_txt_part3+"dev_ip"+config_txt_part4+"dev_ip"+config_txt_part5+IP.toString()+config_txt_part6;
- configbuffer+=config_txt_part1+"Network Mask"+config_txt_part2+"text"+config_txt_part3+"netmask"+config_txt_part4+"netmask"+config_txt_part5+SUBNET.toString()+config_txt_part6;
- configbuffer+=config_txt_part1+"Gateway"+config_txt_part2+"text"+config_txt_part3+"gateway"+config_txt_part4+"gateway"+config_txt_part5+GATEWAY.toString()+config_txt_part6;
- configbuffer+=config_txt_part1+"DNS Server"+config_txt_part2+"text"+config_txt_part3+"dns"+config_txt_part4+"dns"+config_txt_part5+DNS.toString()+config_txt_part6;
- configbuffer+=config_txt_part1+"Hostname"+config_txt_part2+"text"+config_txt_part3+"hostname"+config_txt_part4+"hostname"+config_txt_part5+String(HOSTNAME)+config_txt_part6;
- configbuffer+=config_txt_part1+"BMS Server - IP Address"+config_txt_part2+"text"+config_txt_part3+"bms_ip"+config_txt_part4+"bms_ip"+config_txt_part5+MQTT_SERVER.toString()+config_txt_part6;
- configbuffer+=config_txt_part1+"BMS Server - Port"+config_txt_part2+"text"+config_txt_part3+"bms_port"+config_txt_part4+"bms_port"+config_txt_part5+String(MQTT_PORT)+config_txt_part6;
- configbuffer+=config_auth_part1+(MQTT_USE_AUTH?"checked=\"checked\"":"")+config_auth_part2;
- configbuffer+=config_txt_part1+"BMS Server - Username"+config_txt_part2+"text"+config_txt_part3+"bms_username"+config_txt_part4+"bms_username"+config_txt_part5+String(MQTT_USERNAME)+config_txt_part6;
- configbuffer+=config_txt_part1+"BMS Server - Password"+config_txt_part2+"password"+config_txt_part3+"bms_password"+config_txt_part4+"bms_password"+config_txt_part5+String(MQTT_PASSWORD)+config_txt_part6;
- configbuffer+=config_txt_part1+"BMS Server - Endpoint"+config_txt_part2+"text"+config_txt_part3+"bms_endpoint"+config_txt_part4+"bms_endpoint"+config_txt_part5+String(MQTT_BASE_TOPIC)+config_txt_part6;
- configbuffer+=config_part2;
- otaserver.send(200, "text/html", configbuffer); });
-
- otaserver.on("/save_config", HTTP_GET, []()
- {
- otaserver.sendHeader("Connection", "close");
- String configbuffer = "Configuration Saved. Rebooting . . .";
- otaserver.send(200, "text/html", configbuffer);
- bool use_auth = false;
- for(int i=0;i )====="
\ No newline at end of file
diff --git a/src/ota_html/config-textfield-part2.html b/src/ota_html/config-textfield-part2.html
deleted file mode 100644
index 69eaeed..0000000
--- a/src/ota_html/config-textfield-part2.html
+++ /dev/null
@@ -1,2 +0,0 @@
-R"=====(
)====="
\ No newline at end of file
diff --git a/src/ota_html/config.html b/src/ota_html/config.html
deleted file mode 100644
index 703e086..0000000
--- a/src/ota_html/config.html
+++ /dev/null
@@ -1,198 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/src/ota_html/ota-part1.html b/src/ota_html/ota-part1.html
index 1c0e261..a63d855 100644
--- a/src/ota_html/ota-part1.html
+++ b/src/ota_html/ota-part1.html
@@ -1,4 +1,8 @@
R"=====(
-
-)====="
\ No newline at end of file
+R"=====(
+
+ MAC Address + )=====" \ No newline at end of file diff --git a/src/ota_html/ota-part4.html b/src/ota_html/ota-part4.html new file mode 100644 index 0000000..76b974c --- /dev/null +++ b/src/ota_html/ota-part4.html @@ -0,0 +1,5 @@ +R"=====( +
++ Device + )=====" \ No newline at end of file diff --git a/src/ota_html/ota-part5.html b/src/ota_html/ota-part5.html new file mode 100644 index 0000000..d7745f3 --- /dev/null +++ b/src/ota_html/ota-part5.html @@ -0,0 +1,5 @@ +R"=====( +
++ API Server + )=====" \ No newline at end of file diff --git a/src/ota_html/ota-part6.html b/src/ota_html/ota-part6.html new file mode 100644 index 0000000..743ba2a --- /dev/null +++ b/src/ota_html/ota-part6.html @@ -0,0 +1,5 @@ +R"=====( +
++ API Endpoint + )=====" \ No newline at end of file diff --git a/src/ota_html/ota-part7.html b/src/ota_html/ota-part7.html new file mode 100644 index 0000000..567deb3 --- /dev/null +++ b/src/ota_html/ota-part7.html @@ -0,0 +1,5 @@ +R"=====( +
++ Centrally Managed + )=====" \ No newline at end of file diff --git a/src/ota_html/ota-part8.html b/src/ota_html/ota-part8.html new file mode 100644 index 0000000..4f94bee --- /dev/null +++ b/src/ota_html/ota-part8.html @@ -0,0 +1,125 @@ +R"=====( +
+ + + +