1

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;
        }
    }
}
  • link to the code – peeyush tekriwal Apr 11 at 16:10
  • Code, that is this short, should be copied directly into the question and formatted correctly as code by selecting it and pressing the {} button in the editor. I've done this for you now, but please remind it for the next question. – chrisl Apr 11 at 16:11
  • Hey thanks. I did try to add the code in the question itself but it got weird and I couldn't do the formatting clearly so I gave a link. – peeyush tekriwal Apr 11 at 16:17
  • what is 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 be const char* updateURL = "XYZ.php"; or String updateURL = "XYZ.php"; – Juraj Apr 11 at 16:21
3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.