Linux SDK (lite-qmi)  MBPL_SDK_R25_ENG3
common.h
Go to the documentation of this file.
1 
6 #ifndef __COMMON_H
7 #define __COMMON_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #include <stdint.h>
14 #include <stdbool.h>
15 #include "switype_256bit.h"
16 #define SDU_HDR_LEN (3)
17 #define MINREQBKLEN (2048)
18 #define MSGID_AND_LEN (4)
19 #define MSGID_DONT_CARE (0xffff)
20 
21 #ifndef UNUSEDPARAM
22 #define UNUSEDPARAM( x ) (void)x
23 #endif
24 
25 #define DEAULT_LOC_TIMEOUT_IN_SEC 2
26 #define SDK_VALIDATE_INPUT_PACK_PARAM(pCtx, pBuf, pLen ) \
27  if ((pCtx == NULL) || (pBuf == NULL) || (pLen == NULL) ) \
28  {\
29  liteqmi_log(eLOG_DEBUG,"[ pack] %s parameter NULL\n",__func__); \
30  return eQCWWAN_ERR_INVALID_ARG; \
31  }
32 
33 #define SDK_VALIDATE_INPUT_PACK_PARAM_AND_FILL_XID(pCtx, pBuf, pLen ) \
34  if ((pCtx == NULL) || (pBuf == NULL) || (pLen == NULL) ) \
35  {\
36  liteqmi_log(eLOG_DEBUG,"[ pack] %s parameter NULL\n",__func__); \
37  return eQCWWAN_ERR_INVALID_ARG; \
38  } \
39  if (pCtx->xid == 0) \
40  return eQCWWAN_ERR_INVALID_XID; \
41  pBuf[0] = eREQ; \
42  pBuf[1] = pCtx->xid & 0xff; \
43  pBuf[2] = pCtx->xid >> 8;
44 
45 #define SDK_VALIDATE_INPUT_UNPACK_PARAM(pResp, respLen, pOutput ) \
46  if ((pResp == NULL) || (respLen == 0) || (pOutput == NULL) ) \
47  {\
48  liteqmi_log(eLOG_DEBUG,"[ unpack] %s parameter NULL or invalid\n",__func__); \
49  return eQCWWAN_ERR_INVALID_ARG; \
50  }
51 
52 #ifdef SIERRA_ANDROID_RIL
53 /* We have to rename the "logger" because it clashes with Android's logger name. */
54 #define logger swilogger
55 #endif
56 
57 typedef void (* logger)(uint8_t lvl, const char* buff, ...);
58 
59 extern logger glog;
60 extern uint8_t gloglvl;
61 
68  eLOG_INFO,
69  eLOG_DEBUG,
70  eLOG_WARN,
71  eLOG_ERROR,
72  eLOG_FATAL
73 };
74 
79 {
80  eTIMEOUT_2_S = 2000,
81  eTIMEOUT_5_S = 5000,
82  eTIMEOUT_8_S = 8000,
83  eTIMEOUT_10_S = 10000,
84  eTIMEOUT_20_S = 20000,
85  eTIMEOUT_30_S = 30000,
86  eTIMEOUT_60_S = 60000,
87  eTIMEOUT_300_S = 300000,
88  eTIMEOUT_DEFAULT = eTIMEOUT_8_S
89 };
90 
96 enum eQMI_SVC{
97  eCTL=0,
98  eWDS=0x01,
99  eDMS=0x02,
100  eNAS=0x03,
101  eQOS=0x04,
102  eSMS=0x05,
103  eCAT=0x0A,
104  eUIM=0x0B,
105  eLOC=0x10,
106  eSAR=0x11,
107  eIMS=0x12, // 012 IMS Service
108  eTS=0x17,
109  eTMD=0x18,
110  eWDA=0x1A,
111  eIMSA=0x21,
112  eDSD=0x2A, //DSD is assigned QMI service type 0x2A
113  eRMS=225,
114  eSWILOC=246,
115  eSWINAS=252, // 0xFC
116  eSWIDMS=254
117 };
118 
124 enum msgtype{
125  eREQ=0,
126  eRSP=2,
127  eIND=4
128 };
129 
139 typedef struct{
140  uint16_t xid;
141  int timeout;
142  uint16_t msgid;
143  uint8_t svc;
144 } pack_qmi_t;
145 
154 typedef struct{
155  enum msgtype type;
156  uint16_t msgid;
157  uint16_t xid;
158 } unpack_qmi_t;
159 
169 uint16_t helper_get_xid(uint8_t *qmi_resp);
170 
180 uint16_t helper_get_msgid(uint8_t *qmi_resp);
181 
192 uint16_t helper_get_error_code(uint8_t *qmi_resp);
193 
203 char* helper_get_error_reason(uint16_t retVal);
204 
215 const char* helper_get_resp_ctx(
216  uint8_t svc,
217  uint8_t *pbuf,
218  uint16_t len,
219  unpack_qmi_t *pCtx
220 );
221 
231 const char* helper_get_req_str(
232  uint8_t svc,
233  uint8_t *req,
234  uint32_t len
235 );
236 
242 unsigned unpack_result_code_only(uint8_t *pMdmResp);
243 
255 int helper_set_log_func(logger func);
256 
269 void liteqmi_log(
270  uint8_t lvl,
271  const char* fmt, ...
272 );
273 
279 int helper_set_log_lvl(uint8_t lvl);
280 
281 /* Internal helper for pack/unpack function */
282 void fill_sdu_hdr(
283  pack_qmi_t *pCtx,
284  uint8_t *pReqBuf
285 );
286 
287 /* Internal helper for packing context */
288 void fill_pack_ctx(
289  pack_qmi_t *pCtx,
290  uint8_t *pReqBuf,
291  uint16_t *pLen,
292  uint8_t svc,
293  int timeout
294 );
295 
301 char* get_version();
302 
308 char* liteqmi_GetVersion();
309 
319  uint8_t *encoded_str,
320  uint8_t encoded_len,
321  uint8_t *decoded_str
322 );
323 
339 int helper_isBootLoader_DebugEnabled(const char* szPath, const char* pQsn );
340 
341 #define SWI_INIT_UNPACK_RESULT_VALUE {0, SWI_UINT256_INT_VALUE}
342 
350 typedef struct
351 {
352  uint16_t Tlvresult;
353  swi_uint256_t ParamPresenceMask;
355 
356 #ifdef __cplusplus
357 } /* extern "C" { */
358 #endif
359 
360 #endif
uint16_t helper_get_msgid(uint8_t *qmi_resp)
eLOG_LEVEL
Definition: common.h:67
unsigned unpack_result_code_only(uint8_t *pMdmResp)
uint16_t helper_get_xid(uint8_t *qmi_resp)
const char * helper_get_req_str(uint8_t svc, uint8_t *req, uint32_t len)
int helper_set_log_lvl(uint8_t lvl)
int helper_isBootLoader_DebugEnabled(const char *szPath, const char *pQsn)
void liteqmi_log(uint8_t lvl, const char *fmt,...)
msgtype
Definition: common.h:124
Definition: common.h:350
eTimeout
Definition: common.h:78
char * liteqmi_GetVersion()
int helper_set_log_func(logger func)
void liteqmi_helper_decode7bitAsciiEncString(uint8_t *encoded_str, uint8_t encoded_len, uint8_t *decoded_str)
char * get_version()
Definition: common.h:154
eQMI_SVC
Definition: common.h:96
char * helper_get_error_reason(uint16_t retVal)
Definition: common.h:139
const char * helper_get_resp_ctx(uint8_t svc, uint8_t *pbuf, uint16_t len, unpack_qmi_t *pCtx)
uint16_t helper_get_error_code(uint8_t *qmi_resp)