Skip to content

Commit 4339db4

Browse files
committed
Fixes to build on ESP8266
1 parent 2e21540 commit 4339db4

File tree

7 files changed

+52
-51
lines changed

7 files changed

+52
-51
lines changed

platformio.ini

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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}
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
147164
upload_protocol = espota
148165
upload_port = openevse.local
149-
monitor_speed = ${common.monitor_speed}
166+
#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/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/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

src/web_server.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
#endif
44

55
#include <Arduino.h>
6-
#include <Update.h>
76

87
typedef const __FlashStringHelper *fstr_t;
98

109
#ifdef ESP32
1110

1211
#include <WiFi.h>
12+
#include <Update.h>
1313

1414
#elif defined(ESP8266)
1515

1616
#include <ESP8266WiFi.h>
17+
#include <Updater.h>
1718

1819
#else
1920
#error Platform not supported
@@ -868,7 +869,7 @@ handleUpdateUpload(MongooseHttpServerRequest *request, int ev, MongooseString fi
868869
lcd_display(F(""), 0, 1, 10 * 1000, LCD_CLEAR_LINE);
869870
lcd_loop();
870871

871-
if(!Update.begin()) {
872+
if(!Update.begin(ESPAL.getUpdateSize())) {
872873
handleUpdateError(request);
873874
}
874875
}

0 commit comments

Comments
 (0)