[SOLVED] mega-20210503 doesn't compile on Arduino 1.8.15

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
diyprojectz
Normal user
Posts: 6
Joined: 05 Feb 2021, 20:07

[SOLVED] mega-20210503 doesn't compile on Arduino 1.8.15

#1 Post by diyprojectz » 01 Aug 2021, 12:35

Followed instructions from:

https://espeasy.readthedocs.io/en/lates ... sy-sources

I just need P065 (DFPLayer Mini) on 1M ESP-01S, no other changes made. Tried Arduino 1.8.13 and 1.8.15, doesn't compile, produces this error:

Code: Select all

C:\software\arduino-1.8.15\portable\sketchbook\ESPEasy\src\Commands\GPIO.cpp: In function 'bool gpio_mode_range_helper(byte, byte, EventStruct*, const char*)':

C:\software\arduino-1.8.15\portable\sketchbook\ESPEasy\src\Commands\GPIO.cpp:925:38: error: cannot convert 'String' to 'bool' in return

  925 |         return return_command_success();

      |                ~~~~~~~~~~~~~~~~~~~~~~^~

      |                                      |

      |                                      String

C:\software\arduino-1.8.15\portable\sketchbook\ESPEasy\src\Commands\GPIO.cpp:928:37: error: cannot convert 'String' to 'bool' in return

  928 |         return return_command_failed();

      |                ~~~~~~~~~~~~~~~~~~~~~^~

      |                                     |

      |                                     String

C:\software\arduino-1.8.15\portable\sketchbook\ESPEasy\src\Commands\GPIO.cpp:932:35: error: cannot convert 'String' to 'bool' in return

  932 |       return return_command_failed();

      |              ~~~~~~~~~~~~~~~~~~~~~^~

      |                                   |

      |                                   String

C:\software\arduino-1.8.15\portable\sketchbook\ESPEasy\src\Commands\GPIO.cpp:936:33: error: cannot convert 'String' to 'bool' in return

  936 |     return return_command_failed();

      |            ~~~~~~~~~~~~~~~~~~~~~^~

      |                                 |

      |                                 String

exit status 1

Error compiling for board Generic ESP8266 Module.
Context:

Code: Select all

String Command_GPIO_Mode(struct EventStruct *event, const char* Line)
{
  if (gpio_mode_range_helper(event->Par1, event->Par2, event, Line))
    return return_command_success();
  else 
    return return_command_failed();
}

String Command_GPIO_ModeRange(struct EventStruct *event, const char* Line)
{
  bool success=true;
  for (byte i=event->Par1;i<=event->Par2;i++) {
    success &= gpio_mode_range_helper(i, event->Par3, event, Line);
  }
  return success?return_command_success():return_command_failed();
}

bool gpio_mode_range_helper(byte pin, byte pinMode, struct EventStruct *event, const char* Line)
{
  String logPrefix;// = new char;
  String logPostfix;// = new char;
  pluginID_t pluginID=INVALID_PLUGIN_ID;
  //Line[0]='g':gpio; ='p':pcfgpio; ='m':mcpgpio
  bool success = getPluginIDAndPrefix(Line[0], pluginID, logPrefix);

  if (success && checkValidPortRange(pluginID, pin))
  {
	  //int8_t state=0;
	  byte mode=255;
    //bool setSuccess=false;

    switch (pinMode) {
      case 0:
        mode = PIN_MODE_OUTPUT;
        logPostfix = F("OUTPUT");
        break;
      case 1:
        mode = PIN_MODE_INPUT_PULLUP;
        logPostfix = F("INPUT PULLUP");
        break;
      case 2:
        mode = PIN_MODE_INPUT;
        logPostfix = F("INPUT");
        break;
    }
    
    if (mode < 255) { 
      switch(pluginID) {
        case PLUGIN_GPIO:
          /* setSuccess = */ setGPIOMode(pin, mode);
          break;
        case PLUGIN_PCF:
          //set pin = 1 when INPUT
          /* setSuccess = */ setPCFMode(pin, mode);
          break;
        case PLUGIN_MCP:
          /* setSuccess = */ setMCPMode(pin, mode);
          break;
      }

      const uint32_t key = createKey(pluginID,pin);

      if (globalMapPortStatus[key].mode != PIN_MODE_OFFLINE)
      {
        int8_t currentState;
        GPIO_Read(pluginID, pin, currentState);
        //state = currentState;

        if (currentState==-1) {
          mode=PIN_MODE_OFFLINE;
          //state = -1;
        }

        createAndSetPortStatus_Mode_State(key,mode,currentState);
        
        String log = logPrefix + String(F(" : port#")) + String(pin) + String(F(": MODE set to ")) + logPostfix + String(F(". Value = ")) + String(currentState);
        addLog(LOG_LEVEL_INFO, log);
        SendStatusOnlyIfNeeded(event, SEARCH_PIN_STATE, key, log, 0);
        return return_command_success();
      } else {
        logErrorGpioOffline(logPrefix,pin);
        return return_command_failed();
      }
    } else {
      logErrorModeOutOfRange(logPrefix,pin);
      return return_command_failed();
    }
  } else {
    logErrorGpioOutOfRange(logPrefix,pin, Line);
    return return_command_failed();
  }
}

