Code hangs in cmd_query()
Posted by: Dag Hovden
Date: December 03, 2015 07:23AM
I have a sketch running on an Adafruit Huzzah ESP8266 board (using ESP8266WiFi.h instead of WiFi.h), collecting some data and sending the data to a MySQL database in my local network, the latter using the mysql_connector. The insert query typically looks like this
INSERT INTO datalog.datalogmeasdata (UserID,Date,Time,MeasValID,MeasVal) VALUES (1,'2-12-2015','10:15:46',2,436)
Normally, it takes about 20-25 sec to execute which is quite long but not a problem, the data collected doesn't change all that fast anyway.
However, at times the code never returns from the cmd_query() calls and I have to reset the Huzzah to get the sketch running again. This can happen after 15 minutes or after 9 hours, seems quite random to me. The database is still there, that I can check from my local PC.
Is there way to specify a timeout value for cmd_query() and get it to return an error code when the query fails?
I have had a look at the code but not in any depth. There seems to be some waiting going on but only if WiFi is not defined (i.e. using Ethernet) which I don't really understand.
Anyway, grateful for any suggestions, pointers, ideas :-)