Skip to content

Commit 28ffc95

Browse files
authored
Merge pull request #97 from OpenEVSE/esp8622_port
ESP8622 port
2 parents 222565e + 3ab7e1d commit 28ffc95

File tree

12 files changed

+63
-62
lines changed

12 files changed

+63
-62
lines changed

platformio.ini

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ lib_deps =
3838
3939
4040
41-
41+
4242
extra_scripts = scripts/extra_script.py
4343
debug_flags =
4444
-DENABLE_DEBUG
@@ -54,24 +54,20 @@ ota_flags = -DENABLE_OTA -DWIFI_LED=LED_BUILTIN
5454
src_build_flags =
5555
# -DENABLE_ASYNC_WIFI_SCAN
5656
build_flags =
57-
-DCS_PLATFORM=CS_P_ESP32
58-
-DMG_ENABLE_SSL=1
5957
-DMG_ENABLE_HTTP_STREAMING_MULTIPART=1
60-
-DMG_SSL_MBED_DUMMY_RANDOM=1
61-
-DMG_SSL_IF=MG_SSL_IF_MBEDTLS
62-
-DMG_SSL_IF_MBEDTLS_FREE_CERTS=1
58+
-DMG_ENABLE_SNTP=1
6359
#-DMG_SSL_IF_MBEDTLS_MAX_FRAG_LEN=2048
6460
#-DARDUINO_MONGOOSE_DEFAULT_STREAM_BUFFER=2048
6561
#-DARDUINO_MONGOOSE_SEND_BUFFER_SIZE=2048
6662
#-DENABLE_DEBUG
6763
#-DCS_ENABLE_DEBUG
6864
#-DMBEDTLS_DEBUG_C
69-
-DMG_ENABLE_SNTP=1
7065
build_flags_esp8266 =
71-
-DMG_ESP8266
72-
-DCS_PLATFORM=CS_P_ESP8266
7366
build_flags_esp32 =
74-
-DCS_PLATFORM=CS_P_ESP32
67+
-DMG_ENABLE_SSL=1
68+
-DMG_SSL_MBED_DUMMY_RANDOM=1
69+
-DMG_SSL_IF=MG_SSL_IF_MBEDTLS
70+
-DMG_SSL_IF_MBEDTLS_FREE_CERTS=1
7571
src_build_flags_esp32 =
7672
-DENABLE_OTA
7773
build_partitions_esp32 = min_spiffs.csv
@@ -88,7 +84,7 @@ monitor_flags = --filter=esp8266_exception_decoder
8884
# specify exact Arduino ESP SDK version, requires platformio 3.5+ (curently dev version)
8985
# http://docs.platformio.org/en/latest/projectconf/section_env_general.html#platform
9086
platform = https://github.com/platformio/platform-espressif8266.git#release/v1.6.0
91-
platform_stage = https://github.com/platformio/platform-espressif8266.git#feature/stage
87+
platform_stage = https://github.com/platformio/platform-espressif8266.git#develop
9288
#platform_esp32 = https://github.com/platformio/platform-espressif32.git#feature/stage
9389
#platform_esp32 = https://github.com/platformio/platform-espressif32.git#develop
9490
platform_esp32 = [email protected]
@@ -99,6 +95,9 @@ platform = ${common.platform}
9995
board = esp12e
10096
framework = arduino
10197
lib_deps = ${common.lib_deps}
98+
build_flags =
99+
${common.build_flags}
100+
${common.build_flags_esp8266}
102101
src_build_flags = ${common.version} ${common.src_build_flags}
103102
# Upload at faster baud: takes 20s instead of 50s. Use 'pio run -t upload -e evse_slow to use slower default baud rate'
104103
upload_speed = 921600
@@ -110,6 +109,9 @@ platform = ${common.platform}
110109
board = esp12e
111110
framework = arduino
112111
lib_deps = ${common.lib_deps}
112+
build_flags =
113+
${common.build_flags}
114+
${common.build_flags_esp8266}
113115
src_build_flags = ${common.version} ${common.src_build_flags}
114116
monitor_speed = ${common.monitor_speed}
115117
extra_scripts = ${common.extra_scripts}
@@ -119,6 +121,9 @@ platform = ${common.platform}
119121
board = esp12e
120122
framework = arduino
121123
lib_deps = ${common.lib_deps}
124+
build_flags =
125+
${common.build_flags}
126+
${common.build_flags_esp8266}
122127
src_build_flags = ${common.version}.dev ${common.src_build_flags} ${common.ota_flags} ${common.debug_flags}
123128
upload_protocol = espota
124129
upload_port = openevse.local
@@ -130,8 +135,11 @@ platform = ${common.platform}
130135
board = esp12e
131136
framework = arduino
132137
lib_deps = ${common.lib_deps}
138+
build_flags =
139+
${common.build_flags}
140+
${common.build_flags_esp8266}
133141
src_build_flags = ${common.version}.dev ${common.src_build_flags} ${common.ota_flags} ${common.debug_flags}
134-
upload_speed=921600
142+
upload_speed = 921600
135143
monitor_speed = ${common.monitor_speed}
136144
extra_scripts = ${common.extra_scripts}
137145

