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;
 }
 }
}
chrisl
16.6k2 gold badges18 silver badges27 bronze badges
asked Apr 11, 2019 at 16:03
6
  • docs.google.com/document/d/… Commented Apr 11, 2019 at 16:10
  • link to the code Commented Apr 11, 2019 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. Commented Apr 11, 2019 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. Commented Apr 11, 2019 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"; Commented Apr 11, 2019 at 16:21

1 Answer 1

4

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.

answered Apr 11, 2019 at 17:19
1
  • Thank you. It worked!/ Commented Apr 12, 2019 at 7:25

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.