118 SetCommunicationInterfaceL(); |
118 SetCommunicationInterfaceL(); |
119 |
119 |
120 // Setup NCM data interface |
120 // Setup NCM data interface |
121 SetDataInterfaceL(aDataEpBufferSize); |
121 SetDataInterfaceL(aDataEpBufferSize); |
122 |
122 |
123 // Retrieve data interface number |
123 // Retrieve Control interface number(alter 0) |
124 TUint8 dataInterfaceNumber = 1; |
124 TUint8 controlInterfaceNumber = 0; |
125 User::LeaveIfError(DataInterfaceNumber(dataInterfaceNumber)); |
125 User::LeaveIfError(InterfaceNumber(iCommLdd,0,controlInterfaceNumber)); |
|
126 |
|
127 // Retrieve data interface number(alter 0) |
|
128 TUint8 dataInterfaceNumber = 0; |
|
129 User::LeaveIfError(InterfaceNumber(iDataLdd,0,dataInterfaceNumber)); |
126 |
130 |
127 // Setup NCM class descriptor with correct interface number |
131 // Setup NCM class descriptor with correct interface number |
128 User::LeaveIfError(SetupClassSpecificDescriptor(dataInterfaceNumber)); |
132 User::LeaveIfError(SetupClassSpecificDescriptor(controlInterfaceNumber,dataInterfaceNumber)); |
129 OstTraceFunctionExit1( CNCMCLIENTMANAGER_SETNCMINTERFACESL_EXIT, this ); |
133 OstTraceFunctionExit1( CNCMCLIENTMANAGER_SETNCMINTERFACESL_EXIT, this ); |
130 } |
134 } |
131 |
135 |
132 /** |
136 /** |
133 * Transfer NCM interface handlers from NCM class controller to NCM |
137 * Transfer NCM interface handlers from NCM class controller to NCM |
445 |
449 |
446 // Union functional descriptor- CDC spec table 16 |
450 // Union functional descriptor- CDC spec table 16 |
447 descriptor.iUnSize = 0x05; |
451 descriptor.iUnSize = 0x05; |
448 descriptor.iUnType = 0x24; |
452 descriptor.iUnType = 0x24; |
449 descriptor.iUnSubType = 0x06; |
453 descriptor.iUnSubType = 0x06; |
450 descriptor.iUnMasterInterface = 0; |
454 descriptor.iUnMasterInterface = aControlInterfaceNumber; |
451 descriptor.iUnSlaveInterface = aDataInterfaceNumber; |
455 descriptor.iUnSlaveInterface = aDataInterfaceNumber; |
452 |
456 |
453 OstTrace0( TRACE_NORMAL, CNCMCLIENTMANAGER_SETUPCLASSSPECIFICDESCRIPTOR_PRE_SET_BLOCK, "About to call SetCSInterfaceDescriptorBlock" ); |
457 OstTrace0( TRACE_NORMAL, CNCMCLIENTMANAGER_SETUPCLASSSPECIFICDESCRIPTOR_PRE_SET_BLOCK, "About to call SetCSInterfaceDescriptorBlock" ); |
454 res = iCommLdd.SetCSInterfaceDescriptorBlock(0, descriptor.Des()); |
458 res = iCommLdd.SetCSInterfaceDescriptorBlock(0, descriptor.Des()); |
455 if (res != KErrNone) |
459 if (res != KErrNone) |
498 OstTraceFunctionExitExt( CNCMCLIENTMANAGER_SETMACADDRESSSTRING_EXIT, this, ret ); |
502 OstTraceFunctionExitExt( CNCMCLIENTMANAGER_SETMACADDRESSSTRING_EXIT, this, ret ); |
499 return ret; |
503 return ret; |
500 } |
504 } |
501 |
505 |
502 /** |
506 /** |
503 * Get NCM data interface number |
507 * Get interface number |
504 * @param aInterfaceNumber NCM data interface number |
508 * @param aLdd The logic device driver which can be used to query for. |
505 * @return Error. |
509 * @param aSettingsNumber The alter settings for the interface |
506 */ |
510 * @param [out] aInterfaceNumber Carry out the interface bumber back to caller. |
507 TInt CNcmClientManager::DataInterfaceNumber(TUint8& aInterfaceNumber) |
511 * @return KErrNone If interface number is return via aInterfaceNumber. |
508 { |
512 * Other system wide error code if anything went wrong. |
509 OstTraceFunctionEntryExt( CNCMCLIENTMANAGER_DATAINTERFACENUMBER_ENTRY, this ); |
513 */ |
510 |
514 TInt CNcmClientManager::InterfaceNumber(RDevUsbcScClient& aLdd,TInt aSettingsNumber,TUint8& aInterfaceNumber) |
|
515 { |
|
516 OstTraceFunctionEntryExt( CNCMCLIENTMANAGER_INTERFACENUMBER_ENTRY, this ); |
|
517 |
|
518 // Get descriptor size first |
511 TInt interfaceSize = 0; |
519 TInt interfaceSize = 0; |
512 |
520 TInt res = aLdd.GetInterfaceDescriptorSize(aSettingsNumber, interfaceSize); |
513 // 0 means the main interface in the LDD API |
|
514 TInt res = iDataLdd.GetInterfaceDescriptorSize(0, interfaceSize); |
|
515 |
|
516 if ( KErrNone == res ) |
521 if ( KErrNone == res ) |
517 { |
522 { |
518 OstTraceFunctionExitExt( CNCMCLIENTMANAGER_DATAINTERFACENUMBER_EXIT, this, res ); |
523 OstTraceFunctionExitExt( CNCMCLIENTMANAGER_INTERFACENUMBER_EXIT, this, res ); |
519 return res; |
524 return res; |
520 } |
525 } |
521 |
526 |
|
527 // Allocate enough buffer |
522 HBufC8* interfaceBuf = HBufC8::New(interfaceSize); |
528 HBufC8* interfaceBuf = HBufC8::New(interfaceSize); |
523 if ( !interfaceBuf ) |
529 if ( !interfaceBuf ) |
524 { |
530 { |
525 OstTraceFunctionExitExt( CNCMCLIENTMANAGER_DATAINTERFACENUMBER_EXIT_DUP1, this, KErrNoMemory); |
531 OstTraceFunctionExitExt( CNCMCLIENTMANAGER_INTERFACENUMBER_EXIT_DUP1, this, KErrNoMemory); |
526 return KErrNoMemory; |
532 return KErrNoMemory; |
527 } |
533 } |
528 |
534 |
|
535 // Get the buffer back |
529 TPtr8 interfacePtr = interfaceBuf->Des(); |
536 TPtr8 interfacePtr = interfaceBuf->Des(); |
530 interfacePtr.SetLength(0); |
537 interfacePtr.SetLength(0); |
531 // 0 means the main interface in the LDD API |
538 res = aLdd.GetInterfaceDescriptor(aSettingsNumber, interfacePtr); |
532 res = iDataLdd.GetInterfaceDescriptor(0, interfacePtr); |
|
533 |
|
534 if ( KErrNone == res ) |
539 if ( KErrNone == res ) |
535 { |
540 { |
536 delete interfaceBuf; |
541 delete interfaceBuf; |
537 OstTraceFunctionExitExt( CNCMCLIENTMANAGER_DATAINTERFACENUMBER_EXIT_DUP2, this, res ); |
542 OstTraceFunctionExitExt( CNCMCLIENTMANAGER_INTERFACENUMBER_EXIT_DUP2, this, res ); |
538 return res; |
543 return res; |
539 } |
544 } |
540 |
545 |
541 OstTrace1(TRACE_NORMAL, CNCMCLIENTMANAGER_DATAINTERFACENUMBER_INTERFACE_INFO, "***Interface length =% d", interfacePtr.Length()); |
546 OstTrace1(TRACE_NORMAL, CNCMCLIENTMANAGER_INTERFACENUMBER_INTERFACE_INFO, "***Interface length =% d", interfacePtr.Length()); |
|
547 |
|
548 #ifdef OST_TRACE_COMPILER_IN_USE // to depress a build warning incase no ost trace is used |
542 for ( TInt i = 0 ; i < interfacePtr.Length() ; i++ ) |
549 for ( TInt i = 0 ; i < interfacePtr.Length() ; i++ ) |
543 { |
550 { |
544 OstTrace1(TRACE_NORMAL, CNCMCLIENTMANAGER_DATAINTERFACENUMBER_INTERFACE_INFO2, "***** %x", interfacePtr[i]); |
551 OstTrace1(TRACE_NORMAL, CNCMCLIENTMANAGER_INTERFACENUMBER_INTERFACE_INFO2, "***** %x", interfacePtr[i]); |
545 } |
552 } |
546 |
553 #endif |
|
554 |
547 const TUint8* buffer = reinterpret_cast<const TUint8*>(interfacePtr.Ptr()); |
555 const TUint8* buffer = reinterpret_cast<const TUint8*>(interfacePtr.Ptr()); |
|
556 |
548 // 2 is where the interface number is, according to the LDD API |
557 // 2 is where the interface number is, according to the LDD API |
549 aInterfaceNumber = buffer[2]; |
558 aInterfaceNumber = buffer[2]; |
550 OstTraceExt1(TRACE_NORMAL, CNCMCLIENTMANAGER_DATAINTERFACENUMBER, "Interface number = %hhu", aInterfaceNumber); |
559 |
551 |
560 OstTraceExt1(TRACE_NORMAL, CNCMCLIENTMANAGER_INTERFACENUMBER, "Interface number = %hhu", aInterfaceNumber); |
|
561 |
|
562 // Now it is safe to delete the buffer we allocated. |
552 delete interfaceBuf; |
563 delete interfaceBuf; |
553 |
564 |
554 OstTraceFunctionExitExt( CNCMCLIENTMANAGER_DATAINTERFACENUMBER_EXIT_DUP3, this, KErrNone ); |
565 OstTraceFunctionExitExt( CNCMCLIENTMANAGER_INTERFACENUMBER_EXIT_DUP3, this, KErrNone ); |
555 return KErrNone; |
566 return KErrNone; |
556 } |
567 } |