本文整理汇总了Java中javax.bluetooth.LocalDevice.setDiscoverable方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDevice.setDiscoverable方法的具体用法?Java LocalDevice.setDiscoverable怎么用?Java LocalDevice.setDiscoverable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.bluetooth.LocalDevice
的用法示例。
在下文中一共展示了LocalDevice.setDiscoverable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initDevicePairingBluetooth
import javax.bluetooth.LocalDevice; //导入方法依赖的package包/类
public BluetoothPairingInformation initDevicePairingBluetooth()
throws BluetoothStateException, InterruptedException {
// This is the first time we are going to touch the Bluetooth API so we
// should attach our logger to the com.intel.bluetooth logging
appendBluetoothLogging();
// Make bluetooth device discoverbale!
LocalDevice local = LocalDevice.getLocalDevice();
try {
local.setDiscoverable(DiscoveryAgent.GIAC);
} catch (BluetoothStateException e) {
logger.debug(
"PanboxClient : initDevicePairingBluetooth : First try to set discoverable failed. Will try again in 1sec.");
Thread.sleep(1000);
local.setDiscoverable(DiscoveryAgent.GIAC);
}
// setting LocalDevice is only need for Linux, since on Windows we
// bluecove only supports one device!
BluetoothPairingInformation info = new BluetoothPairingInformation(local);
extendPairingInformation(info);
return info;
}
示例2: start
import javax.bluetooth.LocalDevice; //导入方法依赖的package包/类
public Map start(String aConfig) {
deviceDef = new Util().loadDeviceDefinition(aConfig);
log = new StringBuilder();
Map<String, Object> info = new HashMap<String, Object>();
log.append("Starting\n");
// retrieve the local Bluetooth device object
LocalDevice local = null;
// setup the server to listen for connection
try {
local = LocalDevice.getLocalDevice();
local.setDiscoverable(DiscoveryAgent.GIAC);
log.append("Make ").append(local.getFriendlyName()).append(" discoverable\n");
String uuidString = (String) deviceDef.get("UUID");
UUID uuid = new UUID(uuidString, false);
info.put("UUID", uuidString);
String url = "btspp://localhost:" + uuid.toString() + ";name=RemoteBluetooth";
notifier = (StreamConnectionNotifier) Connector.open(url);
info.put("Local btaddr", local.getBluetoothAddress());
info.put("Local name ", local.getFriendlyName());
String bluecoveVersion = LocalDevice.getProperty("bluecove");
if (bluecoveVersion != null) {
info.put("bluecove", bluecoveVersion);
info.put("stack", LocalDevice.getProperty("bluecove.stack"));
info.put("stack version", LocalDevice.getProperty("bluecove.stack.version"));
info.put("radio manufacturer", LocalDevice.getProperty("bluecove.radio.manufacturer"));
info.put("radio version", LocalDevice.getProperty("bluecove.radio.version"));
}
} catch (Exception e) {
e.printStackTrace();
log.append("Failure:\n").append(e).append("\n");
info.put("Error", e.getMessage());
stop();
}
connectThread = new ConnectThread();
connectThread.start();
return info;
}
示例3: SimpleServer
import javax.bluetooth.LocalDevice; //导入方法依赖的package包/类
public SimpleServer(String name) throws BluetoothStateException {
EnvSettings.setSystemProperties();
LocalDevice localDevice = LocalDevice.getLocalDevice();
System.out.println("Local bt address " + localDevice.getBluetoothAddress());
System.out.println("Local bt name " + localDevice.getFriendlyName());
localDevice.setDiscoverable(DiscoveryAgent.GIAC);
int connectionsCount = 0;
while (run(name) && connectionsCount < 10) {
connectionsCount ++;
}
System.exit(0);
}