|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include "HciCmdQTimer.h" |
|
22 #include "HciCmdQUtil.h" |
|
23 |
|
24 #include <bluetooth/hcicmdqcontroller.h> |
|
25 #include <bluetooth/logger.h> |
|
26 |
|
27 #ifdef __FLOG_ACTIVE |
|
28 _LIT8(KLogComponent, LOG_COMPONENT_HCICMDQ); |
|
29 #endif |
|
30 |
|
31 /** |
|
32 Starts the completion timer. |
|
33 */ |
|
34 void CHCICmdQTimer::Restart(TUint aMilliseconds, |
|
35 TUint aCommandQItemId, |
|
36 MHCITimerClient& aClient) |
|
37 { |
|
38 LOG_FUNC |
|
39 |
|
40 iClient = &aClient; |
|
41 iCommandQItemId = aCommandQItemId; |
|
42 |
|
43 Cancel(); |
|
44 After(aMilliseconds * 1000); |
|
45 } |
|
46 |
|
47 void CHCICmdQTimer::ConstructL() |
|
48 { |
|
49 LOG_FUNC |
|
50 |
|
51 CTimer::ConstructL(); |
|
52 CActiveScheduler::Add(this); |
|
53 } |
|
54 |
|
55 CHCICmdQTimer::CHCICmdQTimer() |
|
56 : CTimer(EPriorityStandard), iCommandQItemId(KInvalidCommandQueueItemId) |
|
57 { |
|
58 LOG_FUNC |
|
59 } |
|
60 |
|
61 /* |
|
62 This timer ensures that the stack can recover from hardware failing to |
|
63 respond to a command in a timely manner, specified by the QDP, by |
|
64 calling back into the stack when the timeout expires. The timer is |
|
65 started when the command is issued. A command must not take longer |
|
66 than the starvation timeout to complete. |
|
67 */ |
|
68 /*static*/ CHCICmdQCompletionTimer* CHCICmdQCompletionTimer::NewL() |
|
69 { |
|
70 LOG_STATIC_FUNC |
|
71 |
|
72 CHCICmdQCompletionTimer* self = new (ELeave) CHCICmdQCompletionTimer(); |
|
73 CleanupStack::PushL(self); |
|
74 self->ConstructL(); |
|
75 CleanupStack::Pop(self); |
|
76 return self; |
|
77 } |
|
78 |
|
79 CHCICmdQCompletionTimer::CHCICmdQCompletionTimer() |
|
80 : CHCICmdQTimer() |
|
81 { |
|
82 } |
|
83 |
|
84 void CHCICmdQCompletionTimer::RunL() |
|
85 { |
|
86 LOG_FUNC |
|
87 __ASSERT_ALWAYS(iClient != NULL, PANIC(KHCICmdQPanic, ENullTimerClient)); |
|
88 |
|
89 iClient->CompletionTimeoutFired(iCommandQItemId); |
|
90 } |
|
91 |
|
92 /* |
|
93 This timer is started whenever the head of the pending commands queue |
|
94 changes. It is used to restart the stack in the event that the |
|
95 pending queue is not processed frequently enough. |
|
96 */ |
|
97 /*static*/ CHCICmdQStarvationTimer* CHCICmdQStarvationTimer::NewL() |
|
98 { |
|
99 LOG_STATIC_FUNC |
|
100 |
|
101 CHCICmdQStarvationTimer* self = new (ELeave) CHCICmdQStarvationTimer(); |
|
102 CleanupStack::PushL(self); |
|
103 self->ConstructL(); |
|
104 CleanupStack::Pop(self); |
|
105 return self; |
|
106 } |
|
107 |
|
108 CHCICmdQStarvationTimer::CHCICmdQStarvationTimer() |
|
109 : CHCICmdQTimer() |
|
110 { |
|
111 } |
|
112 |
|
113 void CHCICmdQStarvationTimer::RunL() |
|
114 { |
|
115 LOG_FUNC |
|
116 |
|
117 __ASSERT_ALWAYS(iClient != NULL, PANIC(KHCICmdQPanic, ENullTimerClient)); |
|
118 |
|
119 iClient->StarvationTimeoutFired(iCommandQItemId); |
|
120 } |