Debian Codegraph @

gobi-api/Gobi_2012-06-18-1054/GobiSampleCM/GobiCMCallback.cpp

raw
1 /*===========================================================================
2 FILE:
3 GobiCMCallback.cpp
4
5 DESCRIPTION:
6 Contains the implementation of each Gobi CM callback function.
7
8 Copyright (c) 2012, Code Aurora Forum. All rights reserved.
9
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright
15 notice, this list of conditions and the following disclaimer in the
16 documentation and/or other materials provided with the distribution.
17 * Neither the name of Code Aurora Forum nor
18 the names of its contributors may be used to endorse or promote
19 products derived from this software without specific prior written
20 permission.
21
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 POSSIBILITY OF SUCH DAMAGE.
34 ===========================================================================*/
35
36 //---------------------------------------------------------------------------
37 // Include Files
38 //---------------------------------------------------------------------------
39 #include "SampleCM.h"
40 #include "GobiCMCallback.h"
41 #include <sstream>
42
43 /*=========================================================================*/
44 // Free Methods
45 /*=========================================================================*/
46
47 /*===========================================================================
48 METHOD:
49 WDSEventReportCallback (Free Method)
50
51 DESCRIPTION:
52 Function called by WDS event report callback
53
54 PARAMETERS:
55 svcID [ I ] - QMI service ID
56 msgID [ I ] - QMI message ID
57 handle [ I ] - Handle to Gobi API connection
58 outLen [ I ] - Length of indication buffer
59 pOut [ I ] - Indication buffer
60
61 RETURN VALUE:
62 None
63 ===========================================================================*/
64 void WDSEventReportCallback(
65 ULONG svcID,
66 ULONG msgID,
67 GOBIHANDLE /* handle */,
68 ULONG outLen,
69 const BYTE * pOut )
70 {
71 if (gpCM == 0 || svcID != 1 || msgID != 1)
72 {
73 return;
74 }
75
76 std::map <UINT8, const sQMIRawContentHeader *> tlvs = GetTLVs( &pOut[0], outLen );
77 std::map <UINT8, const sQMIRawContentHeader *>::const_iterator pIter = tlvs.find( 0x17 );
78 if (pIter != tlvs.end())
79 {
80 const sQMIRawContentHeader * pTmp = pIter->second;
81 if (pTmp->mLength >= sizeof (sWDSEventReportIndication_DataBearerTechnology))
82 {
83 pTmp++;
84 const sWDSEventReportIndication_DataBearerTechnology * pDBT =
85 (const sWDSEventReportIndication_DataBearerTechnology *)pTmp;
86
87 gpCM->OnDataBearerCBNotification( pDBT->mDataBearerTechnology );
88 }
89 }
90
91 ULONGLONG txTotalBytes = ULLONG_MAX;
92 ULONGLONG rxTotalBytes = ULLONG_MAX;
93
94 pIter = tlvs.find( 0x19 );
95 if (pIter != tlvs.end())
96 {
97 const sQMIRawContentHeader * pTmp = pIter->second;
98 if (pTmp->mLength >= sizeof (sWDSEventReportIndication_TXBytes))
99 {
100 pTmp++;
101 const sWDSEventReportIndication_TXBytes * pTX =
102 (const sWDSEventReportIndication_TXBytes *)pTmp;
103
104 txTotalBytes = pTX->mTXByteTotal;
105 }
106 }
107
108 pIter = tlvs.find( 0x1A );
109 if (pIter != tlvs.end())
110 {
111 const sQMIRawContentHeader * pTmp = pIter->second;
112 if (pTmp->mLength >= sizeof (sWDSEventReportIndication_RXBytes))
113 {
114 pTmp++;
115 const sWDSEventReportIndication_RXBytes * pRX =
116 (const sWDSEventReportIndication_RXBytes *)pTmp;
117
118 rxTotalBytes = pRX->mRXByteTotal;
119 }
120 }
121
122 if (txTotalBytes != ULLONG_MAX || rxTotalBytes != ULLONG_MAX)
123 {
124 gpCM->OnByteTotalsNotification( rxTotalBytes, txTotalBytes );
125 }
126 }
127
128 /*===========================================================================
129 METHOD:
130 WDSSessionStateCallback (Free Method)
131
132 DESCRIPTION:
133 Function called by WDS packet service status callback
134
135 PARAMETERS:
136 svcID [ I ] - QMI service ID
137 msgID [ I ] - QMI message ID
138 handle [ I ] - Handle to Gobi API connection
139 outLen [ I ] - Length of indication buffer
140 pOut [ I ] - Indication buffer
141
142 RETURN VALUE:
143 None
144 ===========================================================================*/
145 void WDSSessionStateCallback(
146 ULONG svcID,
147 ULONG msgID,
148 GOBIHANDLE /* handle */,
149 ULONG outLen,
150 const BYTE * pOut )
151 {
152 if (gpCM == 0 || svcID != 1 || msgID != 34)
153 {
154 return;
155 }
156
157 ULONG state = ULONG_MAX;
158
159 std::map <UINT8, const sQMIRawContentHeader *> tlvs = GetTLVs( &pOut[0], outLen );
160 std::map <UINT8, const sQMIRawContentHeader *>::const_iterator pIter = tlvs.find( 0x01 );
161 if (pIter != tlvs.end())
162 {
163 const sQMIRawContentHeader * pTmp = pIter->second;
164 if (pTmp->mLength >= sizeof (sWDSPacketServiceStatusReportIndication_Status))
165 {
166 pTmp++;
167 const sWDSPacketServiceStatusReportIndication_Status * pState =
168 (const sWDSPacketServiceStatusReportIndication_Status *)pTmp;
169
170 state = pState->mConnectionStatus;
171 }
172 }
173
174 if (state != ULONG_MAX)
175 {
176 gpCM->OnSessionStateCBNotification( state );
177 }
178 }
179
180 /*===========================================================================
181 METHOD:
182 NASEventReportCallback (Free Method)
183
184 DESCRIPTION:
185 Function called by NAS event report callback
186
187 PARAMETERS:
188 svcID [ I ] - QMI service ID
189 msgID [ I ] - QMI message ID
190 handle [ I ] - Handle to Gobi API connection
191 outLen [ I ] - Length of indication buffer
192 pOut [ I ] - Indication buffer
193
194 RETURN VALUE:
195 None
196 ===========================================================================*/
197 void NASEventReportCallback(
198 ULONG svcID,
199 ULONG msgID,
200 GOBIHANDLE /* handle */,
201 ULONG outLen,
202 const BYTE * pOut )
203 {
204 if (gpCM == 0 || svcID != 3 || msgID != 2)
205 {
206 return;
207 }
208
209 std::map <UINT8, const sQMIRawContentHeader *> tlvs = GetTLVs( &pOut[0], outLen );
210 std::map <UINT8, const sQMIRawContentHeader *>::const_iterator pIter = tlvs.find( 0x10 );
211 if (pIter == tlvs.end())
212 {
213 return;
214 }
215
216 const sQMIRawContentHeader * pTmp = pIter->second;
217 if (pTmp->mLength >= sizeof (sNASEventReportIndication_SignalStrength))
218 {
219 pTmp++;
220 const sNASEventReportIndication_SignalStrength * pSS =
221 (const sNASEventReportIndication_SignalStrength *)pTmp;
222
223 gpCM->OnSignalStrengthCBNotificaion( pSS->mSignalStrengthdBm,
224 pSS->mRadioInterface );
225 }
226 }
227
228 /*===========================================================================
229 METHOD:
230 NASServingSystemCallback (Free Method)
231
232 DESCRIPTION:
233 Function called by NAS serving system callback
234
235 PARAMETERS:
236 svcID [ I ] - QMI service ID
237 msgID [ I ] - QMI message ID
238 handle [ I ] - Handle to Gobi API connection
239 outLen [ I ] - Length of indication buffer
240 pOut [ I ] - Indication buffer
241
242 RETURN VALUE:
243 None
244 ===========================================================================*/
245 void NASServingSystemCallback(
246 ULONG svcID,
247 ULONG msgID,
248 GOBIHANDLE /* handle */,
249 ULONG outLen,
250 const BYTE * pOut )
251 {
252 if (gpCM == 0 || svcID != 3 || msgID != 36)
253 {
254 return;
255 }
256
257 std::map <UINT8, const sQMIRawContentHeader *> tlvs = GetTLVs( &pOut[0], outLen );
258 std::map <UINT8, const sQMIRawContentHeader *>::const_iterator pIter = tlvs.find( 0x10 );
259 if (pIter != tlvs.end())
260 {
261 const sQMIRawContentHeader * pTmp = pIter->second;
262 if (pTmp->mLength >= sizeof (sNASServingSystemIndication_RoamingIndicator))
263 {
264 pTmp++;
265 const sNASServingSystemIndication_RoamingIndicator * pRI =
266 (const sNASServingSystemIndication_RoamingIndicator *)pTmp;
267
268 BYTE roam = pRI->mRoamingIndicator;
269 if (roam == 0xFF)
270 {
271 gpCM->SetRoam( "Unknown" );
272 }
273 else
274 {
275 std::ostringstream roamStr;
276 roamStr << roam;
277 gpCM->SetRoam( roamStr.str() );
278 }
279 }
280 }
281
282 pIter = tlvs.find( 0x11 );
283 if (pIter != tlvs.end())
284 {
285 const sQMIRawContentHeader * pTmp = pIter->second;
286 ULONG tlvLen = (ULONG)pTmp->mLength;
287 ULONG dsLen = (ULONG)sizeof( sNASServingSystemIndication_DataServices );
288 if (tlvLen < dsLen)
289 {
290 return;
291 }
292
293 pTmp++;
294 const sNASServingSystemIndication_DataServices * pDS =
295 (const sNASServingSystemIndication_DataServices *)pTmp;
296
297 ULONG dcCount = (ULONG)pDS->mNumberOfDataCapabilities;
298 ULONG dcSz = (ULONG)sizeof( eQMINASDataServiceCapabilities2 );
299 dsLen += dcCount * dcSz;
300 if (tlvLen < dsLen)
301 {
302 return;
303 }
304
305 pDS++;
306 gpCM->OnDataCapsNotification( dcCount,
307 (eQMINASDataServiceCapabilities2 *)pDS );
308 }
309 }