LinuxQMISDK-Lite  SLQS04.00.15
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 #define SDU_HDR_LEN (3)
15 #define MINREQBKLEN (2048)
16 #define MSGID_AND_LEN (4)
17 #define MSGID_DONT_CARE (0xffff)
18 
19 #ifndef UNUSEDPARAM
20 #define UNUSEDPARAM( x ) (void)x
21 #endif
22 
23 #define DEAULT_LOC_TIMEOUT_IN_SEC 2
24 #define SDK_VALIDATE_INPUT_PACK_PARAM(pCtx, pBuf, pLen ) \
25  if ((pCtx == NULL) || (pBuf == NULL) || (pLen == NULL) ) \
26  {\
27  liteqmi_log(eLOG_DEBUG,"[ pack] %s parameter NULL\n",__func__); \
28  return eQCWWAN_ERR_INVALID_ARG; \
29  }
30 
31 #define SDK_VALIDATE_INPUT_PACK_PARAM_AND_FILL_XID(pCtx, pBuf, pLen ) \
32  if ((pCtx == NULL) || (pBuf == NULL) || (pLen == NULL) ) \
33  {\
34  liteqmi_log(eLOG_DEBUG,"[ pack] %s parameter NULL\n",__func__); \
35  return eQCWWAN_ERR_INVALID_ARG; \
36  } \
37  if (pCtx->xid == 0) \
38  return eQCWWAN_ERR_INVALID_XID; \
39  pBuf[0] = eREQ; \
40  pBuf[1] = pCtx->xid & 0xff; \
41  pBuf[2] = pCtx->xid >> 8;
42 
43 #define SDK_VALIDATE_INPUT_UNPACK_PARAM(pResp, respLen, pOutput ) \
44  if ((pResp == NULL) || (respLen == 0) || (pOutput == NULL) ) \
45  {\
46  liteqmi_log(eLOG_DEBUG,"[ unpack] %s parameter NULL or invalid\n",__func__); \
47  return eQCWWAN_ERR_INVALID_ARG; \
48  }
49 
50 typedef void (* logger)(uint8_t lvl, const char* buff);
51 
52 extern logger glog;
53 extern uint8_t gloglvl;
54 
63 };
64 
69 {
70  eTIMEOUT_2_S = 2000,
71  eTIMEOUT_5_S = 5000,
72  eTIMEOUT_8_S = 8000,
73  eTIMEOUT_10_S = 10000,
74  eTIMEOUT_20_S = 20000,
75  eTIMEOUT_30_S = 30000,
76  eTIMEOUT_60_S = 60000,
77  eTIMEOUT_300_S = 300000,
79 };
80 
84 enum eQMI_SVC{
88  eNAS=3,
90  eSMS=5,
91  ePDS=0x06,
92  eVOICE=0x09,
93  eCAT=0x0A,
94  eUIM=0x0B,
95  eLOC=0x10,
96  eSAR=0x11,
97  eIMS=0x12, // 012 IMS Service
98  eTMD=0x18,
99  eIMSA=0x21,
100  eRMS=225,
101  eSWIOMA=240,
102  eAUDIO=241,
103  eSWIM2MCMD=243, // 0xF3 SWI M2M general commands
104  eSWIM2MCMD_AVC2=0xfd, // 0xFD SWI M2M general commands
106  eSWIAUDIO= 245, // 245 Swi Audio service
107  eSWILOC=246,
109 };
110 
114 enum msgtype{
115  eREQ=0,
116  eRSP=2,
118 };
119 
127 typedef struct{
128  uint16_t xid;
129  int timeout;
130  uint16_t msgid;
131  uint8_t svc;
132 } pack_qmi_t;
133 
140 typedef struct{
141  enum msgtype type;
142  uint16_t msgid;
143  uint16_t xid;
144 } unpack_qmi_t;
145 
146 uint16_t helper_get_xid(uint8_t *qmi_resp);
147 
148 uint16_t helper_get_error_code(uint8_t *qmi_resp);
149 char* helper_get_error_reason(uint16_t retVal);
150 
159 const char* helper_get_resp_ctx(
160  uint8_t svc,
161  uint8_t *pbuf,
162  uint32_t len,
163  unpack_qmi_t *pCtx
164  );
165 
173 const char* helper_get_req_str(
174  uint8_t svc,
175  uint8_t *req,
176  uint32_t len
177  );
178 
182 unsigned unpack_result_code_only(
183  uint8_t *pMdmResp);
184 
188 int helper_set_log_func(logger func);
189 
190 void liteqmi_log(
191  uint8_t lvl,
192  const char* fmt, ...
193  );
194 
198 int helper_set_log_lvl(uint8_t lvl);
199 
200 //internal helper for pack/unpack function
201 void fill_sdu_hdr(
202  pack_qmi_t *pCtx,
203  uint8_t *pReqBuf
204  );
205 
206 void fill_pack_ctx(
207  pack_qmi_t *pCtx,
208  uint8_t *pReqBuf,
209  uint16_t *pLen,
210  uint8_t svc,
211  int timeout
212  );
216 char* get_version();
217 
221 char* liteqmi_GetVersion();
222 
230  uint8_t *encoded_str,
231  uint8_t encoded_len,
232  uint8_t *decoded_str
233  );
234 
235 #ifdef __cplusplus
236 } /* extern "C" { */
237 #endif
238 
239 #endif
void fill_pack_ctx(pack_qmi_t *pCtx, uint8_t *pReqBuf, uint16_t *pLen, uint8_t svc, int timeout)
Definition: common.h:91
int timeout
Definition: common.h:129
Definition: common.h:96
Definition: common.h:88
Definition: common.h:87
char * helper_get_error_reason(uint16_t retVal)
Definition: common.h:97
const char * helper_get_resp_ctx(uint8_t svc, uint8_t *pbuf, uint32_t len, unpack_qmi_t *pCtx)
Definition: common.h:62
Definition: common.h:70
Definition: common.h:98
Definition: common.h:71
int helper_set_log_lvl(uint8_t lvl)
Definition: common.h:117
Definition: common.h:93
Definition: common.h:94
Definition: common.h:73
Definition: common.h:78
Definition: common.h:115
Definition: common.h:107
Definition: common.h:101
logger glog
Definition: common.h:75
uint16_t helper_get_xid(uint8_t *qmi_resp)
Definition: common.h:61
Definition: common.h:90
Definition: common.h:92
Definition: common.h:89
eTimeout
Definition: common.h:68
uint16_t xid
Definition: common.h:143
uint16_t xid
Definition: common.h:128
Definition: common.h:85
void liteqmi_log(uint8_t lvl, const char *fmt,...)
uint16_t msgid
Definition: common.h:130
Definition: common.h:72
Definition: common.h:102
const char * helper_get_req_str(uint8_t svc, uint8_t *req, uint32_t len)
Definition: common.h:86
void liteqmi_helper_decode7bitAsciiEncString(uint8_t *encoded_str, uint8_t encoded_len, uint8_t *decoded_str)
Definition: common.h:59
char * liteqmi_GetVersion()
uint16_t helper_get_error_code(uint8_t *qmi_resp)
Definition: common.h:106
Definition: common.h:74
void(* logger)(uint8_t lvl, const char *buff)
Definition: common.h:50
void fill_sdu_hdr(pack_qmi_t *pCtx, uint8_t *pReqBuf)
Definition: common.h:100
Definition: common.h:105
Definition: common.h:140
uint8_t svc
Definition: common.h:131
Definition: common.h:77
Definition: common.h:103
char * get_version()
int helper_set_log_func(logger func)
uint16_t msgid
Definition: common.h:142
unsigned unpack_result_code_only(uint8_t *pMdmResp)
Definition: common.h:99
Definition: common.h:127
Definition: common.h:104
Definition: common.h:60
Definition: common.h:108
uint8_t gloglvl
Definition: common.h:76
eLOG_LEVEL
Definition: common.h:58
eQMI_SVC
Definition: common.h:84
Definition: common.h:95
msgtype
Definition: common.h:114
Definition: common.h:116

Copyright (c) 2011-2015 Sierra Wireless, Inc. All rights reserved