LinuxQMISDK  SLQS04.00.11
 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 #include <stdint.h>
9 #define SDU_HDR_LEN (3)
10 #define MINREQBKLEN (2048)
11 #define MSGID_AND_LEN (4)
12 #define MSGID_DONT_CARE (0xffff)
13 
14 #ifndef UNUSEDPARAM
15 #define UNUSEDPARAM( x ) (void)x
16 #endif
17 
18 #define DEAULT_LOC_TIMEOUT_IN_SEC 2
19 #define SDK_VALIDATE_INPUT_PACK_PARAM(pCtx, pBuf, pLen ) \
20  if ((pCtx == NULL) || (pBuf == NULL) || (pLen == NULL) ) \
21  {\
22  liteqmi_log(eLOG_DEBUG,"[ pack] %s parameter NULL\n",__func__); \
23  return eQCWWAN_ERR_INVALID_ARG; \
24  }
25 
26 #define SDK_VALIDATE_INPUT_PACK_PARAM_AND_FILL_XID(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  if (pCtx->xid == 0) \
33  return eQCWWAN_ERR_INVALID_XID; \
34  pBuf[0] = eREQ; \
35  pBuf[1] = pCtx->xid & 0xff; \
36  pBuf[2] = pCtx->xid >> 8;
37 
38 #define SDK_VALIDATE_INPUT_UNPACK_PARAM(pResp, respLen, pOutput ) \
39  if ((pResp == NULL) || (respLen == 0) || (pOutput == NULL) ) \
40  {\
41  liteqmi_log(eLOG_DEBUG,"[ unpack] %s parameter NULL or invalid\n",__func__); \
42  return eQCWWAN_ERR_INVALID_ARG; \
43  }
44 
45 typedef void (* logger)(uint8_t lvl, const char* buff);
46 
47 extern logger glog;
48 extern uint8_t gloglvl;
49 
58 };
59 
64 {
65  eTIMEOUT_2_S = 2000,
66  eTIMEOUT_5_S = 5000,
67  eTIMEOUT_8_S = 8000,
68  eTIMEOUT_10_S = 10000,
69  eTIMEOUT_20_S = 20000,
70  eTIMEOUT_30_S = 30000,
71  eTIMEOUT_60_S = 60000,
72  eTIMEOUT_300_S = 300000,
74 };
75 
79 enum eQMI_SVC{
83  eNAS=3,
85  eSMS=5,
86  ePDS=0x06,
87  eVOICE=0x09,
88  eCAT=0x0A,
89  eUIM=0x0B,
90  eLOC=0x10,
91  eSAR=0x11,
92  eIMS=0x12, // 012 IMS Service
93  eTMD=0x18,
94  eIMSA=0x21,
95  eRMS=225,
96  eSWIOMA=240,
97  eAUDIO=241,
98  eSWIM2MCMD=243, // 0xF3 SWI M2M general commands
100  eSWIAUDIO= 245, // 245 Swi Audio service
101  eSWILOC=246,
102 };
103 
107 enum msgtype{
108  eREQ=0,
109  eRSP=2,
111 };
112 
120 typedef struct{
121  uint16_t xid;
122  int timeout;
123  uint16_t msgid;
124  uint8_t svc;
125 } pack_qmi_t;
126 
133 typedef struct{
134  enum msgtype type;
135  uint16_t msgid;
136  uint16_t xid;
137 } unpack_qmi_t;
138 
139 uint16_t helper_get_xid(uint8_t *qmi_resp);
140 
149 const char* helper_get_resp_ctx(
150  uint8_t svc,
151  uint8_t *pbuf,
152  uint32_t len,
153  unpack_qmi_t *pCtx
154  );
155 
159 unsigned unpack_result_code_only(
160  uint8_t *pMdmResp);
161 
165 int helper_set_log_func(logger func);
166 
167 void liteqmi_log(
168  uint8_t lvl,
169  const char* fmt, ...
170  );
171 
175 int helper_set_log_lvl(uint8_t lvl);
176 
177 //internal helper for pack/unpack function
178 void fill_sdu_hdr(
179  pack_qmi_t *pCtx,
180  uint8_t *pReqBuf
181  );
182 
183 void fill_pack_ctx(
184  pack_qmi_t *pCtx,
185  uint8_t *pReqBuf,
186  uint16_t *pLen,
187  uint8_t svc,
188  int timeout
189  );
193 char* get_version();
194 
198 char* liteqmi_GetVersion();
199 
207  uint8_t *encoded_str,
208  uint8_t encoded_len,
209  uint8_t *decoded_str
210  );
211 
212 #endif
void fill_pack_ctx(pack_qmi_t *pCtx, uint8_t *pReqBuf, uint16_t *pLen, uint8_t svc, int timeout)
Definition: common.h:86
int timeout
Definition: common.h:122
Definition: common.h:91
Definition: common.h:83
Definition: common.h:82
Definition: common.h:92
const char * helper_get_resp_ctx(uint8_t svc, uint8_t *pbuf, uint32_t len, unpack_qmi_t *pCtx)
Definition: common.h:57
Definition: common.h:65
Definition: common.h:93
Definition: common.h:66
int helper_set_log_lvl(uint8_t lvl)
Definition: common.h:110
Definition: common.h:88
Definition: common.h:89
Definition: common.h:68
Definition: common.h:73
Definition: common.h:108
Definition: common.h:101
Definition: common.h:96
logger glog
Definition: common.h:70
uint16_t helper_get_xid(uint8_t *qmi_resp)
Definition: common.h:56
Definition: common.h:85
Definition: common.h:87
Definition: common.h:84
eTimeout
Definition: common.h:63
uint16_t xid
Definition: common.h:136
uint16_t xid
Definition: common.h:121
Definition: common.h:80
void liteqmi_log(uint8_t lvl, const char *fmt,...)
uint16_t msgid
Definition: common.h:123
Definition: common.h:67
Definition: common.h:97
Definition: common.h:81
void liteqmi_helper_decode7bitAsciiEncString(uint8_t *encoded_str, uint8_t encoded_len, uint8_t *decoded_str)
Definition: common.h:54
char * liteqmi_GetVersion()
Definition: common.h:100
Definition: common.h:69
void(* logger)(uint8_t lvl, const char *buff)
Definition: common.h:45
void fill_sdu_hdr(pack_qmi_t *pCtx, uint8_t *pReqBuf)
Definition: common.h:95
Definition: common.h:99
Definition: common.h:133
uint8_t svc
Definition: common.h:124
Definition: common.h:72
Definition: common.h:98
char * get_version()
int helper_set_log_func(logger func)
uint16_t msgid
Definition: common.h:135
unsigned unpack_result_code_only(uint8_t *pMdmResp)
Definition: common.h:94
Definition: common.h:120
Definition: common.h:55
uint8_t gloglvl
Definition: common.h:71
eLOG_LEVEL
Definition: common.h:53
eQMI_SVC
Definition: common.h:79
Definition: common.h:90
msgtype
Definition: common.h:107
Definition: common.h:109

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