LinuxQMISDK  SLQS04.00.06
 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 typedef void (* logger)(uint8_t lvl, const char* buff);
39 
40 extern logger glog;
41 extern uint8_t gloglvl;
42 
51 };
52 
57 {
58  eTIMEOUT_2_S = 2000,
59  eTIMEOUT_5_S = 5000,
60  eTIMEOUT_8_S = 8000,
61  eTIMEOUT_10_S = 10000,
62  eTIMEOUT_20_S = 20000,
63  eTIMEOUT_30_S = 30000,
64  eTIMEOUT_60_S = 60000,
65  eTIMEOUT_300_S = 300000,
67 };
68 
72 enum eQMI_SVC{
76  eNAS=3,
78  eSMS=5,
79  ePDS=0x06,
80  eVOICE=0x09,
81  eCAT=0x0A,
82  eUIM=0x0B,
83  eLOC=0x10,
84  eSAR=0x11,
85  eTMD=0x18,
86  eIMSA=0x21,
87  eRMS=225,
88  eSWIOMA=240,
89  eSWIM2MCMD=243, // 0xF3 SWI M2M general commands
91  eSWILOC=246,
92 };
93 
97 enum msgtype{
98  eREQ=0,
99  eRSP=2,
101 };
102 
110 typedef struct{
111  uint16_t xid;
112  int timeout;
113  uint16_t msgid;
114  uint8_t svc;
115 } pack_qmi_t;
116 
123 typedef struct{
124  enum msgtype type;
125  uint16_t msgid;
126  uint16_t xid;
127 } unpack_qmi_t;
128 
129 uint16_t helper_get_xid(uint8_t *qmi_resp);
130 
139 const char* helper_get_resp_ctx(
140  uint8_t svc,
141  uint8_t *pbuf,
142  uint32_t len,
143  unpack_qmi_t *pCtx
144  );
145 
149 unsigned unpack_result_code_only(
150  uint8_t *pMdmResp);
151 
155 int helper_set_log_func(logger func);
156 
157 void liteqmi_log(
158  uint8_t lvl,
159  const char* fmt, ...
160  );
161 
165 int helper_set_log_lvl(uint8_t lvl);
166 
167 //internal helper for pack/unpack function
168 void fill_sdu_hdr(
169  pack_qmi_t *pCtx,
170  uint8_t *pReqBuf
171  );
172 
173 void fill_pack_ctx(
174  pack_qmi_t *pCtx,
175  uint8_t *pReqBuf,
176  uint16_t *pLen,
177  uint8_t svc,
178  int timeout
179  );
183 char* get_version();
184 
188 char* liteqmi_GetVersion();
189 
190 #endif
void fill_pack_ctx(pack_qmi_t *pCtx, uint8_t *pReqBuf, uint16_t *pLen, uint8_t svc, int timeout)
Definition: common.h:79
int timeout
Definition: common.h:112
Definition: common.h:84
Definition: common.h:76
Definition: common.h:75
const char * helper_get_resp_ctx(uint8_t svc, uint8_t *pbuf, uint32_t len, unpack_qmi_t *pCtx)
Definition: common.h:50
Definition: common.h:58
Definition: common.h:85
Definition: common.h:59
int helper_set_log_lvl(uint8_t lvl)
Definition: common.h:100
Definition: common.h:81
Definition: common.h:82
Definition: common.h:61
Definition: common.h:66
Definition: common.h:98
Definition: common.h:91
Definition: common.h:88
logger glog
Definition: common.h:63
uint16_t helper_get_xid(uint8_t *qmi_resp)
Definition: common.h:49
Definition: common.h:78
Definition: common.h:80
Definition: common.h:77
eTimeout
Definition: common.h:56
uint16_t xid
Definition: common.h:126
uint16_t xid
Definition: common.h:111
Definition: common.h:73
void liteqmi_log(uint8_t lvl, const char *fmt,...)
uint16_t msgid
Definition: common.h:113
Definition: common.h:60
Definition: common.h:74
Definition: common.h:47
char * liteqmi_GetVersion()
Definition: common.h:62
void(* logger)(uint8_t lvl, const char *buff)
Definition: common.h:38
void fill_sdu_hdr(pack_qmi_t *pCtx, uint8_t *pReqBuf)
Definition: common.h:87
Definition: common.h:90
Definition: common.h:123
uint8_t svc
Definition: common.h:114
Definition: common.h:65
Definition: common.h:89
char * get_version()
int helper_set_log_func(logger func)
uint16_t msgid
Definition: common.h:125
unsigned unpack_result_code_only(uint8_t *pMdmResp)
Definition: common.h:86
Definition: common.h:110
Definition: common.h:48
uint8_t gloglvl
Definition: common.h:64
eLOG_LEVEL
Definition: common.h:46
eQMI_SVC
Definition: common.h:72
Definition: common.h:83
msgtype
Definition: common.h:97
Definition: common.h:99

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