LinuxQMISDK-Lite  SLQS04.00.12
 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
105  eSWIAUDIO= 245, // 245 Swi Audio service
106  eSWILOC=246,
107 };
108 
112 enum msgtype{
113  eREQ=0,
114  eRSP=2,
116 };
117 
125 typedef struct{
126  uint16_t xid;
127  int timeout;
128  uint16_t msgid;
129  uint8_t svc;
130 } pack_qmi_t;
131 
138 typedef struct{
139  enum msgtype type;
140  uint16_t msgid;
141  uint16_t xid;
142 } unpack_qmi_t;
143 
144 uint16_t helper_get_xid(uint8_t *qmi_resp);
145 
154 const char* helper_get_resp_ctx(
155  uint8_t svc,
156  uint8_t *pbuf,
157  uint32_t len,
158  unpack_qmi_t *pCtx
159  );
160 
164 unsigned unpack_result_code_only(
165  uint8_t *pMdmResp);
166 
170 int helper_set_log_func(logger func);
171 
172 void liteqmi_log(
173  uint8_t lvl,
174  const char* fmt, ...
175  );
176 
180 int helper_set_log_lvl(uint8_t lvl);
181 
182 //internal helper for pack/unpack function
183 void fill_sdu_hdr(
184  pack_qmi_t *pCtx,
185  uint8_t *pReqBuf
186  );
187 
188 void fill_pack_ctx(
189  pack_qmi_t *pCtx,
190  uint8_t *pReqBuf,
191  uint16_t *pLen,
192  uint8_t svc,
193  int timeout
194  );
198 char* get_version();
199 
203 char* liteqmi_GetVersion();
204 
212  uint8_t *encoded_str,
213  uint8_t encoded_len,
214  uint8_t *decoded_str
215  );
216 
217 #ifdef __cplusplus
218 } /* extern "C" { */
219 #endif
220 
221 #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:127
Definition: common.h:96
Definition: common.h:88
Definition: common.h:87
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:115
Definition: common.h:93
Definition: common.h:94
Definition: common.h:73
Definition: common.h:78
Definition: common.h:113
Definition: common.h:106
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:141
uint16_t xid
Definition: common.h:126
Definition: common.h:85
void liteqmi_log(uint8_t lvl, const char *fmt,...)
uint16_t msgid
Definition: common.h:128
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()
Definition: common.h:105
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:104
Definition: common.h:138
uint8_t svc
Definition: common.h:129
Definition: common.h:77
Definition: common.h:103
char * get_version()
int helper_set_log_func(logger func)
uint16_t msgid
Definition: common.h:140
unsigned unpack_result_code_only(uint8_t *pMdmResp)
Definition: common.h:99
Definition: common.h:125
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:112
Definition: common.h:114

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