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

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