15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <kernel.h> // For Kern |
19 #include <kernel.h> // For Kern |
|
20 #include <phonetisi.h> // // For ISI_HEADER_OFFSET_MEDIA |
|
21 |
20 #include "isilink.h" // For DISILink |
22 #include "isilink.h" // For DISILink |
21 #include "iscedefs.h" // For EMuxISI... |
23 #include "iscedefs.h" // For EMuxISI... |
22 #include "mlinkmuxif.h" // For MLinkMuxIf |
24 #include "mlinkmuxif.h" // For MLinkMuxIf |
23 #include "isiroutertrace.h" // For C_TRACE, ASSERT_RESET.. and fault codes |
25 #include "isiroutertrace.h" // For C_TRACE, ASSERT_RESET.. and fault codes |
24 #include "misilinkrouterif.h" // For MISILinkRouterIf |
26 #include "misilinkrouterif.h" // For MISILinkRouterIf |
25 #include "isihelpers.h" // For ISI_HEADER_OFFSET_MEDIA |
|
26 |
|
27 |
27 |
28 // Faults |
28 // Faults |
29 enum TISILinkFaults |
29 enum TISILinkFaults |
30 { |
30 { |
31 EISILinkNullPtr = 0x01, |
31 EISILinkNullPtr = 0x01, |
42 MISILinkRouterIf* aRouter, |
42 MISILinkRouterIf* aRouter, |
43 const TUint8 aMediaId, |
43 const TUint8 aMediaId, |
44 const TUint8 aTrxId |
44 const TUint8 aTrxId |
45 ) |
45 ) |
46 { |
46 { |
47 C_TRACE( ( _T( "MISIRouterLinkIf::CreateLinkF 0x%x %d %d>" ), aRouter, aMediaId, aTrxId ) ); |
47 C_TRACE( ( _T( "MISIRouterLinkIf::CreateLinkF 0x%x 0x%x 0x%x>" ), aRouter, aMediaId, aTrxId ) ); |
48 ASSERT_RESET_ALWAYS( aRouter, ( EISILinkNullPtr | EDISILinkTraceId << KClassIdentifierShift ) ); |
48 ASSERT_RESET_ALWAYS( aRouter, ( EISILinkNullPtr | EDISILinkTraceId << KClassIdentifierShift ) ); |
49 DISILink* link = new DISILink( aRouter, aMediaId, aTrxId ); |
49 DISILink* link = new DISILink( aRouter, aMediaId, aTrxId ); |
50 ASSERT_RESET_ALWAYS( link, ( EISILinkMemAllocFailed | EDISILinkTraceId << KClassIdentifierShift ) ); |
50 ASSERT_RESET_ALWAYS( link, ( EISILinkMemAllocFailed | EDISILinkTraceId << KClassIdentifierShift ) ); |
51 C_TRACE( ( _T( "MISIRouterLinkIf::CreateLinkF 0x%x %d %d created 0x%x<" ), aRouter, aMediaId, aTrxId, link ) ); |
51 C_TRACE( ( _T( "MISIRouterLinkIf::CreateLinkF 0x%x 0x%x 0x%x created 0x%x<" ), aRouter, aMediaId, aTrxId, link ) ); |
52 return link; |
52 return link; |
53 } |
53 } |
54 |
54 |
55 DISILink::DISILink( |
55 DISILink::DISILink( |
56 ) : iRouter( NULL ), |
56 ) : iRouter( NULL ), |
57 iMux( NULL ), |
57 iMux( NULL ), |
58 iTrxPresent( EFalse ) |
58 iTrxPresent( EFalse ) |
59 { |
59 { |
60 C_TRACE( ( _T( "DISILink::DISILink 0x%x>" ), this ) ); |
60 C_TRACE( ( _T( "DISILink::DISILink 0x%x>" ), this ) ); |
61 iMediaId = 0; // TODO change to PN_MEDIA_NOT_USED when bridge supports this |
61 iMediaId = 0; |
62 C_TRACE( ( _T( "DISILink::DISILink 0x%x<" ), this ) ); |
62 C_TRACE( ( _T( "DISILink::DISILink 0x%x<" ), this ) ); |
63 } |
63 } |
64 |
64 |
65 DISILink::DISILink( |
65 DISILink::DISILink( |
66 MISILinkRouterIf* aRouter, |
66 MISILinkRouterIf* aRouter, |
68 const TUint8 aTrxId |
68 const TUint8 aTrxId |
69 ) : iRouter( aRouter ), |
69 ) : iRouter( aRouter ), |
70 iMediaId( aMediaId ), |
70 iMediaId( aMediaId ), |
71 iTrxId( aTrxId ) |
71 iTrxId( aTrxId ) |
72 { |
72 { |
73 C_TRACE( ( _T( "DISILink::DISILink 0x%x mediaid %d trxid %d>" ), this, aMediaId, aTrxId ) ); |
73 C_TRACE( ( _T( "DISILink::DISILink 0x%x mediaid 0x%x trxid 0x%x>" ), this, aMediaId, aTrxId ) ); |
74 // ISI Media |
74 // ISI Media |
75 iMux = MLinkMuxIf::Register( this, aTrxId, EMuxISI ); |
75 iMux = MLinkMuxIf::Register( this, aTrxId, EMuxISI ); |
76 ASSERT_RESET_ALWAYS( aRouter, ( EISILinkRegisterFailed | EDISILinkTraceId << KClassIdentifierShift ) ); |
76 ASSERT_RESET_ALWAYS( aRouter, ( EISILinkRegisterFailed | EDISILinkTraceId << KClassIdentifierShift ) ); |
77 C_TRACE( ( _T( "DISILink::DISILink 0x%x mediaid %d trxid %d<" ), this, iMediaId, iTrxId ) ); |
77 C_TRACE( ( _T( "DISILink::DISILink 0x%x mediaid 0x%x trxid 0x%x<" ), this, iMediaId, iTrxId ) ); |
78 } |
78 } |
79 |
79 |
80 DISILink::~DISILink() |
80 DISILink::~DISILink() |
81 { |
81 { |
82 C_TRACE( ( _T( "DISILink::~DISILink 0x%x>" ), this ) ); |
82 C_TRACE( ( _T( "DISILink::~DISILink 0x%x>" ), this ) ); |
91 ) |
91 ) |
92 { |
92 { |
93 C_TRACE( ( _T( "DISILink::Receive 0x%x 0x%x>" ), this, &aMsg ) ); |
93 C_TRACE( ( _T( "DISILink::Receive 0x%x 0x%x>" ), this, &aMsg ) ); |
94 ASSERT_RESET_ALWAYS( iMux, ( EISILinkInitFailed | EDISILinkTraceId << KClassIdentifierShift ) ); |
94 ASSERT_RESET_ALWAYS( iMux, ( EISILinkInitFailed | EDISILinkTraceId << KClassIdentifierShift ) ); |
95 ASSERT_RESET_ALWAYS( aMsg.Ptr()[ ISI_HEADER_OFFSET_MEDIA ] == iMediaId, ( EISILinkWrongMedia | aMsg.Ptr()[ 0 ] << KMediaIdShift | EDISILinkTraceId << KClassIdentifierShift ) ); |
95 ASSERT_RESET_ALWAYS( aMsg.Ptr()[ ISI_HEADER_OFFSET_MEDIA ] == iMediaId, ( EISILinkWrongMedia | aMsg.Ptr()[ 0 ] << KMediaIdShift | EDISILinkTraceId << KClassIdentifierShift ) ); |
96 iRouter->RouteISIMessage( aMsg ); |
96 iRouter->ReceiveISIMessage( aMsg, iTrxId ); |
97 C_TRACE( ( _T( "DISILink::Receive 0x%x 0x%x<" ), this, &aMsg ) ); |
97 C_TRACE( ( _T( "DISILink::Receive 0x%x 0x%x<" ), this, &aMsg ) ); |
98 } |
98 } |
99 |
99 |
100 /* |
100 /* |
101 * Called with FM held, no blocking no nesting of FMs and no allocation. |
101 * Called with FM held, no blocking no nesting of FMs and no allocation. |
105 ) |
105 ) |
106 { |
106 { |
107 // No traces allowed due to not allowed to block. |
107 // No traces allowed due to not allowed to block. |
108 ASSERT_RESET_ALWAYS( ( iTrxPresent != aPresent ), ( EISILinkTrxPresenceSyncFailed | EDISILinkTraceId << KClassIdentifierShift ) ); |
108 ASSERT_RESET_ALWAYS( ( iTrxPresent != aPresent ), ( EISILinkTrxPresenceSyncFailed | EDISILinkTraceId << KClassIdentifierShift ) ); |
109 iTrxPresent = aPresent; |
109 iTrxPresent = aPresent; |
|
110 iRouter->StateChanged(); |
110 } |
111 } |
111 // From MMuxLinkIf end |
112 // From MMuxLinkIf end |
112 |
113 |
113 // From MISIRouterLinkIf start |
114 // From MISIRouterLinkIf start |
114 void DISILink::Release( |
115 void DISILink::Release( |
122 |
123 |
123 TBool DISILink::Send( |
124 TBool DISILink::Send( |
124 TDes8& aMsg |
125 TDes8& aMsg |
125 ) |
126 ) |
126 { |
127 { |
127 C_TRACE( ( _T( "DISILink::Send 0x%x 0x%x>" ), this, &aMsg ) ); |
128 C_TRACE( ( _T( "DISILink::Send 0x%x 0x%x iMediaId 0x%x >" ), this, &aMsg, iMediaId ) ); |
128 ASSERT_RESET_ALWAYS( iMux, ( EISILinkInitFailed2 | EDISILinkTraceId << KClassIdentifierShift ) ); |
129 ASSERT_RESET_ALWAYS( iMux, ( EISILinkInitFailed2 | EDISILinkTraceId << KClassIdentifierShift ) ); |
129 if( iTrxPresent ) |
130 if( iTrxPresent ) |
130 { |
131 { |
131 TUint8* msgPtr = const_cast<TUint8*>( aMsg.Ptr() ); |
132 TUint8* msgPtr = const_cast<TUint8*>( aMsg.Ptr() ); |
132 msgPtr[ ISI_HEADER_OFFSET_MEDIA ] = iMediaId; |
133 msgPtr[ ISI_HEADER_OFFSET_MEDIA ] = iMediaId; |
133 // Send with default prio. |
134 // Send with default prio. |
134 iMux->Send( aMsg, EMuxISI ); |
135 iMux->Send( aMsg, EMuxISI ); |
135 C_TRACE( ( _T( "DISILink::Send ok 0x%x %d 0x%x<" ), this, iTrxPresent, &aMsg) ); |
136 C_TRACE( ( _T( "DISILink::Send ok 0x%x 0x%x 0x%x<" ), this, iTrxPresent, &aMsg) ); |
136 return ETrue; |
137 return ETrue; |
137 } |
138 } |
138 C_TRACE( ( _T( "DISILink::Send failed 0x%x %d 0x%x<" ), this, iTrxPresent, &aMsg) ); |
139 // No need for else, by default false |
|
140 C_TRACE( ( _T( "DISILink::Send failed 0x%x 0x%x 0x%x<" ), this, iTrxPresent, &aMsg) ); |
139 return EFalse; |
141 return EFalse; |
140 } |
142 } |
|
143 |
|
144 TUint8 DISILink::GetTrxId() |
|
145 { |
|
146 //C_TRACE( ( _T( "DISILink::GetTrxId return %d <>" ), this, iTrxId ) ); |
|
147 return iTrxId; |
|
148 |
|
149 } |
141 // From MISIRouterLinkIf end |
150 // From MISIRouterLinkIf end |