*/
typedef enum
{
- LOCATIONS_METHOD_NONE=0, /**< Undefined method. */
+ LOCATIONS_METHOD_NONE=-1, /**< Undefined method. */
LOCATIONS_METHOD_HYBRID, /**< This method selects the best method available at the moment. */
LOCATIONS_METHOD_GPS, /**< This method uses Global Positioning System. */
LOCATIONS_METHOD_WPS, /**< This method uses Wifi Positioning System. */
typedef void(*location_zone_changed_cb )(location_boundary_state_e state, double latitude, double longitude, double altitude, time_t timestamp, void *user_data);
/**
+ * @brief Checks whether the given location method is avaliable or not.
+ * @param[in] method The location method to be checked
+ * @return @c true if the specified location method is supported, \n else @c false
+ * @see location_manager_create()
+ * @see location_manager_get_method()
+ */
+bool location_manager_is_supported_method(location_method_e method);
+
+
+/**
* @brief Creates a new location manager.
* @remarks @a manager must be released location_manager_destroy() by you.
* @param[in] method The location method
* @details
* The result is current altitude, latitude, and longitude, with a measurement timestamp.
*
- * If altitude is negative, only altitude and latitude are available (fix status is 2D).
- * If altitude is positive, fix status is 3D and returned altitude value is the result of measurement.
+ * If @a altitude is negative, only altitude and latitude are available (fix status is 2D).
+ * If @a altitude is positive, fix status is 3D and returned altitude value is the result of measurement.
*
* @param[in] manager The location manager handle
* @param[out] altitude The current altitude (meters)
int location_manager_get_accuracy(location_manager_h manager, location_accuracy_level_e *level, double *horizontal, double *vertical);
/**
+ * @brief Gets the last known position information which is recorded.
+ * @details
+ * The @altitude, @latitude, @longitude, and @timestamp values should be 0, if there is no record of any previous position information.
+ * @param[in] manager The location manager handle
+ * @param[out] altitude The last known altitude (meters)
+ * @param[out] latitude The last known latitude [-90.0 ~ 90.0] (degrees)
+ * @param[out] longitude The last known longitude [-180.0 ~ 180.0] (degrees)
+ * @param[out] timestamp The timestamp (time when measurement took place)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #LOCATIONS_ERROR_NONE Successful
+ * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument
+ * @pre The location manager handle must be created by location_manager_create()
+ */
+int location_manager_get_last_known_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, time_t *timestamp);
+
+/**
* @brief Registers a callback function to be invoked every 1 second with updated position information.
*
* @param[in] manager The location manager handle
* @param[in] callback The callback function to register
+ * @param[in] interval The interval [1 ~ 120] (seconds)
* @param[in] user_data The user data to be passed to the callback function
* @return 0 on success, otherwise a negative error value.
* @retval #LOCATIONS_ERROR_NONE Successful
* @see location_manager_unset_position_updated_cb()
* @see location_position_updated_cb()
*/
-int location_manager_set_position_updated_cb(location_manager_h manager, location_position_updated_cb callback, void *user_data);
+int location_manager_set_position_updated_cb(location_manager_h manager, location_position_updated_cb callback, int interval, void *user_data);
/**
* @brief Unregisters the callback function.
msg = "LOCATIONS_ERROR_NONE";
break;
case LOCATION_ERROR_NETWORK_FAILED:
+ case LOCATION_ERROR_NETWORK_NOT_CONNECTED:
ret = LOCATIONS_ERROR_NETWORK_FAILED;
msg = "LOCATIONS_ERROR_NETWORK_FAILED";
break;
* Public Implementation
*/
+bool location_manager_is_supported_method(location_method_e method)
+{
+ LocationMethod _method = LOCATION_METHOD_NONE;
+ switch(method)
+ {
+ case LOCATIONS_METHOD_HYBRID :
+ _method = LOCATION_METHOD_HYBRID;
+ break;
+ case LOCATIONS_METHOD_GPS:
+ _method = LOCATION_METHOD_GPS;
+ break;
+ case LOCATIONS_METHOD_WPS :
+ _method = LOCATION_METHOD_WPS;
+ break;
+ case LOCATIONS_METHOD_SPS :
+ _method = LOCATION_METHOD_SPS;
+ break;
+ default :
+ _method = LOCATION_METHOD_NONE;
+ break;
+ }
+ return location_is_supported_method(_method);
+}
+
int location_manager_create(location_method_e method, location_manager_h* manager)
{
LOCATIONS_NULL_ARG_CHECK(manager);
return LOCATIONS_ERROR_NONE;
}
-int location_manager_set_position_updated_cb(location_manager_h manager, location_position_updated_cb callback, void *user_data)
+int location_manager_get_last_known_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, time_t *timestamp)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(altitude);
+ LOCATIONS_NULL_ARG_CHECK(latitude);
+ LOCATIONS_NULL_ARG_CHECK(longitude);
+ LOCATIONS_NULL_ARG_CHECK(timestamp);
+
+ location_manager_s *handle = (location_manager_s*)manager;
+
+ LocationMethod _method = LOCATION_METHOD_NONE;
+ g_object_get(handle->object, "method", &_method, NULL);
+
+ int ret;
+ LocationLastPosition pos;
+ ret = location_get_last_known_position(handle->object, _method, &pos);
+ if (ret == LOCATION_ERROR_UNKNOWN)
+ {
+ *altitude = 0;
+ *latitude = 0;
+ *longitude =0;
+ *timestamp = 0;
+ LOGI("[%s] There is no record of any previous position information. ",__FUNCTION__);
+ return LOCATIONS_ERROR_NONE;
+ }
+ else if( ret != LOCATION_ERROR_NONE)
+ {
+ return _convert_error_code(ret,(char*)__FUNCTION__);
+ }
+
+ *altitude = pos.altitude;
+ *latitude = pos.latitude;
+ *longitude = pos.longitude;
+ *timestamp = pos.timestamp;
+ return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_set_position_updated_cb(location_manager_h manager, location_position_updated_cb callback, int interval, void *user_data)
{
+ LOCATIONS_CHECK_CONDITION(interval>=1 && interval<=120, LOCATIONS_ERROR_INVALID_PARAMETER,"LOCATIONS_ERROR_INVALID_PARAMETER");
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ location_manager_s *handle = (location_manager_s*)manager;
+ g_object_set(handle->object, "update-interval", interval, NULL);
return _set_callback(_LOCATIONS_EVENT_TYPE_POSITION,manager,callback,user_data);
}