blob: 4244f82bf6f4d8d46893aed98da84773f501f486 [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +08001/*-----------------------------------------------------------------------------------------------*/
2/**
3 @file ql_cell_locator.h
4 @brief Common API
5*/
6/*-----------------------------------------------------------------------------------------------*/
7/*-------------------------------------------------------------------------------------------------
8 Copyright (c) 2018 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
9 Quectel Wireless Solution Proprietary and Confidential.
10-------------------------------------------------------------------------------------------------*/
11/*-------------------------------------------------------------------------------------------------
12 EDIT HISTORY
13 This section contains comments describing changes made to the file.
14 Notice that changes are listed in reverse chronological order.
15 $Header: $
16 when who what, where, why
17 -------- --- ----------------------------------------------------------
18 20190321 baron.qian Created .
19-------------------------------------------------------------------------------------------------*/
20#ifdef __cplusplus
21 extern "C" {
22#endif
23#ifndef __QL_CELL_LOCATOR_H__
24#define __QL_CELL_LOCATOR_H__
25
26/**/
27#define LOCATOR_MAX_ADDRESS_SIZE (256)
28#define LOCATOR_MAX_ERR_MSG_SIZE (256)
29
30
31typedef enum {
32 Q_LOC_ADDR_UTF8 = 0,
33 Q_LOC_ADDR_GBK,
34 Q_LOC_ADDR_ASCII,
35 Q_LOC_ADDR_NUM,
36}QUECLOCATOR_CHARSET;
37
38typedef struct {
39 int err_code;
40 char err_msg[LOCATOR_MAX_ERR_MSG_SIZE];
41} ql_cell_err;
42
43typedef struct {
44 /*longtitude*/
45 double lon;
46 /*latitude*/
47 double lat;
48 /*accuracy*/
49 unsigned short accuracy;
50 /*address charset, not support yet*/
51 QUECLOCATOR_CHARSET charset;
52 /*address info, not support yet*/
53 unsigned char addrinfo[LOCATOR_MAX_ADDRESS_SIZE];
54 /*address length, not support yet*/
55 unsigned short addrlen;
56 /*result*/
57 ql_cell_err err;
58} ql_cell_resp;
59
60
61/*-----------------------------------------------------------------------------------------------*/
62/**
63 @brief cell locator init function, when you want to use cell locator, call this function first!
64 @return if success return 0, else return -1
65 */
66/*-----------------------------------------------------------------------------------------------*/
67int ql_cell_locator_init();
68
69
70int ql_cell_locator_release();
71
72/*-----------------------------------------------------------------------------------------------*/
73/**
74 @brief set locator query server and port, server length must be less than 255 bytes.
75 @param[in] server the query server ip address
76 @param[in] port the query server port
77 @return if success return 0, else return -1
78 */
79/*-----------------------------------------------------------------------------------------------*/
80int ql_cell_locator_set_server(const char *server, unsigned short port);
81
82/*-----------------------------------------------------------------------------------------------*/
83/**
84 @brief set locator query timeout, the value must between 1-300 [seconds]
85 @param[in] timeout value of query timeout
86 @return if success return 0, else return -1
87 */
88/*-----------------------------------------------------------------------------------------------*/
89int ql_cell_locator_set_timeout(unsigned short timeout);
90
91
92/*-----------------------------------------------------------------------------------------------*/
93/**
94 @brief set locator query token, token length must be 16 bytes. the token Used to verify that
95 the client accessing the service is valid.
96 @param[in] token string of token which want to be setted.
97 @param[in] length of token string.
98 @return if success return 0, else return -1
99 */
100/*-----------------------------------------------------------------------------------------------*/
101int ql_cell_locator_set_token(const char *token, int len);
102
103/*-----------------------------------------------------------------------------------------------*/
104/**
105 @brief perform cell locator query
106 @param[out] resp include query result or set the error_msg and error_code
107 @return if success return 0, else return -1
108 */
109/*-----------------------------------------------------------------------------------------------*/
110int ql_cell_locator_perform(ql_cell_resp *resp);
111
112
113#endif /* !__QL_CELL_LOCATOR_H__ */
114#ifdef __cplusplus
115}
116#endif