/* nps variables */
NpsManagerHandle nps_handle;
unsigned long period;
- NpsManagerPositionExt pos;
+ NpsManagerPositionExt wps;
NpsManagerLastPositionExt last_pos;
Plugin_LocationInfo location;
}
}
-static void nps_set_last_position(NpsManagerPositionExt pos)
+static void nps_set_last_position(NpsManagerPositionExt wps)
{
- LOG_NPS(DBG_LOW, "nps_set_last_position[%d]", pos.timestamp);
+ LOG_NPS(DBG_LOW, "nps_set_last_position[%d]", wps.timestamp);
char location[128] = {0,};
- snprintf(location, sizeof(location), "%.6lf;%.6lf;%.2lf;%.2lf;%.2lf;%.2lf;", pos.latitude, pos.longitude, pos.altitude, pos.speed, pos.direction, pos.hor_accuracy);
+ snprintf(location, sizeof(location), "%.6lf;%.6lf;%.2lf;%.2lf;%.2lf;%.2lf;", wps.latitude, wps.longitude, wps.altitude, wps.speed, wps.direction, wps.hor_accuracy);
- setting_set_int(VCONFKEY_LOCATION_NV_LAST_WPS_TIMESTAMP, pos.timestamp);
+ setting_set_int(VCONFKEY_LOCATION_NV_LAST_WPS_TIMESTAMP, wps.timestamp);
setting_set_string(VCONFKEY_LOCATION_NV_LAST_WPS_LOCATION, location);
}
-static void nps_set_position(lbs_server_s *lbs_server, NpsManagerPositionExt pos)
+static void nps_set_position(lbs_server_s *lbs_server, NpsManagerPositionExt wps)
{
- LOG_NPS(DBG_LOW, "set position timestamp : %d", pos.timestamp);
- lbs_server->last_pos.timestamp = pos.timestamp;
+ LOG_NPS(DBG_LOW, "nps set position timestamp[%d]", wps.timestamp);
+ lbs_server->last_pos.timestamp = wps.timestamp;
setting_set_int(VCONFKEY_LOCATION_LAST_WPS_TIMESTAMP, lbs_server->last_pos.timestamp);
- if ((lbs_server->last_pos.latitude != pos.latitude) || (lbs_server->last_pos.longitude != pos.longitude)) {
- lbs_server->last_pos.latitude = pos.latitude;
- lbs_server->last_pos.longitude = pos.longitude;
- lbs_server->last_pos.altitude = pos.altitude;
- lbs_server->last_pos.hor_accuracy = pos.hor_accuracy;
- lbs_server->last_pos.speed = pos.speed;
- lbs_server->last_pos.direction = pos.direction;
+ if ((lbs_server->last_pos.latitude != wps.latitude) || (lbs_server->last_pos.longitude != wps.longitude)) {
+ lbs_server->last_pos.latitude = wps.latitude;
+ lbs_server->last_pos.longitude = wps.longitude;
+ lbs_server->last_pos.altitude = wps.altitude;
+ lbs_server->last_pos.hor_accuracy = wps.hor_accuracy;
+ lbs_server->last_pos.speed = wps.speed;
+ lbs_server->last_pos.direction = wps.direction;
setting_set_double(VCONFKEY_LOCATION_LAST_WPS_LATITUDE, lbs_server->last_pos.latitude);
setting_set_double(VCONFKEY_LOCATION_LAST_WPS_LONGITUDE, lbs_server->last_pos.longitude);
int last_timestamp = 0;
setting_get_int(VCONFKEY_LOCATION_NV_LAST_WPS_TIMESTAMP, &last_timestamp);
- LOG_NPS(DBG_LOW, "last_time stamp: %d, pos.timestamp: %d, UPDATE_INTERVAL: %d ", last_timestamp, pos.timestamp, UPDATE_INTERVAL);
- if ((pos.timestamp - last_timestamp) > UPDATE_INTERVAL)
- nps_set_last_position(pos);
+ LOG_NPS(DBG_LOW, "last_time stamp: %d, wps.timestamp: %d, UPDATE_INTERVAL: %d ", last_timestamp, wps.timestamp, UPDATE_INTERVAL);
+ if ((wps.timestamp - last_timestamp) > UPDATE_INTERVAL)
+ nps_set_last_position(wps);
}
static void nps_set_status(lbs_server_s *lbs_server, LbsStatus status)
LOG_NPS(DBG_ERR, "lbs_server is NULL!!");
return;
}
- LOG_NPS(DBG_LOW, "Previous status: %d, Current status: %d", lbs_server->status, status);
+ LOG_NPS(DBG_LOW, "status changed : %d --> [%d]", lbs_server->status, status);
if (lbs_server->status == status) {
LOG_NPS(DBG_WARN, "Don't update NPS status");
return;
setting_set_int(VCONFKEY_LOCATION_WPS_STATE, POSITION_OFF);
if (status != LBS_STATUS_AVAILABLE)
- lbs_server->pos.fields = LBS_POSITION_FIELDS_NONE;
+ lbs_server->wps.fields = LBS_POSITION_FIELDS_NONE;
lbs_server_emit_status_changed(lbs_server->lbs_dbus_server, LBS_SERVER_METHOD_NPS, status);
}
-static void nps_update_position(lbs_server_s *lbs_server, NpsManagerPositionExt pos)
+static void nps_update_position(lbs_server_s *lbs_server, NpsManagerPositionExt wps)
{
if (!lbs_server) {
LOG_NPS(DBG_ERR, "lbs-server is NULL!!");
GVariant *accuracy = NULL;
- lbs_server->pos.fields = pos.fields;
- lbs_server->pos.timestamp = pos.timestamp;
- lbs_server->pos.latitude = pos.latitude;
- lbs_server->pos.longitude = pos.longitude;
- lbs_server->pos.altitude = pos.altitude;
- lbs_server->pos.hor_accuracy = pos.hor_accuracy;
- lbs_server->pos.ver_accuracy = pos.ver_accuracy;
+ lbs_server->wps.fields = wps.fields;
+ lbs_server->wps.timestamp = wps.timestamp;
+ lbs_server->wps.latitude = wps.latitude;
+ lbs_server->wps.longitude = wps.longitude;
+ lbs_server->wps.altitude = wps.altitude;
+ lbs_server->wps.hor_accuracy = wps.hor_accuracy;
+ lbs_server->wps.ver_accuracy = wps.ver_accuracy;
- accuracy = g_variant_ref_sink(g_variant_new("(idd)", lbs_server->pos.acc_level, lbs_server->pos.hor_accuracy, lbs_server->pos.ver_accuracy));
+ accuracy = g_variant_ref_sink(g_variant_new("(idd)", lbs_server->wps.acc_level, lbs_server->wps.hor_accuracy, lbs_server->wps.ver_accuracy));
- LOG_NPS(DBG_LOW, "time:%d", lbs_server->pos.timestamp);
+ LOG_NPS(DBG_LOW, "[WPS] time: %d, latitude : %.6lf, longitude : %.6lf", lbs_server->wps.timestamp, lbs_server->wps.latitude, lbs_server->wps.longitude);
#ifdef TIZEN_DEVICE
if (lbs_server->is_fused_running)
- send_wps_position_to_fused_engine(pos.timestamp, pos.latitude, pos.longitude, pos.hor_accuracy, pos.ver_accuracy);
+ send_wps_position_to_fused_engine(wps.timestamp, wps.latitude, wps.longitude, wps.hor_accuracy, wps.ver_accuracy);
#endif
lbs_server_emit_position_changed(lbs_server->lbs_dbus_server, LBS_SERVER_METHOD_NPS,
- lbs_server->pos.fields, lbs_server->pos.timestamp, lbs_server->pos.latitude,
- lbs_server->pos.longitude, lbs_server->pos.altitude, lbs_server->pos.speed,
- lbs_server->pos.direction, 0.0, accuracy);
+ lbs_server->wps.fields, lbs_server->wps.timestamp, lbs_server->wps.latitude,
+ lbs_server->wps.longitude, lbs_server->wps.altitude, lbs_server->wps.speed,
+ lbs_server->wps.direction, 0.0, accuracy);
g_variant_unref(accuracy);
}
nps_set_status(lbs_server, LBS_STATUS_AVAILABLE);
- NpsManagerPositionExt pos;
- memset(&pos, 0x00, sizeof(NpsManagerPositionExt));
+ NpsManagerPositionExt wps;
+ memset(&wps, 0x00, sizeof(NpsManagerPositionExt));
- pos.timestamp = timestamp;
+ wps.timestamp = timestamp;
if (location.latitude) {
- pos.fields |= LBS_POSITION_EXT_FIELDS_LATITUDE;
- pos.latitude = location.latitude;
+ wps.fields |= LBS_POSITION_EXT_FIELDS_LATITUDE;
+ wps.latitude = location.latitude;
}
if (location.longitude) {
- pos.fields |= LBS_POSITION_EXT_FIELDS_LONGITUDE;
- pos.longitude = location.longitude;
+ wps.fields |= LBS_POSITION_EXT_FIELDS_LONGITUDE;
+ wps.longitude = location.longitude;
}
if (location.altitude) {
- pos.fields |= LBS_POSITION_EXT_FIELDS_ALTITUDE;
- pos.altitude = location.altitude;
+ wps.fields |= LBS_POSITION_EXT_FIELDS_ALTITUDE;
+ wps.altitude = location.altitude;
}
if (location.speed >= 0) {
- pos.fields |= LBS_POSITION_EXT_FIELDS_SPEED;
- pos.speed = location.speed;
+ wps.fields |= LBS_POSITION_EXT_FIELDS_SPEED;
+ wps.speed = location.speed;
}
if (location.bearing >= 0) {
- pos.fields |= LBS_POSITION_EXT_FIELDS_DIRECTION;
- pos.direction = location.bearing;
+ wps.fields |= LBS_POSITION_EXT_FIELDS_DIRECTION;
+ wps.direction = location.bearing;
}
- pos.acc_level = LBS_ACCURACY_LEVEL_STREET;
- pos.hor_accuracy = location.hpe;
- pos.ver_accuracy = vertical_accuracy;
+ wps.acc_level = LBS_ACCURACY_LEVEL_STREET;
+ wps.hor_accuracy = location.hpe;
+ wps.ver_accuracy = vertical_accuracy;
- nps_update_position(lbs_server, pos);
+ nps_update_position(lbs_server, wps);
- nps_set_position(lbs_server, pos);
+ nps_set_position(lbs_server, wps);
return FALSE;
}
if (lbs_server->token != NULL) {
LOG_NPS(DBG_LOW, "Token = %s", lbs_server->token);
int ret = get_nps_plugin_module()->offlineLocation((unsigned char *)key,
- NPS_UNIQUE_ID_LEN, lbs_server->token, 0,
- __nps_callback, lbs_server);
+ NPS_UNIQUE_ID_LEN, lbs_server->token, 0, __nps_callback, lbs_server);
+
if (ret) {
if (lbs_server->is_nps_running) {
LOG_NPS(DBG_LOW, "offlineLocation() called nps_callback successfully.");
}
static gboolean location_source_selector(lbs_server_s *lbs_server, gint fused_mode);
-static void plugin_status_controller(lbs_server_s *lbs_server);
+static gboolean plugin_status_controller(lbs_server_s *lbs_server);
static void request_plugin_interval(lbs_server_s *lbs_server);
static void start_tracking(lbs_server_s *lbs_server, lbs_server_method_e method, gint fused_mode)
if (lbs_server->is_mock_running != MOCK_RUNNING_OFF && lbs_server->is_gps_running == FALSE && lbs_server->is_nps_running == FALSE)
mock_start_tracking(lbs_server);
- if (location_source_selector(lbs_server, fused_mode))
- plugin_status_controller(lbs_server);
+ if (location_source_selector(lbs_server, fused_mode)) {
+ if (plugin_status_controller(lbs_server))
+ break;
+ }
if (nps_is_dummy_plugin_module() != TRUE)
nps_offline_location(lbs_server);
return FALSE;
}
-static void plugin_status_controller(lbs_server_s *lbs_server)
+static gboolean plugin_status_controller(lbs_server_s *lbs_server)
{
LOG_FUNC;
+ gboolean ret = FALSE;
if (lbs_server->current_location_source == LOCATION_SOURCE_GPS) {
LOG_FUSED(DBG_LOW, "-->> LOCATION_SOURCE_GPS");
if (lbs_server->is_gps_running == FALSE)
- gps_plugin_start(lbs_server);
+ ret = gps_plugin_start(lbs_server);
if (lbs_server->is_nps_running)
nps_plugin_stop(lbs_server);
gps_plugin_stop(lbs_server);
if (lbs_server->is_nps_running == FALSE)
- nps_plugin_start(lbs_server);
+ ret = nps_plugin_start(lbs_server);
} else if (lbs_server->current_location_source == LOCATION_SOURCE_BOTH) {
LOG_FUSED(DBG_LOW, "-->> LOCATION_SOURCE_BOTH");
if (lbs_server->is_gps_running == FALSE)
- gps_plugin_start(lbs_server);
+ ret = gps_plugin_start(lbs_server);
if (lbs_server->is_nps_running == FALSE)
- nps_plugin_start(lbs_server);
+ ret = nps_plugin_start(lbs_server);
} else if (lbs_server->current_location_source == LOCATION_SOURCE_NONE) {
LOG_FUSED(DBG_LOW, "-->> LOCATION_SOURCE_NONE");
if (lbs_server->is_nps_running)
nps_plugin_stop(lbs_server);
}
+
+ return ret;
}
static void find_min_interval_foreach_cb(gpointer key, gpointer value, gpointer userdata)
lbs_server->period = 5000;
nps_set_status(lbs_server, LBS_STATUS_UNAVAILABLE);
- lbs_server->pos.fields = LBS_POSITION_EXT_FIELDS_NONE;
- lbs_server->pos.timestamp = 0;
- lbs_server->pos.latitude = 0.0;
- lbs_server->pos.longitude = 0.0;
- lbs_server->pos.altitude = 0.0;
- lbs_server->pos.acc_level = LBS_POSITION_EXT_FIELDS_NONE;
- lbs_server->pos.hor_accuracy = -1.0;
- lbs_server->pos.ver_accuracy = -1.0;
+ lbs_server->wps.fields = LBS_POSITION_EXT_FIELDS_NONE;
+ lbs_server->wps.timestamp = 0;
+ lbs_server->wps.latitude = 0.0;
+ lbs_server->wps.longitude = 0.0;
+ lbs_server->wps.altitude = 0.0;
+ lbs_server->wps.acc_level = LBS_POSITION_EXT_FIELDS_NONE;
+ lbs_server->wps.hor_accuracy = -1.0;
+ lbs_server->wps.ver_accuracy = -1.0;
lbs_server->last_pos.timestamp = 0;
lbs_server->last_pos.latitude = 0.0;