Skocz do zawartości

Błąd kompilacji logowania do bazy MySQL w Platformio


Pomocna odpowiedź

Napisano

Witam

Mam błędy w przy kompilowaniu programu w VSC Platformio z logowaniem do MySQL, jednak jak ten sam kod kompiluje w Arduino IDE  to jest ok.

Może mi ktoś to wyjaśnić gdzie jest problem?

Płytka to ESP8266 D1 Mini 

#include <Arduino.h>

/*
  MySQL Connector/Arduino Przykład: połącz przez nazwę hosta

  Ten przykład pokazuje, jak połączyć się z serwerem MySQL, rozwiązując problem
  nazwa hosta w przypadkach, gdy nie znasz adresu IP serwera lub
  zmienia się, ponieważ znajduje się w chmurze.

  Aby uzyskać więcej informacji i dokumentacji, odwiedź wiki:
  https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki.

  INSTRUKCJA UŻYCIA

  1) Zmień zmienną hostname na nazwę hosta serwera MySQL
  2) Zmień użytkownika i hasło na poprawny użytkownik i hasło MySQL
  3) Podłącz kabel USB do Arduino
  4) Wybierz odpowiednią płytę i port
  5) Skompiluj i prześlij szkic do swojego Arduino
  6) Po przesłaniu otwórz Monitor szeregowy (użyj prędkości 115200) i obserwuj

  Jeśli nie widzisz komunikatów wskazujących, że masz połączenie, zapoznaj się z
  podręcznik zawierający wskazówki dotyczące rozwiązywania problemów. Najczęstsze problemy z serwerem to
  niedostępny z sieci lub nazwa użytkownika i hasło są nieprawidłowe.

  Uwaga: Adres MAC może być dowolny, o ile jest unikalny w Twojej sieci.

  Autor: dr Charles A. Bell
*/

#include <WiFiClient.h>  
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
#include <Dns.h>




byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress server_addr(193,239,44,56);  // IP of the MySQL *server* here
char user[] = "heniugg";              // MySQL user login username
char password[] = "xxxxx";        // MySQL user login password

// WiFi card example
char ssid[] = "DrayTek";    // your SSID
char pass[] = "xxxxxx";       // your SSID Password

WiFiClient client;            // Use this for WiFi instead of EthernetClient
MySQL_Connection conn((Client *)&client);

void setup() {
  Serial.begin(115200);
  //while (!Serial); // wait for serial port to connect. Needed for Leonardo only

  // Begin WiFi section
  int status = WiFi.begin(ssid, pass);
  if ( status != WL_CONNECTED) {
    Serial.println("Couldn't get a wifi connection");
    while(true);
  }
  // print out info about the connection:
  else {
    Serial.println("Connected to network");
    IPAddress ip = WiFi.localIP();
    Serial.print("My IP address is: ");
    Serial.println(ip);
  }
  // End WiFi section

  Serial.println("Connecting...");
  if (conn.connect(server_addr, 3306, user, password)) {
    delay(1000);
  }
  else
    Serial.println("Connection failed.");
  conn.close();
}

void loop() {
}

a kompilator w terminalu daje:

> Executing task in folder MySql: C:\Users\heniu\.platformio\penv\Scripts\platformio.exe run <

