Methods Summary |
---|
public void | addConnection(java.lang.String address)Registers a new connection to a remote device.
PicoNode pico = (PicoNode)piconet.get(address);
if (pico == null) {
piconet.put(address, pico = new PicoNode());
}
pico.connections++;
|
public boolean | authenticate(java.lang.String address)Authenticates remote device.
PicoNode pico = (PicoNode)piconet.get(address);
if (pico == null) {
return false;
}
pico.authenticated = true;
return true;
|
public boolean | authorize(java.lang.String address, int handle)Authorizes a Bluetooth connection.
return true;
|
public boolean | bond(java.lang.String address, java.lang.String pin)Initiates pairing with a remote device.
return true;
|
public boolean | enableBluetooth()Enables Bluetooth radio and the Bluetooth protocol stack for use.
isBluetoothEnabled = true;
return true;
|
public boolean | encrypt(java.lang.String address, boolean enable)
return false;
|
public int | getAccessCode()
return accessCode;
|
public java.lang.String | getBluetoothAddress()Returns local Bluetooth address.
return com.sun.midp.jsr082.BluetoothUtils.getAddressString(
DeviceEmul.getLocalDeviceEmul().getAddress());
|
public int | getConnectionCount(java.lang.String address)Returns the number of connections to the remote device.
PicoNode pico = (PicoNode)piconet.get(address);
return pico != null ? pico.connections : 0;
|
public DeviceClass | getDeviceClass()
return deviceClass;
|
public java.lang.String | getFriendlyName()Returns user-friendly name for the local device.
return friendlyName;
|
public java.lang.String | getFriendlyName(java.lang.String address)Retrieves the user-friendly name for specified remote device.
return address;
|
private static boolean | getInternalBooleanProperty(java.lang.String key, boolean def)Gets the internal property indicated by the specified key
as an boolean
or returns the specified default value if property reading failed.
// Implicitly throw NPE if key is null
if (key.length() == 0) {
throw new IllegalArgumentException("Key cannot be empty");
}
boolean val = def;
String prop = Configuration.getProperty(key);
if (prop != null) {
if (prop.equalsIgnoreCase("true") ||
prop.equalsIgnoreCase("yes")) {
val = true;
} else if (prop.equalsIgnoreCase("false") ||
prop.equalsIgnoreCase("no")) {
val = false;
}
}
return val;
|
private static int | getInternalIntProperty(java.lang.String key, int radix, int def)Gets the internal property indicated by the specified key
as an int in the specified radix
or returns the specified default value if property reading failed.
// Implicitly throws NPE if key is null
if (key.length() == 0) {
throw new IllegalArgumentException("Key cannot be empty");
}
try {
String prop = Configuration.getProperty(key);
return Integer.parseInt(prop, radix);
} catch (NumberFormatException nfe) {
return def;
}
|
private static java.lang.String | getInternalStringProperty(java.lang.String key, java.lang.String def)Gets the internal property indicated by the specified key
as an String
or returns the specified default value if the property is not found.
// Implicitly throw NPE if key is null
if (key.length() == 0) {
throw new IllegalArgumentException("Key cannot be empty");
}
String prop = Configuration.getProperty(key);
return (prop != null) ? prop : def;
|
public java.lang.String | getPasskey(java.lang.String address)Retrieves PIN code to use for pairing with a remote device. If the
PIN code is not known, PIN entry dialog is displayed.
return passKey;
|
public java.util.Vector | getPreknownDevices()Returns list of preknown devices in a Vector.
return null;
|
public boolean | isAuthenticated(java.lang.String address)Checks if a remote device was authenticated.
return true;
|
public boolean | isBluetoothEnabled()Queries the power state of the Bluetooth device.
return isBluetoothEnabled;
|
public boolean | isConnectable()Checks if the local device is in connectable mode.
return true;
|
public boolean | isEncrypted(java.lang.String address)Checks if connections to a remote are encrypted.
return true;
|
public boolean | isPaired(java.lang.String address)Checks if the local device has a bond with a remote device.
return true;
|
public boolean | isTrusted(java.lang.String address)Checks if a remote device is trusted (authorized for all services).
return true;
|
private void | loadPropertyValues()Extracts initial configuration values from properties.
// extract the bluetooth device power state
isBluetoothEnabled = getInternalBooleanProperty("bluetooth.enable",
isBluetoothEnabled);
// extract the device friendly name.
friendlyName = getInternalStringProperty(
"bluetooth.device.friendlyName", friendlyName);
// extract the device class.
deviceClassBase = getInternalIntProperty("bluetooth.device.class", 16,
deviceClassBase);
// extract the discoverable mode.
accessCode = getInternalIntProperty("bluetooth.device.accessCode", 16,
accessCode);
|
public void | removeConnection(java.lang.String address)Unregisters an existing connection to a remote device.
PicoNode pico = (PicoNode)piconet.get(address);
if (pico.connections == 0) {
throw new RuntimeException("No open connections for " + address);
}
if (--pico.connections == 0) {
piconet.remove(address);
}
|
public boolean | setAccessCode(int accessCode)
if (DeviceEmul.getLocalDeviceEmul().updateDiscoverable(accessCode)) {
this.accessCode = accessCode;
return true;
}
return false;
|
public boolean | setServiceClasses(int classes)
deviceClass = new DeviceClass(deviceClassBase | classes);
DeviceEmul.getLocalDeviceEmul().updateDeviceClass(deviceClass);
return true;
|