Skip to content

Commit 62f3d3f

Browse files
committed
fix broken imports under ESP32
use ESP32 rather than ESP_PLATFORM - it's ambigious standardise to ifdef ESP32 elif defined(ESP8266) use ifdef over if defined where possible
1 parent 368bfef commit 62f3d3f

21 files changed

+132
-135
lines changed

lib/framework/APStatus.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#ifndef APStatus_h
22
#define APStatus_h
33

4-
#if defined(ESP8266)
4+
#ifdef ESP32
5+
#include <WiFi.h>
6+
#include <AsyncTCP.h>
7+
#elif defined(ESP8266)
58
#include <ESP8266WiFi.h>
69
#include <ESPAsyncTCP.h>
7-
#elif defined(ESP_PLATFORM)
8-
#include <AsyncTCP.h>
9-
#include <WiFi.h>
1010
#endif
1111

1212
#include <ArduinoJson.h>

lib/framework/ArduinoJsonJWT.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ String ArduinoJsonJWT::getSecret() {
2121
String ArduinoJsonJWT::sign(String& payload) {
2222
unsigned char hmacResult[32];
2323
{
24-
#if defined(ESP_PLATFORM)
24+
#ifdef ESP32
2525
mbedtls_md_context_t ctx;
2626
mbedtls_md_type_t md_type = MBEDTLS_MD_SHA256;
2727
mbedtls_md_init(&ctx);
@@ -30,7 +30,7 @@ String ArduinoJsonJWT::sign(String& payload) {
3030
mbedtls_md_hmac_update(&ctx, (unsigned char*)payload.c_str(), payload.length());
3131
mbedtls_md_hmac_finish(&ctx, hmacResult);
3232
mbedtls_md_free(&ctx);
33-
#else
33+
#elif defined(ESP8266)
3434
br_hmac_key_context keyCtx;
3535
br_hmac_key_init(&keyCtx, &br_sha256_vtable, _secret.c_str(), _secret.length());
3636
br_hmac_context hmacCtx;
@@ -93,12 +93,12 @@ void ArduinoJsonJWT::parseJWT(String jwt, JsonDocument& jsonDocument) {
9393
String ArduinoJsonJWT::encode(const char* cstr, int inputLen) {
9494
// prepare encoder
9595
base64_encodestate _state;
96-
#if defined(ESP8266)
97-
base64_init_encodestate_nonewlines(&_state);
98-
size_t encodedLength = base64_encode_expected_len_nonewlines(inputLen) + 1;
99-
#elif defined(ESP_PLATFORM)
96+
#ifdef ESP32
10097
base64_init_encodestate(&_state);
10198
size_t encodedLength = base64_encode_expected_len(inputLen) + 1;
99+
#elif defined(ESP8266)
100+
base64_init_encodestate_nonewlines(&_state);
101+
size_t encodedLength = base64_encode_expected_len_nonewlines(inputLen) + 1;
102102
#endif
103103
// prepare buffer of correct length, returning an empty string on failure
104104
char* buffer = (char*)malloc(encodedLength * sizeof(char));

lib/framework/ArduinoJsonJWT.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
#include <ArduinoJson.h>
66
#include <libb64/cdecode.h>
77
#include <libb64/cencode.h>
8-
#if defined(ESP_PLATFORM)
8+
9+
#ifdef ESP32
910
#include <mbedtls/md.h>
10-
#else
11+
#elif defined(ESP8266)
1112
#include <bearssl/bearssl_hmac.h>
1213
#endif
1314

lib/framework/ESP8266React.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33

44
#include <Arduino.h>
55

6-
#if defined(ESP8266)
7-
#include <ESP8266WiFi.h>
8-
#include <ESPAsyncTCP.h>
9-
#elif defined(ESP_PLATFORM)
6+
#ifdef ESP32
7+
#include <WiFi.h>
108
#include <AsyncTCP.h>
119
#include <SPIFFS.h>
12-
#include <WiFi.h>
10+
#elif defined(ESP8266)
11+
#include <ESP8266WiFi.h>
12+
#include <ESPAsyncTCP.h>
13+
#include <FS.h>
1314
#endif
1415

1516
#include <APSettingsService.h>
1617
#include <APStatus.h>
1718
#include <AuthenticationService.h>
18-
#include <FS.h>
1919
#include <NTPSettingsService.h>
2020
#include <NTPStatus.h>
2121
#include <OTASettingsService.h>

lib/framework/NTPSettingsService.cpp

+12-13
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22

33
NTPSettingsService::NTPSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager) :
44
AdminSettingsService(server, fs, securityManager, NTP_SETTINGS_SERVICE_PATH, NTP_SETTINGS_FILE) {
5-
#if defined(ESP8266)
6-
_onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected(
7-
std::bind(&NTPSettingsService::onStationModeDisconnected, this, std::placeholders::_1));
8-
_onStationModeGotIPHandler =
9-
WiFi.onStationModeGotIP(std::bind(&NTPSettingsService::onStationModeGotIP, this, std::placeholders::_1));
10-
#elif defined(ESP_PLATFORM)
5+
#ifdef ESP32
116
WiFi.onEvent(
127
std::bind(&NTPSettingsService::onStationModeDisconnected, this, std::placeholders::_1, std::placeholders::_2),
138
WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED);
149
WiFi.onEvent(std::bind(&NTPSettingsService::onStationModeGotIP, this, std::placeholders::_1, std::placeholders::_2),
1510
WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP);
11+
#elif defined(ESP8266)
12+
_onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected(
13+
std::bind(&NTPSettingsService::onStationModeDisconnected, this, std::placeholders::_1));
14+
_onStationModeGotIPHandler =
15+
WiFi.onStationModeGotIP(std::bind(&NTPSettingsService::onStationModeGotIP, this, std::placeholders::_1));
1616
#endif
17-
1817
NTP.onNTPSyncEvent([this](NTPSyncEvent_t ntpEvent) {
1918
_ntpEvent = ntpEvent;
2019
_syncEventTriggered = true;
@@ -68,24 +67,24 @@ void NTPSettingsService::onConfigUpdated() {
6867
_reconfigureNTP = true;
6968
}
7069

71-
#if defined(ESP8266)
72-
void NTPSettingsService::onStationModeGotIP(const WiFiEventStationModeGotIP& event) {
70+
#ifdef ESP32
71+
void NTPSettingsService::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
7372
Serial.printf("Got IP address, starting NTP Synchronization\n");
7473
_reconfigureNTP = true;
7574
}
7675

77-
void NTPSettingsService::onStationModeDisconnected(const WiFiEventStationModeDisconnected& event) {
76+
void NTPSettingsService::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) {
7877
Serial.printf("WiFi connection dropped, stopping NTP.\n");
7978
_reconfigureNTP = false;
8079
NTP.stop();
8180
}
82-
#elif defined(ESP_PLATFORM)
83-
void NTPSettingsService::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
81+
#elif defined(ESP8266)
82+
void NTPSettingsService::onStationModeGotIP(const WiFiEventStationModeGotIP& event) {
8483
Serial.printf("Got IP address, starting NTP Synchronization\n");
8584
_reconfigureNTP = true;
8685
}
8786

88-
void NTPSettingsService::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) {
87+
void NTPSettingsService::onStationModeDisconnected(const WiFiEventStationModeDisconnected& event) {
8988
Serial.printf("WiFi connection dropped, stopping NTP.\n");
9089
_reconfigureNTP = false;
9190
NTP.stop();

lib/framework/NTPSettingsService.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ class NTPSettingsService : public AdminSettingsService {
3737
bool _syncEventTriggered = false;
3838
NTPSyncEvent_t _ntpEvent;
3939

40-
#if defined(ESP8266)
40+
#ifdef ESP32
41+
void onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
42+
void onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info);
43+
#elif defined(ESP8266)
4144
WiFiEventHandler _onStationModeDisconnectedHandler;
4245
WiFiEventHandler _onStationModeGotIPHandler;
4346

4447
void onStationModeGotIP(const WiFiEventStationModeGotIP& event);
4548
void onStationModeDisconnected(const WiFiEventStationModeDisconnected& event);
46-
#elif defined(ESP_PLATFORM)
47-
void onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
48-
void onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info);
4949
#endif
5050

5151
void configureNTP();

lib/framework/NTPStatus.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#ifndef NTPStatus_h
22
#define NTPStatus_h
33

4-
#if defined(ESP8266)
4+
#ifdef ESP32
5+
#include <WiFi.h>
6+
#include <AsyncTCP.h>
7+
#elif defined(ESP8266)
58
#include <ESP8266WiFi.h>
69
#include <ESPAsyncTCP.h>
7-
#elif defined(ESP_PLATFORM)
8-
#include <AsyncTCP.h>
9-
#include <WiFi.h>
1010
#endif
1111

1212
#include <ArduinoJson.h>

lib/framework/OTASettingsService.cpp

+9-10
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
OTASettingsService::OTASettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager) :
44
AdminSettingsService(server, fs, securityManager, OTA_SETTINGS_SERVICE_PATH, OTA_SETTINGS_FILE) {
5-
#if defined(ESP8266)
6-
_onStationModeGotIPHandler =
7-
WiFi.onStationModeGotIP(std::bind(&OTASettingsService::onStationModeGotIP, this, std::placeholders::_1));
8-
#elif defined(ESP_PLATFORM)
5+
#ifdef ESP32
96
WiFi.onEvent(std::bind(&OTASettingsService::onStationModeGotIP, this, std::placeholders::_1, std::placeholders::_2),
107
WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP);
8+
#elif defined(ESP8266)
9+
_onStationModeGotIPHandler =
10+
WiFi.onStationModeGotIP(std::bind(&OTASettingsService::onStationModeGotIP, this, std::placeholders::_1));
1111
#endif
1212
}
1313

@@ -43,7 +43,7 @@ void OTASettingsService::writeToJsonObject(JsonObject& root) {
4343

4444
void OTASettingsService::configureArduinoOTA() {
4545
if (_arduinoOTA) {
46-
#if defined(ESP_PLATFORM)
46+
#ifdef ESP32
4747
_arduinoOTA->end();
4848
#endif
4949
delete _arduinoOTA;
@@ -75,13 +75,12 @@ void OTASettingsService::configureArduinoOTA() {
7575
_arduinoOTA->begin();
7676
}
7777
}
78-
79-
#if defined(ESP8266)
80-
void OTASettingsService::onStationModeGotIP(const WiFiEventStationModeGotIP& event) {
78+
#ifdef ESP32
79+
void OTASettingsService::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
8180
configureArduinoOTA();
8281
}
83-
#elif defined(ESP_PLATFORM)
84-
void OTASettingsService::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
82+
#elif defined(ESP8266)
83+
void OTASettingsService::onStationModeGotIP(const WiFiEventStationModeGotIP& event) {
8584
configureArduinoOTA();
8685
}
8786
#endif

lib/framework/OTASettingsService.h

+6-7
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
#include <AdminSettingsService.h>
55

6-
#if defined(ESP8266)
7-
#include <ESP8266mDNS.h>
8-
#elif defined(ESP_PLATFORM)
6+
#ifdef ESP32
97
#include <ESPmDNS.h>
8+
#elif defined(ESP8266)
9+
#include <ESP8266mDNS.h>
1010
#endif
1111

1212
#include <ArduinoOTA.h>
@@ -38,12 +38,11 @@ class OTASettingsService : public AdminSettingsService {
3838
String _password;
3939

4040
void configureArduinoOTA();
41-
42-
#if defined(ESP8266)
41+
#ifdef ESP32
42+
void onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
43+
#elif defined(ESP8266)
4344
WiFiEventHandler _onStationModeGotIPHandler;
4445
void onStationModeGotIP(const WiFiEventStationModeGotIP& event);
45-
#elif defined(ESP_PLATFORM)
46-
void onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
4746
#endif
4847
};
4948

lib/framework/RestartService.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ RestartService::RestartService(AsyncWebServer* server, SecurityManager* security
99

1010
void RestartService::restart(AsyncWebServerRequest* request) {
1111
request->onDisconnect([]() {
12-
#if defined(ESP8266)
13-
ESP.reset();
14-
#elif defined(ESP_PLATFORM)
12+
#ifdef ESP32
1513
ESP.restart();
14+
#elif defined(ESP8266)
15+
ESP.reset();
1616
#endif
1717
});
1818
request->send(200);

lib/framework/RestartService.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#ifndef RestartService_h
22
#define RestartService_h
33

4-
#if defined(ESP8266)
4+
#ifdef ESP32
5+
#include <WiFi.h>
6+
#include <AsyncTCP.h>
7+
#elif defined(ESP8266)
58
#include <ESP8266WiFi.h>
69
#include <ESPAsyncTCP.h>
7-
#elif defined(ESP_PLATFORM)
8-
#include <AsyncTCP.h>
9-
#include <WiFi.h>
1010
#endif
1111

1212
#include <ESPAsyncWebServer.h>

lib/framework/SettingsService.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#ifndef SettingsService_h
22
#define SettingsService_h
33

4-
#if defined(ESP8266)
4+
#ifdef ESP32
5+
#include <WiFi.h>
6+
#include <AsyncTCP.h>
7+
#elif defined(ESP8266)
58
#include <ESP8266WiFi.h>
69
#include <ESPAsyncTCP.h>
7-
#elif defined(ESP_PLATFORM)
8-
#include <AsyncTCP.h>
9-
#include <WiFi.h>
1010
#endif
1111

1212
#include <ArduinoJson.h>

lib/framework/SimpleService.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#ifndef Service_h
22
#define Service_h
33

4-
#if defined(ESP8266)
4+
#ifdef ESP32
5+
#include <WiFi.h>
6+
#include <AsyncTCP.h>
7+
#elif defined(ESP8266)
58
#include <ESP8266WiFi.h>
69
#include <ESPAsyncTCP.h>
7-
#elif defined(ESP_PLATFORM)
8-
#include <AsyncTCP.h>
9-
#include <WiFi.h>
1010
#endif
1111

1212
#include <ArduinoJson.h>

lib/framework/SystemStatus.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ SystemStatus::SystemStatus(AsyncWebServer* server, SecurityManager* securityMana
1010
void SystemStatus::systemStatus(AsyncWebServerRequest* request) {
1111
AsyncJsonResponse* response = new AsyncJsonResponse(false, MAX_ESP_STATUS_SIZE);
1212
JsonObject root = response->getRoot();
13-
#if defined(ESP8266)
14-
root["esp_platform"] = "esp8266";
15-
#elif defined(ESP_PLATFORM)
13+
#ifdef ESP32
1614
root["esp_platform"] = "esp32";
15+
#elif defined(ESP8266)
16+
root["esp_platform"] = "esp8266";
1717
#endif
1818
root["cpu_freq_mhz"] = ESP.getCpuFreqMHz();
1919
root["free_heap"] = ESP.getFreeHeap();

lib/framework/SystemStatus.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#ifndef SystemStatus_h
22
#define SystemStatus_h
33

4-
#if defined(ESP8266)
4+
#ifdef ESP32
5+
#include <WiFi.h>
6+
#include <AsyncTCP.h>
7+
#elif defined(ESP8266)
58
#include <ESP8266WiFi.h>
69
#include <ESPAsyncTCP.h>
7-
#elif defined(ESP_PLATFORM)
8-
#include <AsyncTCP.h>
9-
#include <WiFi.h>
1010
#endif
1111

1212
#include <ArduinoJson.h>

lib/framework/WiFiScanner.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ void WiFiScanner::listNetworks(AsyncWebServerRequest* request) {
3131
network["ssid"] = WiFi.SSID(i);
3232
network["bssid"] = WiFi.BSSIDstr(i);
3333
network["channel"] = WiFi.channel(i);
34-
#if defined(ESP8266)
35-
network["encryption_type"] = convertEncryptionType(WiFi.encryptionType(i));
36-
#elif defined(ESP_PLATFORM)
34+
#ifdef ESP32
3735
network["encryption_type"] = (uint8_t)WiFi.encryptionType(i);
36+
#elif defined(ESP8266)
37+
network["encryption_type"] = convertEncryptionType(WiFi.encryptionType(i));
3838
#endif
3939
}
4040
response->setLength();
@@ -46,7 +46,7 @@ void WiFiScanner::listNetworks(AsyncWebServerRequest* request) {
4646
}
4747
}
4848

49-
#if defined(ESP8266)
49+
#ifdef ESP8266
5050
/*
5151
* Convert encryption type to standard used by ESP32 rather than the translated form which the esp8266 libaries expose.
5252
*

0 commit comments

Comments
 (0)