1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
213 } |
214 } |
214 |
215 |
215 void CHCIFacade::SetControllerToHostFlowControlOpcode(THCIErrorCode aHciErr, const THCIEventBase* /*aEvent*/, const CHCICommandBase* /*aRelatedCommand*/) |
216 void CHCIFacade::SetControllerToHostFlowControlOpcode(THCIErrorCode aHciErr, const THCIEventBase* /*aEvent*/, const CHCICommandBase* /*aRelatedCommand*/) |
216 { |
217 { |
217 LOG_FUNC |
218 LOG_FUNC |
218 LOG(_L("HCIFacade: SetControllerToHostFlowControl Command Complete Event")); |
219 LOG1(_L8("HCIFacade: SetControllerToHostFlowControl Command Complete Event (result = 0x%02x)"), aHciErr); |
219 iLinkMuxer->RecordHostControllerToHostFlowControl(aHciErr == EOK ? ETrue:EFalse); |
220 if(aHciErr == EOK) |
|
221 { |
|
222 // flow control mode set - so provide the host buffer settings |
|
223 CHCICommandBase* command = NULL; |
|
224 TRAPD(err, command = CHostBufferSizeCommand::NewL(KStackACLBuffersSize, KStackSCOBuffersSize, |
|
225 KStackACLBuffersNum, KStackSCOBuffersNum)); |
|
226 if(err == KErrNone) |
|
227 { |
|
228 err = SendInitialisationCommand(command); |
|
229 } |
|
230 if(err != KErrNone) |
|
231 { |
|
232 // unfortunately at this stage we are stuck since we need to inform |
|
233 // the controller of our buffers. We've failed to initialise. |
|
234 LOG1(_L8("Failed to send HostBufferSize command(%d) - initialisation failed"), err); |
|
235 iInitialisationError = ETrue; |
|
236 } |
|
237 } |
|
238 else // we'll drop back to no flow control to the host |
|
239 { |
|
240 iLinkMuxer->RecordHostControllerToHostFlowControl(EFalse); |
|
241 } |
|
242 } |
|
243 |
|
244 void CHCIFacade::HostBufferSizeOpcode(THCIErrorCode aHciErr, const THCIEventBase* /*aEvent*/, const CHCICommandBase* /*aRelatedCommand*/) |
|
245 { |
|
246 LOG_FUNC |
|
247 LOG1(_L8("HCIFacade: HostBufferSizeOpcode Command Complete Event (result = 0x%02x)"), aHciErr); |
|
248 if(aHciErr == EOK) |
|
249 { |
|
250 // all set-up for controller to host flow-control |
|
251 iLinkMuxer->RecordHostControllerToHostFlowControl(ETrue); |
|
252 } |
|
253 else |
|
254 { |
|
255 // If we've failed to perform this command then the stack is stuck |
|
256 // half initialised to perform controller to host flow control. |
|
257 LOG(_L8("Failed to set the host buffer size in controller - initialisation failed")); |
|
258 iInitialisationError = ETrue; |
|
259 } |
220 } |
260 } |
221 |
261 |
222 void CHCIFacade::WriteScanEnableOpcode(THCIErrorCode aHciErr, const THCIEventBase* /*aEvent*/, const CHCICommandBase* /*aRelatedCommand*/) |
262 void CHCIFacade::WriteScanEnableOpcode(THCIErrorCode aHciErr, const THCIEventBase* /*aEvent*/, const CHCICommandBase* /*aRelatedCommand*/) |
223 { |
263 { |
224 LOG_FUNC |
264 LOG_FUNC |
349 iLinkMgrProtocol.SetLocalFeatures(aHciErr, features); |
389 iLinkMgrProtocol.SetLocalFeatures(aHciErr, features); |
350 |
390 |
351 if(iLinkMgrProtocol.IsSecureSimplePairingSupportedLocally()) |
391 if(iLinkMgrProtocol.IsSecureSimplePairingSupportedLocally()) |
352 { |
392 { |
353 CWriteSimplePairingModeCommand* cmd = NULL; |
393 CWriteSimplePairingModeCommand* cmd = NULL; |
354 TRAP_IGNORE(cmd = CWriteSimplePairingModeCommand::NewL(ESimplePairingEnabled)); |
394 TRAPD(err, cmd = CWriteSimplePairingModeCommand::NewL(ESimplePairingEnabled)); |
355 static_cast<void>(SendInitialisationCommand(cmd)); |
395 if(err == KErrNone) |
356 iLinksMgr->SecMan().SetLocalSimplePairingMode(ETrue); //probably unnecessary |
396 { |
|
397 err = SendInitialisationCommand(cmd); |
|
398 } |
|
399 if(err != KErrNone) |
|
400 { |
|
401 LOG(_L("HCIFacade: ReadLocalSupportedFeaturesOpcode Error")); |
|
402 iInitialisationError = ETrue; |
|
403 } |
357 } |
404 } |
358 else |
405 else |
359 { |
406 { |
360 iLinksMgr->SecMan().SetLocalSimplePairingMode(EFalse); |
407 iLinksMgr->SecMan().SetLocalSimplePairingMode(EFalse); |
361 } |
408 } |
362 } |
409 } |
363 else |
410 else |
364 { |
411 { |
365 iLinkMgrProtocol.SetLocalFeatures(aHciErr, TBTFeatures(0)); |
412 iLinkMgrProtocol.SetLocalFeatures(aHciErr, TBTFeatures(0)); |
|
413 iLinksMgr->SecMan().SetLocalSimplePairingMode(EFalse); // for want of a better solution |
366 } |
414 } |
367 |
415 |
368 iReadLocalSupportedFeaturesComplete = ETrue; |
416 iReadLocalSupportedFeaturesComplete = ETrue; |
369 if (iReadLocalVersionComplete) |
417 if (iReadLocalVersionComplete) |
370 { |
418 { |
564 |
612 |
565 case KSetControllerToHostFlowControlOpcode: |
613 case KSetControllerToHostFlowControlOpcode: |
566 SetControllerToHostFlowControlOpcode(aHciErr, aEvent, aRelatedCommand); |
614 SetControllerToHostFlowControlOpcode(aHciErr, aEvent, aRelatedCommand); |
567 break; |
615 break; |
568 |
616 |
|
617 case KHostBufferSizeOpcode: |
|
618 HostBufferSizeOpcode(aHciErr, aEvent, aRelatedCommand); |
|
619 break; |
|
620 |
569 case KWriteScanEnableOpcode: |
621 case KWriteScanEnableOpcode: |
570 WriteScanEnableOpcode(aHciErr, aEvent, aRelatedCommand); |
622 WriteScanEnableOpcode(aHciErr, aEvent, aRelatedCommand); |
571 break; |
623 break; |
572 |
624 |
573 case KSetAFHHostChannelClassificationOpcode: |
625 case KSetAFHHostChannelClassificationOpcode: |
620 // Only the inquiry manager issues remote name requests. |
672 // Only the inquiry manager issues remote name requests. |
621 FTRACE(FPrint(_L("Error!! Unsolicited inquiry-type command complete event (opcode: 0x%04x)"), aOpcode)); |
673 FTRACE(FPrint(_L("Error!! Unsolicited inquiry-type command complete event (opcode: 0x%04x)"), aOpcode)); |
622 __ASSERT_DEBUG(EFalse, Panic(EHCIUnmatchedInquiryEvent)); |
674 __ASSERT_DEBUG(EFalse, Panic(EHCIUnmatchedInquiryEvent)); |
623 break; |
675 break; |
624 |
676 |
|
677 case KWriteSimplePairingModeOpcode: |
|
678 { |
|
679 WriteSimplePairingModeOpcode(aHciErr, aEvent, aRelatedCommand); |
|
680 break; |
|
681 } |
|
682 |
625 // Security related events that are sent from the facade. |
683 // Security related events that are sent from the facade. |
626 case KWriteSimplePairingModeOpcode: |
|
627 case KReadLocalOOBDataOpcode: |
684 case KReadLocalOOBDataOpcode: |
628 case KRemoteOOBDataRequestReplyOpcode: |
685 case KRemoteOOBDataRequestReplyOpcode: |
629 case KRemoteOOBDataRequestNegativeReplyOpcode: |
686 case KRemoteOOBDataRequestNegativeReplyOpcode: |
630 case KIOCapabilityRequestReplyOpcode: |
687 case KIOCapabilityRequestReplyOpcode: |
631 case KUserConfirmationRequestReplyOpcode: |
688 case KUserConfirmationRequestReplyOpcode: |
657 case KPeriodicInquiryModeOpcode: |
714 case KPeriodicInquiryModeOpcode: |
658 case KExitPeriodicInquiryModeOpcode: |
715 case KExitPeriodicInquiryModeOpcode: |
659 case KSetEventFilterOpcode: |
716 case KSetEventFilterOpcode: |
660 case KCreateNewUnitKeyOpcode: |
717 case KCreateNewUnitKeyOpcode: |
661 case KWriteAuthenticationEnableOpcode: |
718 case KWriteAuthenticationEnableOpcode: |
662 case KHostNumberOfCompletedPacketsOpcode: |
|
663 case KWriteEncryptionModeOpcode: |
719 case KWriteEncryptionModeOpcode: |
664 case KWritePageTimeoutOpcode: |
720 case KWritePageTimeoutOpcode: |
665 case KReadConnectionAcceptTimeoutOpcode: |
721 case KReadConnectionAcceptTimeoutOpcode: |
666 case KWriteConnectionAcceptTimeoutOpcode: |
722 case KWriteConnectionAcceptTimeoutOpcode: |
667 case KWriteVoiceSettingOpcode: |
723 case KWriteVoiceSettingOpcode: |
668 case KHostBufferSizeOpcode: |
|
669 case KReadAFHChannelMapOpcode: |
724 case KReadAFHChannelMapOpcode: |
670 case KReadAFHChannelAssessmentModeOpcode: |
725 case KReadAFHChannelAssessmentModeOpcode: |
671 case KReadPageTimeoutOpcode: |
726 case KReadPageTimeoutOpcode: |
672 case KCreateConnectionCancelOpcode: |
727 case KCreateConnectionCancelOpcode: |
673 case KReadLMPHandleOpcode: |
728 case KReadLMPHandleOpcode: |
712 |
767 |
713 case KReadSimplePairingModeOpcode: |
768 case KReadSimplePairingModeOpcode: |
714 case KSendKeypressNotificationOpcode: |
769 case KSendKeypressNotificationOpcode: |
715 |
770 |
716 case KWriteSimplePairingDebugModeOpcode: |
771 case KWriteSimplePairingDebugModeOpcode: |
|
772 |
|
773 // below here are command complete events we definitely shouldn't receive |
|
774 // but have been left for safety until a complete analysis is done. |
|
775 case KHostNumberOfCompletedPacketsOpcode: |
717 |
776 |
718 // Catch all the events we do not handle |
777 // Catch all the events we do not handle |
719 LOG1(_L("Warning!! Unhandled Command Complete Event (opcode:%d)"), aOpcode); |
778 LOG1(_L("Warning!! Unhandled Command Complete Event (opcode:%d)"), aOpcode); |
720 break; |
779 break; |
721 |
780 |
793 { |
852 { |
794 __ASSERT_ALWAYS(iOutstandingCommands.Count()==0, Panic(EHCICtrlrInitFailedToRemoveCmd)); |
853 __ASSERT_ALWAYS(iOutstandingCommands.Count()==0, Panic(EHCICtrlrInitFailedToRemoveCmd)); |
795 } |
854 } |
796 } |
855 } |
797 |
856 |
|
857 void CHCIFacade::WriteSimplePairingModeOpcode(THCIErrorCode aHciErr, const THCIEventBase* /*aEvent*/, const CHCICommandBase* /*aRelatedCommand*/) |
|
858 { |
|
859 LOG_FUNC |
|
860 if(aHciErr == EOK) |
|
861 { |
|
862 iLinksMgr->SecMan().SetLocalSimplePairingMode(ETrue); |
|
863 } |
|
864 else |
|
865 { |
|
866 iInitialisationError = ETrue; |
|
867 } |
|
868 } |
|
869 |
798 void CHCIFacade::CommandStatusEvent(const THCIEventBase& aEvent, const CHCICommandBase* aRelatedCommand) |
870 void CHCIFacade::CommandStatusEvent(const THCIEventBase& aEvent, const CHCICommandBase* aRelatedCommand) |
799 { |
871 { |
800 LOG_FUNC |
872 LOG_FUNC |
801 const TCommandStatusEvent& commandStatusEvent = TCommandStatusEvent::Cast(aEvent); |
873 const TCommandStatusEvent& commandStatusEvent = TCommandStatusEvent::Cast(aEvent); |
802 THCIOpcode opcode = commandStatusEvent.CommandOpcode(); |
874 THCIOpcode opcode = commandStatusEvent.CommandOpcode(); |
874 conn.iLinkType = EeSCOLink; |
946 conn.iLinkType = EeSCOLink; |
875 |
947 |
876 TBTSyncConnectOpts syncOpts(0, 0, 0, 0, EuLawLog); |
948 TBTSyncConnectOpts syncOpts(0, 0, 0, 0, EuLawLog); |
877 |
949 |
878 iLinksMgr->SynchronousConnectionComplete(hciErr, conn, syncOpts); |
950 iLinksMgr->SynchronousConnectionComplete(hciErr, conn, syncOpts); |
879 break; |
|
880 } |
|
881 |
|
882 case KHostNumberOfCompletedPacketsOpcode: |
|
883 { |
|
884 iLinksMgr->CompletedPackets(KInvalidConnectionHandle, 0); //no packets |
|
885 break; |
951 break; |
886 } |
952 } |
887 |
953 |
888 case KReadRemoteExtendedFeaturesOpcode: |
954 case KReadRemoteExtendedFeaturesOpcode: |
889 { |
955 { |
913 case KChangeConnectionPacketTypeOpcode: |
979 case KChangeConnectionPacketTypeOpcode: |
914 { |
980 { |
915 iLinksMgr->PacketTypeChange(hciErr, KInvalidConnectionHandle,0); |
981 iLinksMgr->PacketTypeChange(hciErr, KInvalidConnectionHandle,0); |
916 break; |
982 break; |
917 } |
983 } |
918 |
984 |
|
985 case KWriteSimplePairingModeOpcode: |
|
986 { |
|
987 WriteSimplePairingModeOpcode(hciErr, &commandStatusEvent, aRelatedCommand); |
|
988 break; |
|
989 } |
|
990 |
919 default: |
991 default: |
920 // Complete any other commands with an error |
992 // Complete any other commands with an error |
921 CommandCompleteEvent(opcode, hciErr, NULL, NULL); |
993 CommandCompleteEvent(opcode, hciErr, NULL, NULL); |
922 break; |
994 break; |
923 } |
995 } |