@@ -142,11 +150,21 @@ platform = ${common.platform_stage}
142150
board = esp12e
143151
framework = arduino
144152
lib_deps = ${common.lib_deps}
145-
build_flags = -DDEBUG_ESP_WIFI
146-
src_build_flags = ${common.version}.stag ${common.src_build_flags} ${common.ota_flags} ${common.debug_flags}
147-
upload_protocol = espota
148-
upload_port = openevse.local
153+
build_flags =
154+
-ggdb
155+
-DDEBUG_ESP_WIFI
156+
${common.build_flags}
157+
${common.build_flags_esp8266}
158+
src_build_flags =
159+
${common.version}.stag
160+
${common.src_build_flags}
161+
${common.ota_flags}
162+
${common.debug_flags}
163+
upload_speed = 921600
164+
#upload_protocol = espota
165+
#upload_port = openevse.local
149166
monitor_speed = ${common.monitor_speed}
167+
monitor_flags = ${common.monitor_flags}
150168
extra_scripts = ${common.extra_scripts}
151169

152170
# staging Arduino framwork and latest libs
@@ -155,6 +173,9 @@ platform = ${common.platform_stage}
155173
board = esp12e
156174
framework = arduino
157175
lib_deps = https://github.com/knolleary/pubsubclient, https://github.com/me-no-dev/ESPAsyncWebServer.git, https://github.com/me-no-dev/ESPAsyncTCP.git
176+
build_flags =
177+
${common.build_flags}
178+
${common.build_flags_esp8266}
158179
src_build_flags = ${common.version}.stagelib ${common.src_build_flags} ${common.ota_flags} ${common.debug_flags}
159180
upload_protocol = espota
160181
upload_port = openevse.local

src/app_config.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ String mqtt_vrms;
4747
String mqtt_announce_topic;
4848

4949
// Time
50-
String time_zone;
50+
String timezone;
5151

5252
// 24-bits of Flags
5353
uint32_t flags;
@@ -86,7 +86,7 @@ ConfigOpt *opts[] =
8686
new ConfigOptDefenition<String>(sntp_hostname, SNTP_DEFAULT_HOST, "sntp_hostname", "sh"),
8787

8888
// Time
89-
new ConfigOptDefenition<String>(time_zone, "", "time_zone", "tz"),
89+
new ConfigOptDefenition<String>(timezone, "", "time_zone", "tz"),
9090

9191
// EMONCMS SERVER strings
9292
new ConfigOptDefenition<String>(emoncms_server, "https://data.openevse.com/emoncms", "emoncms_server", "es"),
@@ -169,7 +169,7 @@ void config_changed(String name)
169169
DBUGF("%s changed", name.c_str());
170170

