- Thread starter
- #901
odam2k
Well-Known Member
Really clean lines there man, nice work!
It's like sewing I enjoy making these boards, but I would like to create real pcbs once I finalize them, if I ever do...
How To Use Progressive Web App aka PWA On 420 Magazine Forum
Note: This feature may not be available in some browsers.
Really clean lines there man, nice work!
Really clean lines there man, nice work!
How is the sql data sent to the database? I can help here for sure but need a little more detail.
boolean connectedToSQL()
{
int counter = 0;
while ((!mySqlConnection.connected()) && (counter < 5))
{
IPAddress ip;
if (ip.fromString(espCfg.esp8266_Config.mySqlServerAddress))
{
mySqlConnection.connect(ip, espCfg.esp8266_Config.mySqlServerPort, espCfg.esp8266_Config.mySqlUsername, espCfg.esp8266_Config.mySqlPassword);
}
else
{
Serial.print("Cannot parse IP Address for Sql Server: ");
Serial.println(espCfg.esp8266_Config.mySqlServerAddress);
}
counter++;
}
if (mySqlConnection.connected())
{
lastSqlConnCheckOkTimestamp = millis();
}
else
{
lastSqlConnCheckFailedTimestamp = millis();
sendError("Unable to connect to MySql");
}
return mySqlConnection.connected();
}
int fetchSensorIdList()
{
int _sensorCounter = 0;
snprintf_P(tmpBuffer, sizeof(tmpBuffer),
PSTR("SELECT `sensorId`, `blynkSendFreqSec`, `secondsBetweenScans` FROM `%s`.`vw_active_sensor_info` where `moduleId` = %i order by `portNumber`; "),
espCfg.esp8266_Config.mySqlInstance, moduleCfg.moduleId);
mySqlConnectionClose();
if (connectedToSQL())
{
clearSensorList();
MySQL_Cursor *cur_memList = new MySQL_Cursor(&mySqlConnection);
cur_memList->execute(tmpBuffer);
column_names *colsList = cur_memList->get_columns();
row_values *rowList = NULL;
do {
rowList = cur_memList->get_next_row();
if (rowList != NULL)
{
for (int f = 0; f < colsList->num_fields; f++)
{
if (strcmp(colsList->fields[f]->name, "sensorId") == 0) sensorList[_sensorCounter].sensorId = atoi(rowList->values[f]);
if (strcmp(colsList->fields[f]->name, "blynkSendFreqSec") == 0) sensorList[_sensorCounter].blynkSendFreqSec = atoi(rowList->values[f]);
if (strcmp(colsList->fields[f]->name, "secondsBetweenScans") == 0) sensorList[_sensorCounter].secondsBetweenScans = atoi(rowList->values[f]);
}
_sensorCounter++;
}
} while (rowList != NULL);
delete cur_memList;
mySqlConnectionClose(); // ADDED Aug 22 - does no good...
}
return _sensorCounter;
}
How is the sql data sent to the database? I can help here for sure but need a little more detail.
Wednesday, August 21, 2019
Rumors, whispers, and a WTH?
Some good news, I've managed to convince theaccountantwife to release a few more dollars this month for my hobby As it sits, I've got 20 pumps and 4 x 8 relay modules in my shopping baskets along with a few other goodies for some other projects. If priorities don't change before the end of the month, I will be moving forward with the automatic watering.
I know eh? I can hear the whispering... "He's said that before!"
The mySqlConnectionClose() simply did a mySqlConnection.close(); but it didn't help, just slowed things down, so now the method is empty...
Sorry I haven't commented much, but following your activity. Your variable getting appended may be just be a good old-fashioned memory leak.
Did you put a mySqlConnection.close() back into your code at least?
As far as home-etching, I have yet to see a hobby version worth anything that's "affordable". If you find out, I'll be excited!
mySqlConnectionClose();
if (connectedToSQL())
{
...
}
Just noticed this...
but later on you do the mySqlConnectionClose(); again towards the end of the routine. How does your .execute() method even work correctly on a closed connection?