ChuckBell / MySQL_Connector_Arduino

Database connector library for using MySQL with your Arduino projects.
332 stars 133 forks source link

Issue for Verify/Compile the example of connect_wifi #30

Closed Titus-Song closed 6 years ago

Titus-Song commented 6 years ago

Hello, now I want to build a project for connecting MySQL by wifi, but I found Issue when I try to verify/compile the example code of connect_wifi in your file but "Error compilling", example code is :

include // Use this for WiFi instead of Ethernet.h

include

include

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

IPAddress server_addr(10,0,1,35); // IP of the MySQL server here char user[] = "root"; // MySQL user login username char password[] = "secret"; // MySQL user login password

// WiFi card example char ssid[] = "horse_pen"; // your SSID char pass[] = "noname"; // 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);

Issue for Error compilling:

This report would have more information with "Show verbose output during compilation" enabled in File > Preferences. Arduino: 1.0.6 (Windows 7), Board: "Arduino Mega 2560 or Mega ADK" In file included from C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Connection.h:37, from C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:32: C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Packet.h:51: error: ISO C++ forbids declaration of 'Client' with no type C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Packet.h:51: error: expected ';' before '' token C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Packet.h:54: error: expected `)' before '' token In file included from C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:32: C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Connection.h:41: error: expected `)' before '*' token C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Connection.h:43: error: 'IPAddress' has not been declared C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Connection.h: In member function 'int MySQL_Connection::connected()': C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Connection.h:44: error: 'client' was not declared in this scope C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp: At global scope: C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:58: error: 'boolean MySQL_Connection::connect' is not a static member of 'class MySQL_Connection' C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:58: error: 'IPAddress' was not declared in this scope C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:58: error: expected primary-expression before 'int' C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:58: error: expected primary-expression before 'char' C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:59: error: expected primary-expression before 'char' C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:59: error: initializer expression list treated as compound expression C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:60: error: expected ',' or ';' before '{' token

How to solve it? I have download your silimar library of 2016, but issue is same. In fact, I also got issue when I try to the example code about connect MySql by Ethernet, its issue is about "SPI". After add "#include " into code , it is ok. Something wrong in my setting or my computer???

ChuckBell commented 6 years ago

Hello,

As always, fix one error at a time ....

C/C++ is a case sensitive language. You declared the WiFi client as “client” by the next line uses Client”. Check your sketch against the example and fix the case issues.

Dr. Bell

On Sat, Jan 20, 2018 at 08:17 Titus-Song notifications@github.com wrote:

Hello, now I want to build a project for connecting MySQL by wifi, but I found Issue when I try to verify/compile the example code of connect_wifi in your file but "Error compilling", example code is :

include // Use this for WiFi instead of Ethernet.h

include

include

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

IPAddress server_addr(10,0,1,35); // IP of the MySQL server here char user[] = "root"; // MySQL user login username char password[] = "secret"; // MySQL user login password

// WiFi card example char ssid[] = "horse_pen"; // your SSID char pass[] = "noname"; // 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);

Issue for Error compilling:

This report would have more information with "Show verbose output during compilation" enabled in File > Preferences. Arduino: 1.0.6 (Windows 7), Board: "Arduino Mega 2560 or Mega ADK" In file included from C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Connection.h:37, from C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:32: C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Packet.h:51: error: ISO C++ forbids declaration of 'Client' with no type C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Packet.h:51: error: expected ';' before ' ' token C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Packet.h:54: error: expected )' before '' token In file included from C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:32: C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Connection.h:41: error: expected)' before '*' token C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Connection.h:43: error: 'IPAddress' has not been declared C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Connection.h: In member function 'int MySQL_Connection::connected()': C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src/MySQL_Connection.h:44: error: 'client' was not declared in this scope C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp: At global scope: C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:58: error: 'boolean MySQL_Connection::connect' is not a static member of 'class MySQL_Connection' C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:58: error: 'IPAddress' was not declared in this scope C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:58: error: expected primary-expression before 'int' C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:58: error: expected primary-expression before 'char' C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:59: error: expected primary-expression before 'char' C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:59: error: initializer expression list treated as compound expression C:\Program Files\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp:60: error: expected ',' or ';' before '{' token

How to solve it? I have download your silimar library of 2016, but issue is same. In fact, I also got issue when I try to the example code about connect MySql by Ethernet, its issue is about "SPI". After add "#include " into code , it is ok. Something wrong in my setting or my computer???

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/30, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4D3d-4YkKzAeHiEq41F8ItPwyXG9ks5tMed7gaJpZM4RlbyW .

Titus-Song commented 6 years ago

@ChuckBell Hi, Thank you for your replay! In fact, this code is the example from your library files. I didnot change it. But though I change the "client" to "client1", the issue is same. Maybe there is something wrong in my wifi Library. Can you give me a link to download wifi library that fits for your MySQL_Connector_Arduino lib?

