return TRUE;
}
-static void _gps_plugin_handler_init(gps_server_t *server, char *module_name)
+static gboolean _gps_plugin_handler_init(gps_server_t *server, char *module_name)
{
if (module_name == NULL) {
LOG_GPS(DBG_ERR, "Fail : module_name is NULL");
- return;
+ return FALSE;
}
server->gps_plugin.handle = NULL;
server->gps_plugin.name = (char *)malloc(strlen(module_name) + 1);
- g_return_if_fail(server->gps_plugin.name);
+ g_return_val_if_fail(server->gps_plugin.name, FALSE);
g_strlcpy(server->gps_plugin.name, module_name, strlen(module_name) + 1);
+
+ return TRUE;
}
static void _gps_plugin_handler_deinit(gps_server_t *server)
server = _initialize_gps_data();
if (server == NULL)
return -1;
+
check_plugin_module(module_name);
- _gps_plugin_handler_init(server, module_name);
+ if (!_gps_plugin_handler_init(server, module_name)) {
+ LOG_GPS(DBG_ERR, "Fail to init plugin handle");
+ return -1;
+ }
+
_gps_get_nmea_replay_mode(server);
_gps_notify_params(server);
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_NPS_LOC_ITEM)
+ 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;
+ default:
break;
+ }
+ if (++index == MAX_NPS_LOC_ITEM) break;
last_location[index] = (char *)strtok_r(NULL, ";", &last);
}
-
- if (index != MAX_NPS_LOC_ITEM) {
- MOD_NPS_LOGD("Error item index");
- 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);
}
}
- level = LOCATION_ACCURACY_LEVEL_STREET;
-
if (timestamp)
status = LOCATION_STATUS_3D_FIX;
else
return LOCATION_ERROR_NOT_AVAILABLE;
+ level = LOCATION_ACCURACY_LEVEL_STREET;
*position = location_position_new((guint) timestamp, latitude, longitude, altitude, status);
*velocity = location_velocity_new((guint) timestamp, speed, direction, 0.0);
*accuracy = location_accuracy_new(level, hor_accuracy, -1.0);