Skip to content

Commit

Permalink
Improve debug
Browse files Browse the repository at this point in the history
  • Loading branch information
roleoroleo committed Mar 20, 2023
1 parent e027a35 commit 0047ba1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/mqtt/mqtt-sonoff/include/sql.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#include <mqueue.h>
#include <sqlite3.h>

#define SQL_DEBUG 0

#define IPCSYS_DB "/mnt/mtd/db/ipcsys.db"
#define IPCMMC_DB "/mnt/mmc/AVRecordFile.db"

Expand Down
22 changes: 15 additions & 7 deletions src/mqtt/mqtt-sonoff/src/sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ static void call_callback(SQL_MESSAGE_TYPE type);
static void call_callback_cmd(SQL_COMMAND_TYPE type);
static void sql_debug(const char* fmt, ...);

extern int debug;

//-----------------------------------------------------------------------------
// MESSAGES HANDLERS
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -203,6 +205,7 @@ static void *sql_thread(void *args)
}
}
ret = sqlite3_reset(stmt1);
sql_debug("stmt1 completed.\n");

ret = sqlite3_step(stmt2);
if (ret == SQLITE_ROW) {
Expand All @@ -228,6 +231,7 @@ static void *sql_thread(void *args)
}
}
ret = sqlite3_reset(stmt2);
sql_debug("stmt2 completed.\n");

ret = sqlite3_step(stmt3);
if (ret == SQLITE_ROW) {
Expand All @@ -241,6 +245,7 @@ static void *sql_thread(void *args)
}
}
ret = sqlite3_reset(stmt3);
sql_debug("stmt3 completed.\n");

ret = sqlite3_step(stmt4);
if (ret == SQLITE_ROW) {
Expand All @@ -256,6 +261,7 @@ static void *sql_thread(void *args)
}
}
ret = sqlite3_reset(stmt4);
sql_debug("stmt4 completed.\n");

ret = sqlite3_step(stmt5);
if (ret == SQLITE_ROW) {
Expand All @@ -269,6 +275,7 @@ static void *sql_thread(void *args)
}
}
ret = sqlite3_reset(stmt5);
sql_debug("stmt5 completed.\n");

usleep(1000*1000);
}
Expand All @@ -277,8 +284,9 @@ static void *sql_thread(void *args)
sqlite3_finalize(stmt2);
sqlite3_finalize(stmt3);
sqlite3_finalize(stmt4);
sqlite3_finalize(stmt5);

return 0;
pthread_exit(NULL);
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -356,10 +364,10 @@ static void call_callback_cmd(SQL_COMMAND_TYPE type)

static void sql_debug(const char* fmt, ...)
{
#if SQL_DEBUG
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
#endif
if (debug) {
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
}
}

0 comments on commit 0047ba1

Please sign in to comment.