author | mikaruus |
Tue, 19 Oct 2010 13:16:20 +0300 | |
changeset 9 | 8486d82aef45 |
parent 7 | fa67e03b87df |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* Copyright (c) 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 the License "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: |
|
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
13 |
* |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
14 |
* Description: |
0 | 15 |
* |
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
9 | 20 |
#include <kernel.h> // For Kern |
21 |
#include <pn_const.h> // For PN_OBJ_ROUTING_REQ |
|
22 |
#include <phonetisi.h> // For ISI_HEADER_OFFSET_... |
|
23 |
#include <commisi.h> // For COMMON_ISA_... |
|
0 | 24 |
|
9 | 25 |
#include "isirouter.h" // For DISIRouter |
26 |
#include "isiroutertrace.h" // For C_TRACE, ASSERT_RESET.. and fault codes |
|
27 |
#include "misirouterlinkif.h" // For MISIRouterLinkIf |
|
28 |
#include "isihelpers.h" // For GET_SENDER_DEV... |
|
29 |
#include "memapi.h" // For MemApi |
|
30 |
#include <trxdefs.h> // For ETrxTest... |
|
31 |
#include "isicltransceiver.h" // For DISICLTransceiver |
|
32 |
#include <nsisi.h> // For PN_NAMESERVICE... |
|
33 |
#include "isirouterservice.h" // For DIsiRouterService |
|
34 |
#include "isimsgqueue.h" // For DISIMsgQueue |
|
35 |
#include "iscnokiadefinitions.h" // For EIscNokiaUsbPhonetLink |
|
36 |
#ifdef USE_MEDIAAPI |
|
37 |
#include <pn_isimedia_const.h> // For PN_DEV_PC |
|
38 |
#endif /* USE_MEDIAAPI */ |
|
0 | 39 |
|
40 |
// Faults |
|
41 |
enum TISICLTransceiverFaults |
|
42 |
{ |
|
43 |
EISICLTransceiverMemAllocFailure = 0x01, |
|
44 |
EISICLTransceiverMemAllocFailure1, |
|
9 | 45 |
EISICLTransceiverMemAllocFailure2, |
46 |
EISICLTransceiverMemAllocFailure3, |
|
47 |
EISICLTransceiverMemAllocFailure4, |
|
48 |
EISICLTransceiverMemAllocFailure5, |
|
49 |
EISICLTransceiverMemAllocFailure6, |
|
50 |
EISICLTransceiverMemAllocFailure7, |
|
51 |
EISICLTransceiverMemAllocFailure8, |
|
52 |
#ifdef USE_MEDIAAPI |
|
53 |
EISICLTransceiverMemAllocFailure9, |
|
54 |
EISICLTransceiverMemAllocFailure10, |
|
55 |
#endif /* USE_MEDIAAPI */ |
|
0 | 56 |
EISICLTransceiverNotSupportedMedia, |
57 |
EISICLTransceiverOverTheLimits, |
|
58 |
EISICLTransceiverNULLPtr, |
|
9 | 59 |
EISICLTransceiverNULLPtr2, |
60 |
EISICLTransceiverNULLPtr3, |
|
61 |
EISICLTransceiverNULLPtr4, |
|
62 |
EISICLTransceiverNULLPtr5, |
|
63 |
EISICLTransceiverNULLPtr6, |
|
64 |
EISICLTransceiverNULLPtr7, |
|
0 | 65 |
EISICLTransceiverNotSupportedDevice, |
9 | 66 |
EISICLTransceiverDeviceConnection, |
67 |
EISICLTransceiverCommIsaEntityNotReachableResp, |
|
68 |
EISICLTransceiverNotThreadContext, |
|
69 |
EISICLTransceiverMutexCreateFailed, |
|
70 |
EISICLTransceiverMutexWaitFailed, |
|
71 |
EISICLTransceiverMutexWaitFailed2, |
|
0 | 72 |
}; |
73 |
||
9 | 74 |
// Constants |
75 |
const TInt KDfcPriority( 5 ); |
|
76 |
||
77 |
DMutex* DISICLTransceiver::iDynamicDeviceTableMutex = NULL; |
|
78 |
_LIT8( KISICLTransceiverMutex, "ISICLTransceiverMutex" ); |
|
79 |
||
80 |
DISICLTransceiver::DISICLTransceiver( |
|
81 |
DISIRouter& aRouter, |
|
82 |
TDfcQue* aThreadPtr |
|
83 |
) |
|
84 |
: iShRouter( aRouter ) |
|
0 | 85 |
{ |
86 |
C_TRACE( ( _T( "DISICLTransceiver::DISICLTransceiver>" ) ) ); |
|
9 | 87 |
ASSERT_RESET_ALWAYS( aThreadPtr, ( EISICLTransceiverNULLPtr7 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
88 |
iShStateChangedDfc = new TDfc( StateChangedDfc, this, aThreadPtr, KDfcPriority ); |
|
89 |
ASSERT_RESET_ALWAYS( iShStateChangedDfc, ( EISICLTransceiverMemAllocFailure6 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
90 |
||
91 |
iRxQueueDfc = new TDfc( RxQueueDfc, this, aThreadPtr, KDfcPriority ); |
|
92 |
ASSERT_RESET_ALWAYS( iShStateChangedDfc, ( EISICLTransceiverMemAllocFailure8 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
93 |
||
94 |
DISIDevice* dev = new DISIDevice( PN_DEV_MODEM, |
|
95 |
MISIRouterLinkIf::CreateLinkF( this, PN_MEDIA_MODEM_HOST_IF, ETrxSharedMemory) |
|
96 |
); |
|
97 |
ASSERT_RESET_ALWAYS( dev, ( EISICLTransceiverMemAllocFailure3 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
98 |
iShDevices.Append( dev ); |
|
99 |
#ifdef USE_MEDIAAPI |
|
100 |
DISIDevice* dev2 = new DISIDevice( PN_DEV_PC, // append to dynamic table if needed |
|
101 |
MISIRouterLinkIf::CreateLinkF( this, PN_MEDIA_USB, ETrxUSB ) |
|
102 |
); |
|
103 |
ASSERT_RESET_ALWAYS( dev2, ( EISICLTransceiverMemAllocFailure9 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
104 |
iShDevices.Append( dev2 ); |
|
105 |
||
106 |
DISIDevice* dev4 = new DISIDevice( PN_DEV_PC, // append to dynamic table if needed |
|
107 |
MISIRouterLinkIf::CreateLinkF( this, PN_MEDIA_BT, ETrxBT ) |
|
108 |
); |
|
109 |
ASSERT_RESET_ALWAYS( dev4, ( EISICLTransceiverMemAllocFailure10 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
110 |
iShDevices.Append( dev4 ); |
|
111 |
#endif /* USE_MEDIAAPI */ |
|
112 |
DISIDevice* dev3 = new DISIDevice( PN_DEV_DUMMYIST, |
|
113 |
MISIRouterLinkIf::CreateLinkF( this, PN_MEDIA_TEST, ETrxTest ) |
|
114 |
); |
|
115 |
ASSERT_RESET_ALWAYS( dev3, ( EISICLTransceiverMemAllocFailure5 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
116 |
iShDevices.Append( dev3 ); |
|
117 |
||
118 |
iRouterService = new DIsiRouterService( *this ); |
|
119 |
ASSERT_RESET_ALWAYS( iRouterService, ( EISICLTransceiverMemAllocFailure2 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
120 |
||
121 |
iRxQueue = new DISIMsgQueue( KISIMainRxQueueSize ); |
|
122 |
ASSERT_RESET_ALWAYS( iRxQueue, ( EISICLTransceiverMemAllocFailure7 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
123 |
||
124 |
TInt err( Kern::MutexCreate( iDynamicDeviceTableMutex, KISICLTransceiverMutex, KMutexOrdGeneral0 ) ); |
|
125 |
ASSERT_RESET_ALWAYS( ( KErrNone == err ), ( EISICLTransceiverMutexCreateFailed | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
126 |
#ifdef USE_MEDIAAPI |
|
127 |
iDevPcLastSendTrxId = EAmountOfTrxs; //put a maxvalue |
|
128 |
iDevPcLastActiveTrxId = EAmountOfTrxs; //put a maxvalue |
|
129 |
#endif /* USE_MEDIAAPI */ |
|
0 | 130 |
C_TRACE( ( _T( "DISICLTransceiver::DISICLTransceiver<" ) ) ); |
131 |
} |
|
132 |
||
133 |
DISICLTransceiver::~DISICLTransceiver() |
|
134 |
{ |
|
135 |
C_TRACE( ( _T( "DISICLTransceiver::~DISICLTransceiver>" ) ) ); |
|
9 | 136 |
|
137 |
iShDevices.ResetAndDestroy(); |
|
138 |
||
139 |
if ( iRouterService ) |
|
140 |
{ |
|
141 |
delete iRouterService; |
|
142 |
iRouterService = NULL; |
|
143 |
} |
|
144 |
||
145 |
if ( iShStateChangedDfc ) |
|
146 |
{ |
|
147 |
iShStateChangedDfc->Cancel(); |
|
148 |
delete iShStateChangedDfc; |
|
149 |
iShStateChangedDfc = NULL; |
|
150 |
} |
|
151 |
||
152 |
if( iRxQueue ) |
|
0 | 153 |
{ |
9 | 154 |
C_TRACE( ( _T( "DISICLTransceiver::ResetQueues 0x%x iRxQueue 0x%x" ), this, iRxQueue ) ); |
155 |
while( iRxQueue->Count() ) |
|
0 | 156 |
{ |
9 | 157 |
MemApi::DeallocBlock( iRxQueue->Get() ); |
0 | 158 |
} |
159 |
} |
|
9 | 160 |
|
161 |
if( iRxQueueDfc ) |
|
162 |
{ |
|
163 |
C_TRACE( ( _T( "DISIUserChannel::~DISIUserChannel 0x%x iRxQueueDfc 0x%x" ), this, iRxQueueDfc ) ); |
|
164 |
iRxQueueDfc->Cancel(); |
|
165 |
delete iRxQueueDfc; |
|
166 |
iRxQueueDfc = NULL; |
|
167 |
} |
|
168 |
||
0 | 169 |
C_TRACE( ( _T( "DISICLTransceiver::~DISICLTransceiver<" ) ) ); |
9 | 170 |
|
171 |
} |
|
172 |
||
173 |
TInt DISICLTransceiver::SendCommIsaEntityNotReachableResp( |
|
174 |
TDes8& aNotDeliveredMessage |
|
175 |
) |
|
176 |
{ |
|
177 |
C_TRACE( ( _T( "DISICLTransceiver::SendCommIsaEntityNotReachableResp 0x%x>" ), &aNotDeliveredMessage ) ); |
|
178 |
const TUint8* notDeliveredMsgPtr( aNotDeliveredMessage.Ptr() ); |
|
179 |
TInt error = KErrAlreadyExists; |
|
180 |
// Avoid COMM_ISA_ENTITY_NOT_REACHABLE_RESP loop. |
|
181 |
if( ( notDeliveredMsgPtr[ ISI_HEADER_OFFSET_MESSAGEID ] == COMMON_MESSAGE ) && |
|
182 |
( ( notDeliveredMsgPtr[ ISI_HEADER_OFFSET_SUBMESSAGEID ] == COMM_ISA_ENTITY_NOT_REACHABLE_RESP ) || |
|
183 |
( notDeliveredMsgPtr[ ISI_HEADER_OFFSET_SUBMESSAGEID ] == COMM_SERVICE_NOT_IDENTIFIED_RESP ) ) ) |
|
184 |
{ |
|
185 |
C_TRACE( ( _T( "DISICLTransceiver Not sending another CommIsaEntityNotReachableResp 0x%x 0x%x" ), &aNotDeliveredMessage, notDeliveredMsgPtr[ ISI_HEADER_OFFSET_SUBMESSAGEID ] ) ); |
|
186 |
} |
|
187 |
else |
|
188 |
{ |
|
189 |
// Follows COMM specification: 000.031 |
|
190 |
TUint8 length( ISI_HEADER_SIZE + SIZE_COMMON_MESSAGE_COMM_ISA_ENTITY_NOT_REACHABLE_RESP ); |
|
191 |
TDes8& respMsg = MemApi::AllocBlock( length ); |
|
192 |
ASSERT_RESET_ALWAYS( length > ISI_HEADER_OFFSET_MESSAGEID, ( EISICLTransceiverOverTheLimits | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
193 |
TUint8* respMsgPtr = const_cast<TUint8*>( respMsg.Ptr() ); |
|
194 |
// We start to append from transaction id. |
|
195 |
respMsg.SetLength( ISI_HEADER_OFFSET_TRANSID ); |
|
196 |
// Get the header until messageid from prev. message. |
|
197 |
// Just turn receiver and sender device and object vice versa. |
|
198 |
respMsgPtr[ ISI_HEADER_OFFSET_MEDIA ] = notDeliveredMsgPtr[ ISI_HEADER_OFFSET_MEDIA ]; |
|
199 |
SET_RECEIVER_DEV( respMsgPtr, GET_SENDER_DEV( aNotDeliveredMessage ) ); |
|
200 |
SET_SENDER_DEV ( respMsgPtr, GET_RECEIVER_DEV( aNotDeliveredMessage ) ); |
|
201 |
respMsgPtr[ ISI_HEADER_OFFSET_RESOURCEID ] = notDeliveredMsgPtr[ ISI_HEADER_OFFSET_RESOURCEID ]; |
|
202 |
SET_LENGTH( respMsgPtr, ( length - PN_HEADER_SIZE ) ); |
|
203 |
SET_RECEIVER_OBJ( respMsgPtr, GET_SENDER_OBJ( aNotDeliveredMessage ) ); |
|
204 |
SET_SENDER_OBJ( respMsgPtr, GET_RECEIVER_OBJ( aNotDeliveredMessage ) ); |
|
205 |
// Set from undelivered message |
|
206 |
respMsg.Append( notDeliveredMsgPtr[ ISI_HEADER_OFFSET_TRANSID ] ); |
|
207 |
// Message Identifier |
|
208 |
respMsg.Append( COMMON_MESSAGE ); |
|
209 |
// Sub message Identifier. |
|
210 |
respMsg.Append( COMM_ISA_ENTITY_NOT_REACHABLE_RESP ); |
|
211 |
// Not Delivered Message from original message. |
|
212 |
respMsg.Append( notDeliveredMsgPtr[ ISI_HEADER_OFFSET_MESSAGEID ] ); |
|
213 |
// Status |
|
214 |
respMsg.Append( COMM_ISA_ENTITY_NOT_AVAILABLE );// different status in a case of device not existing |
|
215 |
// Filler |
|
216 |
const TUint8 KFiller( 0x00 ); |
|
217 |
respMsg.Append( KFiller ); |
|
218 |
// Filler |
|
219 |
respMsg.Append( KFiller ); |
|
220 |
// Filler |
|
221 |
respMsg.Append( KFiller ); |
|
222 |
error = RouteISIMessage( respMsg, EFalse ); |
|
223 |
// Programming error in this function if below assert is raised |
|
224 |
ASSERT_RESET_ALWAYS( KErrNone == error, ( EISICLTransceiverCommIsaEntityNotReachableResp | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
225 |
} |
|
226 |
MemApi::DeallocBlock( aNotDeliveredMessage ); |
|
227 |
C_TRACE( ( _T( "DISICLTransceiver::SendCommIsaEntityNotReachableResp 0x%x<" ), &aNotDeliveredMessage ) ); |
|
228 |
return error; |
|
229 |
||
0 | 230 |
} |
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
231 |
|
9 | 232 |
// This is called in 1...N thread contextes |
233 |
void DISICLTransceiver::ReceiveISIMessage( |
|
234 |
const TDesC8& aMessage, |
|
235 |
const TUint8 aTrxId |
|
236 |
) |
|
0 | 237 |
{ |
9 | 238 |
C_TRACE( ( _T( "DISICLTransceiver::ReceiveMsg 0x%x 0x%x 0x%x>" ), this, &aMessage, aTrxId ) ); |
239 |
// Can only be called from thread context. |
|
240 |
ASSERT_THREAD_CONTEXT_ALWAYS( ( EISICLTransceiverNotThreadContext | EDISIUserChannelTraceId << KClassIdentifierShift ) ); |
|
241 |
||
242 |
TUint8 txDevId = GET_SENDER_DEV( aMessage.Ptr() ); |
|
243 |
if ( DynamicDevice( txDevId ) ) |
|
244 |
{ |
|
245 |
TUint8 staticDevId(0); |
|
246 |
const TInt count( iShDevices.Count() ); |
|
247 |
TInt index(0); |
|
248 |
TBool staticDeviceFound(EFalse); |
|
249 |
MISIRouterLinkIf* Link = NULL; |
|
250 |
while( !staticDeviceFound && ( index < count ) ) |
|
251 |
{ |
|
252 |
C_TRACE( ( _T( "DISICLTransceiver::ReceiveMsg find static device for trx 0x%x index %d" ), aTrxId, index ) ); |
|
253 |
DISIDevice* tmpDevice = iShDevices[ index ]; |
|
254 |
ASSERT_RESET_ALWAYS( tmpDevice, ( EISICLTransceiverNULLPtr4 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
255 |
tmpDevice->LockDeviceFM(); |
|
256 |
Link = tmpDevice->GetLink(); |
|
257 |
if( Link->GetTrxId() == aTrxId ) |
|
258 |
{ |
|
259 |
staticDevId = tmpDevice->GetDeviceIdentifier(); |
|
260 |
tmpDevice->FreeDeviceFM(); |
|
261 |
C_TRACE( ( _T( "DISICLTransceiver::ReceiveMsg static device 0x%x trx 0x%x" ), this, &aMessage, aTrxId ) ); |
|
262 |
staticDeviceFound = ETrue; |
|
263 |
} |
|
264 |
else |
|
265 |
{ |
|
266 |
tmpDevice->FreeDeviceFM(); |
|
267 |
} |
|
268 |
index++; |
|
269 |
} |
|
270 |
#ifdef USE_MEDIAAPI |
|
271 |
if ( PN_DEV_PC == GET_SENDER_DEV( aMessage.Ptr() )) |
|
272 |
{ |
|
273 |
C_TRACE( ( _T( "DISICLTransceiver::ReceiveMsg 0x%x 0x%x trx id = %d<" ), this, &aMessage, (Link->GetTrxId()) ) ); |
|
274 |
iDevPcLastActiveTrxId = iDevPcLastSendTrxId; |
|
275 |
iDevPcLastSendTrxId = Link->GetTrxId(); |
|
276 |
} |
|
277 |
#endif /* USE_MEDIAAPI */ |
|
278 |
UpdateDynamicDeviceTable( txDevId, staticDevId ); |
|
279 |
} |
|
280 |
// else static device. No need to save trxId |
|
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
281 |
|
9 | 282 |
iRxQueue->Add( aMessage ); |
283 |
iRxQueueDfc->Enque(); |
|
284 |
C_TRACE( ( _T( "DISICLTransceiver::ReceiveMsg 0x%x 0x%x 0x%x<" ), this, &aMessage, aTrxId ) ); |
|
285 |
} |
|
286 |
||
287 |
void DISICLTransceiver::RxQueueDfc( |
|
288 |
TAny* aPtr // Pointer to this object. |
|
289 |
) |
|
290 |
{ |
|
291 |
C_TRACE( ( _T( "DISICLTransceiver::RxQueueDfc ->" ) ) ); |
|
292 |
||
293 |
DISICLTransceiver& tmp = *reinterpret_cast<DISICLTransceiver*>( aPtr ); |
|
294 |
if( tmp.iRxQueue->Count() > 0 ) |
|
295 |
{ |
|
296 |
TDes8& msg( tmp.iRxQueue->Get() ); |
|
297 |
||
298 |
tmp.RouteISIMessage( msg, EFalse ); |
|
299 |
// Check here too to avoid unnecessary dfc queuing. |
|
300 |
if( tmp.iRxQueue->Count() > 0 ) |
|
301 |
{ |
|
302 |
C_TRACE( ( _T( "DISICLTransceiver::RxQueueDfc enque RxQueueDfc" ) ) ); |
|
303 |
tmp.iRxQueueDfc->Enque(); |
|
304 |
} |
|
305 |
} |
|
306 |
C_TRACE( ( _T( "DISICLTransceiver::RxQueueDfc <-" ) ) ); |
|
307 |
} |
|
308 |
||
309 |
||
310 |
TInt DISICLTransceiver::RouteISIMessage( |
|
311 |
TDes8& aMessage, |
|
312 |
TBool aDynamicSenderCheckNeeded |
|
313 |
) |
|
314 |
{ |
|
315 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage 0x%x 0x%x> len %d" ), &aMessage, aDynamicSenderCheckNeeded, aMessage.Length() ) ); |
|
316 |
const TUint8* msgPtr = aMessage.Ptr(); |
|
317 |
ISIMESSAGE_TRACE( aMessage ); |
|
318 |
TInt error( ValidateISIMessage( aMessage ) ); |
|
319 |
if( KErrNone != error ) |
|
320 |
{ |
|
321 |
TRACE_ASSERT_ALWAYS; |
|
322 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage invalid message 0x%x" ), &aMessage ) ); |
|
323 |
MemApi::DeallocBlock( aMessage ); |
|
324 |
} |
|
325 |
else |
|
0 | 326 |
{ |
9 | 327 |
TBool sendOk( EFalse ); |
328 |
if ( aDynamicSenderCheckNeeded )// Save dynamic device ids from PN_DEV_OWN |
|
329 |
{ |
|
330 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage from ISI Router" ) ) ); |
|
331 |
TUint8 txDeviceIdentifier = GET_SENDER_DEV( aMessage ); |
|
332 |
if ( DynamicDevice( txDeviceIdentifier ) ) |
|
333 |
{ |
|
334 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage from ISI Router Dynamic Dev" ) ) ); |
|
335 |
UpdateDynamicDeviceTable( txDeviceIdentifier, PN_DEV_OWN ); |
|
336 |
#ifndef USE_MEDIAAPI |
|
337 |
ASSERT_RESET_ALWAYS( txDeviceIdentifier == PN_DEV_PC, 0xdeaddead );// only supported PN_DEV_PC with EIscNokiaUsbPhonetLink |
|
338 |
#endif /* USE_MEDIAAPI */ |
|
339 |
} |
|
340 |
} |
|
341 |
||
342 |
TUint8 rxDeviceIdentifier = GET_RECEIVER_DEV( aMessage ); |
|
343 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage rxDeviceIdentifier 0x%x" ), rxDeviceIdentifier ) ); |
|
344 |
||
345 |
if ( DynamicDevice( rxDeviceIdentifier ) ) |
|
346 |
{ |
|
347 |
DynamicToStaticDevice( rxDeviceIdentifier ); |
|
348 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage rxDeviceIdentifier after 0x%x" ), rxDeviceIdentifier ) ); |
|
349 |
} |
|
350 |
||
351 |
||
352 |
if( rxDeviceIdentifier == PN_DEV_OWN ) |
|
353 |
{ |
|
354 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage PN_DEV_OWN 0x%x" ), &aMessage ) ); |
|
355 |
TUint16 objId(0xffff); |
|
356 |
#ifndef USE_MEDIAAPI |
|
357 |
if ( GET_RECEIVER_DEV( aMessage ) == PN_DEV_PC ) |
|
358 |
{ |
|
359 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage to PN_DEV_PC in PN_DEV_OWN" )) ); |
|
360 |
objId = EIscNokiaUsbPhonetLink; |
|
361 |
} |
|
362 |
else |
|
363 |
{ |
|
364 |
objId = GET_RECEIVER_OBJ( aMessage ); |
|
365 |
} |
|
366 |
#endif /* USE_MEDIAAPI */ |
|
367 |
#ifdef USE_MEDIAAPI |
|
368 |
objId = GET_RECEIVER_OBJ( aMessage ); |
|
369 |
#endif /* USE_MEDIAAPI */ |
|
370 |
sendOk = iShRouter.Receive( aMessage, objId ); |
|
371 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage PN_DEV_OWN 0x%x ok %d" ), &aMessage, sendOk ) ); |
|
372 |
} |
|
373 |
else |
|
374 |
{ |
|
375 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage Not PN_DEV_OWN 0x%x" ), &aMessage ) ); |
|
376 |
MISIRouterLinkIf* link = NULL; |
|
377 |
||
378 |
||
379 |
const TInt count( iShDevices.Count() ); |
|
380 |
for( TInt index( 0 ); index < count; index++ ) |
|
381 |
{ |
|
382 |
DISIDevice* tmpDevice = iShDevices[ index ]; |
|
383 |
ASSERT_RESET_ALWAYS( tmpDevice, ( EISICLTransceiverNULLPtr4 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
384 |
tmpDevice->LockDeviceFM(); |
|
385 |
if( tmpDevice->GetDeviceIdentifier() == rxDeviceIdentifier ) |
|
386 |
{ |
|
387 |
link = tmpDevice->GetLink(); |
|
388 |
tmpDevice->FreeDeviceFM(); |
|
389 |
#ifndef USE_MEDIAAPI |
|
390 |
sendOk = link->Send( aMessage ); |
|
391 |
break; |
|
392 |
#endif /* USE_MEDIAAPI */ |
|
393 |
#ifdef USE_MEDIAAPI |
|
394 |
if ( GET_RECEIVER_DEV( aMessage ) == PN_DEV_PC ) |
|
395 |
{ |
|
396 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage PN_DEV_PC %d, %d" ), link->GetTrxId(), iDevPcLastSendTrxId ) ); |
|
397 |
if(iDevPcLastSendTrxId < EAmountOfTrxs) |
|
398 |
{ |
|
399 |
if ( link->GetTrxId() == iDevPcLastSendTrxId ) |
|
400 |
{ |
|
401 |
if (link->StateConnected()) |
|
402 |
{ |
|
403 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage PN_DEV_PC %d, Msg mediaid 0x%x" ), link->GetTrxId(), msgPtr[ ISI_HEADER_OFFSET_MEDIA ] ) ); |
|
404 |
sendOk = link->Send( aMessage ); |
|
405 |
break; |
|
406 |
} |
|
407 |
} |
|
408 |
} |
|
409 |
else |
|
410 |
{ |
|
411 |
break; |
|
412 |
} |
|
413 |
} |
|
414 |
else |
|
415 |
{ |
|
416 |
sendOk = link->Send( aMessage ); |
|
417 |
break; |
|
418 |
} |
|
419 |
#endif /* USE_MEDIAAPI */ |
|
420 |
} |
|
421 |
else |
|
422 |
{ |
|
423 |
tmpDevice->FreeDeviceFM(); |
|
424 |
} |
|
425 |
} |
|
426 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage Not PN_DEV_OWN ok %d" ), &aMessage, sendOk ) ); |
|
427 |
} |
|
428 |
if( !sendOk ) |
|
429 |
{ |
|
430 |
TRACE_ASSERT_ALWAYS; |
|
431 |
error = SendCommIsaEntityNotReachableResp( aMessage ); |
|
432 |
} |
|
433 |
} |
|
434 |
C_TRACE( ( _T( "DISICLTransceiver::RouteISIMessage 0x%x<" ), &aMessage ) ); |
|
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
435 |
return error; |
0 | 436 |
} |
437 |
||
9 | 438 |
void DISICLTransceiver::GetDeviceConnectionStates( |
439 |
RArray<TUint8>& aDeviceIdentifierList, |
|
440 |
const TBool aConnectedDevice |
|
441 |
) |
|
0 | 442 |
{ |
9 | 443 |
C_TRACE( ( _T( "DISICLTransceiver::GetDeviceConnectionStates 0x%x 0x%x>" ), &aDeviceIdentifierList, aConnectedDevice ) ); |
444 |
||
445 |
const TInt count( iShDevices.Count() ); |
|
446 |
for( TInt index( 0 ); index < count; index++ ) |
|
0 | 447 |
{ |
9 | 448 |
DISIDevice* tmpDevice = iShDevices[ index ]; |
449 |
ASSERT_RESET_ALWAYS( tmpDevice, ( EISICLTransceiverNULLPtr3 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
450 |
tmpDevice->LockDeviceFM(); |
|
451 |
if( tmpDevice->GetDeviceState() == aConnectedDevice ) |
|
452 |
{ |
|
453 |
const TUint8 deviceIdentifier( tmpDevice->GetDeviceIdentifier() ); |
|
454 |
tmpDevice->FreeDeviceFM(); |
|
455 |
aDeviceIdentifierList.Append( deviceIdentifier ); |
|
456 |
} |
|
457 |
else |
|
458 |
{ |
|
459 |
tmpDevice->FreeDeviceFM(); |
|
460 |
} |
|
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
461 |
} |
9 | 462 |
C_TRACE( ( _T( "DISICLTransceiver::GetDeviceConnectionStates 0x%x 0x%x<" ), &aDeviceIdentifierList, aConnectedDevice ) ); |
0 | 463 |
} |
464 |
||
465 |
// KErrBadDescriptor, if message length too small |
|
466 |
// KErrUnderFlow, if message length too big. |
|
467 |
// KErrCouldNotConnect, if receiver object is out of scope. |
|
468 |
TInt DISICLTransceiver::ValidateISIMessage( |
|
469 |
TDes8& aMessage |
|
470 |
) |
|
471 |
{ |
|
9 | 472 |
|
0 | 473 |
C_TRACE( ( _T( "DISICLTransceiver::ValidateISIMessage 0x%x>" ), &aMessage ) ); |
474 |
const TUint16 descLength( aMessage.Length() ); |
|
475 |
TInt msgOk( KErrNone ); |
|
476 |
msgOk = ( ISI_HEADER_OFFSET_MESSAGEID >= descLength ) ? KErrBadDescriptor : msgOk; |
|
477 |
TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk ); |
|
478 |
// Get ISI message length after known that the descriptor is big enough. |
|
479 |
const TUint8* msgPtr( aMessage.Ptr() ); |
|
480 |
const TUint16 isiMsgLength( GET_LENGTH( msgPtr ) + PN_HEADER_SIZE ); |
|
481 |
// If the descriptor length is less than ISI message length. |
|
482 |
msgOk = ( ( msgOk == KErrNone && isiMsgLength > descLength ) ? KErrUnderflow : msgOk ); |
|
483 |
TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk ); |
|
484 |
// If the ISI message length is bigger that the largest supported. |
|
485 |
msgOk = ( ( msgOk == KErrNone && isiMsgLength > KMaxISIMsgSize ) ? KErrUnderflow : msgOk ); |
|
486 |
TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk ); |
|
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
487 |
// If the ISI message length with PN_HEADER_SIZE is less or equal than ISI_HEADER_OFFSET_MESSAGEID. |
0 | 488 |
msgOk = ( ( msgOk == KErrNone && isiMsgLength <= ISI_HEADER_OFFSET_MESSAGEID ) ? KErrUnderflow : msgOk ); |
489 |
TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk ); |
|
490 |
TRACE_ASSERT_INFO( msgOk == KErrNone, isiMsgLength ); |
|
491 |
TRACE_ASSERT_INFO( msgOk == KErrNone, descLength ); |
|
492 |
C_TRACE( ( _T( "DISICLTransceiver::ValidateISIMessage %d<" ), msgOk ) ); |
|
493 |
return msgOk; |
|
494 |
} |
|
495 |
||
9 | 496 |
// NOTE!! Called with FM held. Not allowed to block or nothing. Not even print traces! |
497 |
// Called in N Thread context |
|
498 |
void DISICLTransceiver::StateChanged( |
|
499 |
// None |
|
500 |
) |
|
501 |
{ |
|
502 |
||
503 |
iShStateChangedDfc->Enque(); |
|
504 |
||
505 |
} |
|
506 |
||
507 |
void DISICLTransceiver::StateChangedDfc( |
|
508 |
TAny* aPtr |
|
509 |
) |
|
510 |
{ |
|
511 |
C_TRACE( ( _T( "DISICLTransceiver::StateChangedDfc>" ) ) ); |
|
512 |
DISICLTransceiver* self = reinterpret_cast<DISICLTransceiver*>( aPtr ); |
|
513 |
ASSERT_RESET_ALWAYS( self, ( EISICLTransceiverNULLPtr5 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
514 |
self->ReadStateChanges(); |
|
515 |
C_TRACE( ( _T( "DISICLTransceiver::StateChangedDfc<" ) ) ); |
|
516 |
} |
|
517 |
||
518 |
void DISICLTransceiver::ReadStateChanges( |
|
519 |
// None |
|
0 | 520 |
) |
521 |
{ |
|
9 | 522 |
|
523 |
C_TRACE( ( _T( "DISICLTransceiver::ReadStateChanges>" ) ) ); |
|
524 |
||
525 |
const TInt count( iShDevices.Count() ); |
|
526 |
for( TInt index( 0 ); index < count; index++ ) |
|
0 | 527 |
{ |
9 | 528 |
DISIDevice* tmpDevice = iShDevices[ index ]; |
529 |
ASSERT_RESET_ALWAYS( tmpDevice, ( EISICLTransceiverNULLPtr6 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
530 |
tmpDevice->LockDeviceFM(); |
|
531 |
const TBool connected = tmpDevice->GetDeviceState();// tee paremmaksi |
|
532 |
||
533 |
#ifdef USE_MEDIAAPI |
|
534 |
MISIRouterLinkIf* link = NULL; |
|
535 |
link = tmpDevice->GetLink(); |
|
536 |
#endif /* USE_MEDIAAPI */ |
|
537 |
if( connected != tmpDevice->GetDeviceOldState() ) |
|
0 | 538 |
{ |
9 | 539 |
tmpDevice->SetDeviceOldState( connected ); |
540 |
const TUint8 deviceIdentifier = tmpDevice->GetDeviceIdentifier(); |
|
541 |
tmpDevice->FreeDeviceFM(); |
|
542 |
#ifdef USE_MEDIAAPI |
|
543 |
C_TRACE( ( _T( "DISICLTransceiver::ReadStateChanges trxid 0x%x state changed>" ),link->GetTrxId() ) ); |
|
544 |
if( (link->GetTrxId() == iDevPcLastSendTrxId) && (!connected) ) |
|
545 |
{ |
|
546 |
C_TRACE( ( _T( "DISICLTransceiver::ReadStateChanges trxid 0x%x disconneted>" ),link->GetTrxId() ) ); |
|
547 |
iDevPcLastSendTrxId = iDevPcLastActiveTrxId; |
|
548 |
iDevPcLastActiveTrxId = EAmountOfTrxs; //put a maxvalue |
|
549 |
} |
|
550 |
#endif /* USE_MEDIAAPI */ |
|
551 |
iRouterService->SendDeviceConnectionStateChangedInd( connected, deviceIdentifier ); |
|
552 |
} |
|
553 |
else |
|
554 |
{ |
|
555 |
tmpDevice->FreeDeviceFM(); |
|
556 |
} |
|
557 |
} |
|
558 |
C_TRACE( ( _T( "DISICLTransceiver::ReadStateChanges<" ) ) ); |
|
559 |
} |
|
560 |
||
561 |
TBool DISICLTransceiver::DynamicDevice( const TUint8 aDevId ) |
|
562 |
{ |
|
563 |
C_TRACE( ( _T( "DISICLTransceiver::DynamicDevice 0x%x>" ), aDevId ) ); |
|
564 |
TBool dynamicDevice(EFalse); |
|
565 |
switch( aDevId ) |
|
566 |
{ |
|
567 |
case PN_DEV_MODEM: |
|
568 |
case PN_DEV_DUMMYIST: |
|
569 |
case PN_DEV_OWN: |
|
570 |
{ |
|
571 |
//already set as EFalse |
|
0 | 572 |
break; |
573 |
} |
|
574 |
default: |
|
575 |
{ |
|
9 | 576 |
dynamicDevice = ETrue; |
0 | 577 |
break; |
578 |
} |
|
579 |
} |
|
9 | 580 |
C_TRACE( ( _T( "DISICLTransceiver::DynamicDevice 0x%x<" ), dynamicDevice ) ); |
581 |
return dynamicDevice; |
|
582 |
} |
|
583 |
||
584 |
void DISICLTransceiver::UpdateDynamicDeviceTable( const TUint8 aDynamicDevId, const TUint8 aStaticDevId ) |
|
585 |
{ |
|
586 |
C_TRACE( ( _T( "DISICLTransceiver::UpdateDynamicDeviceTable 0x%x 0x%x>" ), aDynamicDevId, aStaticDevId) ); |
|
587 |
TBool deviceExist(EFalse); |
|
588 |
TInt count(iDynamicDeviceTable.Count()); |
|
589 |
TInt err( Kern::MutexWait( *iDynamicDeviceTableMutex ) ); |
|
590 |
ASSERT_RESET_ALWAYS( ( err == KErrNone ), ( EISICLTransceiverMutexWaitFailed2 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
591 |
for( TUint8 i = 0; i < count; i++ ) |
|
592 |
{ |
|
593 |
C_TRACE( ( _T( "DISICLTransceiver::UpdateDynamicDeviceTable find dynamic device %d" ), i) ); |
|
594 |
if( iDynamicDeviceTable[ i ]->iDynamicDevId == aDynamicDevId ) |
|
595 |
{ |
|
596 |
C_TRACE( ( _T( "DISICLTransceiver::UpdateDynamicDeviceTable dyn dev exist i = %d aDynamicDevId 0x%x staticDevId 0x%x previous 0x%x" ), i, iDynamicDeviceTable[ i ]->iDynamicDevId, aStaticDevId, iDynamicDeviceTable[ i ]->iStaticDevId ) ); |
|
597 |
iDynamicDeviceTable[ i ]->iStaticDevId = aStaticDevId; |
|
598 |
deviceExist = ETrue; |
|
599 |
break; |
|
600 |
} |
|
601 |
} |
|
602 |
||
603 |
if ( !deviceExist ) |
|
604 |
{ |
|
605 |
C_TRACE( ( _T( "DISICLTransceiver::UpdateDynamicDeviceTable new dynamic device added 0x%x 0x%x" ), aDynamicDevId, aStaticDevId ) ); |
|
606 |
iDynamicDeviceTable.Append( new TDynamicDevice( aDynamicDevId, aStaticDevId ) ); |
|
607 |
} |
|
608 |
Kern::MutexSignal( *iDynamicDeviceTableMutex ); |
|
609 |
C_TRACE( ( _T( "DISICLTransceiver::UpdateDynamicDeviceTable 0x%x 0x%x<" ), aDynamicDevId, aStaticDevId) ); |
|
0 | 610 |
} |
611 |
||
9 | 612 |
void DISICLTransceiver::DynamicToStaticDevice( TUint8& aRxDev ) |
613 |
{ |
|
614 |
C_TRACE( ( _T( "DISICLTransceiver::DynamicToStaticDevice aRxDev>" ), &aRxDev ) ); |
|
615 |
TInt err( Kern::MutexWait( *iDynamicDeviceTableMutex ) ); |
|
616 |
ASSERT_RESET_ALWAYS( ( err == KErrNone ), ( EISICLTransceiverMutexWaitFailed | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
617 |
for( TUint8 i = 0; i < iDynamicDeviceTable.Count(); i++ ) |
|
618 |
{ |
|
619 |
if( iDynamicDeviceTable[ i ]->iDynamicDevId == aRxDev ) |
|
620 |
{ |
|
621 |
C_TRACE( ( _T( "DISICLTransceiver::DynamicToStaticDevice dyn dev exist i = %d iDynamicDevId 0x%x iStaticDevId 0x%x" ), i, iDynamicDeviceTable[ i ]->iDynamicDevId, iDynamicDeviceTable[ i ]->iStaticDevId) ); |
|
622 |
aRxDev = iDynamicDeviceTable[ i ]->iStaticDevId; |
|
623 |
break; |
|
624 |
} |
|
625 |
} |
|
626 |
Kern::MutexSignal( *iDynamicDeviceTableMutex ); |
|
627 |
C_TRACE( ( _T( "DISICLTransceiver::DynamicToStaticDevice aRxDev<" ), &aRxDev ) ); |
|
628 |
} |
|
629 |
||
630 |
||
631 |
DISICLTransceiver::DISIDevice::DISIDevice( |
|
632 |
const TUint8 aDeviceIdentifier, |
|
633 |
MISIRouterLinkIf* aLink |
|
634 |
) |
|
635 |
{ |
|
636 |
C_TRACE( ( _T( "DISICLTransceiver::DISIDevice::DISIDevice 0x%x 0x%x 0x%x>" ), aDeviceIdentifier, aLink ) ); |
|
637 |
iShDeviceIdentifier = aDeviceIdentifier; |
|
638 |
iShOldDeviceConnectedState = EFalse; |
|
639 |
ASSERT_RESET_ALWAYS( aLink, ( EISICLTransceiverNULLPtr2 | EDISICLTransceiverTraceId << KClassIdentifierShift ) ); |
|
640 |
iShLink = aLink; |
|
641 |
iShDeviceMutex = new NFastMutex(); |
|
642 |
ASSERT_RESET_ALWAYS( iShDeviceMutex, EISICLTransceiverNULLPtr6 | EDISICLTransceiverTraceId << KClassIdentifierShift ); |
|
643 |
C_TRACE( ( _T( "DISICLTransceiver::DISIDevice::DISIDevice<" ) ) ); |
|
644 |
} |
|
645 |
||
646 |
DISICLTransceiver::DISIDevice::~DISIDevice() |
|
647 |
{ |
|
648 |
C_TRACE( ( _T( "DISICLTransceiver::DISIDevice::~DISIDevice>" ) ) ); |
|
649 |
iShLink->Release(); |
|
650 |
iShLink = NULL; |
|
651 |
// If not exists faulted already. |
|
652 |
delete iShDeviceMutex; |
|
653 |
iShDeviceMutex = NULL; |
|
654 |
C_TRACE( ( _T( "DISICLTransceiver::DISIDevice::~DISIDevice<" ) ) ); |
|
655 |
} |
|
656 |
||
657 |
MISIRouterLinkIf* DISICLTransceiver::DISIDevice::GetLink() |
|
658 |
{ |
|
659 |
// C_TRACE( ( _T( "DISICLTransceiver::DISIDevice::GetLink<> 0x%x" ), iShLink ) ); |
|
660 |
return iShLink; |
|
661 |
} |
|
662 |
||
663 |
TUint8 DISICLTransceiver::DISIDevice::GetDeviceIdentifier() |
|
664 |
{ |
|
665 |
// C_TRACE( ( _T( "DISICLTransceiver::DISIDevice::GetDeviceIdentifier<> 0x%x" ), iShDeviceIdentifier ) ); |
|
666 |
return iShDeviceIdentifier; |
|
667 |
} |
|
668 |
||
669 |
TBool DISICLTransceiver::DISIDevice::GetDeviceState() |
|
670 |
{ |
|
671 |
// C_TRACE( ( _T( "DISICLTransceiver::DISIDevice::GetDeviceState<>" ) ) ); |
|
672 |
return iShLink->StateConnected(); |
|
673 |
} |
|
674 |
||
675 |
TBool DISICLTransceiver::DISIDevice::GetDeviceOldState() |
|
676 |
{ |
|
677 |
// C_TRACE( ( _T( "DISICLTransceiver::DISIDevice::GetDeviceOldState<> 0x%x" ), iShOldDeviceConnectedState ) ); |
|
678 |
return iShOldDeviceConnectedState; |
|
679 |
} |
|
680 |
||
681 |
void DISICLTransceiver::DISIDevice::SetDeviceOldState( |
|
682 |
TBool aConnected |
|
683 |
) |
|
684 |
{ |
|
685 |
// C_TRACE( ( _T( "DISICLTransceiver::DISIDevice::SetDeviceOldState<> 0x%x 0x%x" ), iShOldDeviceConnectedState, aConnected ) ); |
|
686 |
iShOldDeviceConnectedState = aConnected; |
|
687 |
} |
|
688 |
||
689 |
void DISICLTransceiver::DISIDevice::LockDeviceFM( |
|
690 |
// None |
|
691 |
) |
|
692 |
{ |
|
693 |
C_TRACE( ( _T( "DISICLTransceiver::DISIDevice::LockDeviceFM<>" ) ) ); |
|
694 |
NKern::FMWait( iShDeviceMutex ); |
|
695 |
} |
|
696 |
||
697 |
void DISICLTransceiver::DISIDevice::FreeDeviceFM( |
|
698 |
// None |
|
699 |
) |
|
700 |
{ |
|
701 |
NKern::FMSignal( iShDeviceMutex ); |
|
702 |
C_TRACE( ( _T( "DISICLTransceiver::DISIDevice::FreeDeviceFM<>" ) ) ); |
|
703 |
} |