LinuxQMISDK  SLQS04.00.13
 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,
108 };
109 
113 enum msgtype{
114  eREQ=0,
115  eRSP=2,
117 };
118 
126 typedef struct{
127  uint16_t xid;
128  int timeout;
129  uint16_t msgid;
130  uint8_t svc;
131 } pack_qmi_t;
132 
139 typedef struct{
140  enum msgtype type;
141  uint16_t msgid;
142  uint16_t xid;
143 } unpack_qmi_t;
144 
145 uint16_t helper_get_xid(uint8_t *qmi_resp);
146 
147 uint16_t helper_get_error_code(uint8_t *qmi_resp);
148 char* helper_get_error_reason(uint16_t retVal);
149 
158 const char* helper_get_resp_ctx(
159  uint8_t svc,
160  uint8_t *pbuf,
161  uint32_t len,
162  unpack_qmi_t *pCtx
163  );
164 
168 unsigned unpack_result_code_only(
169  uint8_t *pMdmResp);
170 
174 int helper_set_log_func(logger func);
175 
176 void liteqmi_log(
177  uint8_t lvl,
178  const char* fmt, ...
179  );
180 
184 int helper_set_log_lvl(uint8_t lvl);
185 
186 //internal helper for pack/unpack function
187 void fill_sdu_hdr(
188  pack_qmi_t *pCtx,
189  uint8_t *pReqBuf
190  );
191 
192 void fill_pack_ctx(
193  pack_qmi_t *pCtx,
194  uint8_t *pReqBuf,
195  uint16_t *pLen,
196  uint8_t svc,
197  int timeout
198  );
202 char* get_version();
203 
207 char* liteqmi_GetVersion();
208 
216  uint8_t *encoded_str,
217  uint8_t encoded_len,
218  uint8_t *decoded_str
219  );
220 
221 #ifdef __cplusplus
222 } /* extern "C" { */
223 #endif
224 
225 #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:128
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:116
Definition: common.h:93
Definition: common.h:94
Definition: common.h:73
Definition: common.h:78
Definition: common.h:114
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:142
uint16_t xid
Definition: common.h:127
Definition: common.h:85
void liteqmi_log(uint8_t lvl, const char *fmt,...)
uint16_t msgid
Definition: common.h:129
Definition: common.h:72
Definition: common.h:102
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:139
uint8_t svc
Definition: common.h:130
Definition: common.h:77
Definition: common.h:103
char * get_version()
int helper_set_log_func(logger func)
uint16_t msgid
Definition: common.h:141
unsigned unpack_result_code_only(uint8_t *pMdmResp)
Definition: common.h:99
Definition: common.h:126
Definition: common.h:104
Definition: common.h:60
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:113
Definition: common.h:115

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