ChuckBell commented 6 years ago

Ok, but this:

MySQL_Connection conn((Client *)&client);

Should be:

MySQL_Connection conn((WiFiClient *)&client);

Notice the spelling. ;)

On Sat, Jan 20, 2018 at 09:07 Titus-Song notifications@github.com wrote:

@ChuckBell https://github.com/chuckbell Hi, Thank you for your replay! In fact, this code is the example from your library files. I didnot change it. But though I change the "client" to "client1", the issue is same. Maybe there is something wrong in my wifi Library. Can you give me a link to download wifi library that fits for your MySQL_Connector_Arduino lib?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/30#issuecomment-359174054, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4HiaShW_hZaP827qCzT_og_1Fl6Tks5tMfM8gaJpZM4RlbyW .

Titus-Song commented 6 years ago

@ChuckBell Unfortunately, After change to "MySQL_Connection conn((WiFiClient *)&client);", The issue is same. Now i am using wifi library and SPI library of arduino-1.0.6, they were build 2014, does it fit?

One more information: When I verify/compile another example code about connecting MySql by Ethernet, its issue is about "SPI". so I add "#include " into code , it is ok.

ChuckBell commented 6 years ago

Ok, good. Can we close this issue?

On 1/20/18 9:41 AM, Titus-Song wrote:

@ChuckBell https://github.com/chuckbell Unfortunately, After change to "MySQL_Connection conn((WiFiClient *)&client);", The issue is same. Now i am using wifi library and SPI library of arduino-1.0.6, they were build 2014, does it fit?

One more information: When I verify/compile another example code about connecting MySql by Ethernet, its issue is about "SPI". so I add "#include " into code , it is ok.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/30#issuecomment-359176162, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4MTttDzZCF6sMCuGlod5P524LaDlks5tMfsRgaJpZM4RlbyW.

Titus-Song commented 6 years ago

@ChuckBell Hello teacher! Sorry to trouble again, my leader did not agree to use Ethernet, he still want to use wifi to connect MySql.

Acorrding to issue about "ISO C++ forbids declaration of 'Client' with no type", we think that your MySql library is imcompatible with Wifi libarary in " declaration of 'Client'".

So may we change your code of MySQL_Connection.h and MySQL_Packet.h from "Client" to another name such as "SqlClient" to solve imcompatible issue directly???

My leader also want to know, if we use msSQL rather than MySql, could we download msSQL libarary? Best regards.

ChuckBell commented 6 years ago

Hello,

The code is available through GitHub and you can use it anyway you want for your own purposes - so long as you follow the license. ;)

I am not sure why you want to change the internal library to use SqlClient because the library is compatible with the Arduino WiFi library. Unless you're using some other WiFi library in which case you may indeed need to change some things. But be forewarned: the connector is designed to work with the Arduino libraries. Unless the library you want to use is 100% compatible, you may have other issues.

Also, the connector is designed to work with MySQL - the MySQL maintained by Oracle. It does not work with any other database system nor is it guaranteed to work with other variants of MySQL.

All that said, I'd like to help you if you need my assistance but I need some more information. If you could tell me the board you are using along with the WiFi shield and versions of MySQL, Arduino IDE, and the connector, I may be able to test things on my end.

Dr. Bell

On 1/22/18 10:05 AM, Titus-Song wrote:

@ChuckBell https://github.com/chuckbell Hello teacher! Sorry to trouble again, my leader did not agree to use Ethernet, he still want to use wifi to connect MySql.

Acorrding to issue about "ISO C++ forbids declaration of 'Client' with no type", we think that your MySql library is imcompatible with Wifi libarary in " declaration of 'Client'".

So may we change your code of MySQL_Connection.h and MySQL_Packet.h from "Client" to another name such as "SqlClient" to solve imcompatible issue directly???

My leader also want to know, if we use msSQL rather than MySql, could we download msSQL libarary? Best regards.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/30#issuecomment-359450474, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4OKbsopYEviMjJtvfji-ZhB1677zks5tNKO_gaJpZM4RlbyW.

Titus-Song commented 6 years ago

@ChuckBell Thank you for you reply, you are so helpful, God bless you! I trust your code, but I really do not know why I can not verify/compile the code successful. Can you tell me what version of Arduino WiFi library or Arduino software in your test, I will download it.

Titus-Song commented 6 years ago

@ChuckBell Good News! I have verify/compile successful after download new version of Arduino WiFi library Thank you! I will remeber your help!!! Teacher

ChuckBell commented 6 years ago

Excellent! You're welcome.

On 1/22/18 11:17 AM, Titus-Song wrote:

@ChuckBell https://github.com/chuckbell Good News! I have verify/compile successful after download new version of Arduino WiFi library Thank you! I will remeber your help!!! Teacher

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/30#issuecomment-359476882, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4L_WNIZBquAY0isizITWKe0fP0xkks5tNLSwgaJpZM4RlbyW.