Made the code ESP32-compatible.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-06 12:12:58 +02:00
parent c9dfc908af
commit 560b71425d
4 changed files with 39 additions and 7 deletions

View File

@ -1,4 +1,12 @@
#include <ArduinoOTA.h>
#if defined( ESP8266 )
#include <ESP8266mDNS.h>
#elif defined( ESP32 )
#include <ESPmDNS.h>
#else
#error Neither ESP32 nor ESP8266 set!
#endif
#include <ArduinoOTA.h>
#include "config.h"
void ota_setup() {
@ -27,7 +35,16 @@ void ota_setup() {
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});
char client_id[30];
snprintf(client_id, 30, HOSTNAME, ESP.getChipId());
int chipid;
#if defined( ESP8266 )
chipid = ESP.getChipId();
#elif defined( ESP32 )
chipid = ESP.getEfuseMac() & 0xFFFFFF;
#else
#error Neither ESP32 nor ESP8266 set.
#endif
snprintf(client_id, 30, HOSTNAME, chipid);
LOG("OTA * Starting OTA with client_id "); LOGln(client_id);
ArduinoOTA.setHostname(client_id);
ArduinoOTA.begin();