#define DBG_ERR LOG_ERROR
#ifdef GPS_DLOG_DEBUG /* Debug mode */
-#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)
+#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)
-#define SECLOG_PLUGIN(dbg_lvl,fmt,args...) SECURE_SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##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, fmt, ##args)
#endif
#endif
gps_event.event_data.pos_ind.pos.ver_accuracy = data->ver_accuracy;
}
- if (g_gps_event_cb != NULL) {
+ if (g_gps_event_cb != NULL)
g_gps_event_cb(&gps_event, g_user_data);
- }
}
void gps_plugin_replay_batch_event(pos_data_t *data, replay_timeout *timer)
LOG_PLUGIN(DBG_LOW, "Add location info to batch file [%s]", buf);
ret = fwrite(buf, 1, strlen(buf), timer->batch_fd);
- if (ret != strlen(buf)) {
+ if (ret != strlen(buf))
LOG_PLUGIN(DBG_ERR, "Fail to write file[%s]", batch_path);
- }
(timer->num_of_batch)++ ;
}
}
if (timer->lcd_mode == VCONFKEY_PM_STATE_NORMAL) {
- if ((timestamp - timer->batch_start_time) >= timer->batch_interval) {
+ if ((timestamp - timer->batch_start_time) >= timer->batch_interval)
timer->is_flush = TRUE;
- }
+
} else {
- if ((timestamp - timer->batch_start_time) >= timer->batch_period) {
+ if ((timestamp - timer->batch_start_time) >= timer->batch_period)
timer->is_flush = TRUE;
- }
}
if (timer->is_flush) {
}
}
- if (g_gps_event_cb != NULL) {
+ if (g_gps_event_cb != NULL)
g_gps_event_cb(&gps_event, g_user_data);
- }
}
void gps_plugin_replay_nmea_event(nmea_data_t *data)
memcpy(gps_event.event_data.nmea_ind.nmea.data, data->data, data->len);
}
- if (g_gps_event_cb != NULL) {
+ if (g_gps_event_cb != NULL)
g_gps_event_cb(&gps_event, g_user_data);
- }
if (gps_event.event_data.nmea_ind.nmea.data != NULL) {
free(gps_event.event_data.nmea_ind.nmea.data);
gps_event_info_t gps_event;
gps_event.event_id = GPS_EVENT_START_SESSION;
- if (ret == TRUE) {
+ if (ret == TRUE)
gps_event.event_data.start_session_rsp.error = GPS_ERR_NONE;
- } else {
+ else
gps_event.event_data.start_session_rsp.error = GPS_ERR_COMMUNICATION;
- }
- if (g_gps_event_cb != NULL) {
+ if (g_gps_event_cb != NULL)
g_gps_event_cb(&gps_event, g_user_data);
- }
}
void gps_plugin_respond_stop_session(void)
gps_event.event_id = GPS_EVENT_STOP_SESSION;
gps_event.event_data.stop_session_rsp.error = GPS_ERR_NONE;
- if (g_gps_event_cb != NULL) {
+ if (g_gps_event_cb != NULL)
g_gps_event_cb(&gps_event, g_user_data);
- }
}
gboolean gps_plugin_replay_read_nmea(replay_timeout *timer, char *nmea_data)
}
if (g_gps_event_cb != NULL) {
- if (err != READ_NOT_FIXED) {
+ if (err != READ_NOT_FIXED)
gps_plugin_replay_pos_event(timer->pos_data);
- }
+
gps_plugin_replay_sv_event(timer->sv_data);
}
ret = TRUE;
}
if (g_gps_event_cb != NULL) {
- if (timer->batch_mode == BATCH_MODE_ON) {
+ if (timer->batch_mode == BATCH_MODE_ON)
gps_plugin_replay_batch_event(timer->pos_data, timer);
- }
}
ret = TRUE;
return ret;
void gps_plugin_stop_replay_mode(replay_timeout *timer)
{
- if (timer->replay_mode == REPLAY_NMEA && fclose(timer->fd) != 0) {
+ if (timer->replay_mode == REPLAY_NMEA && fclose(timer->fd) != 0)
LOG_PLUGIN(DBG_ERR, "fclose failed");
- }
+
timer->fd = NULL;
if (timer->timeout_src != NULL && timer->default_context != NULL && !g_source_is_destroyed(timer->timeout_src)) {
char *str;
str = setting_get_string(VCONFKEY_LOCATION_NMEA_FILE_NAME);
- if (str == NULL) {
+ if (str == NULL)
return FALSE;
- }
+
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);
gboolean ret = FALSE;
if (timer->replay_mode == REPLAY_NMEA) {
- if (gps_plugin_get_nmea_fd(timer) == FALSE) {
+ if (gps_plugin_get_nmea_fd(timer) == FALSE)
return FALSE;
- }
}
if (timer->default_context == NULL) {
timer->default_context = g_main_context_default();
- if (timer->default_context == NULL) {
+
+ if (timer->default_context == NULL)
return ret;
- }
}
if (timer->timeout_src != NULL) {
time(×tamp);
if (timer->replay_mode == REPLAY_NMEA) {
- if (gps_plugin_get_nmea_fd(timer) == FALSE) {
+ if (gps_plugin_get_nmea_fd(timer) == FALSE)
return FALSE;
- }
}
if (timer->default_context == NULL) {
timer->default_context = g_main_context_default();
- if (timer->default_context == NULL) {
+
+ if (timer->default_context == NULL)
return ret;
- }
}
if (timer->timeout_src != NULL) {
void gps_plugin_stop_batch_mode(replay_timeout *timer)
{
- if (timer->batch_mode == BATCH_MODE_ON) {
+ if (timer->batch_mode == BATCH_MODE_ON)
timer->batch_mode = BATCH_MODE_OFF;
- }
if (timer->batch_fd != NULL) {
fclose(timer->batch_fd);
static void replay_mode_changed_cb(keynode_t *key, void *data)
{
- if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &g_replay_timer->replay_mode) == FALSE) {
+ if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &g_replay_timer->replay_mode) == FALSE)
g_replay_timer->replay_mode = REPLAY_OFF;
- }
if (g_replay_timer->replay_mode == REPLAY_NMEA) {
- if (gps_plugin_get_nmea_fd(g_replay_timer) == FALSE) {
+ if (gps_plugin_get_nmea_fd(g_replay_timer) == FALSE)
LOG_PLUGIN(DBG_ERR, "Fail to get nmea fd.");
- }
+
} else {
if (g_replay_timer->fd != NULL) {
fclose(g_replay_timer->fd);
g_replay_timer->lcd_mode = VCONFKEY_PM_STATE_LCDOFF;
}
- if (g_replay_timer->lcd_mode == VCONFKEY_PM_STATE_NORMAL) {
+ if (g_replay_timer->lcd_mode == VCONFKEY_PM_STATE_NORMAL)
g_replay_timer->is_flush = TRUE;
- }
return;
}
timer->batch_mode = BATCH_MODE_OFF;
timer->is_flush = FALSE;
- if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &timer->replay_mode) == FALSE) {
+ if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &timer->replay_mode) == FALSE)
timer->replay_mode = REPLAY_OFF;
- }
+
setting_notify_key_changed(VCONFKEY_LOCATION_REPLAY_MODE, replay_mode_changed_cb);
- if (setting_get_int(VCONFKEY_PM_STATE, &timer->lcd_mode) == FALSE) {
+ if (setting_get_int(VCONFKEY_PM_STATE, &timer->lcd_mode) == FALSE)
timer->lcd_mode = VCONFKEY_PM_STATE_LCDOFF;
- }
+
setting_notify_key_changed(VCONFKEY_PM_STATE, display_mode_changed_cb);
timer->pos_data = (pos_data_t *) malloc(sizeof(pos_data_t));
void gps_plugin_replay_timer_deinit(replay_timeout *timer)
{
- if (timer == NULL) {
+ if (timer == NULL)
return;
- }
if (timer->pos_data != NULL) {
free(timer->pos_data);
gps_action_start_data_t *gps_start_data = gps_action_data;
switch (gps_action) {
- case GPS_ACTION_SEND_PARAMS:
- break;
- case GPS_ACTION_START_SESSION:
- gps_plugin_start_replay_mode(g_replay_timer);
- break;
- case GPS_ACTION_STOP_SESSION:
- gps_plugin_stop_replay_mode(g_replay_timer);
- break;
- case GPS_ACTION_START_BATCH:
- gps_plugin_start_batch_mode(g_replay_timer, gps_start_data->interval, gps_start_data->period);
- break;
- case GPS_ACTION_STOP_BATCH:
- gps_plugin_stop_batch_mode(g_replay_timer);
- gps_plugin_stop_replay_mode(g_replay_timer);
- break;
- case GPS_INDI_SUPL_VERIFICATION:
- case GPS_INDI_SUPL_DNSQUERY:
- case GPS_ACTION_START_FACTTEST:
- case GPS_ACTION_STOP_FACTTEST:
- case GPS_ACTION_REQUEST_SUPL_NI:
- LOG_PLUGIN(DBG_LOW, "Don't use action type : [ %d ]", gps_action);
- break;
- default:
- break;
+ case GPS_ACTION_SEND_PARAMS:
+ break;
+ case GPS_ACTION_START_SESSION:
+ gps_plugin_start_replay_mode(g_replay_timer);
+ break;
+ case GPS_ACTION_STOP_SESSION:
+ gps_plugin_stop_replay_mode(g_replay_timer);
+ break;
+ case GPS_ACTION_START_BATCH:
+ gps_plugin_start_batch_mode(g_replay_timer, gps_start_data->interval, gps_start_data->period);
+ break;
+ case GPS_ACTION_STOP_BATCH:
+ gps_plugin_stop_batch_mode(g_replay_timer);
+ gps_plugin_stop_replay_mode(g_replay_timer);
+ break;
+ case GPS_INDI_SUPL_VERIFICATION:
+ case GPS_INDI_SUPL_DNSQUERY:
+ case GPS_ACTION_START_FACTTEST:
+ case GPS_ACTION_STOP_FACTTEST:
+ case GPS_ACTION_REQUEST_SUPL_NI:
+ LOG_PLUGIN(DBG_LOW, "Don't use action type : [ %d ]", gps_action);
+ break;
+ default:
+ break;
}
return TRUE;
static unsigned char nmea_parser_c2n(unsigned char ch)
{
- if (ch <= '9') {
+ if (ch <= '9')
return ch - '0';
- } else {
+ else
return (ch - 'A') + 10;
- }
}
int nmea_parser_verify_checksum(char *nmea_sen)
int checksum = 0;
int sum = 0;
- for (i = 0; i < strlen(nmea_sen) && (nmea_sen[i] != '*'); i++) {
+ for (i = 0; i < strlen(nmea_sen) && (nmea_sen[i] != '*'); i++)
checksum ^= nmea_sen[i];
- }
- if (++i + 1 < strlen(nmea_sen)) {
+ if (++i + 1 < strlen(nmea_sen))
sum = (nmea_parser_c2n(nmea_sen[i]) << 4) + nmea_parser_c2n(nmea_sen[i + 1]);
- }
if (sum == checksum) {
ret = 0;
while ((*s != 0) && (num_tokens < MAX_TOEKNS)) {
switch (state) {
- case 0:
- if (*s == ',') {
- *s = 0;
- state = 1;
- }
- break;
- case 1:
- token[num_tokens++] = s;
- if (*s == ',') {
- *s = 0;
- } else {
- state = 0;
- }
- break;
+ case 0:
+ if (*s == ',') {
+ *s = 0;
+ state = 1;
+ }
+ break;
+ case 1:
+ token[num_tokens++] = s;
+ if (*s == ',')
+ *s = 0;
+ else
+ state = 0;
+
+ break;
}
s++;
}
int deg;
double remainder;
- if ((*lat == 0) || (*bearing == 0)) {
+ if ((*lat == 0) || (*bearing == 0))
return latitude;
- }
ns = (*bearing == 'N') ? NORTH : SOUTH;
int deg;
double remainder;
- if (*lon == 0 || (*bearing == 0)) {
+ if (*lon == 0 || (*bearing == 0))
return longitude;
- }
ew = (*bearing == 'E') ? EAST : WEST;
{
double altitude;
- if (*alt == 0) {
+ if (*alt == 0)
return 0.0;
- }
altitude = atof(alt);
altitude = (*unit == 'M') ? altitude : altitude * METER_TO_FEET;
/* selection_type = *token[1]; */
memset(used_sat, 0, sizeof(used_sat));
- for (i = 0; i < MAX_GPS_NUM_SAT_USED; i++) {
+ for (i = 0; i < MAX_GPS_NUM_SAT_USED; i++)
used_sat[i] = atoi(token[i + 3]);
- }
+
/* pdop = atof(token[15]); */
/* hdop = atof(token[16]); */
int nmea_parser_sentence(char *sentence, char *token[], pos_data_t *pos, sv_data_t *sv)
{
int ret = READ_SUCCESS;
- if (strcmp(sentence, "GPGGA") == 0) {
+ if (strcmp(sentence, "GPGGA") == 0)
ret = nmea_parser_gpgga(token, pos, sv);
- } else if (strcmp(sentence, "GPRMC") == 0) {
+ else if (strcmp(sentence, "GPRMC") == 0)
ret = nmea_parser_gprmc(token, pos);
- } else if (strcmp(sentence, "GPGLL") == 0) {
+ else if (strcmp(sentence, "GPGLL") == 0)
ret = nmea_parser_gpgll(token, pos);
- } else if (strcmp(sentence, "GPGSA") == 0) {
+ else if (strcmp(sentence, "GPGSA") == 0)
ret = nmea_parser_gpgsa(token, pos);
- } else if (strcmp(sentence, "GPVTG") == 0) {
+ else if (strcmp(sentence, "GPVTG") == 0)
ret = nmea_parser_gpvtg(token, pos);
- } else if (strcmp(sentence, "GPGSV") == 0) {
+ else if (strcmp(sentence, "GPGSV") == 0)
ret = nmea_parser_gpgsv(token, sv);
- } else {
+ else
LOG_PLUGIN(DBG_LOW, "Unsupported sentence : [%s]\n", sentence);
- }
+
return ret;
}
#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, "[%-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)
+#define LOG_PLUGIN(dbg_lvl, fmt, args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args)
#endif
#endif
if (xps_plugin) {
if (xps_plugin->location) {
- if (xps_plugin->location->latitude < 90) {
+ if (xps_plugin->location->latitude < 90)
xps_plugin->location->latitude++;
- } else {
+ else
xps_plugin->location->latitude = 0;
- }
- if (xps_plugin->location->longitude < 180) {
+
+ if (xps_plugin->location->longitude < 180)
xps_plugin->location->longitude++;
- } else {
+ else
xps_plugin->location->longitude = 0;
- }
- if (xps_plugin->location->age < 10000) {
+
+ if (xps_plugin->location->age < 10000)
xps_plugin->location->age++;
- } else {
+ else
xps_plugin->location->age = 0;
- }
- if (xps_plugin->location->altitude < 5000) {
+
+ if (xps_plugin->location->altitude < 5000)
xps_plugin->location->altitude++;
- } else {
+ else
xps_plugin->location->altitude = 0;
- }
- if (xps_plugin->location->bearing < 90) {
+
+ if (xps_plugin->location->bearing < 90)
xps_plugin->location->bearing++;
- } else {
+ else
xps_plugin->location->bearing = 0;
- }
- if (xps_plugin->location->hpe < 100) {
+
+ if (xps_plugin->location->hpe < 100)
xps_plugin->location->hpe++;
- } else {
+ else
xps_plugin->location->hpe = 0;
- }
- if (xps_plugin->location->speed < 250) {
+
+ if (xps_plugin->location->speed < 250)
xps_plugin->location->speed++;
- } else {
+ else
xps_plugin->location->speed = 0;
- }
+
}
/* called intervals */
- if (xps_plugin->location_cb) {
+ if (xps_plugin->location_cb)
xps_plugin->location_cb(xps_plugin->arg, xps_plugin->location, NULL);
- }
+
}
return TRUE;
}
/* call CancelCallback */
- if (cb) {
+ if (cb)
cb(arg);
- }
+
return TRUE;
}
if (xps_plugin) {
if (xps_plugin->location) {
- if (xps_plugin->location->latitude < 90) {
+ if (xps_plugin->location->latitude < 90)
xps_plugin->location->latitude++;
- } else {
+ else
xps_plugin->location->latitude = 0;
- }
- if (xps_plugin->location->longitude < 180) {
+
+ if (xps_plugin->location->longitude < 180)
xps_plugin->location->longitude++;
- } else {
+ else
xps_plugin->location->longitude = 0;
- }
- if (xps_plugin->location->age < 10000) {
+
+ if (xps_plugin->location->age < 10000)
xps_plugin->location->age++;
- } else {
+ else
xps_plugin->location->age = 0;
- }
- if (xps_plugin->location->altitude < 5000) {
+
+ if (xps_plugin->location->altitude < 5000)
xps_plugin->location->altitude++;
- } else {
+ else
xps_plugin->location->altitude = 0;
- }
- if (xps_plugin->location->bearing < 90) {
+
+ if (xps_plugin->location->bearing < 90)
xps_plugin->location->bearing++;
- } else {
+ else
xps_plugin->location->bearing = 0;
- }
- if (xps_plugin->location->hpe < 100) {
+
+ if (xps_plugin->location->hpe < 100)
xps_plugin->location->hpe++;
- } else {
+ else
xps_plugin->location->hpe = 0;
- }
- if (xps_plugin->location->speed < 250) {
+
+ if (xps_plugin->location->speed < 250)
xps_plugin->location->speed++;
- } else {
+ else
xps_plugin->location->speed = 0;
- }
+
}
/* called intervals */
- if (xps_plugin->location_cb) {
+ if (xps_plugin->location_cb)
xps_plugin->location_cb(xps_plugin->arg, xps_plugin->location, NULL);
- }
+
}
return TRUE;
}
/* call CancelCallback */
- if (cb) {
+ if (cb)
cb(arg);
- }
+
return TRUE;
}