I'm using Arduino IDE for ESP32 WROOM board. I am testing the OTA feature with the ESP32httpUpdate library. I am using the example sketch of the library with the name httpUpdate.ino However, as soon as I change the update url with a string pointer that I declare globally, it is throwing a compile error that String does not name a type. Any ideas?
/**
* httpUpdate.ino
*
* Created on: 27.11.2015
*
*/
String* FIRMWARE_UPDATE_VERSION = "1000";
String* updateURL = "XYZ.php";
#include <Arduino.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <ESP32httpUpdate.h>
#define USE_SERIAL Serial
void setup() {
USE_SERIAL.begin(115200);
// USE_SERIAL.setDebugOutput(true);
USE_SERIAL.println();
USE_SERIAL.println();
USE_SERIAL.println();
for(uint8_t t = 4; t > 0; t--) {
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
USE_SERIAL.flush();
delay(1000);
}
WiFi.begin("SSID", "PASSWORD");
}
void loop() {
// wait for WiFi connection
Serial.println("Yolo");
if((WiFi.status() == WL_CONNECTED)) {
t_httpUpdate_return ret = ESPhttpUpdate.update(updateURL, FIRMWARE_UPDATE_VERSION);
switch(ret) {
case HTTP_UPDATE_FAILED:
USE_SERIAL.printf("HTTP_UPDATE_FAILD Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
break;
case HTTP_UPDATE_NO_UPDATES:
USE_SERIAL.println("HTTP_UPDATE_NO_UPDATES");
break;
case HTTP_UPDATE_OK:
USE_SERIAL.println("HTTP_UPDATE_OK");
break;
}
}
}
1 Answer 1
String
is included by Arduino.h. Before #include <Arduino.h>
String
is not defined. Move #include <Arduino.h>
to the top of the file or remove it. If you remove it, the Arduino builder adds it.
-
Thank you. It worked!/peeyush tekriwal– peeyush tekriwal2019年04月12日 07:25:34 +00:00Commented Apr 12, 2019 at 7:25
{}
button in the editor. I've done this for you now, but please remind it for the next question.String* updateURL = "XYZ.php";
? you assign a pointer to constant char array to a pointer to String object. Where did you see something like this? It should beconst char* updateURL = "XYZ.php";
orString updateURL = "XYZ.php";