Made the code ESP32-compatible.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
19
src/ota.cpp
19
src/ota.cpp
@ -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();
|
||||
|
Reference in New Issue
Block a user