本文整理汇总了Java中javax.bluetooth.RemoteDevice.getBluetoothAddress方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteDevice.getBluetoothAddress方法的具体用法?Java RemoteDevice.getBluetoothAddress怎么用?Java RemoteDevice.getBluetoothAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.bluetooth.RemoteDevice
的用法示例。
在下文中一共展示了RemoteDevice.getBluetoothAddress方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serviceSearchCompleted
import javax.bluetooth.RemoteDevice; //导入方法依赖的package包/类
@Override
public void serviceSearchCompleted(int arg0, int arg1) {
Map<String, ServiceRecord> ports = new HashMap<String, ServiceRecord>();
for (Entry<RemoteDevice, ServiceRecord[]> entry : services.entrySet()) {
RemoteDevice remoteDevice = entry.getKey();
ServiceRecord service = findService(entry.getValue());
if (service != null) {
String name = "noname";
try {
name = remoteDevice.getFriendlyName(false);
} catch (Exception e) {
}
name += " " + remoteDevice.getBluetoothAddress();
ports.put(name, service);
}
}
bluetoothConnection.setPorts(ports);
synchronized (lock) {
lock.notify();
}
}
示例2: run
import javax.bluetooth.RemoteDevice; //导入方法依赖的package包/类
@Override
State run() {
if (candidates.isEmpty()) return states.startInquiry();
CandidateDevice current = candidates.pop();
RemoteDevice btDevice = current.btDevice;
String btAddress = btDevice.getBluetoothAddress();
final String name;
try {
name = btDevice.getFriendlyName(false);
} catch (IOException e) {
return states.identificationRejected(btAddress);
}
if (!isWiiRemote(name)) {
return states.identifiedAsNonWiiRemote(btAddress);
}
return states.openControlPipe(btAddress);
}
示例3: remoteDevice2BluetoothDevice
import javax.bluetooth.RemoteDevice; //导入方法依赖的package包/类
private BluetoothDevice remoteDevice2BluetoothDevice(RemoteDevice device)
{
String address;
String name;
address = device.getBluetoothAddress();
try
{
name = device.getFriendlyName(false);
}
catch (IOException e)
{
name = UNKNOWN_NAME;
}
return new BluetoothDeviceImpl(address, name);
}
示例4: deviceDiscovered
import javax.bluetooth.RemoteDevice; //导入方法依赖的package包/类
public void deviceDiscovered(RemoteDevice btDevice, DeviceClass btClass) {
if(btDevice.getBluetoothAddress().startsWith(SPHERO_IEEE_OUI)) {
System.out.println("Found a Sphero nearby!");
Sphero s = null;
try {
s = new Sphero(btDevice.getBluetoothAddress(), btDevice.getFriendlyName(false), Sphero.SPP_DEFAULT_CHANNEL);
} catch (IOException e) {
s = new Sphero(btDevice.getBluetoothAddress(), "Unknown", 1);
}
System.out.println(s.getBluetoothAddress() + " " + s.getFriendlyName());
spherosDiscovered.add(s);
} else {
System.out.println("Found some other Bluetooth device.");
}
}
示例5: toBluetoothDevice
import javax.bluetooth.RemoteDevice; //导入方法依赖的package包/类
/**
* transforms a {@link RemoteDevice} object from the bluecove API to our own datastructure for bluetooth devices
*
* @param btDevice the device coming from the bluecove API
* @return an instance of our own bluetooth device data structure
*/
private static BluetoothDevice toBluetoothDevice(RemoteDevice btDevice) {
String address = btDevice.getBluetoothAddress();
String friendlyName = "";
try {
friendlyName = btDevice.getFriendlyName(false);
} catch (IOException e) {
// no friendly name accessible, let's ignore that
}
boolean paired = btDevice.isTrustedDevice();
return new BluetoothDevice(address, friendlyName, paired);
}
示例6: getNodeAddress
import javax.bluetooth.RemoteDevice; //导入方法依赖的package包/类
/**
*
* This method returns the node address.
*
* @param input String "localNode" to retreive the address of the local device.
* A ServiceRecord or StreamConnection object to retreive the address of a
* remote device.
*
* @return The node network address.
* @throws IOException
*/
public String getNodeAddress(Object input) throws IOException{
// Checks whether the input is a String and the String equals "localnode".
// If so the address of the LocalDevice is returned.
if(input.getClass().isInstance(new String())){
String inputString = (String)input;
// Make sure that we won't get any UPPER/lower case problems
inputString.toLowerCase();
if(inputString.equals("localnode"))return LocalDevice.getLocalDevice().getBluetoothAddress();
}
// Input type is object because superclass cannot relate to ServiceRecord which is a bluetooth specific class.
// This method is valid either the input type is ServiceRecord or StreamConnection.
RemoteDevice remoteDevice = null;
try{
ServiceRecord serviceRecord = (ServiceRecord) input;
remoteDevice = serviceRecord.getHostDevice();
}catch(ClassCastException cce1){
// Could not cast the input object to ServiceRecord. Trying streamConnection instead ;-)
try{
StreamConnection streamConnection = (StreamConnection) input;
remoteDevice = RemoteDevice.getRemoteDevice(streamConnection);
}catch(ClassCastException cce2){
//This will only happen if the input object type is wrong
log.logException("BluetoothNetwork.getNodeAddress()",cce2,false);
}catch(IOException ioe){
log.logException("BluetoothNetwork.getNodeAddress()",ioe,false);
throw ioe;
}
}
return remoteDevice.getBluetoothAddress();
}