From: chakradhar pogiri Date: Wed, 13 Jan 2021 10:28:03 +0000 (+0530) Subject: Location hal : Implementation of HAL interface X-Git-Tag: submit/tizen/20210219.112041^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_7.0;p=platform%2Fhal%2Fapi%2Flocation.git Location hal : Implementation of HAL interface Change-Id: Ie5fe1ab15e2612107e15c5e64d3c8f7f619ab7e7 --- diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6ab7035 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,51 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-api-location C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}/bin") +SET(INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include") +SET(LIBDIR ${CMAKE_LIBDIR_PREFIX}) +SET(VERSION_MAJOR 0) +SET(VERSION "${VERSION_MAJOR}.1.0") + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${PREFIX}/bin") +SET(INCLUDEDIR "${PREFIX}/include") +SET(LIBDIR ${CMAKE_LIBDIR_PREFIX}) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +SET(PKG_MODULES + dlog + hal-api-common +) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED ${PKG_MODULES}) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fPIE") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -lrt") +SET(CMAKE_EXE_LINKER_FLAGS "-pie") + +ADD_DEFINITIONS("-DLOG_TAG=\"HALAPI_LOCATION\"") + +SET(SRCS + src/hal-api-location.c) + +ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl -lm -Wl,-z,nodelete,--no-undefined) +SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) + +CONFIGURE_FILE( ${PROJECT_NAME}.pc ${PROJECT_NAME}.pc @ONLY) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-location.h DESTINATION ${INCLUDEDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-location-interface.h DESTINATION ${INCLUDEDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..247c97d --- /dev/null +++ b/LICENSE @@ -0,0 +1,203 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/hal-api-location.pc b/hal-api-location.pc new file mode 100644 index 0000000..3e5cabe --- /dev/null +++ b/hal-api-location.pc @@ -0,0 +1,16 @@ +# Package Information for pkg-config + +package_name=hal-api-location +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@/hal +libdir=@LIBDIR@/hal +includedir=@INCLUDEDIR@/hal + +Name: ${package_name} +Description: ${package_name} interface +Version: @VERSION@ + +Requires: +Libs: -L${libdir} -l${package_name} +Cflags: -I${includedir} +CXXflags: -I${includedir} diff --git a/include/common.h b/include/common.h new file mode 100644 index 0000000..b69f8b8 --- /dev/null +++ b/include/common.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#include +#define _D(fmt, args...) SLOGD(fmt, ##args) +#define _I(fmt, args...) SLOGI(fmt, ##args) +#define _W(fmt, args...) SLOGW(fmt, ##args) +#define _E(fmt, args...) SLOGE(fmt, ##args) + +#endif /* __COMMON_H__ */ diff --git a/include/hal-location-interface.h b/include/hal-location-interface.h new file mode 100644 index 0000000..ded2e59 --- /dev/null +++ b/include/hal-location-interface.h @@ -0,0 +1,684 @@ +/* + * HAL (Hardware Abstract Layer) Location API + * + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __HAL_LOCATION_INTERFACE__ +#define __HAL_LOCATION_INTERFACE__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_REQUESTER_ID_LEN (128) +#define MAX_CLIENT_NAME_LEN (128) +#define MAX_SUPL_URL_LEN (128) + +/** Maximum number of satellite which is in used */ +#define MAX_GPS_NUM_SAT_USED (12) + +/** Maximum number of satellite which is in view */ +#define MAX_GPS_NUM_SAT_IN_VIEW (32) + +/** + * This enumeration has error type. + */ +typedef enum { + GPS_ERR_NONE = 0, /**< Error None */ + GPS_ERR_TIMEOUT = -100, /**< pos_cb error GPS Timeout */ + GPS_ERR_OUT_OF_SERVICE = -101, /**< pos_cb error GPS out of service */ + GPS_ERR_COMMUNICATION = -200, /**< Plugin event callback error */ +} gps_error_t; + +/** + * This enumeration has geofence service status. + */ +typedef enum { + GEOFENCE_STATUS_UNAVAILABLE = 0, + GEOFENCE_STATUS_AVAILABLE = 1, +} geofence_status_t; + +/** + * This enumeration has geofence service error type. + */ +typedef enum { + GEOFENCE_ERR_NONE = 0, + GEOFENCE_ERR_TOO_MANY_GEOFENCE = -100, + GEOFENCE_ERR_ID_EXISTS = -101, + GEOFENCE_ERR_ID_UNKNOWN = -200, + GEOFENCE_ERR_INVALID_TRANSITION = -300, + GEOFENCE_ERR_UNKNOWN = -400, +} geofence_error_t; + +/** + * This enumeration has XTRA request error type (wearable profile use only). + */ +typedef enum { + XTRA_REQUEST_ERR_NONE = 0, + XTRA_REQUEST_ERR_UNKNOWN = -100, +} xtra_request_error_t; + +/** + * This structure defines the GPS position data. + */ +typedef struct { + time_t timestamp; /**< Timestamp */ + double latitude; /**< Latitude data (in degree) */ + double longitude; /**< Longitude data (in degree) */ + double altitude; /**< Altitude data (in meter) */ + double speed; /**< Speed (in m/s) */ + double bearing; /**< Direction from true north(in degree) */ + double hor_accuracy; /**< Horizontal position error(in meter) */ + double ver_accuracy; /**< Vertical position error(in meter) */ +} pos_data_t; + +/** + * This structure defines the GPS batch data. + */ +typedef struct { + int num_of_location; /**< Number of batch data */ + pos_data_t *data; +} batch_data_t; + +/** + * This structure defines the satellite data. + */ +typedef struct { + int prn; /**< Pseudo Random Noise code of satellite */ + int snr; /**< Signal to Noise Ratio */ + int elevation; /**< Elevation */ + int azimuth; /**< Degrees from true north */ + int used; /**< Satellite was used for position fix */ +} sv_info_t; + +/** + * This structure defines the GPS satellite in view data. + */ +typedef struct { + time_t timestamp; /**< Timestamp */ + unsigned char pos_valid; /**< TRUE, if position is valid */ + int num_of_sat; /**< Number of satellites in view */ + sv_info_t sat[MAX_GPS_NUM_SAT_IN_VIEW]; /**< Satellite information */ +} sv_data_t; + +/** + * This structure defines the NMEA data. + */ +typedef struct { + time_t timestamp; /**< Timestamp */ + int len; /**< NMEA data length */ + char *data; /**< Raw NMEA data */ +} nmea_data_t; + +/** + * This structure defines the geofence data. + */ +typedef struct { + int geofence_id; /**< Geofence ID */ + double latitude; /**< Latitude data (in degree) */ + double longitude; /**< Longitude data (in degree) */ + int radius; /**< Radius data (in meters) */ +} geofence_data_t; + +typedef struct { + char imsi[16]; /**< IMSI */ + int mcc; /**< MCC */ + int mnc; /**< MNC */ + int lac; /**< Location area code */ + int psc; /**< Primary Srambling code */ + int cid; /**< Cell id */ +} mobile_info_t; + +/** + * This enumeration has GPS session type. + */ +typedef enum { + GPS_SESSION_SINGLE_FIX = 0, /**< Single fix starting */ + GPS_SESSION_TRACKING_MODE /**< Tracking mode starting */ +} gps_session_t; + +/** + * This enumeration has GPS operation mode. + */ +typedef enum { + GPS_OPERATION_STANDALONE = 0, /**< GPS standalone (no assistance) */ + GPS_OPERATION_MS_BASED, /**< MS-Based AGPS */ + GPS_OPERATION_MS_ASSISTED /**< MS-Assisted AGPS */ +} gps_operation_t; + +/** + * This enumeration has GPS starting type. + */ +typedef enum { + GPS_STARTING_HOT_ = 0, /**< Hot start */ + GPS_STARTING_COLD, /**< Cold start */ + GPS_STARTING_NONE /**< None */ +} gps_starting_t; + +/** + * This enumeration has the SSL mode. + */ +typedef enum { + AGPS_SSL_DISABLE = 0, /**< SSL disable */ + AGPS_SSL_ENABLE /**< SSL enable */ +} agps_ssl_mode_t; + +/** + * This enumeration has the SSL certification type. + */ +typedef enum { + AGPS_CERT_VERISIGN = 0, + AGPS_CERT_THAWTE, + AGPS_CERT_CMCC, + AGPS_CERT_SPIRENT_TEST, + AGPS_CERT_THALES_TEST, + AGPS_CERT_CMCC_TEST, + AGPS_CERT_BMC_TEST, + AGPS_CERT_GOOGLE +} agps_ssl_cert_type_t; + +/** + * This enumeration has the verification confirm type. + */ +typedef enum { + AGPS_VER_CNF_YES = 0x00, /**< Specifies Confirmation yes. */ + AGPS_VER_CNF_NO = 0x01, /**< Specifies Confirmation no. */ + AGPS_VER_CNF_NORESPONSE = 0x02 /**< Specifies Confirmation no response. */ +} agps_verification_cnf_type_t; + +/** + * This enumeration has the zone in/out type. + */ +typedef enum { + GEOFENCE_ZONE_OUT = 0x00, + GEOFENCE_ZONE_IN = 0x01, + GEOFENCE_ZONE_UNCERTAIN = 0x02 +} geofence_zone_state_t; + +/** + * This structure is used to get the Extra Fix request parameters. + */ +typedef struct { + int accuracy; /**< accuracy */ + int tbf; /**< time between fixes */ + int num_fixes; /**< num fixes */ + unsigned char timeout; /**< session timeout */ +} gps_qos_param_t; + +/** + * GPS asynchronous event type + */ +typedef enum { + GPS_EVENT_START_SESSION = 0x0000, /**< The session is started */ + GPS_EVENT_STOP_SESSION, /**< The session is stopped */ + GPS_EVENT_CHANGE_INTERVAL, /**< Change updating interval */ + GPS_EVENT_REPORT_POSITION = 0x0100, /**< Bring up GPS position data */ + GPS_EVENT_REPORT_SATELLITE, /**< Bring up GPS SV data */ + GPS_EVENT_REPORT_NMEA, /**< Bring up GPS NMEA data */ + GPS_EVENT_REPORT_BATCH, /**< Bring up GPS batch data */ + GPS_EVENT_SET_OPTION = 0x0200, /**< The option is set */ + GPS_EVENT_GET_REF_LOCATION = 0x0300, /**< Get the reference location for AGPS */ + GPS_EVENT_GET_IMSI, /**< Get IMSI for identification */ + GPS_EVENT_GET_REF_TIME, /**< Get the reference time for AGPS */ + GPS_EVENT_OPEN_DATA_CONNECTION = 0x0400, /**< Request opening data network connection */ + GPS_EVENT_CLOSE_DATA_CONNECTION, /**< Request closing data network connection */ + GPS_EVENT_DNS_LOOKUP_IND, /**< Request resolving host name */ + GPS_EVENT_AGPS_VERIFICATION_INDI, /**< Verification indicator for AGPS is required */ + GPS_EVENT_FACTORY_TEST = 0x0500, /**< Factory test is done */ + GPS_EVENT_GEOFENCE_TRANSITION = 0x0600, /**< Geofence transition is occured */ + GPS_EVENT_GEOFENCE_STATUS, /**< Report geofence serivce status */ + GPS_EVENT_ADD_GEOFENCE, /**< Geofence is added(Start geofence) */ + GPS_EVENT_DELETE_GEOFENCE, /**< Geofence is deleted(Stop geofence) */ + GPS_EVENT_PAUSE_GEOFENCE, /**< Geofence is paused */ + GPS_EVENT_RESUME_GEOFENCE, /**< Geofence is resumed */ + GPS_EVENT_REQUEST_XTRA = 0x0700, /**< XTRA is requested. Used by Wearable profile only. */ + GPS_EVENT_ERR_CAUSE = 0xFFFF /**< Some error is occurred */ +} gps_event_id_t; + +/** + * Start session response event data + */ +typedef struct { + gps_error_t error; +} gps_start_session_ev_info_t; + +/** + * Response of stop session + */ +typedef struct { + gps_error_t error; +} gps_stop_session_ev_info_t; + +/** + * Set option response event data + */ +typedef struct { + gps_error_t error; +} gps_set_option_ev_info_t; + +typedef struct { + gps_error_t error; +} gps_change_interval_ev_info_t; + +/** + * Position data from GPS + */ +typedef struct { + gps_error_t error; + pos_data_t pos; +} gps_pos_ev_info_t; + +/** + * Batch data from GPS + */ +typedef struct { + gps_error_t error; + batch_data_t batch; +} gps_batch_ev_info_t; + +/** + * Satellite data from GPS + */ +typedef struct { + gps_error_t error; + sv_data_t sv; +} gps_sv_ev_info_t; + +/** + * NMEA data from GPS + */ +typedef struct { + gps_error_t error; + nmea_data_t nmea; +} gps_nmea_ev_info_t; + +/** + * This enumeration defines values for notify type for GPS verification message. + */ +typedef enum { + AGPS_NOTIFY_NO_VERIFY = 0x00, + AGPS_NOTIFY_ONLY = 0x01, + AGPS_NOTIFY_ALLOW_NORESPONSE = 0x02, + AGPS_NOTIFY_NOTALLOW_NORESPONSE = 0x03, + AGPS_NOTIFY_PRIVACY_NEEDED = 0x04, + AGPS_NOTIFY_PRIVACY_OVERRIDE = 0x05 +} agps_notify_t; + +/** + * This enumeration defines values for requester type for GPS verification message + */ +typedef enum { + AGPS_REQ_LOGICAL_NAME = 0x00, /**< Specifies logical name. */ + AGPS_REQ_EMAIL_ADDR = 0x01, /**< Specifies e-mail address */ + AGPS_REQ_MSISDN = 0x02, /**< Specifies MSISDN number */ + AGPS_REQ_URL = 0x03, /**< Specifies URL */ + AGPS_REQ_SIPURL = 0x04, /**< Specifies SIPURL */ + AGPS_REQ_MIN = 0x05, /**< Specifies MIN */ + AGPS_REQ_MDN = 0x06, /**< Specifies MDN */ + AGPS_REQ_UNKNOWN = 0x07 /**< Unknown request */ +} agps_supl_format_t; + +/** + * This enumeration defines values for GPS encoding type for GPS verification message. + */ +typedef enum { + AGPS_ENCODE_ISO646IRV = 0x00, + AGPS_ENCODE_ISO8859 = 0x01, + AGPS_ENCODE_UTF8 = 0x02, + AGPS_ENCODE_UTF16 = 0x03, + AGPS_ENCODE_UCS2 = 0x04, + AGPS_ENCODE_GSMDEFAULT = 0x05, + AGPS_ENCODE_SHIFT_JIS = 0x06, + AGPS_ENCODE_JIS = 0x07, + AGPS_ENCODE_EUC = 0x08, + AGPS_ENCODE_GB2312 = 0x09, + AGPS_ENCODE_CNS11643 = 0x0A, + AGPS_ENCODE_KSC1001 = 0x0B, + AGPS_ENCODE_GERMAN = 0x0C, + AGPS_ENCODE_ENGLISH = 0x0D, + AGPS_ENCODE_ITALIAN = 0x0E, + AGPS_ENCODE_FRENCH = 0x0F, + AGPS_ENCODE_SPANISH = 0x10, + AGPS_ENCODE_DUTCH = 0x11, + AGPS_ENCODE_SWEDISH = 0x12, + AGPS_ENCODE_DANISH = 0x13, + AGPS_ENCODE_PORTUGUESE = 0x14, + AGPS_ENCODE_FINNISH = 0x15, + AGPS_ENCODE_NORWEGIAN = 0x16, + AGPS_ENCODE_GREEK = 0x17, + AGPS_ENCODE_TURKISH = 0x18, + AGPS_ENCODE_HUNGARIAN = 0x19, + AGPS_ENCODE_POLISH = 0x1A, + AGPS_ENCODE_LANGUAGE_UNSPEC = 0xFF +} agps_encoding_scheme_t; + +/** + * This enumeration defines values for GPS encoding type for GPS verification message. + */ +typedef enum { + AGPS_ID_ENCODE_ISO646IRV = 0x00, + AGPS_ID_ENCODE_EXN_PROTOCOL_MSG = 0x01, + AGPS_ID_ENCODE_ASCII = 0x02, + AGPS_ID_ENCODE_IA5 = 0x03, + AGPS_ID_ENCODE_UNICODE = 0x04, + AGPS_ID_ENCODE_SHIFT_JIS = 0x05, + AGPS_ID_ENCODE_KOREAN = 0x06, + AGPS_ID_ENCODE_LATIN_HEBREW = 0x07, + AGPS_ID_ENCODE_LATIN = 0x08, + AGPS_ID_ENCODE_GSM = 0x09 +} agps_requester_id_encoding_t; + +/** + * This structure defines the values for GPS Verification message indication. + */ +typedef struct { + /** Specifies notification type refer enum tapi_gps_notify_type_t */ + agps_notify_t notify_type; + + /** Specifies encoding type refer enum tapi_gps_encoding_type_t */ + agps_supl_format_t supl_format; + + /** Specifies requester type */ + agps_encoding_scheme_t datacoding_scheme; + + agps_requester_id_encoding_t requester_id_encoding; + + /** Specifies requester ID */ + char requester_id[MAX_REQUESTER_ID_LEN]; + + /** Specifies client name */ + char client_name[MAX_CLIENT_NAME_LEN]; + + /** Response timer */ + int resp_timer; +} agps_verification_ev_info_t; + +/** + * Factory test result information + */ +typedef struct { + gps_error_t error; + int prn; + double snr; +} gps_factory_test_ev_info_t; + +/** + * DNS query request information + */ +typedef struct { + gps_error_t error; + char domain_name[MAX_SUPL_URL_LEN]; +} gps_dns_query_ev_info_t; + +/** + * Geofecne transition information + */ +typedef struct { + time_t geofence_timestamp; + int geofence_id; + pos_data_t pos; + geofence_zone_state_t state; +} geofence_transition_ev_info_t; + +/** + * Geofecne status information + */ +typedef struct { + geofence_status_t status; + pos_data_t last_pos; +} geofence_status_ev_info_t; + +/** + * Geofecne event information + */ +typedef struct { + int geofence_id; + geofence_error_t error; +} geofence_event_t; + +/** + * Type of XTRA request. Used by Wearable profile only. + */ +typedef enum { + XTRA_REQUEST_TYPE_NONE = 0x00, + XTRA_REQUEST_TYPE_QCOM = 0x01, + XTRA_REQUEST_TYPE_BRCM = 0x02, + XTRA_REQEUST_TYPE_NUM, +} xtra_request_type_t; + +/** + * XTRA request information. Used by Wearable profile only. + */ +typedef struct { + xtra_request_type_t xtra_id; + xtra_request_error_t error; +} xtra_request_info_t; + +typedef struct { + time_t timeout; +}ref_data_request_info_t; + +/** + * GPS event info + */ +typedef union { + /** Callback related with Response */ + gps_start_session_ev_info_t start_session_rsp; + gps_stop_session_ev_info_t stop_session_rsp; + gps_set_option_ev_info_t set_option_rsp; + gps_change_interval_ev_info_t change_interval_rsp; + + /** Callback related with Indication */ + gps_pos_ev_info_t pos_ind; + gps_sv_ev_info_t sv_ind; + gps_nmea_ev_info_t nmea_ind; + gps_batch_ev_info_t batch_ind; + agps_verification_ev_info_t agps_verification_ind; + + gps_factory_test_ev_info_t factory_test_rsp; + gps_dns_query_ev_info_t dns_query_ind; + + /** Callback related with Geofence. */ + geofence_transition_ev_info_t geofence_transition_ind; + geofence_status_ev_info_t geofence_status_ind; + geofence_event_t geofence_event_rsp; + + /** Callback related with XTRA. Used by Wearable profile only. */ + xtra_request_info_t xtra_request_ind; + ref_data_request_info_t ref_data_req_ind; +} gps_event_data_t; + +/** + * Transport Error Cause + */ +typedef enum { + GPS_FAILURE_CAUSE_NORMAL = 0x00, + GPS_FAILURE_CAUSE_FACTORY_TEST, + GPS_FAILURE_CAUSE_DNS_QUERY, + GPS_FAILURE_CAUSE_LBS_SERVER_FINISH +} gps_failure_reason_t; + +/** + * GPS Event Info + */ +typedef struct { + gps_event_id_t event_id; /**< GPS asynchronous event id */ + gps_event_data_t event_data; /**< GPS event information data */ +} gps_event_info_t; + +/** + * Callback function + * LBS server needs to register a callback function with GPS OEM to receive asynchronous events. + */ +typedef int (*gps_event_cb)(gps_event_info_t *gps_event_info, void *user_data); + +/** + * GPS action type + */ +typedef enum { + GPS_ACTION_SEND_PARAMS = 0x000, + GPS_ACTION_START_SESSION, + GPS_ACTION_STOP_SESSION, + GPS_ACTION_CHANGE_INTERVAL, + + GPS_INDI_SUPL_VERIFICATION, + GPS_INDI_SUPL_DNSQUERY, + + GPS_ACTION_START_FACTTEST, + GPS_ACTION_STOP_FACTTEST, + GPS_ACTION_REQUEST_SUPL_NI, + GPS_ACTION_REQUEST_SUPL_NI_NOMODEM, + GPS_ACTION_DELETE_GPS_DATA, + + GPS_ACTION_ADD_GEOFENCE, + GPS_ACTION_DELETE_GEOFENCE, + GPS_ACTION_PAUSE_GEOFENCE, + GPS_ACTION_RESUME_GEOFENCE, + + GPS_ACTION_DOWNLOAD_XTRA, /* Used by Wearable profile only. */ + GPS_ACTION_CONSUMER_CONNECTED, /* Used by Wearable profile only. */ + GPS_ACTION_CONSUMER_DISCONNECTED, /* Used by Wearable profile only. */ + + GPS_ACTION_CHANGE_INTERVAL_SPORTMODE, + + GPS_ACTION_SET_REF_LOCATION, /* Used by Wearable profile only. */ + GPS_ACTION_SET_REF_TIME, /* Used by Wearable profile only. */ + + GPS_ACTION_START_BATCH, + GPS_ACTION_STOP_BATCH, + GPS_ACTION_ADD_REDUCE_SET, + GPS_ACTION_REMOVE_REDUCE_SET +} gps_action_t; + +/** + * Cell information type + */ +typedef enum { + GPS_CELL_INFO_TYPE_aRFCNPresent = 0, + GPS_CELL_INFO_TYPE_bSICPresent, + GPS_CELL_INFO_TYPE_rxLevPresent, + GPS_CELL_INFO_TYPE_frequencyInfoPresent, + GPS_CELL_INFO_TYPE_cellMeasuredResultPresent, + + GPS_CELL_INFO_TYPE_refMCC, + GPS_CELL_INFO_TYPE_refMNC, + GPS_CELL_INFO_TYPE_refLAC, + GPS_CELL_INFO_TYPE_refCI, + GPS_CELL_INFO_TYPE_refUC, + GPS_CELL_INFO_TYPE_aRFCN, + GPS_CELL_INFO_TYPE_bSIC, + GPS_CELL_INFO_TYPE_rxLev +} agps_cell_info_t; + +/** + * Mobile service type + */ +typedef enum { + SVCTYPE_NONE = 0, /**< Unknown network */ + SVCTYPE_NOSVC, /**< Network in no service */ + SVCTYPE_EMERGENCY, /**< Network emergency */ + SVCTYPE_SEARCH, /**< Network search 1900 */ + SVCTYPE_2G, /**< Network 2G */ + SVCTYPE_2_5G, /**< Network 2.5G */ + SVCTYPE_2_5G_EDGE, /**< Network EDGE */ + SVCTYPE_3G, /**< Network UMTS */ + SVCTYPE_HSDPA /**< Network HSDPA */ +} agps_svc_type_t; + +/** + * SUPL network-initiated information + */ +typedef struct { + char *msg_body; /**< SUPL NI message body */ + int msg_size; /**< SUPL NI message size */ + int status; /**< Return code of Status */ +} agps_supl_ni_info_t; + +/** + * SUPL network-initiated information in case of no-modem + */ +typedef struct { + char *msg_body; /**< SUPL NI message body */ + int msg_size; /**< SUPL NI message size */ + char imsi[16]; /**< IMSI */ + int mcc; /**< MCC */ + int mnc; /**< MNC */ + int lac; /**< Location area code */ + int psc; /**< Primary Srambling code */ + int cid; /**< Cell id */ + int status; /**< Return code of Status */ +} agps_supl_ni_nomodem_info_t; + +/** + * Geofence action data type + */ +typedef struct { + geofence_data_t geofence; + geofence_zone_state_t last_state; + int monitor_states; + int notification_responsiveness_ms; + int unknown_timer_ms; +} geofence_action_data_t; + +typedef struct { + int interval; + int period; /**< Emulator */ + int session_status; /**< Emulator */ +} gps_action_start_data_t; + +typedef struct { + int interval; +} gps_action_change_interval_data_t; + +/* +* GPS_ACTION_SET_REF_LOCATION +*/ +typedef struct { + int result; + int reason; + time_t timestamp; /**< Timestamp */ + double latitude; /**< Latitude data (in degree) */ + double longitude; /**< Longitude data (in degree) */ + double accuracy; /**< Horizontal position error(in meter) */ +} gps_action_set_ref_location_t; // Added 2016.06.30 + +/* +* GPS_ACTION_SET_REF_TIME +*/ +typedef struct { + int result; + int reason; + int method; + int64_t ntp_timestamp; /**< Timestamp from NTP */ + int64_t elapsed_systime; /**< Milliseconds since boot, including time spent in sleep */ + int uncertainty; /**< Half of round trip time in milliseconds */ +} gps_action_set_ref_time_t; // Added 2016.06.30 + +typedef struct _hal_backend_location_funcs { + int (*init)(gps_event_cb gps_event_cb, void *user_data); + int (*deinit)(gps_failure_reason_t *reason_code); + int (*request)(gps_action_t gps_action, void *gps_action_data, gps_failure_reason_t *reason_code); +} hal_backend_location_funcs; + +#ifdef __cplusplus +} +#endif +#endif /* __HAL_LOCATION_INTERFACE__ */ + diff --git a/include/hal-location.h b/include/hal-location.h new file mode 100644 index 0000000..43a2a07 --- /dev/null +++ b/include/hal-location.h @@ -0,0 +1,39 @@ +/* + * HAL (Hardware Abstract Layer) Location API + * + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __HAL_LOCATION__ +#define __HAL_LOCATION__ + +#include "hal-location-interface.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int hal_location_get_backend(void); +int hal_location_put_backend(void); + +int hal_location_init(gps_event_cb gps_event_cb, void *user_data); +int hal_location_deinit(gps_failure_reason_t *reason_code); +int hal_location_request(gps_action_t gps_action, void *gps_action_data, gps_failure_reason_t *reason_code); + +#ifdef __cplusplus +} +#endif +#endif /* __HAL_LOCATION__ */ + diff --git a/packaging/hal-api-location-devel.manifest b/packaging/hal-api-location-devel.manifest new file mode 100644 index 0000000..81ace0c --- /dev/null +++ b/packaging/hal-api-location-devel.manifest @@ -0,0 +1,6 @@ + + + + + + diff --git a/packaging/hal-api-location.manifest b/packaging/hal-api-location.manifest new file mode 100644 index 0000000..81ace0c --- /dev/null +++ b/packaging/hal-api-location.manifest @@ -0,0 +1,6 @@ + + + + + + diff --git a/packaging/hal-api-location.spec b/packaging/hal-api-location.spec new file mode 100644 index 0000000..8e58c02 --- /dev/null +++ b/packaging/hal-api-location.spec @@ -0,0 +1,73 @@ +%define module_name location +%define name hal-api-%{module_name} +%define devel_name hal-api-%{module_name}-devel + +### main package ######### +Name: %{name} +Summary: %{name} interface +Version: 0.0.1 +Release: 1 +Group: Development/Libraries +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz +Source1: %{name}.manifest +Source2: %{devel_name}.manifest + +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(gio-2.0) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(gmock) +BuildRequires: pkgconfig(hal-api-common) + +%description +%{name} interface package for product vendor developer + +### devel package ######### +%package -n %{devel_name} +Summary: %{name} interface +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description -n %{devel_name} +%{name} Interface development package for product vendor developer + +### build and install ######### +%prep +%setup -q + +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_LIBDIR_PREFIX=%{_libdir}/ + +%build +cp %{SOURCE1} . +cp %{SOURCE2} . +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%clean +rm -rf %{buildroot} + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + +### contain files to package ######### +%files -n %{name} +%manifest %{name}.manifest +%license LICENSE +%defattr(-,root,root,-) +%{_libdir}/hal/*.so* + +%files -n %{devel_name} +%defattr(-,root,root,-) +%manifest %{devel_name}.manifest +%license LICENSE +%{_includedir}/hal/*.h +%{_libdir}/pkgconfig/%{name}.pc diff --git a/src/hal-api-location.c b/src/hal-api-location.c new file mode 100644 index 0000000..7436d0c --- /dev/null +++ b/src/hal-api-location.c @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include + +#include "hal-location-interface.h" +#include "hal-location.h" +#include "common.h" + +#ifndef EXPORT +#define EXPORT __attribute__ ((visibility("default"))) +#endif + +static hal_backend_location_funcs *g_hal_location_funcs = NULL; + +EXPORT +int hal_location_get_backend(void) +{ + int ret; + + if (g_hal_location_funcs) + return 0; + + ret = hal_common_get_backend(HAL_MODULE_LOCATION, (void **)&g_hal_location_funcs); + if (ret < 0) { + _E("Failed to get backend\n"); + return -EINVAL; + } + + return 0; +} + +EXPORT +int hal_location_put_backend(void) +{ + int ret; + + if (!g_hal_location_funcs) + return -EINVAL; + + ret = hal_common_put_backend(HAL_MODULE_LOCATION, (void *)g_hal_location_funcs); + if (ret < 0) { + _E("Failed to put backend\n"); + return -EINVAL; + } + g_hal_location_funcs = NULL; + + return 0; +} + +EXPORT +int hal_location_init(gps_event_cb gps_event_cb, void *user_data) +{ + if (!g_hal_location_funcs) + return -ENOTSUP; + return g_hal_location_funcs->init(gps_event_cb, user_data); +} + +EXPORT +int hal_location_deinit(gps_failure_reason_t *reason_code) +{ + if (!g_hal_location_funcs) + return -ENOTSUP; + return g_hal_location_funcs->deinit(reason_code); +} + +EXPORT +int hal_location_request(gps_action_t gps_action, void *gps_action_data, gps_failure_reason_t *reason_code) +{ + if (!g_hal_location_funcs) + return -ENOTSUP; + return g_hal_location_funcs->request(gps_action, gps_action_data, reason_code); +}