My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/**
* BlueCove - Java library for Bluetooth
* Copyright (C) 2006-2009 Vlad Skarzhevskyy
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @author vlads
* @version $Id$
*/
package net.sf.bluecove.se;

import java.io.IOException;

import org.bluecove.tester.log.Logger;

import net.sf.bluecove.Configuration;
import net.sf.bluecove.Consts;
import net.sf.bluecove.Switcher;
import net.sf.bluecove.TestResponderCommon;

/**
*
*/
public class Console {

public static void main(String[] args) {
JavaSECommon.initOnce();
Configuration.storage = new FileStorage();
help();

while (true) {
try {
String cmd = readCommand();
if (cmd == null) {
quit();
return;
}
if (cmd.length() == 0) {
help();
continue;
}
cmd = cmd.toUpperCase();
char user_input = cmd.charAt(0);
switch (user_input) {
case 'Q':
quit();
break;
case '\n':
case '?':
case 'H':
help();
break;
case '4':
UIHelper.printFailureLog();
break;
case '*':
Switcher.startDiscovery();
break;
case '7':
Switcher.startServicesSearch();
break;
case '2':
Switcher.startClient();
break;
case '3':
Switcher.clientShutdown();
break;
case '5':
Switcher.startServer();
break;
case '6':
if (cmd.equals("6C")) {
Switcher.closeServerClientConnections();
} else {
Switcher.serverShutdown();
}
break;
case 'P':
TestResponderCommon.printLocalDeviceInfo();
break;
case 'D':
boolean dbg = BlueCoveSpecific.changeDebug();
if (dbg) {
System.out.println("BlueCove Debug ON");
} else {
System.out.println("BlueCove Debug OFF");
}
break;
case 'T':
Switcher.startTCKAgent();
break;
case 'S':
if (cmd.equals("SRR")) {
//RFCOMM Read test
UIHelper.configurationForSpeedTest(Consts.TRAFFIC_GENERATOR_WRITE, false);
} else if (cmd.equals("SRW")) {
//RFCOMM Write test
UIHelper.configurationForSpeedTest(Consts.TRAFFIC_GENERATOR_READ, false);
} else if (cmd.equals("SLR")) {
//L2CAP Read test
UIHelper.configurationForSpeedTest(Consts.TRAFFIC_GENERATOR_WRITE, true);
} else if (cmd.equals("SLW")) {
//L2CAP Write test
UIHelper.configurationForSpeedTest(Consts.TRAFFIC_GENERATOR_READ, true);
} else {
System.out.println("Unknown speed test command '" + cmd + "'");
break;
}
Switcher.startClient();
break;
default :
System.out.println("Unknown command " + cmd);
}
} catch (Throwable e) {
System.out.println("Exception " + e.getMessage());
e.printStackTrace(System.out);
}
}
}

private static String readCommand() throws IOException {
StringBuffer buf = new StringBuffer();
int b;
do {
b = System.in.read();
if ((b == '\n') || (b == '\r')) {
return buf.toString();
}
buf.append((char)b);
} while (b != -1);
return null;

}

private static void help() {
System.out.println("BlueCove tester Console application (keyboard codes the same as in MIDP application)");
System.out.println("\t2 - Start Client");
System.out.println("\t3 - Stop Client");
System.out.println("\t5 - Start Server");
System.out.println("\t6 - Stop Server (6c - Server clients close)");
System.out.println("\t* - Run Discovery");
System.out.println("\t7 - Services Search");
System.out.println("\td - toggle BlueCove Debug");
System.out.println("\tT - Start TCK Agent");
System.out.println("\tP - Print LocalDevice Info");
System.out.println("\tSRR|SRW|SLR|SLW - Speed RFCOMM|L2CAP Read|Write tests");
System.out.println("\tq - Quit");
System.out.flush();
}

private static void quit() {
Logger.debug("quit");
Switcher.clientShutdown();
Switcher.serverShutdownOnExit();
System.exit(0);
}
}

Change log

r2916 by skarzhevskyy on Mar 13, 2009   Diff
Updated javadocs and Copyright
Go to: 
Project members, sign in to write a code review

Older revisions

r2796 by skarzhevskyy on Feb 24, 2009   Diff
Testing L2CAP receive
r2759 by skarzhevskyy on Feb 15, 2009   Diff
readCommand correction
r2758 by skarzhevskyy on Feb 15, 2009   Diff
readCommand correction
All revisions of this file

File info

Size: 6113 bytes, 172 lines

File properties

svn:mime-type
text/plain
svn:eol-style
native
svn:keywords
Date Author Id Revision
Powered by Google Project Hosting