Chat freely about anything...

User avatar
By martinayotte
#34694 What kind of problems ?
Because the sprintf in libc_replacements.c is quite simple and simply redirect it to ets_vsprintf() of the Espressif SDK.
Also, I've almost the latest version and don't have any problems.
User avatar
By danbicks
#34702
martinayotte wrote:What kind of problems ?
Because the sprintf in libc_replacements.c is quite simple and simply redirect it to ets_vsprintf() of the Espressif SDK.
Also, I've almost the latest version and don't have any problems.


Hi Martin,

I have errors with several projects that work perfect in older version before staging, these seem to be all string errors.
Sprintf throws an error and so does strcmp.

error:

NET_MOD.ino: In function 'int32_t getRSSI(const char*)':
NET_MOD:13: error: cannot convert 'String' to 'const char*' for argument '1' to 'int strcmp(const char*, const char*)'
cannot convert 'String' to 'const char*' for argument '1' to 'int strcmp(const char*, const char*)'

Code: Select allint32_t getRSSI(const char* target_ssid) {
  byte available_networks = WiFi.scanNetworks();

  for (int network = 0; network < available_networks; network++) {
    if (strcmp(WiFi.SSID(network), target_ssid) == 0) {
      return WiFi.RSSI(network);
    }
  }
  return 0;
}


The above routine works perfect in my ESP_T_TRACKER project posted on this forum, any ideas why they now error?

Cheers

Dans
User avatar
By martinayotte
#34705 Hi Dans,
But this is completely different issue than the sprintf() problems you've mentioned.
Also, the String class always been like that even for AVR, not only ESP.
The String class doesn't provide implicit conversion to "const char *".
To use String class with strcmp() for example, you need to do explicit conversion with c_str() such as :
Code: Select all    if (strcmp(WiFi.SSID(network).c_str(), target_ssid) == 0) {