LinuxQMISDK-Lite  SLQS04.00.03
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  libpack_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  libpack_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  eCAT=0x0A,
80  eUIM=0x0B,
81  eLOC=0x10,
82  eTMD=0x18,
83  eSWIOMA=240,
84  eSWILOC=246,
85 };
86 
90 enum msgtype{
91  eREQ=0,
92  eRSP=2,
93  eIND=4
94 };
95 
103 typedef struct{
104  uint16_t xid;
105  int timeout;
106  uint16_t msgid;
107  uint8_t svc;
108 } pack_qmi_t;
109 
116 typedef struct{
117  enum msgtype type;
118  uint16_t msgid;
119  uint16_t xid;
120 } unpack_qmi_t;
121 
122 uint16_t helper_get_xid(uint8_t *qmi_resp);
123 
132 const char* helper_get_resp_ctx(
133  uint8_t svc,
134  uint8_t *pbuf,
135  uint32_t len,
136  unpack_qmi_t *pCtx
137  );
138 
142 unsigned unpack_result_code_only(
143  uint8_t *pMdmResp);
144 
148 int helper_set_log_func(logger func);
149 
150 void libpack_log(
151  uint8_t lvl,
152  const char* fmt, ...
153  );
154 
158 int helper_set_log_lvl(uint8_t lvl);
159 
160 //internal helper for pack/unpack function
161 void fill_sdu_hdr(
162  pack_qmi_t *pCtx,
163  uint8_t *pReqBuf
164  );
165 
166 void fill_pack_ctx(
167  pack_qmi_t *pCtx,
168  uint8_t *pReqBuf,
169  uint16_t *pLen,
170  uint8_t svc,
171  int timeout
172  );
176 char* get_version();
177 
181 char* libpack_GetVersion();
182 
183 #endif
void fill_pack_ctx(pack_qmi_t *pCtx, uint8_t *pReqBuf, uint16_t *pLen, uint8_t svc, int timeout)
int timeout
Definition: common.h:105
Definition: common.h:76
Definition: common.h:75
char * libpack_GetVersion()
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:82
void libpack_log(uint8_t lvl, const char *fmt,...)
Definition: common.h:59
int helper_set_log_lvl(uint8_t lvl)
Definition: common.h:93
Definition: common.h:79
Definition: common.h:80
Definition: common.h:61
Definition: common.h:66
Definition: common.h:91
Definition: common.h:84
Definition: common.h:83
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:77
eTimeout
Definition: common.h:56
uint16_t xid
Definition: common.h:119
uint16_t xid
Definition: common.h:104
Definition: common.h:73
uint16_t msgid
Definition: common.h:106
Definition: common.h:60
Definition: common.h:74
Definition: common.h:47
void(* logger)(uint8_t lvl, const char *buff)
Definition: common.h:38
Definition: common.h:62
void fill_sdu_hdr(pack_qmi_t *pCtx, uint8_t *pReqBuf)
Definition: common.h:116
uint8_t svc
Definition: common.h:107
Definition: common.h:65
char * get_version()
int helper_set_log_func(logger func)
uint16_t msgid
Definition: common.h:118
unsigned unpack_result_code_only(uint8_t *pMdmResp)
Definition: common.h:103
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:81
msgtype
Definition: common.h:90
Definition: common.h:92

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