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

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