snprintf(location, sizeof(location), "%s", str);
free(str);
+ index = 0;
last_location[index] = (char *)strtok_r(location, ";", &last);
- while (last_location[index++] != NULL) {
- if (index == MAX_GPS_LOC_ITEM)
- break;
+ while (last_location[index] != NULL) {
+ switch (index) {
+ case 0:
+ last_pos->latitude = strtod(last_location[index], NULL);
+ break;
+ case 1:
+ last_pos->longitude = strtod(last_location[index], NULL);
+ break;
+ case 2:
+ last_pos->altitude = strtod(last_location[index], NULL);
+ break;
+ case 3:
+ last_pos->speed = strtod(last_location[index], NULL);
+ break;
+ case 4:
+ last_pos->bearing = strtod(last_location[index], NULL);
+ break;
+ case 5:
+ last_pos->hor_accuracy = strtod(last_location[index], NULL);
+ break;
+ case 6:
+ last_pos->ver_accuracy = strtod(last_location[index], NULL);
+ break;
+ default:
+ break;
+ }
+ if (++index == MAX_GPS_LOC_ITEM) break;
last_location[index] = (char *)strtok_r(NULL, ";", &last);
}
- index = 0;
-
- last_pos->timestamp = timestamp;
- last_pos->latitude = strtod(last_location[index++], NULL);
- last_pos->longitude = strtod(last_location[index++], NULL);
- last_pos->altitude = strtod(last_location[index++], NULL);
- last_pos->speed = strtod(last_location[index++], NULL);
- last_pos->bearing = strtod(last_location[index++], NULL);
- last_pos->hor_accuracy = strtod(last_location[index++], NULL);
- last_pos->ver_accuracy = strtod(last_location[index], NULL);
LOG_GPS(DBG_LOW, "get_last_position[%d]", last_pos->timestamp);
}
free(str);
last_location[index] = (char *)strtok_r(location, ";", &last);
- while (last_location[index++] != NULL) {
- if (index == MAX_NPS_LOC_ITEM)
- break;
- last_location[index] = (char *)strtok_r(NULL, ";", &last);
- }
- index = 0;
-
lbs_server_nps->last_pos.timestamp = timestamp;
- lbs_server_nps->last_pos.latitude = strtod(last_location[index++], NULL);
- lbs_server_nps->last_pos.longitude = strtod(last_location[index++], NULL);
- lbs_server_nps->last_pos.altitude = strtod(last_location[index++], NULL);
- lbs_server_nps->last_pos.speed = strtod(last_location[index++], NULL);
- lbs_server_nps->last_pos.direction = strtod(last_location[index++], NULL);
- lbs_server_nps->last_pos.hor_accuracy = strtod(last_location[index], NULL);
+ while (last_location[index] != NULL) {
+ switch (index) {
+ case 0:
+ lbs_server_nps->last_pos.latitude = strtod(last_location[index], NULL);
+ break;
+ case 1:
+ lbs_server_nps->last_pos.longitude = strtod(last_location[index], NULL);
+ break;
+ case 2:
+ lbs_server_nps->last_pos.altitude = strtod(last_location[index], NULL);
+ break;
+ case 3:
+ lbs_server_nps->last_pos.speed = strtod(last_location[index], NULL);
+ break;
+ case 4:
+ lbs_server_nps->last_pos.direction = strtod(last_location[index], NULL);
+ break;
+ case 5:
+ lbs_server_nps->last_pos.hor_accuracy = strtod(last_location[index], NULL);
+ break;
+ default:
+ break;
+ }
+ if (++index == MAX_NPS_LOC_ITEM) break;
+ last_location[index] = (char *)strtok_r(NULL, ";", &last);
+ }
LOG_NPS(DBG_LOW, "get nps_last_position timestamp : %d", lbs_server_nps->last_pos.timestamp);
}
static void _deinitialize_gps_data(void)
{
+ if (g_gps_server == NULL) return;
+
if (g_gps_server->pos_data != NULL) {
free(g_gps_server->pos_data);
g_gps_server->pos_data = NULL;
g_gps_server->nmea_data = NULL;
}
- if (g_gps_server != NULL) {
- free(g_gps_server);
- g_gps_server = NULL;
- }
+ free(g_gps_server);
+ g_gps_server = NULL;
}
int initialize_server(int argc, char **argv)
}
}
-#if 0
-static void nmea_callback(GeoclueNmea *nmea, int timestamp, char *data, gpointer userdata)
-{
-}
-#endif
-
static void position_callback(GVariant *param, void *user_data)
{
MOD_LOGD("position_callback");
MOD_LOGE("Fail to create lbs_client_h. Error[%d]", ret);
return LOCATION_ERROR_NOT_AVAILABLE;
}
- MOD_LOGD("gps-manger(%x)", gps_manager);
- MOD_LOGD("pos_cb (%x), user_data(%x)", gps_manager->pos_cb, gps_manager->userdata);
+ MOD_LOGD("gps-manger(%p)", gps_manager);
+ MOD_LOGD("pos_cb (%p), user_data(%p)", gps_manager->pos_cb, gps_manager->userdata);
ret = lbs_client_start(gps_manager->lbs_client, pos_update_interval, LBS_CLIENT_LOCATION_CB | LBS_CLIENT_LOCATION_STATUS_CB | LBS_CLIENT_SATELLITE_CB | LBS_CLIENT_NMEA_CB, on_signal_callback, gps_manager);
if (ret != LBS_CLIENT_ERROR_NONE) {
snprintf(location, sizeof(location), "%s", str);
free(str);
+ index = 0;
last_location[index] = (char *)strtok_r(location, ";", &last);
- while (last_location[index++] != NULL) {
- if (index == MAX_GPS_LOC_ITEM)
- break;
+ while (last_location[index] != NULL) {
+ switch (index) {
+ case 0:
+ latitude = strtod(last_location[index], NULL);
+ break;
+ case 1:
+ longitude = strtod(last_location[index], NULL);
+ break;
+ case 2:
+ altitude = strtod(last_location[index], NULL);
+ break;
+ case 3:
+ speed = strtod(last_location[index], NULL);
+ break;
+ case 4:
+ direction = strtod(last_location[index], NULL);
+ break;
+ case 5:
+ hor_accuracy = strtod(last_location[index], NULL);
+ break;
+ case 6:
+ ver_accuracy = strtod(last_location[index], NULL);
+ break;
+ default:
+ break;
+ }
+ if (++index == MAX_GPS_LOC_ITEM) break;
last_location[index] = (char *)strtok_r(NULL, ";", &last);
}
- if (index != MAX_GPS_LOC_ITEM) {
- return LOCATION_ERROR_NOT_AVAILABLE;
- }
- index = 0;
-
- latitude = strtod(last_location[index++], NULL);
- longitude = strtod(last_location[index++], NULL);
- altitude = strtod(last_location[index++], NULL);
- speed = strtod(last_location[index++], NULL);
- direction = strtod(last_location[index++], NULL);
- hor_accuracy = strtod(last_location[index++], NULL);
- ver_accuracy = strtod(last_location[index], NULL);
}
}