}
add(_rtf);
// Closes the screen
final MenuItem closeSP =
new MenuItem(new StringProvider("Close serial port"), 0x230010,
0);
closeSP.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
close();
}
}));
// Displays the DTR line's state
final MenuItem dtr =
new MenuItem(new StringProvider("Get DTR"), 0x230020, 1);
dtr.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
try {
Status.show("DTR: " + _port.getDtr());
} catch (final IOException ioex) {
Status.show("");
BluetoothDemo
.errorDialog("BluetoothSerialPort#getDtr() threw "
+ ioex.toString());
}
}
}));
// Turns DSR on
final MenuItem dsrOn =
new MenuItem(new StringProvider("DSR on"), 0x230030, 2);
dsrOn.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
Status.show("DSR on");
try {
_port.setDsr(true);
} catch (final IOException ioex) {
Status.show("");
BluetoothDemo
.errorDialog("BluetoothSerialPort#setDsr(boolean) threw "
+ ioex.toString());
}
}
}));
// Turns DSR off
final MenuItem dsrOff =
new MenuItem(new StringProvider("DSR off"), 0x230040, 3);
dsrOff.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
Status.show("DSR off");
try {
_port.setDsr(false);
} catch (final IOException ioex) {
Status.show("");
BluetoothDemo
.errorDialog("BluetoothSerialPort#setDsr(boolean) threw "
+ ioex.toString());
}
}
}));
// Enables loop back
final MenuItem enableLoopback =
new MenuItem(new StringProvider("Enable loopback"), 0x230050, 4);
enableLoopback.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
_loopback = true;
}
}));
// Disables loop back
final MenuItem disableLoopback =
new MenuItem(new StringProvider("Disable loopback"), 0x230060,
5);
disableLoopback.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
_loopback = false;
}
}));
// Sends 1kb of information to the other device
final MenuItem send1k =
new MenuItem(new StringProvider("Send 1k"), 0x230070, 6);
send1k.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,