|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef BTGPSMESSAGESENDER_H |
|
22 #define BTGPSMESSAGESENDER_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <badesca.h> |
|
28 #include "BTGPSDeviceListener.h" |
|
29 |
|
30 |
|
31 // CONSTANTS |
|
32 /** |
|
33 * The size of the output buffer size. This |
|
34 * have to be longer than longest NMEA message |
|
35 */ |
|
36 const TInt KSendMessageSize = 200; |
|
37 |
|
38 |
|
39 // MACROS |
|
40 |
|
41 // DATA TYPES |
|
42 |
|
43 // FUNCTION PROTOTYPES |
|
44 |
|
45 // FORWARD DECLARATIONS |
|
46 class RSocket; |
|
47 class CBTGPSDeviceManager; |
|
48 |
|
49 // CLASS DECLARATION |
|
50 |
|
51 /** |
|
52 * This class is used to send messages to connected BT device. |
|
53 * It doesn't garentee the message can be received from connected |
|
54 * BT device. The message are buffered if necessary to prevent |
|
55 * jams on BT connection. |
|
56 * |
|
57 */ |
|
58 class CBTGPSMessageSender: public CActive, private MBTGPSDeviceListener |
|
59 { |
|
60 public: |
|
61 |
|
62 /** |
|
63 * Two-phase construction. |
|
64 * @param aSocket Reference to RSocket. |
|
65 * @param aDeviceManager Reference to device manager |
|
66 */ |
|
67 static CBTGPSMessageSender * NewL( |
|
68 RSocket& aSocket, |
|
69 CBTGPSDeviceManager& aDeviceManager); |
|
70 |
|
71 /** |
|
72 * Destructor |
|
73 */ |
|
74 virtual ~CBTGPSMessageSender(); |
|
75 |
|
76 /** |
|
77 * Send message |
|
78 * @param aMsg Message to be sent. |
|
79 */ |
|
80 void SendL(const TDesC8& aMsg); |
|
81 |
|
82 private: |
|
83 /** |
|
84 * From CActive |
|
85 */ |
|
86 virtual void RunL(); |
|
87 |
|
88 /** |
|
89 * From CActive |
|
90 */ |
|
91 virtual void DoCancel(); |
|
92 |
|
93 /** |
|
94 * From CActive |
|
95 */ |
|
96 virtual TInt RunError(TInt aError); |
|
97 |
|
98 /** |
|
99 * From MBTGPSDeviceListener |
|
100 */ |
|
101 virtual void BTDeviceStatusChanged( |
|
102 TInt aConnectStatus, |
|
103 TInt aDeviceType, |
|
104 TInt aErr=KErrNone); |
|
105 |
|
106 private: |
|
107 |
|
108 /** |
|
109 * Second phase of the construction |
|
110 */ |
|
111 void ConstructL(); |
|
112 |
|
113 /** |
|
114 * Private constructor |
|
115 */ |
|
116 CBTGPSMessageSender( |
|
117 RSocket& aSocket, |
|
118 CBTGPSDeviceManager& aDeviceManager); |
|
119 |
|
120 /** |
|
121 * Start timer |
|
122 */ |
|
123 void StartTimer(); |
|
124 |
|
125 /** |
|
126 * Timer callback |
|
127 */ |
|
128 void TimerTick(); |
|
129 |
|
130 /** |
|
131 * Static timer callback |
|
132 */ |
|
133 static TInt TimerCallback(TAny* aAny); |
|
134 |
|
135 private: |
|
136 //Socket |
|
137 RSocket& iSocket; |
|
138 |
|
139 //Device manager |
|
140 CBTGPSDeviceManager& iDeviceManager; |
|
141 |
|
142 //Sending buffer |
|
143 CDesC8ArrayFlat* iBuffer; |
|
144 |
|
145 //Timer |
|
146 CPeriodic* iTimer; |
|
147 }; |
|
148 #endif |
|
149 // End of File |
|
150 |