Processing esp12e (platform: espressif8266; board: esp12e; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/esp12e.html
PLATFORM: Espressif 8266 (3.2.0) > Espressif ESP8266 ESP-12E
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES:
 - framework-arduinoespressif8266 @ 3.30002.0 (3.0.2)       
 - tool-esptool @ 1.413.0 (4.13)
 - tool-esptoolpy @ 1.30000.201119 (3.0.0)
 - toolchain-xtensa @ 2.100300.210717 (10.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 36 compatible libraries
Scanning dependencies...
Dependency Graph
|-- MySQL Connector Arduino @ 1.2.1
|   |-- ESP8266WiFi @ 1.0
|   |-- Ethernet @ 2.0.0
|   |   |-- SPI @ 1.0
|-- Ethernet @ 2.0.0
|   |-- SPI @ 1.0
|-- ESP8266HTTPClient @ 1.2
|   |-- ESP8266WiFi @ 1.0
|-- ESP8266WiFi @ 1.0
Building in release mode
Compiling .pio\build\esp12e\src\main.cpp.o
Compiling .pio\build\esp12e\libcdd\MySQL Connector Arduino\MySQL_Cursor.cpp.o
Compiling .pio\build\esp12e\libcdd\MySQL Connector Arduino\MySQL_Encrypt_Sha1.cpp.o
Compiling .pio\build\esp12e\FrameworkArduino\IPAddress.cpp.o
In file included from C:\Users\heniu\.platformio\packages\framework-arduinoespressif8266\libraries\Ethernet\src/Dns.h:8,
                 from src\main.cpp:37:
C:\Users\heniu\.platformio\packages\framework-arduinoespressif8266\libraries\Ethernet\src/Ethernet.h:39: warning: "MAX_SOCK_NUM" redefined 
   39 | #define MAX_SOCK_NUM 8
      |
In file included from C:\Users\heniu\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/ESP8266WiFi.h:28,       
                 from src\main.cpp:32:
C:\Users\heniu\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/wl_definitions.h:42: note: this is the location of the previous definition
   42 | #define MAX_SOCK_NUM  4
      |
.pio\libdeps\esp12e\MySQL Connector Arduino\src\MySQL_Encrypt_Sha1.cpp: In member function 'virtual size_t Encrypt_SHA1::write(uint8_t)':
.pio\libdeps\esp12e\MySQL Connector Arduino\src\MySQL_Encrypt_Sha1.cpp:89:1: error: no return statement in function returning non-void [-Werror=return-type]
   89 | }
      | ^
.pio\libdeps\esp12e\MySQL Connector Arduino\src\MySQL_Encrypt_Sha1.cpp: In member function 'virtual size_t Encrypt_SHA1::write(uint8_t*, int)':
.pio\libdeps\esp12e\MySQL Connector Arduino\src\MySQL_Encrypt_Sha1.cpp:95:1: error: no return statement in function returning non-void [-Werror=return-type]
   95 | }
      | ^
cc1plus.exe: some warnings being treated as errors
*** [.pio\build\esp12e\libcdd\MySQL Connector Arduino\MySQL_Encrypt_Sha1.cpp.o] Error 1
.pio\libdeps\esp12e\MySQL Connector Arduino\src\MySQL_Cursor.cpp:131:5: error: no declaration matches 'int MySQL_Cursor::execute(const char*, boolean)'
  131 | int MySQL_Cursor::execute(const char *query, boolean progmem)
      |     ^~~~~~~~~~~~
.pio\libdeps\esp12e\MySQL Connector Arduino\src\MySQL_Cursor.cpp:89:9: note: candidate is: 'boolean MySQL_Cursor::execute(const char*, boolean)'
   89 | boolean MySQL_Cursor::execute(const char *query, boolean progmem)
      |         ^~~~~~~~~~~~
In file included from .pio\libdeps\esp12e\MySQL Connector Arduino\src\MySQL_Cursor.cpp:32:
.pio\libdeps\esp12e\MySQL Connector Arduino\src/MySQL_Cursor.h:65:7: note: 'class MySQL_Cursor' defined here
   65 | class MySQL_Cursor {
      |       ^~~~~~~~~~~~
.pio\libdeps\esp12e\MySQL Connector Arduino\src\MySQL_Cursor.cpp: In member function 'char* MySQL_Cursor::read_string(int*)':
.pio\libdeps\esp12e\MySQL Connector Arduino\src\MySQL_Cursor.cpp:475:12: warning: 'char* strncpy(char*, const char*, size_t)' output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation]
  475 |     strncpy(str, "NULL", 4);
      |     ~~~~~~~^~~~~~~~~~~~~~~~
*** [.pio\build\esp12e\libcdd\MySQL Connector Arduino\MySQL_Cursor.cpp.o] Error 1
======================================================= [FAILED] Took 5.94 seconds =======================================================
Działanie procesu terminalu „C:\Users\heniu\.platformio\penv\Scripts\platformio.exe 'run'” zostało zakończone z kodem zakończenia: 1.

Terminal zostanie ponownie użyty przez zadania. Naciśnij dowolny klawisz, aby go zamknąć.

 

Bądź aktywny - zaloguj się lub utwórz konto!

Tylko zarejestrowani użytkownicy mogą komentować zawartość tej strony

Utwórz konto w ~20 sekund!

Zarejestruj nowe konto, to proste!

Zarejestruj się »

Zaloguj się

Posiadasz własne konto? Użyj go!

Zaloguj się »
×
×
  • Utwórz nowe...