fix: set printf format depending on size of time

This commit is contained in:
Jens Saalmüller 2022-04-25 07:38:38 +02:00
parent f5491f3e35
commit b5bc536a96
2 changed files with 9 additions and 23 deletions

View File

@ -12,8 +12,6 @@
#ifndef _FDB_CFG_H_
#define _FDB_CFG_H_
#define DEMO_ESP32
/* using KVDB feature */
#define FDB_USING_KVDB
@ -41,9 +39,6 @@
//#include <esp_log.h>
//#define FDB_PRINT(...) ESP_LOGI("fdb", __VA_ARGS__)
/* Use 64 bit for timestamps. */
//#define FDB_USING_TIMESTAMP_64BIT
/* print debug information */
#define FDB_DEBUG_ENABLE

View File

@ -20,6 +20,12 @@
#define FDB_LOG_TAG "[sample][tsdb]"
#ifdef FDB_USING_TIMESTAMP_64BIT
#define __PRITS "ld"
#else
#define __PRITS "d"
#endif
struct env_status {
int temp;
int humi;
@ -90,12 +96,7 @@ static bool query_cb(fdb_tsl_t tsl, void *arg)
fdb_tsdb_t db = arg;
fdb_blob_read((fdb_db_t) db, fdb_tsl_to_blob(tsl, fdb_blob_make(&blob, &status, sizeof(status))));
#ifdef DEMO_ESP32
FDB_INFO("[query_cb] queried a TSL: time: %d, temp: %d, humi: %d\n", tsl->time, status.temp, status.humi);
#else
FDB_INFO("[query_cb] queried a TSL: time: %ld, temp: %d, humi: %d\n", tsl->time, status.temp, status.humi);
#endif
FDB_INFO("[query_cb] queried a TSL: time: %" __PRITS ", temp: %d, humi: %d\n", tsl->time, status.temp, status.humi);
return false;
}
@ -107,12 +108,7 @@ static bool query_by_time_cb(fdb_tsl_t tsl, void *arg)
fdb_tsdb_t db = arg;
fdb_blob_read((fdb_db_t) db, fdb_tsl_to_blob(tsl, fdb_blob_make(&blob, &status, sizeof(status))));
#ifdef DEMO_ESP32
FDB_INFO("[query_by_time_cb] queried a TSL: time: %d, temp: %d, humi: %d\n", tsl->time, status.temp, status.humi);
#else
FDB_INFO("[query_by_time_cb] queried a TSL: time: %ld, temp: %d, humi: %d\n", tsl->time, status.temp, status.humi);
#endif
FDB_INFO("[query_by_time_cb] queried a TSL: time: %" __PRITS ", temp: %d, humi: %d\n", tsl->time, status.temp, status.humi);
return false;
}
@ -121,12 +117,7 @@ static bool set_status_cb(fdb_tsl_t tsl, void *arg)
{
fdb_tsdb_t db = arg;
#ifdef DEMO_ESP32
FDB_INFO("set the TSL (time %d) status from %d to %d\n", tsl->time, tsl->status, FDB_TSL_USER_STATUS1);
#else
FDB_INFO("set the TSL (time %ld) status from %d to %d\n", tsl->time, tsl->status, FDB_TSL_USER_STATUS1);
#endif
FDB_INFO("set the TSL (time %" __PRITS ") status from %d to %d\n", tsl->time, tsl->status, FDB_TSL_USER_STATUS1);
fdb_tsl_set_status(db, tsl, FDB_TSL_USER_STATUS1);
return false;