Unable to compile project on ESP32 board
Opened this issue · 5 comments
Hi there,
I'm trying to implement this project on a M5Stack Core2 (ESP32) board, but am having issues compiling the code. Would love some input or debugging tips!
Error:
/Arduino/libraries/Fetch/src/utils/Url/LCBUrl/LCBUrl.cpp: In member function 'bool LCBUrl::isMDNS(const char*)':
/Arduino/libraries/Fetch/src/utils/Url/LCBUrl/LCBUrl.cpp:579:21: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
char * lastLabel = "\0";
^~~~
/Arduino/libraries/Fetch/src/utils/Url/LCBUrl/LCBUrl.cpp: In member function 'IPAddress LCBUrl::getIP(const char*)':
/Arduino/libraries/Fetch/src/utils/Url/LCBUrl/LCBUrl.cpp:634:48: error: cannot convert 'ip4_addr*' to 'esp_ip4_addr_t*' {aka 'esp_ip4_addr*'}
esp_err_t err = mdns_query_a(hn, 2000, &addr);
^~~~~
In file included from /Users/dblencowe/Library/Arduino15/packages/m5stack/hardware/esp32/2.0.3/libraries/ESPmDNS/src/ESPmDNS.h:46,
from /Arduino/libraries/Fetch/src/utils/Url/LCBUrl/LCBUrl.h:41,
from /Arduino/libraries/Fetch/src/utils/Url/LCBUrl/LCBUrl.cpp:32:
/Users/dblencowe/Library/Arduino15/packages/m5stack/hardware/esp32/2.0.3/tools/sdk/esp32/include/mdns/include/mdns.h:649:83: note: initializing argument 3 of 'esp_err_t mdns_query_a(const char*, uint32_t, esp_ip4_addr_t*)'
esp_err_t mdns_query_a(const char * host_name, uint32_t timeout, esp_ip4_addr_t * addr);
~~~~~~~~~~~~~~~~~^~~~
Project Code
#define LCBURL_MDNS
#include <M5Core2.h>
#include <WiFi.h>
#include <Fetch.h>
const char* ssid = "";
const char* password = "";
const String apiAddress = "";
const String apiToken = "";
const String hostname = "ESP32";
IPAddress localIp;
#define CACert ""
void setup() {
M5.begin();
Serial.begin(115200);
WiFi.setHostname(hostname.c_str());
setupWifi();
Serial.println("Local IP: " + localIp.toString());
RequestOptions options;
options.method = "GET";
options.caCert = CACert;
Response response = fetch("https://api.github.com/", options);
// Printing response body as plain text.
Serial.println();
Serial.println(response.text());
}
void loop() {
}
void setupWifi() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.print("connecting to wifi..");
while (WiFi.status() != WL_CONNECTED) {
Serial.print('.');
delay(1000);
}
Serial.println("");
Serial.print("RRSI: ");
Serial.println(WiFi.RSSI());
localIp = WiFi.localIP();
}
Currently compiling on version 1.8.15 of the Arduino IDE, using an Intel Macbook
Thanks!
@mauromorello could you expand on this a bit? Where are the new files which you update them with?
I know that in the last month a lot of upgrades comes both with espressif board and arduino IDE and I noticed that a library called LCBUrl had received an upgrade too. Unfortunately a old copy of this lib is used inside FETCH lib, and in this way, if the author doesn't upgrade all FETCH lib it never work again.
So what I've done is updating manually the LCBUrl file (the ones highlighted) by copying new version grabbed in github LCBUrl project in the FETCH subfolder.
By the way, this is not the best solution, and if FETCH is not still maintained maybe it's better to use another library.
Gotcha. Thanks for clarifying!
@dblencowe @mauromorello @marcrleonard
I apologize I've been off for a while. I realize there's been some upgrades due. I'll add them asap and publish the new release.