b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | /****************************************************************************** |
| 2 | *(C) Copyright 2014 Marvell International Ltd. |
| 3 | * All Rights Reserved |
| 4 | ******************************************************************************/ |
| 5 | /* ------------------------------------------------------------------------------------------------------------------- |
| 6 | * |
| 7 | * Filename: mbim_util.c |
| 8 | * |
| 9 | * Authors: Adrian Zelezniak |
| 10 | * |
| 11 | * Description: all utiliy functions and macros needed for the MIBM translator |
| 12 | * |
| 13 | * HISTORY: |
| 14 | * Jan 7, 2014 - Initial Version |
| 15 | * |
| 16 | * Notes: |
| 17 | * |
| 18 | ******************************************************************************/ |
| 19 | |
| 20 | #define LOG_TAG "MBIM" |
| 21 | |
| 22 | /****************************************************************************** |
| 23 | * Include files |
| 24 | ******************************************************************************/ |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <stddef.h> |
| 28 | |
| 29 | #include "mbim_types.h" |
| 30 | #include "mbim_basic.h" |
| 31 | #include "mbim_sms.h" |
| 32 | #include "mbim_ussd.h" |
| 33 | #include "mbim_util.h" |
| 34 | #include "mbim_protocol.h" |
| 35 | #if defined (MBIM_MTIL) |
| 36 | #include "mbim_mtil.h" |
| 37 | #include "mbim_mtil_ind.h" |
| 38 | #include "MtilAPI.h" |
| 39 | #include "mbim_cm.h" |
| 40 | #else |
| 41 | #include "mbim_ril.h" |
| 42 | #endif |
| 43 | |
| 44 | |
| 45 | #ifndef MBIM_BASIC_UNUSEDPARAM |
| 46 | #define MBIM_BASIC_UNUSEDPARAM() ((void) cid);((void) transactionId);((void) commandType);((void) infoBufLen);((void) infoBuf_p) |
| 47 | #endif |
| 48 | |
| 49 | extern int property_get(const char *name, const char* value, const char* default_value); |
| 50 | |
| 51 | |
| 52 | /****************************************************************************** |
| 53 | * Macros |
| 54 | ******************************************************************************/ |
| 55 | #define CREATE_BASIC_CONNECT_CONTEXT(pContext, mBuf) \ |
| 56 | pContext = (P_MBIM_MESSAGE_CONTEXT)MBIM_MALLOC(sizeof(MBIM_MESSAGE_CONTEXT)); \ |
| 57 | if (pContext != NULL) { \ |
| 58 | pContext->hdr.cid = cid; \ |
| 59 | pContext->hdr.transId = transactionId; \ |
| 60 | pContext->hdr.uuidIndex = UUID_BASIC_CONNECT_INDEX; \ |
| 61 | pContext->hdr.indication= MBIM_REQUEST; \ |
| 62 | pContext->body = mBuf; \ |
| 63 | pContext->cmd = NULL; \ |
| 64 | } \ |
| 65 | else { \ |
| 66 | if (mBuf != NULL) \ |
| 67 | MBIM_FREE(mBuf); \ |
| 68 | MBIM_LOGE("BASIC UUID: OUT OF MEMORY CID %d (TransactionId = %d, Cmd Type = %d)", cid, transactionId, commandType); \ |
| 69 | return MbimSendFunctionErrorMsg(transactionId, MBIM_ERROR_UNKNOWN); \ |
| 70 | } |
| 71 | |
| 72 | |
| 73 | #define ALLOCATE_RESPONSE_BUFFER(mBuf_p, mSize) \ |
| 74 | mBuf_p = (char *)MBIM_MALLOC(mSize); \ |
| 75 | if (mBuf_p == NULL) { \ |
| 76 | MBIM_LOGE("BASIC UUID: OUT OF MEMORY CID %d (TransactionId = %d, Cmd Type = %d)", cid, transactionId, commandType); \ |
| 77 | return MbimSendFunctionErrorMsg(transactionId, MBIM_ERROR_UNKNOWN); \ |
| 78 | } else \ |
| 79 | { memset(mBuf_p, 0, mSize); } |
| 80 | |
| 81 | |
| 82 | #define ALLOCATE_CMD_BUFFER(context_p, mBuf_p, mSize) \ |
| 83 | mBuf_p = (char *)MBIM_MALLOC(mSize); \ |
| 84 | if (mBuf_p == NULL) { \ |
| 85 | if (context_p->body != NULL) \ |
| 86 | MBIM_FREE(context_p->body); \ |
| 87 | MBIM_LOGE("BASIC UUID: OUT OF MEMORY CID %d (TransactionId = %d, Cmd Type = %d)", cid, transactionId, commandType); \ |
| 88 | return MbimSendFunctionErrorMsg(transactionId, MBIM_ERROR_UNKNOWN); \ |
| 89 | } else { \ |
| 90 | memset(mBuf_p, 0, mSize); \ |
| 91 | context_p->cmd = mBuf_p; \ |
| 92 | } |
| 93 | |
| 94 | |
| 95 | #define ADD_DEVICE_SERVICES(service) *pCidSupported = service; \ |
| 96 | pCidSupported++; \ |
| 97 | pBuf->cidCount++; |
| 98 | |
| 99 | |
| 100 | /****************************************************************************** |
| 101 | * #defines |
| 102 | ******************************************************************************/ |
| 103 | #define DEFAULT_CONTEXT_ALLOC_SIZE (4000) |
| 104 | |
| 105 | |
| 106 | /****************************************************************************** |
| 107 | * Global Variables |
| 108 | ******************************************************************************/ |
| 109 | extern MBIM_DATABASE mbimDb; |
| 110 | Boolean ConfigureAzw = TRUE; |
| 111 | |
| 112 | /* services filer arrays */ |
| 113 | char basicFilterArray[UUID_BASIC_CID_MAX]; |
| 114 | char smsFilterArray[UUID_SMS_CID_MAX]; |
| 115 | char ussdFilterArray[UUID_USSD_CID_MAX]; |
| 116 | |
| 117 | UINT32 cidsFilterArray[UUID_MAX_SERVICE_INDEX][2] = |
| 118 | { |
| 119 | {(UINT32)&basicFilterArray,sizeof(basicFilterArray)}, |
| 120 | {(UINT32)&smsFilterArray,sizeof(smsFilterArray)}, |
| 121 | {(UINT32)&ussdFilterArray,sizeof(ussdFilterArray)}, |
| 122 | {0,0}, |
| 123 | {0,0}, |
| 124 | {0,0}, |
| 125 | {0,0} |
| 126 | }; |
| 127 | |
| 128 | //BS: |
| 129 | Boolean disableUnsolCidConnect = FALSE; |
| 130 | |
| 131 | /****************************************************************************** |
| 132 | * Function prototypes |
| 133 | ******************************************************************************/ |
| 134 | static int addBasicConnectServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf); |
| 135 | static int addSmsServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf); |
| 136 | static int addUssdServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf); |
| 137 | static int addPhonebookServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf); |
| 138 | static int addStkServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf); |
| 139 | static int addAuthServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf); |
| 140 | static int addDssServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf); |
| 141 | static int addBasicExtServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf); |
| 142 | static int addUICCServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf); |
| 143 | static void MbimSetDeviceServiceSubscribeList (P_MBIM_DEVICE_SERVICE_SUBSCRIBE_LIST pDevServSubsList); |
| 144 | |
| 145 | //static int validateCidConnectSetCommand(P_MBIM_SET_CONNECT pSetConnect); |
| 146 | |
| 147 | |
| 148 | int CID_DeviceCaps(BASIC_CID_PARAMS); |
| 149 | int CID_SubscriberReadyStatus(BASIC_CID_PARAMS); |
| 150 | int CID_RadioState(BASIC_CID_PARAMS); |
| 151 | int CID_Pin(BASIC_CID_PARAMS); |
| 152 | int CID_PinList(BASIC_CID_PARAMS); |
| 153 | int CID_HomeProvider(BASIC_CID_PARAMS); |
| 154 | int CID_PreferedProviders(BASIC_CID_PARAMS); |
| 155 | int CID_VisibleProviders(BASIC_CID_PARAMS); |
| 156 | int CID_RegisterState(BASIC_CID_PARAMS); |
| 157 | int CID_PacketService(BASIC_CID_PARAMS); |
| 158 | int CID_SignalState(BASIC_CID_PARAMS); |
| 159 | int CID_Connect(BASIC_CID_PARAMS); |
| 160 | int CID_ProvisionedContexts(BASIC_CID_PARAMS); |
| 161 | int CID_ServiceActivation(BASIC_CID_PARAMS); |
| 162 | int CID_IpConfiguration(BASIC_CID_PARAMS); |
| 163 | int CID_DeviceServices(BASIC_CID_PARAMS); |
| 164 | int CID_DeviceServicesSubscribeList(BASIC_CID_PARAMS); |
| 165 | int CID_PacketStatistics(BASIC_CID_PARAMS); |
| 166 | int CID_NetworkIdleHint(BASIC_CID_PARAMS); |
| 167 | int CID_EmergencyMode(BASIC_CID_PARAMS); |
| 168 | int CID_IpPacketFilters(BASIC_CID_PARAMS); |
| 169 | int CID_MultiCarrierProviders(BASIC_CID_PARAMS); |
| 170 | int CID_NotSupported(BASIC_CID_PARAMS); |
| 171 | |
| 172 | /****************************************************************************** |
| 173 | * External variables |
| 174 | ******************************************************************************/ |
| 175 | basicUuidProcessors basicCidProcessor[UUID_BASIC_CID_MAX] = { |
| 176 | CID_NotSupported, //0 |
| 177 | CID_DeviceCaps, |
| 178 | CID_SubscriberReadyStatus, |
| 179 | CID_RadioState, |
| 180 | CID_Pin, |
| 181 | CID_PinList, |
| 182 | CID_HomeProvider, |
| 183 | CID_PreferedProviders, |
| 184 | CID_VisibleProviders, |
| 185 | CID_RegisterState, |
| 186 | CID_PacketService, //10 |
| 187 | CID_SignalState, |
| 188 | CID_Connect, |
| 189 | CID_ProvisionedContexts, |
| 190 | CID_ServiceActivation, |
| 191 | CID_IpConfiguration, |
| 192 | CID_DeviceServices, |
| 193 | CID_NotSupported, //17 |
| 194 | CID_NotSupported,//18 |
| 195 | CID_DeviceServicesSubscribeList, |
| 196 | CID_PacketStatistics, |
| 197 | CID_NetworkIdleHint, |
| 198 | CID_EmergencyMode, |
| 199 | CID_IpPacketFilters, |
| 200 | CID_MultiCarrierProviders, |
| 201 | }; |
| 202 | |
| 203 | |
| 204 | |
| 205 | /****************************************************************************** |
| 206 | * Code |
| 207 | ******************************************************************************/ |
| 208 | |
| 209 | |
| 210 | /*******************************************************************************\ |
| 211 | * Function: CID_NotSupported |
| 212 | * Description: This function sends Error to HOST when a unknown command is received |
| 213 | * Parameters: dataBuf - String |
| 214 | * |
| 215 | * Returns: 0=OK, <0=Error Code |
| 216 | \*******************************************************************************/ |
| 217 | int CID_NotSupported(BASIC_CID_PARAMS) |
| 218 | { |
| 219 | int rc = MBIM_OK; |
| 220 | |
| 221 | //Added for compilation uof unused parameters on Codeline |
| 222 | MBIM_BASIC_UNUSEDPARAM(); |
| 223 | |
| 224 | |
| 225 | MBIM_LOGE("BASIC UUID: Command %d not supported (TransactionId = %d, Cmd Type = %d)", cid, transactionId, commandType); |
| 226 | //rc = MbimSendFunctionErrorMsg(transactionId, MBIM_ERROR_UNKNOWN); //Send Error to MBIM |
| 227 | rc = MbimSendCommandDone(transactionId, UUID_BASIC_CONNECT_INDEX, |
| 228 | cid, MBIM_STATUS_NO_DEVICE_SUPPORT, 0 , NULL); |
| 229 | |
| 230 | return rc; |
| 231 | } |
| 232 | |
| 233 | #define NUMBER_OF_MAX_DSS_SERVICES 7 |
| 234 | #define NUMBER_OF_MAX_CID 18 |
| 235 | /*******************************************************************************\ |
| 236 | * Function: CID_DeviceServices |
| 237 | * Description: MBIM_CID_DEVEICE_SERVICES (Chapter 10.5.29) |
| 238 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 239 | * |
| 240 | * Returns: 0=OK, <0=Error Code |
| 241 | \*******************************************************************************/ |
| 242 | int CID_DeviceServices(BASIC_CID_PARAMS) |
| 243 | { |
| 244 | int rc = MBIM_OK; |
| 245 | char *buf = NULL; |
| 246 | P_MBIM_DEVICE_SERVICE_INFO serviecInfo_p; |
| 247 | P_OL_PAIR_LIST pairList_p; |
| 248 | P_OL_PAIR_LIST prevPairList_p; |
| 249 | int serviceIndex; |
| 250 | |
| 251 | |
| 252 | |
| 253 | //We only support Query for this command |
| 254 | if (commandType != MBIM_QUERY_COMMAND) |
| 255 | { |
| 256 | return CID_NotSupported(BASIC_CID_PARAMS_USAGE); |
| 257 | } |
| 258 | |
| 259 | //This command is HC |
| 260 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 261 | |
| 262 | //Pickup pointer to header |
| 263 | serviecInfo_p = (P_MBIM_DEVICE_SERVICE_INFO)&buf[0]; |
| 264 | serviecInfo_p->deviceServicesCount = UUID_MAX_SERVICE_INDEX; |
| 265 | serviecInfo_p->maxDssSessions = 1; // Number of Session supported (We start with 1, need to change in the future). |
| 266 | |
| 267 | |
| 268 | ////////////////////////////////////////// |
| 269 | //Add BASIC-CONNECT Cid elements |
| 270 | ////////////////////////////////////////// |
| 271 | |
| 272 | //Add BASIC CID supported Services |
| 273 | pairList_p = (P_OL_PAIR_LIST)&buf[sizeof(MBIM_DEVICE_SERVICE_INFO)]; |
| 274 | pairList_p->offset = sizeof(MBIM_DEVICE_SERVICE_INFO) + serviecInfo_p->deviceServicesCount*sizeof(OL_PAIR_LIST); |
| 275 | pairList_p->size = addBasicConnectServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset])); |
| 276 | |
| 277 | for (serviceIndex = 1 ; serviceIndex < (int)serviecInfo_p->deviceServicesCount ; serviceIndex++) |
| 278 | { |
| 279 | //Add supported services |
| 280 | prevPairList_p = pairList_p; |
| 281 | pairList_p++; |
| 282 | pairList_p->offset = prevPairList_p->offset + prevPairList_p->size; |
| 283 | |
| 284 | switch(serviceIndex) |
| 285 | { |
| 286 | case UUID_SMS_INDEX: |
| 287 | pairList_p->size = addSmsServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset])); |
| 288 | break; |
| 289 | case UUID_USSD_INDEX: |
| 290 | pairList_p->size = addUssdServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset])); |
| 291 | break; |
| 292 | case UUID_PHONEBOOK_INDEX: |
| 293 | pairList_p->size = addPhonebookServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset])); |
| 294 | break; |
| 295 | case UUID_STK_INDEX: |
| 296 | pairList_p->size = addStkServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset])); |
| 297 | break; |
| 298 | case UUID_AUTH_INDEX: |
| 299 | pairList_p->size = addAuthServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset])); |
| 300 | break; |
| 301 | case UUID_DSS_INDEX: |
| 302 | pairList_p->size = addDssServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset])); |
| 303 | break; |
| 304 | case UUID_BASIC_CONNECT_EXTENSIONS_INDEX: |
| 305 | pairList_p->size = addBasicExtServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset])); |
| 306 | break; |
| 307 | case UUID_MS_UICC_LOW_LEVEL_INDEX: |
| 308 | pairList_p->size = addUICCServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset])); |
| 309 | break; |
| 310 | default: |
| 311 | break; |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | //Send the Command Done back to MBIM Host |
| 316 | MbimSendCommandDone(transactionId, UUID_BASIC_CONNECT_INDEX, cid, MBIM_STATUS_SUCCESS, (pairList_p->offset+pairList_p->size) , buf); |
| 317 | |
| 318 | //Free the buffer |
| 319 | MBIM_FREE(buf); |
| 320 | |
| 321 | return rc; |
| 322 | } |
| 323 | |
| 324 | |
| 325 | /*******************************************************************************\ |
| 326 | * Function: addBasicConnectServiceElements |
| 327 | * Description: Adds the supported BASIC_CONNECT CID to the Service Element |
| 328 | * Parameters: P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element |
| 329 | * |
| 330 | * Returns: the size of the current element |
| 331 | \*******************************************************************************/ |
| 332 | static int addBasicConnectServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf) |
| 333 | { |
| 334 | UINT32 *pCidSupported; |
| 335 | |
| 336 | Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_BASIC_CONNECT_INDEX); |
| 337 | pBuf->dssPayload = 0; |
| 338 | pBuf->maxDssInstaces = 0; |
| 339 | pBuf->cidCount = 0; //This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES) |
| 340 | pCidSupported = (UINT32 *)&pBuf->dataBuffer[0]; |
| 341 | |
| 342 | ADD_DEVICE_SERVICES(UUID_BASIC_CID_DEVICE_CAPS); |
| 343 | ADD_DEVICE_SERVICES(UUID_SUBSCRIBER_READY_STATUS); |
| 344 | ADD_DEVICE_SERVICES(UUID_RADIO_STATE); |
| 345 | ADD_DEVICE_SERVICES(UUID_PIN); |
| 346 | ADD_DEVICE_SERVICES(UUID_PIN_LIST); |
| 347 | ADD_DEVICE_SERVICES(UUID_HOME_PROVIDER); |
| 348 | ADD_DEVICE_SERVICES(UUID_PREFERRED_PROVIDERS); |
| 349 | ADD_DEVICE_SERVICES(UUID_VISIBLE_PROVIDERS); |
| 350 | ADD_DEVICE_SERVICES(UUID_REGISTER_STATE); |
| 351 | ADD_DEVICE_SERVICES(UUID_PACKET_SERVICE); |
| 352 | ADD_DEVICE_SERVICES(UUID_SIGNAL_STATE); |
| 353 | ADD_DEVICE_SERVICES(UUID_CONNECT); |
| 354 | ADD_DEVICE_SERVICES(UUID_PROVISIONED_CONTEXTS); |
| 355 | ADD_DEVICE_SERVICES(UUID_SERVICE_ACTIVATION); |
| 356 | ADD_DEVICE_SERVICES(UUID_IP_CONFIGURATION); |
| 357 | ADD_DEVICE_SERVICES(UUID_DEVICE_SERVICES); |
| 358 | ADD_DEVICE_SERVICES(UUID_DEVICE_SERVICE_SUBSCRIBE_LIST); |
| 359 | ADD_DEVICE_SERVICES(UUID_PACKET_STATISTICS); |
| 360 | ADD_DEVICE_SERVICES(UUID_NETWORK_IDLE_HINT); |
| 361 | ADD_DEVICE_SERVICES(UUID_EMERGENCY_MODE); |
| 362 | ADD_DEVICE_SERVICES(UUID_IP_PACKET_FILTERS); |
| 363 | |
| 364 | //return the size of the service element |
| 365 | return ((UINT32)pCidSupported - (UINT32)pBuf ); |
| 366 | } |
| 367 | |
| 368 | /*******************************************************************************\ |
| 369 | * Function: addSmsServiceElements |
| 370 | * Description: Adds the supported SMS CID to the Service Element |
| 371 | * Parameters: P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element |
| 372 | * |
| 373 | * Returns: the size of the current element |
| 374 | \*******************************************************************************/ |
| 375 | static int addSmsServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf) |
| 376 | { |
| 377 | UINT32 *pCidSupported; |
| 378 | |
| 379 | Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_SMS_INDEX); |
| 380 | pBuf->dssPayload = 0; |
| 381 | pBuf->maxDssInstaces = 0; |
| 382 | pBuf->cidCount = 0; //This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES) |
| 383 | pCidSupported = (UINT32 *)&pBuf->dataBuffer[0]; |
| 384 | |
| 385 | ADD_DEVICE_SERVICES(UUID_SMS_CONFIGURATION); |
| 386 | ADD_DEVICE_SERVICES(UUID_SMS_READ); |
| 387 | ADD_DEVICE_SERVICES(UUID_SMS_SEND); |
| 388 | ADD_DEVICE_SERVICES(UUID_SMS_DELETE); |
| 389 | ADD_DEVICE_SERVICES(UUID_SMS_MESSAGE_STORE_STATUS); |
| 390 | |
| 391 | //return the size of the service element |
| 392 | return ((UINT32)pCidSupported - (UINT32)pBuf ); |
| 393 | } |
| 394 | |
| 395 | |
| 396 | /*******************************************************************************\ |
| 397 | * Function: addUssdServiceElements |
| 398 | * Description: Adds the supported USSD CID to the Service Element |
| 399 | * Parameters: P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element |
| 400 | * |
| 401 | * Returns: the size of the current element |
| 402 | \*******************************************************************************/ |
| 403 | static int addUssdServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf) |
| 404 | { |
| 405 | UINT32 *pCidSupported; |
| 406 | |
| 407 | Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_USSD_INDEX); |
| 408 | pBuf->dssPayload = 0; |
| 409 | pBuf->maxDssInstaces = 0; |
| 410 | pBuf->cidCount = 0; //This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES) |
| 411 | pCidSupported = (UINT32 *)&pBuf->dataBuffer[0]; |
| 412 | |
| 413 | ADD_DEVICE_SERVICES(MBIM_CID_USSD); |
| 414 | |
| 415 | //return the size of the service element |
| 416 | return ((UINT32)pCidSupported - (UINT32)pBuf ); |
| 417 | } |
| 418 | |
| 419 | |
| 420 | /*******************************************************************************\ |
| 421 | * Function: addPhonebookServiceElements |
| 422 | * Description: Adds the supported PHONEBOOK CID to the Service Element |
| 423 | * Parameters: P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element |
| 424 | * |
| 425 | * Returns: the size of the current element |
| 426 | \*******************************************************************************/ |
| 427 | static int addPhonebookServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf) |
| 428 | { |
| 429 | UINT32 *pCidSupported; |
| 430 | |
| 431 | Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_PHONEBOOK_INDEX); |
| 432 | pBuf->dssPayload = 0; |
| 433 | pBuf->maxDssInstaces = 0; |
| 434 | pBuf->cidCount = 0; //This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES) |
| 435 | pCidSupported = (UINT32 *)&pBuf->dataBuffer[0]; |
| 436 | |
| 437 | ADD_DEVICE_SERVICES(MBIM_CID_PHONEBOOK_CONFIGURATION); |
| 438 | ADD_DEVICE_SERVICES(MBIM_CID_PHONEBOOK_READ); |
| 439 | ADD_DEVICE_SERVICES(MBIM_CID_PHONEBOOK_DELETE); |
| 440 | ADD_DEVICE_SERVICES(MBIM_CID_PHONEBOOK_WRITE); |
| 441 | |
| 442 | //return the size of the service element |
| 443 | return ((UINT32)pCidSupported - (UINT32)pBuf ); |
| 444 | } |
| 445 | |
| 446 | |
| 447 | /*******************************************************************************\ |
| 448 | * Function: addStkServiceElements |
| 449 | * Description: Adds the supported STK CID to the Service Element |
| 450 | * Parameters: P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element |
| 451 | * |
| 452 | * Returns: the size of the current element |
| 453 | \*******************************************************************************/ |
| 454 | static int addStkServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf) |
| 455 | { |
| 456 | UINT32 *pCidSupported; |
| 457 | |
| 458 | Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_STK_INDEX); |
| 459 | pBuf->dssPayload = 0; |
| 460 | pBuf->maxDssInstaces = 0; |
| 461 | pBuf->cidCount = 0; //This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES) |
| 462 | pCidSupported = (UINT32 *)&pBuf->dataBuffer[0]; |
| 463 | |
| 464 | ADD_DEVICE_SERVICES(MBIM_CID_STK_PAC); |
| 465 | ADD_DEVICE_SERVICES(MBIM_CID_STK_TERMINAL_RESPONSE); |
| 466 | ADD_DEVICE_SERVICES(MBIM_CID_STK_ENVELOPE); |
| 467 | |
| 468 | //return the size of the service element |
| 469 | return ((UINT32)pCidSupported - (UINT32)pBuf ); |
| 470 | } |
| 471 | |
| 472 | |
| 473 | /*******************************************************************************\ |
| 474 | * Function: addAuthServiceElements |
| 475 | * Description: Adds the supported AUTH CID to the Service Element |
| 476 | * Parameters: P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element |
| 477 | * |
| 478 | * Returns: the size of the current element |
| 479 | \*******************************************************************************/ |
| 480 | static int addAuthServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf) |
| 481 | { |
| 482 | UINT32 *pCidSupported; |
| 483 | |
| 484 | Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_AUTH_INDEX); |
| 485 | pBuf->dssPayload = 0; |
| 486 | pBuf->maxDssInstaces = 0; |
| 487 | pBuf->cidCount = 0; //This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES) |
| 488 | pCidSupported = (UINT32 *)&pBuf->dataBuffer[0]; |
| 489 | |
| 490 | // ADD_DEVICE_SERVICES(MBIM_CID_AKA_AUTH); |
| 491 | // ADD_DEVICE_SERVICES(MBIM_CID_AKAP_AUTH); |
| 492 | // ADD_DEVICE_SERVICES(MBIM_CID_SIM_AUTH); |
| 493 | |
| 494 | //return the size of the service element |
| 495 | return ((UINT32)pCidSupported - (UINT32)pBuf ); |
| 496 | } |
| 497 | |
| 498 | |
| 499 | |
| 500 | /*******************************************************************************\ |
| 501 | * Function: addDssServiceElements |
| 502 | * Description: Adds the supported DSS CID to the Service Element |
| 503 | * Parameters: P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element |
| 504 | * |
| 505 | * Returns: the size of the current element |
| 506 | \*******************************************************************************/ |
| 507 | static int addDssServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf) |
| 508 | { |
| 509 | UINT32 *pCidSupported; |
| 510 | |
| 511 | Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_DSS_INDEX); |
| 512 | pBuf->dssPayload = 0; |
| 513 | pBuf->maxDssInstaces = 0; |
| 514 | pBuf->cidCount = 0; //This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES) |
| 515 | pCidSupported = (UINT32 *)&pBuf->dataBuffer[0]; |
| 516 | |
| 517 | ADD_DEVICE_SERVICES(MBIM_CID_DSS_CONNECT); |
| 518 | |
| 519 | //return the size of the service element |
| 520 | return ((UINT32)pCidSupported - (UINT32)pBuf ); |
| 521 | } |
| 522 | |
| 523 | |
| 524 | /*******************************************************************************\ |
| 525 | * Function: addBasicExtServiceElements |
| 526 | * Description: Adds the supported Basic connect extension CID to the Service Element |
| 527 | * Parameters: P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element |
| 528 | * |
| 529 | * Returns: the size of the current element |
| 530 | \*******************************************************************************/ |
| 531 | static int addBasicExtServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf) |
| 532 | { |
| 533 | UINT32 *pCidSupported; |
| 534 | |
| 535 | Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_BASIC_CONNECT_EXTENSIONS_INDEX); |
| 536 | pBuf->dssPayload = 0; |
| 537 | pBuf->maxDssInstaces = 0; |
| 538 | pBuf->cidCount = 0; //This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES) |
| 539 | pCidSupported = (UINT32 *)&pBuf->dataBuffer[0]; |
| 540 | |
| 541 | ADD_DEVICE_SERVICES(MBIM_MS_PROVISIONED_CONTEXT_V2); |
| 542 | ADD_DEVICE_SERVICES(MBIM_CID_VERSION); |
| 543 | ADD_DEVICE_SERVICES(MBIM_CID_MS_MODEM_CONFIG); |
| 544 | ADD_DEVICE_SERVICES(MBIM_CID_MS_REGISTRATION_PARAMS); |
| 545 | |
| 546 | //return the size of the service element |
| 547 | return ((UINT32)pCidSupported - (UINT32)pBuf ); |
| 548 | } |
| 549 | |
| 550 | |
| 551 | static int addUICCServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf) |
| 552 | { |
| 553 | UINT32 *pCidSupported; |
| 554 | |
| 555 | Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_MS_UICC_LOW_LEVEL_INDEX); |
| 556 | pBuf->dssPayload = 0; |
| 557 | pBuf->maxDssInstaces = 0; |
| 558 | pBuf->cidCount = 0; //This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES) |
| 559 | pCidSupported = (UINT32 *)&pBuf->dataBuffer[0]; |
| 560 | |
| 561 | ADD_DEVICE_SERVICES(MBIM_CID_MS_UICC_ATR); |
| 562 | ADD_DEVICE_SERVICES(MBIM_CID_MS_UICC_OPEN_CHANNEL); |
| 563 | ADD_DEVICE_SERVICES(MBIM_CID_MS_UICC_CLOSE_CHANNEL); |
| 564 | ADD_DEVICE_SERVICES(MBIM_CID_MS_UICC_APDU); |
| 565 | ADD_DEVICE_SERVICES(MBIM_CID_MS_UICC_TERMINAL_CAPABILITY); |
| 566 | ADD_DEVICE_SERVICES(MBIM_CID_MS_UICC_RESET); |
| 567 | |
| 568 | //return the size of the service element |
| 569 | return ((UINT32)pCidSupported - (UINT32)pBuf ); |
| 570 | } |
| 571 | |
| 572 | /*******************************************************************************\ |
| 573 | * Function: CID_DeviceCaps |
| 574 | * Description: MBIM_CID_DEVICE_CAPS (Chapter 10.5.1) |
| 575 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 576 | * |
| 577 | * Returns: 0=OK, <0=Error Code |
| 578 | \*******************************************************************************/ |
| 579 | int CID_DeviceCaps(BASIC_CID_PARAMS) |
| 580 | { |
| 581 | int rc = MBIM_OK; |
| 582 | char *buf = NULL; |
| 583 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 584 | |
| 585 | //We only support Query for this command |
| 586 | if (commandType != MBIM_QUERY_COMMAND) |
| 587 | { |
| 588 | return CID_NotSupported(BASIC_CID_PARAMS_USAGE); |
| 589 | } |
| 590 | |
| 591 | //Allocate buffer for response |
| 592 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 593 | |
| 594 | //Creat the context for this command |
| 595 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 596 | |
| 597 | ///////////////////////////////////////// |
| 598 | //Fill the static data |
| 599 | ///////////////////////////////////////// |
| 600 | if (mbimDb.mbimNegVersion >= MBIMEx_v4) |
| 601 | { |
| 602 | P_MBIM_DEVICE_CAPS_INFO_V3 pCapsInfo = NULL; |
| 603 | |
| 604 | pCapsInfo = (P_MBIM_DEVICE_CAPS_INFO_V3)buf; |
| 605 | pCapsInfo->deviceType = MBIMDeviceTypeRemovable; |
| 606 | pCapsInfo->cellularClass = MBIMCellularClassGsm; |
| 607 | pCapsInfo->voiceClass = MBIMVoiceClassNoVoice; //MBIMVoiceClassSimultaneousVoiceData; |
| 608 | pCapsInfo->simClass = MBIMSimClassSimRemovable; |
| 609 | pCapsInfo->dataClass = (MBIMDataClassLTE | MBIMDataClass5G); |
| 610 | pCapsInfo->smsCaps = MBIMSmsCapsNone;//(MBIMSmsCapsPduReceive | MBIMSmsCapsPduSend); |
| 611 | pCapsInfo->controlCaps = MBIMCtrlCapsRegManual; |
| 612 | pCapsInfo->DataSubClass = MBIMDataSubClass5GNR | MBIMDataSubClass5GENDC; |
| 613 | pCapsInfo->maxSessions = 1; |
| 614 | pCapsInfo->ExecutorIndex = 0; |
| 615 | pCapsInfo->WcdmaBandClass = 0; |
| 616 | } |
| 617 | else |
| 618 | { |
| 619 | P_MBIM_DEVICE_CAPS_INFO pCapsInfo = NULL; |
| 620 | pCapsInfo = (P_MBIM_DEVICE_CAPS_INFO)buf; |
| 621 | pCapsInfo->deviceType = MBIMDeviceTypeRemovable; |
| 622 | pCapsInfo->cellularClass = MBIMCellularClassGsm; |
| 623 | pCapsInfo->voiceClass = MBIMVoiceClassNoVoice; //MBIMVoiceClassSimultaneousVoiceData; |
| 624 | pCapsInfo->simClass = MBIMSimClassSimRemovable; |
| 625 | pCapsInfo->dataClass = (MBIMDataClassLTE | MBIMDataClass5G); |
| 626 | pCapsInfo->smsCaps = MBIMSmsCapsNone;//(MBIMSmsCapsPduReceive | MBIMSmsCapsPduSend); |
| 627 | pCapsInfo->controlCaps = MBIMCtrlCapsRegManual; |
| 628 | pCapsInfo->maxSessions = 1;//MAX_NUM_OF_SESSIONS; --> Adrian |
| 629 | |
| 630 | pCapsInfo->CustomDataClassOffset = 0; |
| 631 | pCapsInfo->CustomDataClassSize = 0; |
| 632 | pCapsInfo->deviceIdOffset = offsetof(MBIM_DEVICE_CAPS_INFO, dataBuffer[0]); |
| 633 | } |
| 634 | |
| 635 | #if defined (MBIM_MTIL) |
| 636 | MBIM_LOGD("Sending CGSN. Context = %d", mContext); |
| 637 | |
| 638 | //send MTIL GET command |
| 639 | rc = MtilSendGetNoParams(mContext, MTIL_CODE_AT_CGSN_GET); |
| 640 | #else |
| 641 | rc = MbimTelRequestDeviceId(mContext); |
| 642 | #endif |
| 643 | return rc; |
| 644 | } |
| 645 | |
| 646 | |
| 647 | /*******************************************************************************\ |
| 648 | * Function: CID_SubscriberReadyStatus |
| 649 | * Description: MBIM_CID_SUBSCRIBER_READY_STATUS (Chapter 10.5.2) |
| 650 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 651 | * |
| 652 | * Returns: 0=OK, <0=Error Code |
| 653 | \*******************************************************************************/ |
| 654 | int CID_SubscriberReadyStatus(BASIC_CID_PARAMS) |
| 655 | { |
| 656 | int rc = MBIM_OK; |
| 657 | char *buf = NULL; |
| 658 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 659 | |
| 660 | //We only support Query for this command |
| 661 | if (commandType != MBIM_QUERY_COMMAND) |
| 662 | { |
| 663 | return CID_NotSupported(BASIC_CID_PARAMS_USAGE); |
| 664 | } |
| 665 | |
| 666 | //Allocate buffer for response |
| 667 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 668 | |
| 669 | //Creat the context for this command |
| 670 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 671 | |
| 672 | #if defined (MBIM_MTIL) |
| 673 | MtilSendGetNoParams(mContext, MTIL_CODE_AT_SIM_DEV_STATUS_GET); |
| 674 | #else |
| 675 | MbimTelRequestSimStatus(mContext); |
| 676 | #endif |
| 677 | return rc; |
| 678 | } |
| 679 | |
| 680 | |
| 681 | |
| 682 | /*******************************************************************************\ |
| 683 | * Function: CID_RadioState |
| 684 | * Description: MBIM_CID_RADIO_STATE (Chapter 10.5.3) |
| 685 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 686 | * |
| 687 | * Returns: 0=OK, <0=Error Code |
| 688 | \*******************************************************************************/ |
| 689 | int CID_RadioState(BASIC_CID_PARAMS) |
| 690 | { |
| 691 | int rc = MBIM_OK; |
| 692 | char *buf = NULL; |
| 693 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 694 | P_MBIM_SET_RADIO_STATE pSetRadioState = NULL; |
| 695 | P_MBIM_RADIO_STATE_INFO pRadioStateInfo = NULL; |
| 696 | #if defined (MBIM_MTIL) |
| 697 | char prop [255]; //Added for testing LTE configuration in 3G NW (Will open 3 pdp's as VZN) |
| 698 | #endif |
| 699 | |
| 700 | //Added for compilation uof unused parameters on Codeline |
| 701 | MBIM_BASIC_UNUSEDPARAM(); |
| 702 | |
| 703 | //Allocate buffer for response |
| 704 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 705 | |
| 706 | //Creat the context for this command |
| 707 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 708 | |
| 709 | |
| 710 | ////////////////////////////////////////////////////// |
| 711 | //Take care SET |
| 712 | ///////////////////////////////////////////////////// |
| 713 | if (commandType == MBIM_SET_COMMAND) |
| 714 | { |
| 715 | pSetRadioState = (P_MBIM_SET_RADIO_STATE)infoBuf_p; |
| 716 | |
| 717 | MBIM_LOGD("MBIM_CID_RADIO_STATE --> Set. RadioState = %d", pSetRadioState->RadioState); |
| 718 | |
| 719 | pRadioStateInfo = (P_MBIM_RADIO_STATE_INFO)buf; |
| 720 | pRadioStateInfo->HwRadioState = MBIMRadioOn; |
| 721 | pRadioStateInfo->SwRadioState = (pSetRadioState->RadioState?1:4); |
| 722 | |
| 723 | #if defined (MBIM_MTIL) |
| 724 | //If we are turning radio ON, check if we are in 3G Debug Mode |
| 725 | if (pSetRadioState->RadioState != 0) |
| 726 | { |
| 727 | //check if we are in test mode |
| 728 | property_get(MBIM_VZN_APN_RULE_PROPERTY, (const char *)prop, "replace"); |
| 729 | if (strcmp(prop, MBIM_VZN_APN_RULE_3G_VZN_TEST) == 0) |
| 730 | { |
| 731 | //Send Simulated PLMN Indication |
| 732 | simulatePlmnInfoInd(); |
| 733 | } |
| 734 | } |
| 735 | #endif |
| 736 | |
| 737 | //save in context the requested configuration. (Need to free buffer in failure below) |
| 738 | ALLOCATE_CMD_BUFFER(mContext, mContext->cmd, infoBufLen); |
| 739 | memcpy( mContext->cmd, (char *)infoBuf_p, infoBufLen); |
| 740 | } |
| 741 | ////////////////////////////////////////////////////// |
| 742 | //Take care QUERY |
| 743 | ///////////////////////////////////////////////////// |
| 744 | else |
| 745 | { |
| 746 | MBIM_LOGD("MBIM_CID_RADIO_STATE --> Get"); |
| 747 | } |
| 748 | |
| 749 | #if defined (MBIM_MTIL) |
| 750 | rc = MtilSendGetNoParams(mContext, MTIL_CODE_AT_CFUN_GET); |
| 751 | #else |
| 752 | rc = MbimTelRequestRadioState(mContext); |
| 753 | #endif |
| 754 | return rc; |
| 755 | } |
| 756 | |
| 757 | |
| 758 | /*******************************************************************************\ |
| 759 | * Function: CID_Pin |
| 760 | * Description: MBIM_CID_PIN(Chapter 10.5.4) |
| 761 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 762 | * |
| 763 | * Returns: 0=OK, <0=Error Code |
| 764 | \*******************************************************************************/ |
| 765 | int CID_Pin(BASIC_CID_PARAMS) |
| 766 | { |
| 767 | int rc = MBIM_OK; |
| 768 | char *buf = NULL; |
| 769 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 770 | P_MBIM_SET_PIN pPinSet = NULL; |
| 771 | char pin[16+1] = {0}; |
| 772 | char newPin[16+1] = {0}; |
| 773 | |
| 774 | //Added for compilation uof unused parameters on Codeline |
| 775 | MBIM_BASIC_UNUSEDPARAM(); |
| 776 | |
| 777 | //Allocate buffer for response |
| 778 | ALLOCATE_RESPONSE_BUFFER(buf, sizeof(MBIM_PIN_INFO)); |
| 779 | |
| 780 | //Creat the context for this command |
| 781 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 782 | |
| 783 | //save in context the requested configuration |
| 784 | ALLOCATE_CMD_BUFFER(mContext, mContext->cmd, sizeof(MBIM_SET_PIN)); |
| 785 | memset(mContext->cmd, 0, sizeof(MBIM_SET_PIN)); |
| 786 | |
| 787 | ////////////////////////////////////////////////////// |
| 788 | //Take care of SET |
| 789 | ///////////////////////////////////////////////////// |
| 790 | if (commandType == MBIM_SET_COMMAND) |
| 791 | { |
| 792 | pPinSet = (P_MBIM_SET_PIN)infoBuf_p; |
| 793 | memcpy(mContext->cmd, pPinSet, sizeof(MBIM_SET_PIN)); |
| 794 | |
| 795 | //Get Pin |
| 796 | copyUtf16ToStr(pin, infoBuf_p + pPinSet->pinOffset, pPinSet->pinSize); |
| 797 | pin[pPinSet->pinSize / 2] = 0; |
| 798 | |
| 799 | copyUtf16ToStr(newPin, infoBuf_p + pPinSet->newPinOffset, pPinSet->newPinSize); |
| 800 | newPin[pPinSet->newPinSize / 2] = 0; |
| 801 | |
| 802 | switch (pPinSet->pinOperation) |
| 803 | { |
| 804 | case MBIMPinOperationEnter: |
| 805 | // here we suppose that host knows current PIN state and performs correct operation |
| 806 | #if defined (MBIM_MTIL) |
| 807 | MtilSendCpinSet(mContext, pin, newPin); |
| 808 | #else |
| 809 | MbimTelRequestPinSet(mContext, pin, newPin); |
| 810 | #endif |
| 811 | break; |
| 812 | |
| 813 | case MBIMPinOperationEnable: |
| 814 | #if defined (MBIM_MTIL) |
| 815 | MtilSendClckSet(mContext, MTIL_FAC_SC, 1, pin); |
| 816 | #else |
| 817 | MbimTelRequestPinEnable(mContext, pin); |
| 818 | #endif |
| 819 | break; |
| 820 | |
| 821 | case MBIMPinOperationDisable: |
| 822 | #if defined (MBIM_MTIL) |
| 823 | MtilSendClckSet(mContext, MTIL_FAC_SC, 0, pin); |
| 824 | #else |
| 825 | MbimTelRequestPinDisable(mContext, pin); |
| 826 | #endif |
| 827 | break; |
| 828 | |
| 829 | case MBIMPinOperationChange: |
| 830 | //Get the newPin number |
| 831 | copyUtf16ToStr(newPin, infoBuf_p + pPinSet->newPinOffset, pPinSet->newPinSize); |
| 832 | newPin[pPinSet->newPinSize / 2] = 0; |
| 833 | |
| 834 | #if defined (MBIM_MTIL) |
| 835 | MtilSendCpwdSet(mContext, MTIL_FAC_SC, pin, newPin); |
| 836 | #else |
| 837 | MbimTelRequestPinModify(mContext, pin, newPin); |
| 838 | #endif |
| 839 | break; |
| 840 | }//end of switch |
| 841 | } |
| 842 | |
| 843 | ////////////////////////////////////////////////////// |
| 844 | //Take care of Query |
| 845 | ///////////////////////////////////////////////////// |
| 846 | else |
| 847 | { |
| 848 | #if defined (MBIM_MTIL) |
| 849 | MtilSendGetNoParams(mContext, MTIL_CODE_AT_SIM_DEV_STATUS_GET); |
| 850 | #else |
| 851 | MbimTelRequestSimStatus(mContext); |
| 852 | #endif |
| 853 | } |
| 854 | |
| 855 | return rc; |
| 856 | } |
| 857 | |
| 858 | |
| 859 | |
| 860 | |
| 861 | /*******************************************************************************\ |
| 862 | * Function: CID_PinList |
| 863 | * Description: MBIM_CID_PIN_LIST(Chapter 10.5.5) |
| 864 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 865 | * |
| 866 | * Returns: 0=OK, <0=Error Code |
| 867 | \*******************************************************************************/ |
| 868 | int CID_PinList(BASIC_CID_PARAMS) |
| 869 | { |
| 870 | |
| 871 | int rc = MBIM_OK; |
| 872 | char *buf = NULL; |
| 873 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 874 | |
| 875 | |
| 876 | //We only support Query for this command (Set is supported only if we support MBIM_CTRL_CAPS_MULTI_CARRIER). |
| 877 | if (commandType != MBIM_QUERY_COMMAND) |
| 878 | { |
| 879 | return CID_NotSupported(BASIC_CID_PARAMS_USAGE); |
| 880 | } |
| 881 | |
| 882 | //Allocate buffer for response |
| 883 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 884 | |
| 885 | //Creat the context for this command |
| 886 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 887 | |
| 888 | //Get CPIN information |
| 889 | #if defined (MBIM_MTIL) |
| 890 | MtilSendGetNoParams(mContext, MTIL_CODE_AT_SIM_DEV_STATUS_GET); |
| 891 | #else |
| 892 | MbimTelRequestPinList(mContext); |
| 893 | #endif |
| 894 | |
| 895 | return rc; |
| 896 | } |
| 897 | |
| 898 | |
| 899 | /*******************************************************************************\ |
| 900 | * Function: CID_HomeProvider |
| 901 | * Description: MBIM_CID_HOME_PROVIDER (Chapter 10.5.6) |
| 902 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 903 | * |
| 904 | * Returns: 0=OK, <0=Error Code |
| 905 | \*******************************************************************************/ |
| 906 | int CID_HomeProvider(BASIC_CID_PARAMS) |
| 907 | { |
| 908 | int rc = MBIM_OK; |
| 909 | char *buf = NULL; |
| 910 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 911 | P_MBIM_PROVIDER pMbimProvider = NULL; |
| 912 | UINT32 mbimStatus = MBIM_STATUS_SUCCESS; |
| 913 | |
| 914 | //We only support Query for this command (Set is supported only if we support MBIM_CTRL_CAPS_MULTI_CARRIER). |
| 915 | if (commandType != MBIM_QUERY_COMMAND) |
| 916 | { |
| 917 | return CID_NotSupported(BASIC_CID_PARAMS_USAGE); |
| 918 | } |
| 919 | |
| 920 | //Allocate buffer for response |
| 921 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 922 | |
| 923 | //Creat the context for this command |
| 924 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 925 | |
| 926 | pMbimProvider = (P_MBIM_PROVIDER)buf; |
| 927 | pMbimProvider->errorRate = 0; //Set to Zero if we don't support MBIM_CTRL_CAPS_MULTI_CARRIER; |
| 928 | pMbimProvider->rssi = CID_SIGNAL_STRENGTH_RSSI_UNKOWN; //Set to Zero if we don't support MBIM_CTRL_CAPS_MULTI_CARRIER; |
| 929 | pMbimProvider->cellularClass = MBIMCellularClassGsm; //(set 1 as reference)Set to Zero if we don't support MBIM_CTRL_CAPS_MULTI_CARRIER; |
| 930 | |
| 931 | |
| 932 | if (mbimDb.HomeProviderIdSize == 0) |
| 933 | { |
| 934 | #if defined (MBIM_MTIL) |
| 935 | //Call the next AT command |
| 936 | MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CIMI_GET); |
| 937 | #else |
| 938 | MbimTelRequestHomeProviderId(mContext); |
| 939 | #endif |
| 940 | } |
| 941 | else |
| 942 | { |
| 943 | |
| 944 | //set the correct provider Id,with the correct size |
| 945 | pMbimProvider->providerIdState = MBIM_PROVIDER_STATE_HOME; |
| 946 | pMbimProvider->providerIdOffset = offsetof(MBIM_PROVIDER, dataBuffer[0]); |
| 947 | pMbimProvider->providerIdSize = copyStrToUtf16(((char *)pMbimProvider) + pMbimProvider->providerIdOffset, mbimDb.HomeProviderMccMnc, mbimDb.HomeProviderIdSize); |
| 948 | |
| 949 | //Set provider ID name |
| 950 | pMbimProvider->providerNameOffset = (pMbimProvider->providerIdOffset + pMbimProvider->providerIdSize + 3)&~3; /* account for padding */ |
| 951 | pMbimProvider->providerNameSize = copyStrToUtf16(((char *)pMbimProvider) + pMbimProvider->providerNameOffset, mbimDb.HomeProviderName, strlen(mbimDb.HomeProviderName)); |
| 952 | |
| 953 | //Add Zero termination (UTF-16) |
| 954 | /* Again, padding, and it should not affect the Size */ |
| 955 | //memset((char *)pMbimProvider + pMbimProvider->providerNameOffset + pMbimProvider->providerNameSize, 0, 2); |
| 956 | //pMbimProvider->providerNameSize += 2; |
| 957 | |
| 958 | |
| 959 | if (mbimDb.sim.simReadyState == MBIMSubscriberReadyStateSimNotInserted) |
| 960 | mbimStatus = MBIM_STATUS_SIM_NOT_INSERTED; |
| 961 | else if (mbimDb.sim.simReadyState == MBIMSubscriberReadyStateBadSim) |
| 962 | mbimStatus = MBIM_STATUS_BAD_SIM; |
| 963 | |
| 964 | //Send answer here until next AT command is implemented [TBD ADRIAN - Need to get provider name from SIM] |
| 965 | MbimSendCommandDone( mContext->hdr.transId, |
| 966 | mContext->hdr.uuidIndex, |
| 967 | mContext->hdr.cid, |
| 968 | mbimStatus, |
| 969 | ALIGN32(pMbimProvider->providerNameOffset+pMbimProvider->providerNameSize), |
| 970 | mContext->body ); |
| 971 | |
| 972 | MBIM_FREE_CONTEXT(mContext); |
| 973 | |
| 974 | } |
| 975 | return rc; |
| 976 | } |
| 977 | |
| 978 | |
| 979 | |
| 980 | /*******************************************************************************\ |
| 981 | * Function: CID_PreferedProviders |
| 982 | * Description: MBIM_CID_PREFERRED_PROVIDERS (Chapter 10.5.7) |
| 983 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 984 | * |
| 985 | * Returns: 0=OK, <0=Error Code |
| 986 | \*******************************************************************************/ |
| 987 | int CID_PreferedProviders(BASIC_CID_PARAMS) |
| 988 | { |
| 989 | int rc = MBIM_OK; |
| 990 | char *buf = NULL; |
| 991 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 992 | |
| 993 | //Added for compilation uof unused parameters on Codeline |
| 994 | MBIM_BASIC_UNUSEDPARAM(); |
| 995 | |
| 996 | //Allocate buffer for response |
| 997 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 998 | |
| 999 | //Creat the context for this command |
| 1000 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 1001 | |
| 1002 | |
| 1003 | //We only support Query for this command (Set is supported only if we support MBIM_CTRL_CAPS_MULTI_CARRIER). |
| 1004 | if (commandType == MBIM_SET_COMMAND) |
| 1005 | { |
| 1006 | //send Error to Host |
| 1007 | rc = MbimSendCommandDone(mContext->hdr.transId, |
| 1008 | mContext->hdr.uuidIndex, |
| 1009 | mContext->hdr.cid, |
| 1010 | MBIM_STATUS_OPERATION_NOT_ALLOWED, |
| 1011 | 0, NULL); |
| 1012 | MBIM_FREE_CONTEXT(mContext); |
| 1013 | } |
| 1014 | else |
| 1015 | { |
| 1016 | //Get prefered providers |
| 1017 | #if defined (MBIM_MTIL) |
| 1018 | MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CPOL_GET); |
| 1019 | #else |
| 1020 | MbimTelRequestPreferredProviders(mContext); |
| 1021 | #endif |
| 1022 | } |
| 1023 | |
| 1024 | return rc; |
| 1025 | } |
| 1026 | |
| 1027 | |
| 1028 | /*******************************************************************************\ |
| 1029 | * Function: CID_VisibleProviders |
| 1030 | * Description: MBIM_CID_VISIBLE_PROVIDERS (Chapter 10.5.8) |
| 1031 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 1032 | * |
| 1033 | * Returns: 0=OK, <0=Error Code |
| 1034 | \*******************************************************************************/ |
| 1035 | int CID_VisibleProviders(BASIC_CID_PARAMS) |
| 1036 | { |
| 1037 | int rc = MBIM_OK; |
| 1038 | char *buf = NULL; |
| 1039 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 1040 | #if defined (MBIM_MTIL) |
| 1041 | P_MBIM_VISIBLE_PROVIDERS_REQ pVisibleProvReq = NULL; |
| 1042 | #endif |
| 1043 | P_MBIM_PROVIDERS pMbimProviders = NULL; |
| 1044 | |
| 1045 | //Added for compilation uof unused parameters on Codeline |
| 1046 | MBIM_BASIC_UNUSEDPARAM(); |
| 1047 | |
| 1048 | //We only support Query for this command (Set is supported only if we support MBIM_CTRL_CAPS_MULTI_CARRIER). |
| 1049 | if (commandType != MBIM_QUERY_COMMAND) |
| 1050 | { |
| 1051 | return CID_NotSupported(BASIC_CID_PARAMS_USAGE); |
| 1052 | } |
| 1053 | |
| 1054 | //Allocate buffer for response |
| 1055 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 1056 | |
| 1057 | //Creat the context for this command |
| 1058 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 1059 | |
| 1060 | if (mbimDb.sim.simReadyState == MBIMSubscriberReadyStateSimNotInserted) |
| 1061 | { |
| 1062 | pMbimProviders = (P_MBIM_PROVIDERS)buf; |
| 1063 | pMbimProviders->elementCount = 0; |
| 1064 | |
| 1065 | //send Error to Host |
| 1066 | MbimSendCommandDone( mContext->hdr.transId, |
| 1067 | mContext->hdr.uuidIndex, |
| 1068 | mContext->hdr.cid, |
| 1069 | MBIM_STATUS_SIM_NOT_INSERTED, |
| 1070 | sizeof(MBIM_RADIO_STATE_INFO), |
| 1071 | mContext->body ); |
| 1072 | MBIM_FREE_CONTEXT(mContext); |
| 1073 | } |
| 1074 | else |
| 1075 | { |
| 1076 | //Pick up pointer to request |
| 1077 | #if defined (MBIM_MTIL) |
| 1078 | pVisibleProvReq = (P_MBIM_VISIBLE_PROVIDERS_REQ)infoBuf_p; |
| 1079 | if (pVisibleProvReq->action == MBIMVisibleProvidersActionFullScan) |
| 1080 | { |
| 1081 | MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_COPS_OPT); |
| 1082 | |
| 1083 | MBIM_LOGD("MBIM_CID_VISIBLE_PROVIDERS: CID_VisibleProviders Full scan"); |
| 1084 | } |
| 1085 | else |
| 1086 | { |
| 1087 | MBIM_LOGD("MBIM_CID_VISIBLE_PROVIDERS: CID_VisibleProviders Prefered Scan"); |
| 1088 | |
| 1089 | //[TBD]; |
| 1090 | //MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CPOL_OPT); //This return prefered Providers |
| 1091 | MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_COPS_OPT); //[WorkAround] Adrian need to fix |
| 1092 | |
| 1093 | //MBIM_FREE_CONTEXT(mContext); |
| 1094 | } |
| 1095 | #else |
| 1096 | MbimTelRequestVisibleProviders(mContext); |
| 1097 | MBIM_LOGD("MBIM_CID_VISIBLE_PROVIDERS: CID_VisibleProviders Full scan"); |
| 1098 | #endif |
| 1099 | } |
| 1100 | |
| 1101 | return rc; |
| 1102 | } |
| 1103 | |
| 1104 | |
| 1105 | |
| 1106 | /*******************************************************************************\ |
| 1107 | * Function: CID_RegisterState |
| 1108 | * Description: MBIM_CID_REGISTER_STATE (Chapter 10.5.9) |
| 1109 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 1110 | * |
| 1111 | * Returns: 0=OK, <0=Error Code |
| 1112 | \*******************************************************************************/ |
| 1113 | int CID_RegisterState(BASIC_CID_PARAMS) |
| 1114 | { |
| 1115 | int rc = MBIM_OK; |
| 1116 | char *buf = NULL; |
| 1117 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 1118 | P_MBIM_SET_REGISTRATION_STATE pSetRegisterState = NULL; |
| 1119 | |
| 1120 | //Added for compilation uof unused parameters on Codeline |
| 1121 | MBIM_BASIC_UNUSEDPARAM(); |
| 1122 | |
| 1123 | //Allocate buffer for response |
| 1124 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 1125 | |
| 1126 | //Creat the context for this command |
| 1127 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 1128 | |
| 1129 | ////////////////////////////////////////////////////// |
| 1130 | //Take care SET |
| 1131 | ///////////////////////////////////////////////////// |
| 1132 | if (commandType == MBIM_SET_COMMAND) |
| 1133 | { |
| 1134 | char providerId[9] = {0}; |
| 1135 | int mode, accessTechnology; |
| 1136 | |
| 1137 | MBIM_LOGD("CID_RegisterState - SET"); |
| 1138 | |
| 1139 | pSetRegisterState = (P_MBIM_SET_REGISTRATION_STATE)infoBuf_p; |
| 1140 | if (pSetRegisterState->registerAction == MBIMRegisterActionManual) |
| 1141 | { |
| 1142 | mode = TEL_REG_MODE_MANUAL; |
| 1143 | copyUtf16ToStr(providerId, (infoBuf_p + pSetRegisterState->providerIdOffset), MIN(pSetRegisterState->providerIdSize,16)); |
| 1144 | } |
| 1145 | else |
| 1146 | { |
| 1147 | mode = TEL_REG_MODE_AUTO; |
| 1148 | } |
| 1149 | accessTechnology = getRegisterTech(pSetRegisterState->dataClass); |
| 1150 | |
| 1151 | MBIM_LOGD("CID_RegisterState - Mode = %d, providerId = %s, accessTechnology = %d",mode, providerId, accessTechnology ); |
| 1152 | |
| 1153 | //Send Command to server |
| 1154 | #if defined (MBIM_MTIL) |
| 1155 | mtilSendCopsSet((void *)mContext, mode, accessTechnology, providerId); |
| 1156 | #else |
| 1157 | MbimTelRequestNetworkSelection(mContext, mode, accessTechnology, providerId); |
| 1158 | #endif |
| 1159 | } |
| 1160 | |
| 1161 | ////////////////////////////////////////////////////// |
| 1162 | //Take care Get |
| 1163 | ///////////////////////////////////////////////////// |
| 1164 | else |
| 1165 | { |
| 1166 | MBIM_LOGD("CID_RegisterState - GET"); |
| 1167 | |
| 1168 | #if defined (MBIM_MTIL) |
| 1169 | //Call the next AT command |
| 1170 | MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CGREG_GET); |
| 1171 | #else |
| 1172 | MbimTelRequestRegistrationStatus(mContext); |
| 1173 | #endif |
| 1174 | } |
| 1175 | |
| 1176 | return rc; |
| 1177 | } |
| 1178 | |
| 1179 | |
| 1180 | /*******************************************************************************\ |
| 1181 | * Function: CID_PacketService |
| 1182 | * Description: MBIM_CID_PACKET_SERVICE (Chapter 10.5.10) |
| 1183 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 1184 | * |
| 1185 | * Returns: 0=OK, <0=Error Code |
| 1186 | \*******************************************************************************/ |
| 1187 | int CID_PacketService(BASIC_CID_PARAMS) |
| 1188 | { |
| 1189 | int rc = MBIM_OK; |
| 1190 | char *buf = NULL; |
| 1191 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 1192 | P_MBIM_SET_PACKET_SERVICE pSetPacketService = NULL; |
| 1193 | #if defined (MBIM_MTIL) |
| 1194 | UINT32 action; |
| 1195 | #endif |
| 1196 | //Added for compilation uof unused parameters on Codeline |
| 1197 | MBIM_BASIC_UNUSEDPARAM(); |
| 1198 | |
| 1199 | //Allocate buffer for response |
| 1200 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 1201 | |
| 1202 | //Creat the context for this command |
| 1203 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 1204 | |
| 1205 | //ToDo - find alternative to packet service set and query |
| 1206 | |
| 1207 | ////////////////////////////////////////////////////// |
| 1208 | //Take care SET |
| 1209 | ///////////////////////////////////////////////////// |
| 1210 | if (commandType == MBIM_SET_COMMAND) |
| 1211 | { |
| 1212 | pSetPacketService = (P_MBIM_SET_PACKET_SERVICE)infoBuf_p; |
| 1213 | |
| 1214 | MBIM_LOGD("MBIM_CID_PACKET_SERVICE: SET. Action = %d", pSetPacketService->packetServiceAction); |
| 1215 | |
| 1216 | #if defined (MBIM_MTIL) |
| 1217 | //Need to send command to Attach or detach |
| 1218 | if (pSetPacketService->packetServiceAction == MBIMPacketServiceActionAttach) |
| 1219 | action = 1; |
| 1220 | else |
| 1221 | action = 0; |
| 1222 | |
| 1223 | MtilSendAtCgattSet((void *)mContext, action); |
| 1224 | #else |
| 1225 | MbimTelRequestPacketService(mContext); |
| 1226 | #endif |
| 1227 | } |
| 1228 | else |
| 1229 | { |
| 1230 | MBIM_LOGD("MBIM_CID_PACKET_SERVICE: GET"); |
| 1231 | |
| 1232 | #if defined (MBIM_MTIL) |
| 1233 | //Call the next AT command |
| 1234 | MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CGATT_GET); |
| 1235 | #else |
| 1236 | MbimTelRequestPacketServiceStatus(mContext); |
| 1237 | #endif |
| 1238 | } |
| 1239 | |
| 1240 | |
| 1241 | return rc; |
| 1242 | } |
| 1243 | |
| 1244 | |
| 1245 | |
| 1246 | /*******************************************************************************\ |
| 1247 | * Function: CID_SignalState |
| 1248 | * Description: MBIM_CID_SIGNAL_STATE (Chapter 10.5.11) |
| 1249 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 1250 | * |
| 1251 | * Returns: 0=OK, <0=Error Code |
| 1252 | \*******************************************************************************/ |
| 1253 | int CID_SignalState(BASIC_CID_PARAMS) |
| 1254 | { |
| 1255 | P_MBIM_SET_SIGNAL_STATE pSetSignalState = NULL; |
| 1256 | MBIM_SIGNAL_STATE_INFO signalStateInfo; |
| 1257 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 1258 | char *buf = NULL; |
| 1259 | |
| 1260 | |
| 1261 | //Added for compilation uof unused parameters on Codeline |
| 1262 | MBIM_BASIC_UNUSEDPARAM(); |
| 1263 | |
| 1264 | //If we received command we update the configuration |
| 1265 | if (commandType == MBIM_SET_COMMAND) |
| 1266 | { |
| 1267 | signalStateInfo.signalStrengthInterval = (mbimDb.signalState.signalStrengthInterval?mbimDb.signalState.signalStrengthInterval:1); |
| 1268 | signalStateInfo.RssiThreshold = 0;//mbimDb.signalState.rssiThreshold; |
| 1269 | signalStateInfo.errorRateThreshold = CID_SIGNAL_STRENGTH_ERROR_RATE_THR_DONT_CARE; |
| 1270 | signalStateInfo.rssi = mbimDb.signalState.rssiDb; |
| 1271 | signalStateInfo.errorRate = CID_SIGNAL_STRENGTH_ERROR_RATE_UNKOWN;//CodeBer2MbimCodedValue(mbimDb.signalState.errorRate); |
| 1272 | |
| 1273 | pSetSignalState = (P_MBIM_SET_SIGNAL_STATE)infoBuf_p; |
| 1274 | mbimDb.signalState.signalStrengthInterval = pSetSignalState->signalStrengthInterval; |
| 1275 | mbimDb.signalState.rssiThreshold = pSetSignalState->rssiThreshold; |
| 1276 | mbimDb.signalState.errorRateThreshold = pSetSignalState->errorRateThreshold; |
| 1277 | |
| 1278 | //Send command done to host |
| 1279 | MbimSendCommandDone(transactionId, UUID_BASIC_CONNECT_INDEX, cid, MBIM_STATUS_SUCCESS, sizeof(MBIM_SIGNAL_STATE_INFO), (char *)&signalStateInfo); |
| 1280 | } |
| 1281 | else |
| 1282 | { |
| 1283 | //Allocate buffer for response |
| 1284 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 1285 | |
| 1286 | //Creat the context for this command |
| 1287 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 1288 | |
| 1289 | MbimTelRequestSignalStrength(mContext); |
| 1290 | } |
| 1291 | |
| 1292 | return 0; |
| 1293 | } |
| 1294 | |
| 1295 | /*******************************************************************************\ |
| 1296 | * Function: CID_Connect |
| 1297 | * Description: MBIM_CID_CONNECT (Chapter 10.5.12) |
| 1298 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 1299 | * |
| 1300 | * Returns: 0=OK, <0=Error Code |
| 1301 | \*******************************************************************************/ |
| 1302 | int CID_Connect(BASIC_CID_PARAMS) |
| 1303 | { |
| 1304 | int rc = MBIM_OK; |
| 1305 | char *buf = NULL; |
| 1306 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 1307 | P_MBIM_SET_CONNECT pSetConnect = NULL; |
| 1308 | P_MBIM_CONNECT_INFO connectInfoRsp; |
| 1309 | int mbimStatus = MBIM_STATUS_SUCCESS; |
| 1310 | |
| 1311 | ////////////////////////////////////////////////////// |
| 1312 | //Take care of SET command |
| 1313 | ///////////////////////////////////////////////////// |
| 1314 | if (commandType == MBIM_SET_COMMAND) |
| 1315 | { |
| 1316 | //Allocate buffer for response |
| 1317 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 1318 | |
| 1319 | //Creat the context for this command |
| 1320 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 1321 | |
| 1322 | //save in context the requested configuration. (Need to free buffer in failure below) |
| 1323 | ALLOCATE_CMD_BUFFER(mContext, mContext->cmd, infoBufLen); |
| 1324 | memcpy( mContext->cmd, (char *)infoBuf_p, infoBufLen); |
| 1325 | |
| 1326 | //BS: Turn off CID_CONNECT unsolicitate indication until COMMAND_DONE |
| 1327 | disableUnsolCidConnect = TRUE; |
| 1328 | MBIM_LOGD("MBIM_CID_CONNECT: disableUnsolCidConnect = %d", disableUnsolCidConnect); |
| 1329 | |
| 1330 | #if defined (MBIM_MTIL) |
| 1331 | //Send Get |
| 1332 | MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CGDCONT_GET); |
| 1333 | #else |
| 1334 | MbimTelRequestSetupDataCall(mContext); |
| 1335 | #endif |
| 1336 | } |
| 1337 | |
| 1338 | ////////////////////////////////////////////////////// |
| 1339 | //Take care of GET command |
| 1340 | ///////////////////////////////////////////////////// |
| 1341 | else |
| 1342 | { |
| 1343 | P_MBIM_CONNECT_QUERY_INFO_EX3 pQuery = NULL; |
| 1344 | int len = 0; |
| 1345 | int sessionId = 0; |
| 1346 | |
| 1347 | //Allocate buffer for response |
| 1348 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 1349 | |
| 1350 | //Creat the context for this command |
| 1351 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 1352 | |
| 1353 | connectInfoRsp = (P_MBIM_CONNECT_INFO)mContext->body; |
| 1354 | |
| 1355 | if (mbimDb.mbimNegVersion >= MBIMEx_v3) |
| 1356 | { |
| 1357 | pQuery = (P_MBIM_CONNECT_QUERY_INFO_EX3)infoBuf_p; |
| 1358 | sessionId = pQuery->SessionId; |
| 1359 | len = offsetof(MBIM_CONNECT_INFO, dataBuffer); |
| 1360 | } |
| 1361 | else |
| 1362 | { |
| 1363 | pSetConnect = (P_MBIM_SET_CONNECT)infoBuf_p; |
| 1364 | sessionId = pSetConnect->sessionId; |
| 1365 | len = sizeof(MBIM_CONNECT_INFO_V1); |
| 1366 | } |
| 1367 | |
| 1368 | if (sessionId < MAX_NUM_OF_SESSIONS) |
| 1369 | { |
| 1370 | MBIM_LOGD("MBIM_CID_CONNECT: Session Id: %d, Cid = %d", sessionId, mbimDb.session[sessionId].cid); |
| 1371 | |
| 1372 | if (mbimDb.session[sessionId].cid == 0) |
| 1373 | { |
| 1374 | memset(connectInfoRsp, 0, sizeof(MBIM_CONNECT_INFO)); |
| 1375 | connectInfoRsp->sessionId = sessionId; |
| 1376 | connectInfoRsp->activationState = MBIMActivationStateDeactivated; |
| 1377 | connectInfoRsp->ipType = MBIMContextIPTypeIPv4; |
| 1378 | connectInfoRsp->nwError = CID_CONNECT_MBIM_STATUS_SUCCESS; |
| 1379 | memcpy( (char *)connectInfoRsp->contextType.uuid, MBIMContextTypeNone, sizeof(MBIM_UUID)); |
| 1380 | } |
| 1381 | else |
| 1382 | { |
| 1383 | connectInfoRsp->sessionId = sessionId; |
| 1384 | |
| 1385 | MBIM_LOGD("MBIM_CID_CONNECT: Session Id: %d, Activation State = %d", sessionId, mbimDb.session[sessionId].sessionState); |
| 1386 | connectInfoRsp->activationState = mbimDb.session[sessionId].sessionState; |
| 1387 | |
| 1388 | MBIM_LOGD("MBIM_CID_CONNECT: Session Id: %d, Voice Call State = %d", sessionId, mbimDb.session[sessionId].voiceCallState); |
| 1389 | connectInfoRsp->voiceCallState = mbimDb.session[sessionId].voiceCallState; |
| 1390 | |
| 1391 | MBIM_LOGD("MBIM_CID_CONNECT: Session Id: %d, Ip type = %d", sessionId, mbimDb.session[sessionId].ipType); |
| 1392 | connectInfoRsp->ipType = mbimDb.session[sessionId].ipType; |
| 1393 | connectInfoRsp->ipType = MBIMContextIPTypeIPv4; //adrian debug |
| 1394 | |
| 1395 | memcpy( (char *)connectInfoRsp->contextType.uuid, (char *)&mbimDb.session[sessionId].contextType, sizeof(MBIM_UUID)); |
| 1396 | connectInfoRsp->nwError = CID_CONNECT_MBIM_STATUS_SUCCESS; |
| 1397 | |
| 1398 | mbimDb.internetSessionId = sessionId; |
| 1399 | } |
| 1400 | |
| 1401 | if (mbimDb.mbimNegVersion >= MBIMEx_v3) |
| 1402 | { |
| 1403 | if (mbimDb.session[sessionId].cid == 0) |
| 1404 | { |
| 1405 | connectInfoRsp->AccessMedia = MBIMAccessMediaTypeNone; |
| 1406 | len += mbim_tlv_new((UINT8 *)connectInfoRsp + len, MBIM_TLV_TYPE_WCHAR_STR, NULL, 0); |
| 1407 | } |
| 1408 | else |
| 1409 | { |
| 1410 | connectInfoRsp->AccessMedia = MBIMAccessMediaType3GPP; |
| 1411 | len += mbim_tlv_new_str((UINT8 *)connectInfoRsp + len, (UINT8 *)mbimDb.session[sessionId].APN, strlen(mbimDb.session[sessionId].APN)); |
| 1412 | } |
| 1413 | } |
| 1414 | } |
| 1415 | else |
| 1416 | { |
| 1417 | memset((char *)connectInfoRsp, 0, sizeof(MBIM_CONNECT_INFO)); |
| 1418 | connectInfoRsp->sessionId = sessionId; |
| 1419 | connectInfoRsp->nwError = 0; |
| 1420 | mbimStatus = (MBIM_STATUS_CODE_ENUM)CID_CONNECT_MBIM_STATUS_MAX_ACTIVATED_CONTEXTS; |
| 1421 | } |
| 1422 | |
| 1423 | |
| 1424 | //if (mbimDb.sim.simReadyState == MBIMSubscriberReadyStateSimNotInserted) |
| 1425 | // mbimStatus = MBIM_STATUS_SIM_NOT_INSERTED; |
| 1426 | |
| 1427 | //Send reponse to host |
| 1428 | MbimSendCommandDone(transactionId, UUID_BASIC_CONNECT_INDEX, cid, mbimStatus, len, (char *)mContext->body); |
| 1429 | |
| 1430 | MBIM_FREE_CONTEXT(mContext); |
| 1431 | } |
| 1432 | |
| 1433 | return rc; |
| 1434 | } |
| 1435 | |
| 1436 | |
| 1437 | /*******************************************************************************\ |
| 1438 | * Function: CID_ProvisionedContexts |
| 1439 | * Description: MBIM_CID_PROVISIONED_CONTEXTS(Chapter 10.5.13) |
| 1440 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 1441 | * |
| 1442 | * Returns: 0=OK, <0=Error Code |
| 1443 | \*******************************************************************************/ |
| 1444 | int CID_ProvisionedContexts(BASIC_CID_PARAMS) |
| 1445 | { |
| 1446 | char *buf = NULL; |
| 1447 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 1448 | int rc = MBIM_STATUS_SUCCESS; |
| 1449 | |
| 1450 | //Added for compilation uof unused parameters on Codeline |
| 1451 | MBIM_BASIC_UNUSEDPARAM(); |
| 1452 | |
| 1453 | //Allocate buffer for response |
| 1454 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 1455 | |
| 1456 | //Creat the context for this command |
| 1457 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 1458 | |
| 1459 | MBIM_LOGD("MBIM_CID_PROVISIONED_CONTEXTS:commandType = %d", commandType); |
| 1460 | |
| 1461 | |
| 1462 | //save in context the requested configuration. (Need to free buffer in failure below) |
| 1463 | ALLOCATE_CMD_BUFFER(mContext, mContext->cmd, infoBufLen); |
| 1464 | memcpy( mContext->cmd, (char *)infoBuf_p, infoBufLen); |
| 1465 | |
| 1466 | #if defined (MBIM_MTIL) |
| 1467 | //Send Get |
| 1468 | MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CGDCONT_GET); |
| 1469 | #else |
| 1470 | MbimTelRequestDataCallList((void *)mContext); |
| 1471 | #endif |
| 1472 | return rc; |
| 1473 | } |
| 1474 | int CID_ServiceActivation(BASIC_CID_PARAMS) |
| 1475 | { |
| 1476 | //Added for compilation uof unused parameters on Codeline |
| 1477 | MBIM_BASIC_UNUSEDPARAM(); |
| 1478 | return 0; |
| 1479 | } |
| 1480 | |
| 1481 | |
| 1482 | /*******************************************************************************\ |
| 1483 | * Function: CID_IpConfiguration |
| 1484 | * Description: MBIM_CID_IP_CONFIGURATION(Chapter 10.5.20) |
| 1485 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 1486 | * |
| 1487 | * Returns: 0=OK, <0=Error Code |
| 1488 | \*******************************************************************************/ |
| 1489 | int CID_IpConfiguration(BASIC_CID_PARAMS) |
| 1490 | { |
| 1491 | char *buf = NULL; |
| 1492 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 1493 | P_MBIM_IP_CONFIGURATION_INFO pIpConfigInfoCmd = NULL; |
| 1494 | int rc = MBIM_STATUS_SUCCESS; |
| 1495 | #if 0 |
| 1496 | P_MBIM_IPV4_ELEMENT pIpv4Element = NULL; |
| 1497 | P_MBIM_IPV4_ADDRESS pIpv4Address = NULL; |
| 1498 | int dataLen = 0; |
| 1499 | P_MBIM_IP_CONFIGURATION_INFO pIpConfigInfoRsp = NULL; |
| 1500 | #endif |
| 1501 | |
| 1502 | //Added for compilation uof unused parameters on Codeline |
| 1503 | MBIM_BASIC_UNUSEDPARAM(); |
| 1504 | |
| 1505 | ////////////////////////////////////////////////////// |
| 1506 | //We dont support SET command |
| 1507 | ///////////////////////////////////////////////////// |
| 1508 | if (commandType != MBIM_QUERY_COMMAND) |
| 1509 | { |
| 1510 | return CID_NotSupported(BASIC_CID_PARAMS_USAGE); |
| 1511 | } |
| 1512 | |
| 1513 | ////////////////////////////////////////////////////// |
| 1514 | //Take care of QUERY command |
| 1515 | ///////////////////////////////////////////////////// |
| 1516 | //Allocate buffer for response |
| 1517 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 1518 | |
| 1519 | //Creat the context for this command |
| 1520 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 1521 | |
| 1522 | pIpConfigInfoCmd = (P_MBIM_IP_CONFIGURATION_INFO)infoBuf_p; |
| 1523 | |
| 1524 | /////////////////////////////////////// |
| 1525 | //check for errors |
| 1526 | /////////////////////////////////////// |
| 1527 | if (pIpConfigInfoCmd->sessionId > MAX_NUM_OF_SESSIONS) |
| 1528 | { |
| 1529 | MBIM_LOGE("IP Configuration: Received invalid Session ID = %d", pIpConfigInfoCmd->sessionId); |
| 1530 | rc = MBIM_STATUS_CONTEXT_NOT_ACTIVATED; |
| 1531 | } |
| 1532 | if (rc != MBIM_STATUS_SUCCESS) |
| 1533 | { |
| 1534 | MbimSendFunctionErrorMsg(transactionId, rc); |
| 1535 | MBIM_FREE_CONTEXT(mContext); |
| 1536 | return 0; |
| 1537 | } |
| 1538 | |
| 1539 | MbimTelRequestIpConfig(mContext); |
| 1540 | |
| 1541 | return rc; |
| 1542 | } |
| 1543 | |
| 1544 | /*******************************************************************************\ |
| 1545 | * Function: MbimSetDeviceServiceSubscribeList |
| 1546 | * Description: ToDo - move to static functions.... |
| 1547 | * Parameters: |
| 1548 | * |
| 1549 | * Returns: 0=OK, <0=Error Code |
| 1550 | \*******************************************************************************/ |
| 1551 | static void MbimSetDeviceServiceSubscribeList (P_MBIM_DEVICE_SERVICE_SUBSCRIBE_LIST pDevServSubsList) |
| 1552 | { |
| 1553 | P_MBIM_EVENT_ENTRY pMbimServiceElement; |
| 1554 | UINT32 elementIdx, elementCount; |
| 1555 | int serviceIdx; |
| 1556 | UINT32 cidCount,cidIdx; |
| 1557 | char filterArrayString1 [64]; |
| 1558 | char filterArrayString [256]; |
| 1559 | char *pFilterArray; |
| 1560 | UINT32 deviceServiceSubscribeRefListAddr; |
| 1561 | |
| 1562 | elementCount = pDevServSubsList->elementCount; |
| 1563 | MBIM_LOGD("%s: element count = %d", __FUNCTION__, elementCount); |
| 1564 | |
| 1565 | if (elementCount > 0) |
| 1566 | { |
| 1567 | deviceServiceSubscribeRefListAddr = (UINT32)&pDevServSubsList->deviceServiceSubscribeRefList; |
| 1568 | pMbimServiceElement = (P_MBIM_EVENT_ENTRY)(deviceServiceSubscribeRefListAddr + 8 * elementCount); |
| 1569 | |
| 1570 | for (elementIdx = 0 ; elementIdx < elementCount ; elementIdx++) |
| 1571 | { |
| 1572 | serviceIdx = UUID2Index(&pMbimServiceElement->deviceServiceId); |
| 1573 | MBIM_LOGD("%s: serviceIdx = %d", __FUNCTION__, serviceIdx); |
| 1574 | if (cidsFilterArray[serviceIdx][0] == 0) |
| 1575 | { |
| 1576 | pMbimServiceElement = (P_MBIM_EVENT_ENTRY)((char *)pMbimServiceElement + |
| 1577 | sizeof(pMbimServiceElement->deviceServiceId) + |
| 1578 | sizeof(pMbimServiceElement->cidCount) + |
| 1579 | (pMbimServiceElement->cidCount * sizeof(*pMbimServiceElement->dataBuffer))); |
| 1580 | continue; |
| 1581 | } |
| 1582 | |
| 1583 | pFilterArray = (char *)cidsFilterArray[serviceIdx][0]; |
| 1584 | cidCount = pMbimServiceElement->cidCount; |
| 1585 | MBIM_LOGD("%s: cidCount = %d, max = %d", __FUNCTION__, cidCount, cidsFilterArray[serviceIdx][1]); |
| 1586 | |
| 1587 | if ((serviceIdx >= 0) && (cidCount > 0) && (cidCount < cidsFilterArray[serviceIdx][1])) |
| 1588 | { |
| 1589 | memset((void *)pFilterArray, 0, cidsFilterArray[serviceIdx][1]); |
| 1590 | for (cidIdx = 0; cidIdx < cidCount; cidIdx++) |
| 1591 | { |
| 1592 | pFilterArray[pMbimServiceElement->dataBuffer[cidIdx]] = 1; |
| 1593 | } |
| 1594 | |
| 1595 | //Debug |
| 1596 | sprintf (filterArrayString1, "service %d filter: ", serviceIdx); |
| 1597 | for (cidIdx = 0; cidIdx < cidsFilterArray[serviceIdx][1]; cidIdx++) |
| 1598 | { |
| 1599 | sprintf (filterArrayString, "%s %u=%u ", filterArrayString1, |
| 1600 | (unsigned char)cidIdx, (unsigned char)pFilterArray[cidIdx]); |
| 1601 | } |
| 1602 | MBIM_LOGD("%s: %s", __FUNCTION__, filterArrayString); |
| 1603 | } |
| 1604 | |
| 1605 | pMbimServiceElement = (P_MBIM_EVENT_ENTRY)((char *)pMbimServiceElement + |
| 1606 | sizeof(pMbimServiceElement->deviceServiceId) + |
| 1607 | sizeof(pMbimServiceElement->cidCount) + |
| 1608 | (pMbimServiceElement->cidCount * sizeof(*pMbimServiceElement->dataBuffer))); |
| 1609 | |
| 1610 | } |
| 1611 | } |
| 1612 | } |
| 1613 | |
| 1614 | /*******************************************************************************\ |
| 1615 | * Function: CID_DeviceServicesSubscribeList |
| 1616 | * Description: MBIM_CID_DEVICE_SERVICE_SUBSCRIBE_LIST (Chapter 10.5.30) |
| 1617 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 1618 | * |
| 1619 | * Returns: 0=OK, <0=Error Code |
| 1620 | \*******************************************************************************/ |
| 1621 | int CID_DeviceServicesSubscribeList(BASIC_CID_PARAMS) |
| 1622 | { |
| 1623 | int rc = MBIM_STATUS_SUCCESS; |
| 1624 | char *buf = NULL; |
| 1625 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 1626 | P_MBIM_DEVICE_SERVICE_SUBSCRIBE_LIST pDevServSubsList = NULL; |
| 1627 | |
| 1628 | ////////////////////////////////////////////////////// |
| 1629 | //GET is not supported by this command |
| 1630 | ///////////////////////////////////////////////////// |
| 1631 | if (commandType != MBIM_SET_COMMAND) |
| 1632 | { |
| 1633 | return CID_NotSupported(BASIC_CID_PARAMS_USAGE); |
| 1634 | } |
| 1635 | |
| 1636 | |
| 1637 | ////////////////////////////////////////////////////// |
| 1638 | //SET which Indications we want to receive |
| 1639 | ///////////////////////////////////////////////////// |
| 1640 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 1641 | |
| 1642 | //Creat the context for this command |
| 1643 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 1644 | |
| 1645 | //Copy request to context (we return the same request we received for now). |
| 1646 | memcpy(buf, infoBuf_p, infoBufLen); |
| 1647 | |
| 1648 | //MtilSendInden(mContext, TRUE); |
| 1649 | |
| 1650 | pDevServSubsList = (P_MBIM_DEVICE_SERVICE_SUBSCRIBE_LIST)infoBuf_p; |
| 1651 | |
| 1652 | MbimSetDeviceServiceSubscribeList(pDevServSubsList); |
| 1653 | |
| 1654 | MbimSendCommandDone(transactionId, UUID_BASIC_CONNECT_INDEX, cid, MBIM_STATUS_SUCCESS, infoBufLen, (char *)pDevServSubsList); |
| 1655 | |
| 1656 | MBIM_FREE_CONTEXT(mContext); |
| 1657 | |
| 1658 | return rc; |
| 1659 | } |
| 1660 | |
| 1661 | |
| 1662 | int CID_PacketStatistics(BASIC_CID_PARAMS) |
| 1663 | { |
| 1664 | //Added for compilation uof unused parameters on Codeline |
| 1665 | MBIM_BASIC_UNUSEDPARAM(); |
| 1666 | return 0; |
| 1667 | } |
| 1668 | |
| 1669 | |
| 1670 | /*******************************************************************************\ |
| 1671 | * Function: CID_NetworkIdleHint |
| 1672 | * Description: MBIM_CID_NETWORK_IDLE_HINT (Chapter 10.5.35) |
| 1673 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 1674 | * |
| 1675 | * Returns: 0=OK, <0=Error Code |
| 1676 | \*******************************************************************************/ |
| 1677 | int CID_NetworkIdleHint(BASIC_CID_PARAMS) |
| 1678 | { |
| 1679 | int rc = MBIM_STATUS_SUCCESS; |
| 1680 | MBIM_NETWORK_IDLE_HINT networkIdleHint; |
| 1681 | P_MBIM_NETWORK_IDLE_HINT pNetworkIdleHint; |
| 1682 | |
| 1683 | MBIM_BASIC_UNUSEDPARAM(); |
| 1684 | |
| 1685 | if (commandType == MBIM_SET_COMMAND) |
| 1686 | { |
| 1687 | //Pick up pointer to buffer |
| 1688 | pNetworkIdleHint = (P_MBIM_NETWORK_IDLE_HINT)infoBuf_p; |
| 1689 | |
| 1690 | #if 0 |
| 1691 | if (pNetworkIdleHint->networkIdleHintState == MBIMNetworkIdleHintEnabled) |
| 1692 | ; //Check if we can enter Fast dormancy mode |
| 1693 | else |
| 1694 | ; //Wake up |
| 1695 | #endif |
| 1696 | |
| 1697 | //[TBD what to do --> Need to talk to power people] For now we just return the value |
| 1698 | MbimSendCommandDone( transactionId, |
| 1699 | UUID_BASIC_CONNECT_INDEX, |
| 1700 | cid, |
| 1701 | MBIM_STATUS_SUCCESS, |
| 1702 | sizeof(MBIM_NETWORK_IDLE_HINT), |
| 1703 | (char *)pNetworkIdleHint); |
| 1704 | |
| 1705 | } |
| 1706 | else |
| 1707 | { |
| 1708 | //[TBD] We need to query the fast dormancy |
| 1709 | networkIdleHint.networkIdleHintState = MBIMNetworkIdleHintDisabled; |
| 1710 | MbimSendCommandDone( transactionId, |
| 1711 | UUID_BASIC_CONNECT_INDEX, |
| 1712 | cid, |
| 1713 | MBIM_STATUS_SUCCESS, |
| 1714 | sizeof(MBIM_NETWORK_IDLE_HINT), |
| 1715 | (char *)&networkIdleHint); |
| 1716 | } |
| 1717 | |
| 1718 | return rc; |
| 1719 | |
| 1720 | } |
| 1721 | |
| 1722 | |
| 1723 | /*******************************************************************************\ |
| 1724 | * Function: CID_EmergencyMode |
| 1725 | * Description: MBIM_CID_EMERGENCY_MODE (Chapter 10.5.36) |
| 1726 | * Parameters: BASIC_CID_PARAMS - See description at the start of file |
| 1727 | * |
| 1728 | * Returns: 0=OK, <0=Error Code |
| 1729 | \*******************************************************************************/ |
| 1730 | int CID_EmergencyMode(BASIC_CID_PARAMS) |
| 1731 | { |
| 1732 | int rc = MBIM_STATUS_SUCCESS; |
| 1733 | char *buf = NULL; |
| 1734 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 1735 | P_MBIM_EMERGENCY_MODE_INFO pEmergencyMode = NULL; |
| 1736 | UINT32 mbimStatus = MBIM_STATUS_SUCCESS; |
| 1737 | |
| 1738 | //Added for compilation uof unused parameters on Codeline |
| 1739 | MBIM_BASIC_UNUSEDPARAM(); |
| 1740 | |
| 1741 | ////////////////////////////////////////////////////// |
| 1742 | //We dont support SET command |
| 1743 | ///////////////////////////////////////////////////// |
| 1744 | if (commandType != MBIM_QUERY_COMMAND) |
| 1745 | { |
| 1746 | return CID_NotSupported(BASIC_CID_PARAMS_USAGE); |
| 1747 | } |
| 1748 | |
| 1749 | #ifdef DUMMY |
| 1750 | { |
| 1751 | static int first = 0; |
| 1752 | |
| 1753 | if (!first) |
| 1754 | { |
| 1755 | first = 1; |
| 1756 | sendMbimSmsConfigurationInd(); |
| 1757 | } |
| 1758 | } |
| 1759 | #endif |
| 1760 | |
| 1761 | //Allocate buffer for response |
| 1762 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 1763 | |
| 1764 | //Creat the context for this command |
| 1765 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 1766 | |
| 1767 | //Pick up pointer to buffer |
| 1768 | pEmergencyMode = (P_MBIM_EMERGENCY_MODE_INFO)buf; |
| 1769 | pEmergencyMode->EmergencyMode = MBIMEmergencyModeOff; |
| 1770 | |
| 1771 | if (mbimDb.sim.simReadyState == MBIMSubscriberReadyStateSimNotInserted) |
| 1772 | mbimStatus = MBIM_STATUS_SIM_NOT_INSERTED; |
| 1773 | |
| 1774 | MbimSendCommandDone( transactionId, |
| 1775 | UUID_BASIC_CONNECT_INDEX, |
| 1776 | cid, |
| 1777 | mbimStatus, |
| 1778 | sizeof(MBIM_EMERGENCY_MODE_INFO), |
| 1779 | (char *)pEmergencyMode); |
| 1780 | |
| 1781 | MBIM_FREE_CONTEXT(mContext); |
| 1782 | return rc; |
| 1783 | |
| 1784 | } |
| 1785 | |
| 1786 | int CID_IpPacketFilters(BASIC_CID_PARAMS) |
| 1787 | { |
| 1788 | int rc = MBIM_STATUS_SUCCESS; |
| 1789 | char *buf = NULL; |
| 1790 | P_MBIM_MESSAGE_CONTEXT mContext = NULL; |
| 1791 | |
| 1792 | P_MBIM_IP_PACKET_FILTER pIpFilter; |
| 1793 | |
| 1794 | //MBIM_BASIC_UNUSEDPARAM(); |
| 1795 | |
| 1796 | if (commandType == MBIM_SET_COMMAND) |
| 1797 | { |
| 1798 | pIpFilter = (P_MBIM_IP_PACKET_FILTER)infoBuf_p; |
| 1799 | MbimSendCommandDone( transactionId, |
| 1800 | UUID_BASIC_CONNECT_INDEX, |
| 1801 | cid, |
| 1802 | MBIM_STATUS_SUCCESS, |
| 1803 | infoBufLen, |
| 1804 | (char *)pIpFilter); |
| 1805 | |
| 1806 | } |
| 1807 | else |
| 1808 | { |
| 1809 | ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE); |
| 1810 | CREATE_BASIC_CONNECT_CONTEXT(mContext, buf); |
| 1811 | |
| 1812 | pIpFilter = (P_MBIM_IP_PACKET_FILTER)buf; |
| 1813 | pIpFilter->packetFilterCount = 0; |
| 1814 | |
| 1815 | MbimSendCommandDone( transactionId, |
| 1816 | UUID_BASIC_CONNECT_INDEX, |
| 1817 | cid, |
| 1818 | MBIM_STATUS_SUCCESS, |
| 1819 | sizeof(MBIM_IP_PACKET_FILTER), |
| 1820 | (char *)pIpFilter); |
| 1821 | |
| 1822 | MBIM_FREE_CONTEXT(mContext); |
| 1823 | } |
| 1824 | |
| 1825 | return rc; |
| 1826 | |
| 1827 | } |
| 1828 | |
| 1829 | int CID_MultiCarrierProviders(BASIC_CID_PARAMS) |
| 1830 | { |
| 1831 | //Added for compilation uof unused parameters on Codeline |
| 1832 | MBIM_BASIC_UNUSEDPARAM(); |
| 1833 | return 0; |
| 1834 | } |
| 1835 | |