| 1 |
/*=========================================================================== |
| 2 |
FILE: |
| 3 |
GobiCMDLL.h |
| 4 |
|
| 5 |
DESCRIPTION: |
| 6 |
Simple class to load and interface to the Gobi CM DLL |
| 7 |
|
| 8 |
PUBLIC CLASSES AND METHODS: |
| 9 |
cGobiCMDLL |
| 10 |
This class loads the Gobi CM DLL and then interfaces to it |
| 11 |
|
| 12 |
Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 13 |
|
| 14 |
Redistribution and use in source and binary forms, with or without |
| 15 |
modification, are permitted provided that the following conditions are met: |
| 16 |
* Redistributions of source code must retain the above copyright |
| 17 |
notice, this list of conditions and the following disclaimer. |
| 18 |
* Redistributions in binary form must reproduce the above copyright |
| 19 |
notice, this list of conditions and the following disclaimer in the |
| 20 |
documentation and/or other materials provided with the distribution. |
| 21 |
* Neither the name of Code Aurora Forum nor |
| 22 |
the names of its contributors may be used to endorse or promote |
| 23 |
products derived from this software without specific prior written |
| 24 |
permission. |
| 25 |
|
| 26 |
|
| 27 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 28 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 29 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 30 |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 31 |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 32 |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 33 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 34 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 35 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 36 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 37 |
POSSIBILITY OF SUCH DAMAGE. |
| 38 |
===========================================================================*/ |
| 39 |
|
| 40 |
//--------------------------------------------------------------------------- |
| 41 |
// Pragmas |
| 42 |
//--------------------------------------------------------------------------- |
| 43 |
#pragma once |
| 44 |
|
| 45 |
//--------------------------------------------------------------------------- |
| 46 |
// Include Files |
| 47 |
//--------------------------------------------------------------------------- |
| 48 |
#include "GobiConnectionMgmtAPI.h" |
| 49 |
#include "GobiConnectionMgmtAPIStructs.h" |
| 50 |
#include <map> |
| 51 |
|
| 52 |
//--------------------------------------------------------------------------- |
| 53 |
// Definitions |
| 54 |
//--------------------------------------------------------------------------- |
| 55 |
// Handle to Gobi API |
| 56 |
typedef ULONG_PTR GOBIHANDLE; |
| 57 |
|
| 58 |
// The maximum number of signals |
| 59 |
const ULONG MAX_SIGNALS = 12; |
| 60 |
|
| 61 |
// The maximum number of data capabilities |
| 62 |
const ULONG MAX_DATA_CAPABILITIES = 12; |
| 63 |
|
| 64 |
// Gobi input/output function pointer |
| 65 |
typedef ULONG (* tFNGobiInputOutput)( |
| 66 |
GOBIHANDLE handle, |
| 67 |
ULONG to, |
| 68 |
ULONG inLen, |
| 69 |
const BYTE * pIn, |
| 70 |
ULONG * pOutLen, |
| 71 |
BYTE * pOut ); |
| 72 |
|
| 73 |
/*=========================================================================*/ |
| 74 |
// Free Methods |
| 75 |
/*=========================================================================*/ |
| 76 |
|
| 77 |
/*=========================================================================== |
| 78 |
METHOD: |
| 79 |
GetTLVs (Internal Method) |
| 80 |
|
| 81 |
DESCRIPTION: |
| 82 |
Convert response buffer to a TLV map |
| 83 |
|
| 84 |
PARAMETERS: |
| 85 |
pRsp [ I ] - The response buffer |
| 86 |
rspSz [ I ] - The size of the above buffer |
| 87 |
|
| 88 |
RETURN VALUE: |
| 89 |
std::map <UINT8, const sQMIRawContentHeader *> |
| 90 |
===========================================================================*/ |
| 91 |
inline std::map <UINT8, const sQMIRawContentHeader *> GetTLVs( |
| 92 |
const UINT8 * pRsp, |
| 93 |
ULONG rspSz ) |
| 94 |
{ |
| 95 |
std::map <UINT8, const sQMIRawContentHeader *> retMap; |
| 96 |
|
| 97 |
ULONG dataProcessed = 0; |
| 98 |
const UINT8 * pData = &pRsp[0]; |
| 99 |
while (dataProcessed < rspSz) |
| 100 |
{ |
| 101 |
dataProcessed += (ULONG)sizeof( sQMIRawContentHeader ); |
| 102 |
if (dataProcessed > rspSz) |
| 103 |
{ |
| 104 |
break; |
| 105 |
} |
| 106 |
|
| 107 |
const sQMIRawContentHeader * pTLV = (const sQMIRawContentHeader *)pData; |
| 108 |
dataProcessed += (ULONG)pTLV->mLength; |
| 109 |
if (dataProcessed > rspSz) |
| 110 |
{ |
| 111 |
break; |
| 112 |
} |
| 113 |
|
| 114 |
retMap[pTLV->mTypeID] = pTLV; |
| 115 |
pData = &pRsp[dataProcessed]; |
| 116 |
} |
| 117 |
|
| 118 |
return retMap; |
| 119 |
}; |
| 120 |
|
| 121 |
/*=========================================================================*/ |
| 122 |
// Class cGobiCMDLL |
| 123 |
/*=========================================================================*/ |
| 124 |
class cGobiCMDLL |
| 125 |
{ |
| 126 |
public: |
| 127 |
// Constructor |
| 128 |
cGobiCMDLL() |
| 129 |
: mhGobi( 0 ) |
| 130 |
{ } |
| 131 |
|
| 132 |
// Destructor |
| 133 |
~cGobiCMDLL() |
| 134 |
{ } |
| 135 |
|
| 136 |
// Connect |
| 137 |
ULONG Connect( LPCSTR pInterface ); |
| 138 |
|
| 139 |
// Disconnect |
| 140 |
ULONG Disconnect(); |
| 141 |
|
| 142 |
// Start data session |
| 143 |
ULONG StartDataSession( |
| 144 |
LPCSTR pAPN, |
| 145 |
LPCSTR pUser, |
| 146 |
LPCSTR pPwd, |
| 147 |
ULONG * pSessionID, |
| 148 |
ULONG * pFailureCode ); |
| 149 |
|
| 150 |
// Cancel data session |
| 151 |
ULONG CancelDataSession(); |
| 152 |
|
| 153 |
// Stop data session |
| 154 |
ULONG StopDataSession( ULONG sessionID ); |
| 155 |
|
| 156 |
// Get session state |
| 157 |
ULONG GetSessionState( ULONG * pSessionState ); |
| 158 |
|
| 159 |
// Get session duration |
| 160 |
ULONG GetSessionDuration( ULONGLONG * pSessionDuration ); |
| 161 |
|
| 162 |
// Get data bearer technology |
| 163 |
ULONG GetDataBearerTechnology( ULONG * pDataBearerTech ); |
| 164 |
|
| 165 |
// Get connection rate |
| 166 |
ULONG GetConnectionRate( |
| 167 |
ULONG * pCurTX, |
| 168 |
ULONG * pCurRX, |
| 169 |
ULONG * pMaxTX, |
| 170 |
ULONG * pMaxRX ); |
| 171 |
|
| 172 |
// Get firmware revision |
| 173 |
ULONG GetFirmwareRevision( |
| 174 |
BYTE strSz, |
| 175 |
CHAR * pStr ); |
| 176 |
|
| 177 |
// Get manufacturer |
| 178 |
ULONG GetManufacturer( |
| 179 |
BYTE strSz, |
| 180 |
CHAR * pStr ); |
| 181 |
|
| 182 |
// Get model ID |
| 183 |
ULONG GetModelID( |
| 184 |
BYTE strSz, |
| 185 |
CHAR * pStr ); |
| 186 |
|
| 187 |
// Get hardware revision |
| 188 |
ULONG GetHardwareRevision( |
| 189 |
BYTE strSz, |
| 190 |
CHAR * pStr ); |
| 191 |
|
| 192 |
// Get voice number |
| 193 |
ULONG GetVoiceNumber( |
| 194 |
BYTE voiceSz, |
| 195 |
CHAR * pVoiceStr, |
| 196 |
BYTE minSz, |
| 197 |
CHAR * pMINStr ); |
| 198 |
|
| 199 |
// Get serial numbers |
| 200 |
ULONG GetSerialNumbers( |
| 201 |
BYTE esnSz, |
| 202 |
CHAR * pESNStr, |
| 203 |
BYTE imeiSz, |
| 204 |
CHAR * pIMEIStr, |
| 205 |
BYTE meidSz, |
| 206 |
CHAR * pMEIDStr ); |
| 207 |
|
| 208 |
// Get IMSI |
| 209 |
ULONG GetIMSI( |
| 210 |
BYTE imsiSz, |
| 211 |
CHAR * pIMSIStr ); |
| 212 |
|
| 213 |
// Get signal strengths |
| 214 |
ULONG GetSignalStrengths( |
| 215 |
INT8 * pSigStrengths, |
| 216 |
ULONG * pRadioInterfaces ); |
| 217 |
|
| 218 |
// Get serving network |
| 219 |
ULONG GetServingNetwork( |
| 220 |
ULONG * pDataCapabilities, |
| 221 |
WORD * pMCC, |
| 222 |
WORD * pMNC, |
| 223 |
BYTE nameSize, |
| 224 |
CHAR * pName, |
| 225 |
WORD * pSID, |
| 226 |
WORD * pNID, |
| 227 |
ULONG * pRoam ); |
| 228 |
|
| 229 |
// Get home network |
| 230 |
ULONG GetHomeNetwork( |
| 231 |
WORD * pHomeMCC, |
| 232 |
WORD * pHomeMNC, |
| 233 |
BYTE homeNameSize, |
| 234 |
CHAR * pHomeName, |
| 235 |
WORD * pSID, |
| 236 |
WORD * pNID ); |
| 237 |
|
| 238 |
// Set WDS event report callback |
| 239 |
ULONG SetWDSEventReportCB( |
| 240 |
tFNGenericCallback pCallback, |
| 241 |
BYTE interval ); |
| 242 |
|
| 243 |
// Set WDS packet service status callback |
| 244 |
ULONG SetWDSSessionStateCB( tFNGenericCallback pCallback ); |
| 245 |
|
| 246 |
// Set NAS event report callback |
| 247 |
ULONG SetNASEventReportCB( |
| 248 |
tFNGenericCallback pCallback, |
| 249 |
BYTE thresholdsSize, |
| 250 |
INT8 * pThresholds ); |
| 251 |
|
| 252 |
// Set NAS serving system callback |
| 253 |
ULONG SetNASServingSystemCB( tFNGenericCallback pCallback ); |
| 254 |
|
| 255 |
protected: |
| 256 |
|
| 257 |
// Call a Gobi CM API function that returns a string |
| 258 |
ULONG GetString( |
| 259 |
tFNGobiInputOutput mpFnString, |
| 260 |
BYTE tlvID, |
| 261 |
BYTE strSz, |
| 262 |
CHAR * pStr ); |
| 263 |
|
| 264 |
/* Handle to Gobi API */ |
| 265 |
GOBIHANDLE mhGobi; |
| 266 |
}; |