#define DBG_ERR LOG_ERROR
#ifdef GPS_DLOG_DEBUG /* Debug mode */
-#define LOG_PLUGIN(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, "[%-40s: %-4d] "fmt, __FILE__, __LINE__, ##args)
+#define LOG_PLUGIN(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args)
#define SECLOG_PLUGIN(dbg_lvl,fmt,args...) SECURE_SLOG(dbg_lvl, TAG_GPS_PLUGIN, "[%-40s: %-4d] "fmt, __FILE__, __LINE__, ##args)
#else /* Release(commercial) mode */
#define LOG_PLUGIN(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args)
#include <gps_plugin_intf.h>
#include <dd-display.h>
+#include <tzplatform_config.h>
#include "gps_plugin_debug.h"
#include "nmea_parser.h"
#define REPLAY_NMEA_SET_SIZE 4096
#define REPLAY_NMEA_SENTENCE_SIZE 128
-#define LBS_SERVER_FOLDER "/opt/usr/media/lbs-server"
-#define BATCH_LOG LBS_SERVER_FOLDER"/location_batch.log"
gps_event_cb g_gps_event_cb = NULL;
void *g_user_data = NULL;
time_t timestamp;
time(×tamp);
+ const char *batch_path = tzplatform_mkpath(TZ_SYS_MEDIA, "lbs-server/location_batch.log");
if (timer->batch_fd == NULL) {
if (timer->batch_mode == BATCH_MODE_ON) {
struct stat st = {0};
- if (stat(LBS_SERVER_FOLDER, &st) == -1) {
- if (mkdir(LBS_SERVER_FOLDER, 0777) == -1) {
+ const char *lbs_server_path = tzplatform_mkpath(TZ_SYS_MEDIA, "lbs-server");
+ if (stat(lbs_server_path, &st) == -1) {
+ if (mkdir(lbs_server_path, 0777) == -1) {
LOG_PLUGIN(DBG_ERR, "Fail to create lbs-server folder");
return ;
}
}
- timer->batch_fd = fopen(BATCH_LOG, "w+");
+ timer->batch_fd = fopen(batch_path, "w+");
if (timer->batch_fd == NULL) {
LOG_PLUGIN(DBG_ERR, "Fail to open file [Not available batch_fd]");
return ;
ret = fwrite(buf, 1, strlen(buf), timer->batch_fd);
if (ret != strlen(buf)) {
- LOG_PLUGIN(DBG_ERR, "Fail to write file[%s]", BATCH_LOG);
+ LOG_PLUGIN(DBG_ERR, "Fail to write file[%s]", batch_path);
}
(timer->num_of_batch)++ ;
gps_event_info_t gps_event;
memset(&gps_event, 0, sizeof(gps_event_info_t));
+ if (timer->batch_fd != NULL) {
+ if (fclose(timer->batch_fd) != 0)
+ LOG_PLUGIN(DBG_ERR, "Fail to close file");
+ timer->batch_fd = NULL;
+ }
+
gps_event.event_id = GPS_EVENT_REPORT_BATCH;
timer->batch_start_time = timestamp;
timer->is_flush = FALSE;
g_gps_event_cb(&gps_event, g_user_data);
timer->num_of_batch = 0;
}
-
- if (timer->batch_fd != NULL) {
- fclose(timer->batch_fd);
- timer->batch_fd = NULL;
- }
}
}
if (str == NULL) {
return FALSE;
}
- snprintf(replay_file_path, sizeof(replay_file_path), NMEA_FILE_PATH"%s", str);
+ const char *nmea_file_path = tzplatform_mkpath(TZ_SYS_MEDIA, "lbs-server/replay/");
+ snprintf(replay_file_path, sizeof(replay_file_path), "%s%s", nmea_file_path, str);
SECLOG_PLUGIN(DBG_ERR, "replay file name : %s", replay_file_path);
free(str);
timer->fd = fopen(replay_file_path, "r");
if (timer->fd == NULL) {
SECLOG_PLUGIN(DBG_ERR, "fopen(%s) failed", replay_file_path);
- timer->fd = fopen(DEFAULT_NMEA_LOG, "r");
+ const char *default_nmea_log = tzplatform_mkpath(TZ_SYS_RO_ETC, "lbs-server/replay/nmea_replay.log");
+ timer->fd = fopen(default_nmea_log, "r");
if (timer->fd == NULL) {
- SECLOG_PLUGIN(DBG_ERR, "fopen(%s) failed", DEFAULT_NMEA_LOG);
+ SECLOG_PLUGIN(DBG_ERR, "fopen(%s) failed", default_nmea_log);
return FALSE;
}
}