171171
if(name == "time_zone") {
172-
config_set_timezone(time_zone);
172+
config_set_timezone(timezone);
173173
} else if(name == "flags") {
174174
divertmode_update((config_divert_enabled() && 1 == config_charge_mode()) ? DIVERT_MODE_ECO : DIVERT_MODE_NORMAL);
175175
if(mqtt_connected() != config_mqtt_enabled()) {

src/app_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern String mqtt_vrms;
4343
extern String mqtt_announce_topic;
4444

4545
// Time
46-
extern String time_zone;
46+
extern String timezone;
4747

4848
// Divert settings
4949
extern double divert_attack_smoothing_factor;

src/app_config_v1.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ config_load_v1_settings() {
181181
EEPROM_read_string(EEPROM_SNTP_HOST_START, EEPROM_SNTP_HOST_SIZE, sntp_hostname);
182182

183183
// Timezone
184-
EEPROM_read_string(EEPROM_TIME_ZONE_START, EEPROM_TIME_ZONE_SIZE, time_zone);
185-
config_set_timezone(time_zone);
184+
EEPROM_read_string(EEPROM_TIME_ZONE_START, EEPROM_TIME_ZONE_SIZE, timezone);
185+
config_set_timezone(timezone);
186186

187187
EEPROM.end();
188188
}

src/debug.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
#define DEBUG_BEGIN(speed) DEBUG_PORT.begin(speed)
2222

23-
#ifdef ARDUINO_ESP8266_RELEASE_2_4_0
24-
// Serial.printf_P needs Git version of Arduino Core
25-
#define DBUGF(format, ...) DEBUG_PORT.printf_P(PSTR(format "\n"), ##__VA_ARGS__)
26-
#else
23+
//#ifdef ARDUINO_ESP8266_RELEASE_2_4_0
24+
//// Serial.printf_P needs Git version of Arduino Core
25+
//#define DBUGF(format, ...) DEBUG_PORT.printf_P(PSTR(format "\n"), ##__VA_ARGS__)
26+
//#else
2727
#define DBUGF(format, ...) DEBUG_PORT.printf(format "\n", ##__VA_ARGS__)
28-
#endif
28+
//#endif
2929

3030
#define DBUG(...) DEBUG_PORT.print(__VA_ARGS__)
3131
#define DBUGLN(...) DEBUG_PORT.println(__VA_ARGS__)

src/emoncms.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ void emoncms_publish(JsonDocument &data)
8585
}
8686
});
8787
} else {
88-
emoncms_result(false, String("Disabled"));
88+
if(!emoncms_connected) {
89+
emoncms_result(false, String("Disabled"));
90+
}
8991
}
9092

9193
Profile_End(emoncms_publish, 10);

src/input.cpp

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#include <Arduino.h>
66
#include <ArduinoJson.h>
77

8+
#include <time.h>
9+
#include <sys/time.h>
10+
811
#include "emonesp.h"
912
#include "input.h"
1013
#include "app_config.h"
@@ -247,34 +250,6 @@ handleRapiRead()
247250
}
248251
});
249252

250-
#ifdef ENABLE_LEGACY_API
251-
rapiSender.sendCmd("$GH", [](int ret)
252-
{
253-
if(RAPI_RESPONSE_OK == ret)
254-
{
255-
if(rapiSender.getTokenCnt() >= 2)
256-
{
257-
const char *val;
258-
val = rapiSender.getToken(1);
259-
kwh_limit = strtol(val, NULL, 10);
260-
}
261-
}
262-
});
263-
264-
rapiSender.sendCmd("$G3", [](int ret)
265-
{
266-
if(RAPI_RESPONSE_OK == ret)
267-
{
268-
if(rapiSender.getTokenCnt() >= 2)
269-
{
270-
const char *val;
271-
val = rapiSender.getToken(1);
272-
time_limit = strtol(val, NULL, 10);
273-
}
274-
}
275-
});
276-
#endif
277-
278253
rapiSender.sendCmd("$GE", [](int ret)
279254
{
280255
if(RAPI_RESPONSE_OK == ret)

src/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ void setup()
8585

8686
// Initialise Mongoose networking library
8787
Mongoose.begin();
88+
89+
#if MG_ENABLE_SSL
8890
Mongoose.setRootCa(root_ca);
91+
#endif // MG_ENABLE_SSL
8992

9093
// Bring up the web server
9194
web_server_setup();
@@ -255,5 +258,7 @@ void hardware_setup()
255258
}
256259
#endif
257260

261+
#ifdef ESP32
258262
enableLoopWDT();
263+
#endif // ESP32
259264
}

src/mqtt.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ mqtt_publish(JsonDocument &data) {
207207
topic += kv.key().c_str();
208208
String val = kv.value().as<String>();
209209
mqttclient.publish(topic, val);
210-
topic = mqtt_topic + "/";
211210
}
212211

213212
Profile_End(mqtt_publish, 5);

src/net_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ net_loop()
512512
dnsServer.processNextRequest(); // Captive portal DNS re-dierct
513513
}
514514

515-
Profile_End(net_wifi_loop, 5);
515+
Profile_End(net_loop, 5);
516516
}
517517

518518
void

0 commit comments

Comments
 (0)