bool getGPIOPinStateValues(String& str) {
  // parseString(string, 1) = device (gpio,mcpgpio,pcfgpio) that can be shortened to g, m or p
  // parseString(string, 2) = command (pinstate,pinrange)
  // parseString(string, 3) = gpio 1st number or a range separated by '-'
  bool success=false;
  String logPrefix="";

  if ((parseString(str, 2).length() >= 8) && parseString(str, 2).equalsIgnoreCase(F("pinstate"))) {
    // returns pin value using syntax: [plugin#xxxxxxx#pinstate#x]
    int par1;
    switch (parseString(str, 1)[0]) {
      case 'g':
        if (validIntFromString(parseString(str, 3), par1)) {
          str = String(digitalRead(par1));
          logPrefix="GPIO";
          success=true;
        }
        break;

      case 'm':
        if (validIntFromString(parseString(str, 3), par1)) {
          str = String(GPIO_MCP_Read(par1));
          logPrefix="MCP";
          success=true;
        }
        break;

      case 'p':
        if (validIntFromString(parseString(str, 3), par1)) {
          str = GPIO_PCF_Read(par1);
          logPrefix="PCF";
          success=true;
        }
        break;
    } 
    if (success) {
      addLog(LOG_LEVEL_DEBUG,logPrefix+String(F(" PLUGIN PINSTATE pin ="))+String(par1)+String(F("; value="))+str);
    } else {
      str="0";
      addLog(LOG_LEVEL_INFO,logPrefix+String(F(" PLUGIN PINSTATE. Syntax error. Pin parameter is not numeric")));
    }
  } else if ((parseString(str, 2).length() >= 8) && parseString(str, 2).equalsIgnoreCase(F("pinrange"))) {
    // returns pin value using syntax: [plugin#xxxxxxx#pinrange#x-y]
    int par1,par2;
    bool successPar = false;
    int dashpos = parseString(str, 3).indexOf('-');

    if (dashpos != -1) {
      // Found an extra '-' in the 4th param, will split.
      successPar = validIntFromString(parseString(str, 3).substring(dashpos + 1),par2);
      successPar &= validIntFromString(parseString(str, 3).substring(0, dashpos),par1);
    } 
Please help me resolve this.
Last edited by diyprojectz on 01 Aug 2021, 14:47, edited 2 times in total.

TD-er
Core team member
Posts: 5373
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: mega-20210503 doesn't compile on Arduino 1.8.15

#2 Post by TD-er » 01 Aug 2021, 12:43

At the reported line nrs isn't such a statement.
Can you post a bit more context? ArduinoIDE sometimes messes up the line numbers in reporting compile errors.
Are you sure you have the current sources?

diyprojectz
Normal user
Posts: 6
Joined: 05 Feb 2021, 20:07

Re: mega-20210503 doesn't compile on Arduino 1.8.15

#3 Post by diyprojectz » 01 Aug 2021, 12:53

TD-er wrote: 01 Aug 2021, 12:43Can you post a bit more context?
I just followed the instructions to the letter. Created Arduino portable installation, added esp8266 to board manager, selected GenericESP8266 module with 1MB flash size. Copied lib and src contents according to instruction. Renamed Custom-sample.h into Custom.h, uncommented the line for desired plugin, uncommented /#define USE_CUSTOM_H in ESPEasy_common.h so that Custom.h is used. Pressed Verify/Compile and after a while got the errors in question.
TD-er wrote: 01 Aug 2021, 12:43 Are you sure you have the current sources?
I have this:
https://github.com/letscontrolit/ESPEas ... 210503.zip

TD-er
Core team member
Posts: 5373
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: mega-20210503 doesn't compile on Arduino 1.8.15

#4 Post by TD-er » 01 Aug 2021, 12:59

With context I meant the surrounding lines so I can see where you're getting the error.

I did compare it with the latest source and I suggest to use the latest source as it is more stable regarding WiFi reconnects.

diyprojectz
Normal user
Posts: 6
Joined: 05 Feb 2021, 20:07

Re: mega-20210503 doesn't compile on Arduino 1.8.15

#5 Post by diyprojectz » 01 Aug 2021, 13:14

@TD-er thank you.

I tried with latest sources from github. I get the following error:

Code: Select all

Arduino: 1.8.15 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"





















WARNING: library LiquidCrystal_I2C claims to run on avr architecture(s) and may be incompatible with your current board which runs on esp8266 architecture(s).

C:\software\2arduino-1.8.15\portable\sketchbook\ESPEasy\src\Helpers\_CPlugin_Helper.cpp: In function 'String send_via_http(const String&, WiFiClient&, uint16_t, const String&, const String&, const String&, uint16_t, const String&, const String&, const String&, const String&, int&)':

C:\software\2arduino-1.8.15\portable\sketchbook\ESPEasy\src\Helpers\_CPlugin_Helper.cpp:531:13: error: call to 'HTTPClient::begin' declared with attribute error: obsolete API, use ::begin(WiFiClient, host, port, uri)

  531 |   http.begin(host, port, uri);

      |   ~~~~~~~~~~^~~~~~~~~~~~~~~~~

exit status 1

Error compiling for board Generic ESP8266 Module.
Context:

Code: Select all

bool splitHeaders(int& strpos, const String& multiHeaders, String& name, String& value) {
  if (strpos < 0) {
    return false;
  }
  int colonPos = multiHeaders.indexOf(':', strpos);

  if (colonPos < 0) {
    return false;
  }
  name   = multiHeaders.substring(strpos, colonPos);
  int valueEndPos = multiHeaders.indexOf('\n', colonPos + 1);
  if (valueEndPos < 0) {
    value = multiHeaders.substring(colonPos + 1);
    strpos = -1;
  } else {
    value = multiHeaders.substring(colonPos + 1, valueEndPos);
    strpos = valueEndPos + 1;
  }
  value.replace('\r', ' ');
  value.trim();
  return true;
}

String send_via_http(const String& logIdentifier,
                     WiFiClient  & client,
                     uint16_t      timeout,
                     const String& user,
                     const String& pass,
                     const String& host,
                     uint16_t      port,
                     const String& uri,
                     const String& HttpMethod,
                     const String& header,
                     const String& postStr,
                     int         & httpCode) {
  HTTPClient http;

  http.setAuthorization(user.c_str(), pass.c_str());
  http.setTimeout(timeout);
  http.setUserAgent(get_user_agent_string());

  // Add request header as fall back.
  // When adding another "accept" header, it may be interpreted as:
  // "if you have XXX, send it; or failing that, just give me what you've got."
  http.addHeader(F("Accept"), F("*/*;q=0.1"));

  delay(0);
#if defined(CORE_POST_2_6_0) || defined(ESP32)
  http.begin(client, host, port, uri, false); // HTTP
#else
  http.begin(host, port, uri);
#endif
  
  {
    int headerpos = 0;
    String name, value;
    while (splitHeaders(headerpos, header, name, value)) {
      http.addHeader(name, value);
    }
  }

  // start connection and send HTTP header (and body)
  if (HttpMethod.equals(F("HEAD")) || HttpMethod.equals(F("GET"))) {
    httpCode = http.sendRequest(HttpMethod.c_str());
  } else {
    httpCode = http.sendRequest(HttpMethod.c_str(), postStr);
  }

  String response;

  // httpCode will be negative on error
  if (httpCode > 0) {
    response = http.getString();

    uint8_t loglevel = LOG_LEVEL_ERROR;
    // HTTP codes:
    // 1xx Informational response
    // 2xx Success
    if (httpCode >= 100 && httpCode < 300) {
      loglevel = LOG_LEVEL_INFO;
    }


    if (loglevelActiveFor(loglevel)) {
      String log = F("HTTP : ");
      log += logIdentifier;
      log += ' ';
      log += HttpMethod;
      log += F("... HTTP code: ");
      log += String(httpCode);

      if (response.length() > 0) {
        log += ' ';
        log += response;
      }
      addLog(loglevel, log);
    }
  } else {
    if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
      String log = F("HTTP : ");
      log += logIdentifier;
      log += ' ';
      log += HttpMethod;
      log += F("... failed, error: ");
      log += http.errorToString(httpCode);
      addLog(LOG_LEVEL_ERROR, log);
    }
  }
  http.end();
  return response;
}

String getControllerUser(controllerIndex_t controller_idx, const ControllerSettingsStruct& ControllerSettings)
{
  if (!validControllerIndex(controller_idx)) { return ""; }

  if (ControllerSettings.useExtendedCredentials()) {
    return ExtendedControllerCredentials.getControllerUser(controller_idx);
  }
  return SecuritySettings.ControllerUser[controller_idx];
}
Also added context for 20210503 version to first post.

TD-er
Core team member
Posts: 5373
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: mega-20210503 doesn't compile on Arduino 1.8.15

#6 Post by TD-er » 01 Aug 2021, 13:19

Looks like you're using esp8266/Arduino core 3.0.x instead of core 2.7.4
Can you please check this?

Also the selected flash layout will give the next build error as we're never going to fit in 470 kB.
Please select 128k SPIFFS, the rest for sketch size.

User avatar
Ath
Normal user
Posts: 1090
Joined: 10 Jun 2018, 12:06
Location: NL

Re: mega-20210503 doesn't compile on Arduino 1.8.15

#7 Post by Ath » 01 Aug 2021, 13:36

This all sounds like a good motivation to push further on using VSCode or Atom with PlatformIO as the default platform for ESPEasy...
/Ton

diyprojectz
Normal user
Posts: 6
Joined: 05 Feb 2021, 20:07

Re: mega-20210503 doesn't compile on Arduino 1.8.15

#8 Post by diyprojectz » 01 Aug 2021, 13:55

TD-er wrote: 01 Aug 2021, 13:19 Looks like you're using esp8266/Arduino core 3.0.x instead of core 2.7.4
Can you please check this?
I was indeed using newer version. Managed to compile and upload without errors using 2.7.4 , thank you! Didn't notice 2.7.4 requirement of esp8266 in the docs...
Ath wrote: 01 Aug 2021, 13:36 This all sounds like a good motivation to push further on using VSCode or Atom with PlatformIO as the default platform for ESPEasy...
I'd love to, but PlatformIO seem to require setting Windows ExecutionPolicy to Unrestricted, which is unacceptable for me.

TD-er
Core team member
Posts: 5373
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: mega-20210503 doesn't compile on Arduino 1.8.15

#9 Post by TD-er » 01 Aug 2021, 14:02

The core 3.0.x is only available since a few weeks now and I do have a pull request pending to be able to use the new core.
The reason I have not yet merged it, is because each build feels somewhat like a hit-or-miss whether it is stable.
Not sure yet what is causing it.


I may have to take another look at the need to alter the execution policy to use PlatformIO/VS code.
I do remember it was needed a long time ago, but I'm not sure anymore why it was needed and thus also not sure if it is still needed.
It is possible it can run without, but makes frequent use a bit tedious as it may not start the Python virtual env automatically. But like I said, I may have to look into it.
This is a bit tricky though, as I may need to run it on a clean Windows install to test it.

diyprojectz
Normal user
Posts: 6
Joined: 05 Feb 2021, 20:07

Re: [SOLVED] mega-20210503 doesn't compile on Arduino 1.8.15

#10 Post by diyprojectz » 01 Aug 2021, 14:49

@TD-er thank you very much! Your help allowed me to finally move my project from NodeMCU/Wemos D1 Mini to much more compact ESP-01S boards, I am super grateful!

TD-er
Core team member
Posts: 5373
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [SOLVED] mega-20210503 doesn't compile on Arduino 1.8.15

#11 Post by TD-er » 01 Aug 2021, 15:15

You're welcome.
Good luck with your project.

User avatar
Ath
Normal user
Posts: 1090
Joined: 10 Jun 2018, 12:06
Location: NL

Re: mega-20210503 doesn't compile on Arduino 1.8.15

#12 Post by Ath » 01 Aug 2021, 16:48

TD-er wrote: 01 Aug 2021, 14:02 I may have to take another look at the need to alter the execution policy to use PlatformIO/VS code.
I do remember it was needed a long time ago, but I'm not sure anymore why it was needed and thus also not sure if it is still needed.
It is possible it can run without, but makes frequent use a bit tedious as it may not start the Python virtual env automatically. But like I said, I may have to look into it.
This is a bit tricky though, as I may need to run it on a clean Windows install to test it.
I don't recall having to change that setting after switching to my new laptop, last December, so @diyprojectz, I'd suggest to try and install VSCode/PlatformIO to see if it works for you (VSCode can be installed in Portable mode perfectly fine).
/Ton

Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests