40
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: Echoer for AT commands
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "DunAtCmdEchoer.h"
|
|
19 |
#include "DunDownstream.h"
|
|
20 |
#include "DunDebug.h"
|
|
21 |
|
|
22 |
// ---------------------------------------------------------------------------
|
|
23 |
// Two-phased constructor.
|
|
24 |
// ---------------------------------------------------------------------------
|
|
25 |
//
|
|
26 |
CDunAtCmdEchoer* CDunAtCmdEchoer::NewL(
|
|
27 |
MDunStreamManipulator* aStreamCallback )
|
|
28 |
{
|
|
29 |
CDunAtCmdEchoer* self = new (ELeave) CDunAtCmdEchoer( aStreamCallback );
|
|
30 |
CleanupStack::PushL( self );
|
|
31 |
self->ConstructL();
|
|
32 |
CleanupStack::Pop( self );
|
|
33 |
return self;
|
|
34 |
}
|
|
35 |
|
|
36 |
// ---------------------------------------------------------------------------
|
|
37 |
// Destructor.
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CDunAtCmdEchoer::~CDunAtCmdEchoer()
|
|
41 |
{
|
|
42 |
FTRACE(FPrint( _L("CDunAtCmdEchoer::~CDunAtCmdEchoer()") ));
|
|
43 |
ResetData();
|
|
44 |
FTRACE(FPrint( _L("CDunAtCmdEchoer::~CDunAtCmdEchoer() complete") ));
|
|
45 |
}
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
// Resets data to initial values
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
void CDunAtCmdEchoer::ResetData()
|
|
52 |
{
|
|
53 |
FTRACE(FPrint( _L("CDunAtCmdEchoer::ResetData()") ));
|
|
54 |
// Internal
|
|
55 |
Initialize();
|
|
56 |
FTRACE(FPrint( _L("CDunAtCmdEchoer::ResetData() complete") ));
|
|
57 |
}
|
|
58 |
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
// Sends a character to be echoed
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
TInt CDunAtCmdEchoer::SendEchoCharacter(
|
|
64 |
const TDesC8* aInput,
|
|
65 |
MDunAtCmdEchoer* aCallback )
|
|
66 |
{
|
|
67 |
FTRACE(FPrint( _L("CDunAtCmdEchoer::SendEchoCharacter()") ));
|
|
68 |
if ( iAtEchoState!=EDunStateIdle || iCallback )
|
|
69 |
{
|
|
70 |
FTRACE(FPrint( _L("CDunAtCmdEchoer::SendEchoCharacter() (not ready) complete") ));
|
|
71 |
return KErrNotReady;
|
|
72 |
}
|
|
73 |
iStreamCallback->NotifyDataPushRequest( aInput, this );
|
|
74 |
iCallback = aCallback;
|
|
75 |
iAtEchoState = EDunStateAtCmdEchoing;
|
|
76 |
FTRACE(FPrint( _L("CDunDownstream::SendEchoCharacter() complete" ) ));
|
|
77 |
return KErrNone;
|
|
78 |
}
|
|
79 |
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
// CDunAtCmdEchoer::CDunAtCmdEchoer
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
CDunAtCmdEchoer::CDunAtCmdEchoer( MDunStreamManipulator* aStreamCallback ) :
|
|
85 |
iStreamCallback( aStreamCallback )
|
|
86 |
{
|
|
87 |
Initialize();
|
|
88 |
}
|
|
89 |
|
|
90 |
// ---------------------------------------------------------------------------
|
|
91 |
// CDunAtCmdEchoer::ConstructL
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
void CDunAtCmdEchoer::ConstructL()
|
|
95 |
{
|
|
96 |
FTRACE(FPrint( _L("CDunAtCmdEchoer::ConstructL()") ));
|
|
97 |
if ( !iStreamCallback )
|
|
98 |
{
|
|
99 |
FTRACE(FPrint( _L("CDunAtCmdEchoer::ConstructL() complete") ));
|
|
100 |
User::Leave( KErrGeneral );
|
|
101 |
}
|
|
102 |
FTRACE(FPrint( _L("CDunAtCmdEchoer::ConstructL() complete") ));
|
|
103 |
}
|
|
104 |
|
|
105 |
// ---------------------------------------------------------------------------
|
|
106 |
// Initializes this class
|
|
107 |
// ---------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
void CDunAtCmdEchoer::Initialize()
|
|
110 |
{
|
|
111 |
// Don't initialize iStreamCallback here (it is set through NewL)
|
|
112 |
iCallback = NULL;
|
|
113 |
iAtEchoState = EDunStateIdle;
|
|
114 |
}
|
|
115 |
|
|
116 |
// ---------------------------------------------------------------------------
|
|
117 |
// From MDunCompletionReporter.
|
|
118 |
// Gets called when data push is complete
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
void CDunAtCmdEchoer::NotifyDataPushComplete( TBool /*aAllPushed*/ )
|
|
122 |
{
|
|
123 |
FTRACE(FPrint( _L("CDunAtCmdEchoer::NotifyDataPushComplete()") ));
|
|
124 |
MDunAtCmdEchoer* callback = iCallback;
|
|
125 |
iCallback = NULL;
|
|
126 |
iAtEchoState = EDunStateIdle;
|
|
127 |
callback->NotifyEchoComplete();
|
|
128 |
FTRACE(FPrint( _L("CDunAtCmdEchoer::NotifyDataPushComplete() complete") ));
|
|
129 |
}
|