Skip to content

Unable to compile project on ESP32 board #7

Open
@dblencowe

Description

@dblencowe

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions