本文整理汇总了Java中javax.bluetooth.RemoteDevice类的典型用法代码示例。如果您正苦于以下问题:Java RemoteDevice类的具体用法?Java RemoteDevice怎么用?Java RemoteDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoteDevice类属于javax.bluetooth包,在下文中一共展示了RemoteDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: fireDeviceAppeared
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
/**
* Inform listeners about a device that appeared.
*
* @param device the device that appeared.
*/
private void fireDeviceAppeared(RemoteDevice device)
{
BluetoothDevice bluetoothDevice;
bluetoothDevice = remoteDevice2BluetoothDevice(device);
logger.debug("Discovered device: " + bluetoothDevice); //$NON-NLS-1$
synchronized (monitoringListeners)
{
Iterator i = monitoringListeners.iterator();
while (i.hasNext())
{
BluetoothPresenceListener ml = (BluetoothPresenceListener) i
.next();
ml.deviceAppeared(bluetoothDevice);
}
}
}
示例5: fireDeviceDisappeared
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
/**
* Inform listeners about a device that disappeared.
*
* @param device the device that disappeared.
*/
private void fireDeviceDisappeared(RemoteDevice device)
{
BluetoothDevice bluetoothDevice;
bluetoothDevice = remoteDevice2BluetoothDevice(device);
logger.debug("Lost device: " + bluetoothDevice); //$NON-NLS-1$
synchronized (monitoringListeners)
{
Iterator i = monitoringListeners.iterator();
while (i.hasNext())
{
BluetoothPresenceListener ml = (BluetoothPresenceListener) i
.next();
ml.deviceDisappeared(bluetoothDevice);
}
}
}
示例6: onInquiryResult
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
void onInquiryResult(InquiryResult result) {
if (discListener == null) {
return;
}
String addr = result.getAddress();
Enumeration e = inquiryHistory.elements();
while (e.hasMoreElements()) {
InquiryResult oldResult = (InquiryResult)e.nextElement();
if (oldResult.getAddress().equals(addr)) {
// inquiry result is already in our possession
return;
}
}
inquiryHistory.addElement(result);
RemoteDevice dev
= DiscoveryAgentImpl.getInstance().getRemoteDevice(addr);
DiscoveryAgentImpl.getInstance().addCachedDevice(addr);
discListener.deviceDiscovered(dev, result.getDeviceClass());
}
示例7: retrieveDevices
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
public RemoteDevice[] retrieveDevices(int option) {
switch (option) {
case DiscoveryAgent.CACHED:
// IMPL_NOTE: use native cache keeping addresses of found devices
// to share the cache between multiple isolates
return getCachedDevices();
case DiscoveryAgent.PREKNOWN:
Vector pk = BCC.getInstance().getPreknownDevices();
if (pk == null || pk.size() == 0) {
return null;
}
RemoteDevice[] res = new RemoteDevice[pk.size()];
for (int i = 0; i < pk.size(); i++) {
String addr = (String)pk.elementAt(i);
res[i] = getRemoteDevice(addr);
}
return res;
default:
throw new IllegalArgumentException("Invalid option value: "
+ option);
}
}
示例8: selectFromDevicesList
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
private String selectFromDevicesList(RemoteDevice[] devs, UUID uuid,
int security, boolean master, Hashtable disDevsHash) {
if (devs == null) {
return null;
}
for (int i = 0; i < devs.length; i++) {
if (disDevsHash.put(devs[i], devs[i]) != null) {
continue;
}
String url = selectService(devs[i], uuid, security, master);
if (url != null) {
if (DEBUG) {
System.out.println("\turl=" + url);
}
return url;
}
}
return null;
}
示例9: searchService
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
public int searchService(int[] attrSet, UUID[] uuidSet, RemoteDevice btDev,
DiscoveryListener discListener) throws BluetoothStateException,
IllegalArgumentException {
if (DEBUG) {
System.out.println("- serviceSearcher: initializing");
}
initialize(attrSet, uuidSet, btDev);
if (discListener == null) {
throw new NullPointerException("DiscoveryListener is null");
}
this.discListener = discListener;
return start();
}
示例10: 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.");
}
}
示例11: showui
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
/**
* refresh the list with blutooth devices
*/
public void showui() {
//*** super.deleteAll();
while (super.size() > 0) {
super.delete(0);
}
if (BLUElet.devices.size() > 0) {
for (int i = 0; i < BLUElet.devices.size(); i++) {
try {
RemoteDevice device = (RemoteDevice) BLUElet.devices.elementAt(i);
String name = device.getFriendlyName(false);
append(name, null);
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
append("[No Device Found]", null);
}
}
示例12: printRemoteDevice
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
public static void printRemoteDevice(RemoteDevice dev, DeviceClass devClass) {
try {
System.out.println("Print Remote Device " + dev.getBluetoothAddress());
System.out.println("Name: " + dev.getFriendlyName(false));
System.out.println("Auth: " + dev.isAuthenticated() + " Encrypted: " + dev.isEncrypted() + " Trusted: " + dev.isTrustedDevice());
if (devClass != null) {
System.out.println("MajorDevice:"
+ majorToName(devClass.getMajorDeviceClass()));
System.out.println("MinorDevice:"
+ minorToName(devClass.getMajorDeviceClass(),
devClass.getMinorDeviceClass()));
System.out.println("ServiceClass:");
String[] str = Util.majorServiceToName(devClass.getServiceClasses());
for (int i = 0; i < str.length; i++) {
System.out.println(" " + str[i]);
}
}
} catch (IOException e) {
}
}
示例13: deviceDiscovered
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
@Override
public void deviceDiscovered(RemoteDevice device, DeviceClass deviceClass) {
UUID[] uuids = new UUID[] {new UUID(uuid, false)};
// Try to discover the services associated with the UUID
try {
discoveryAgent.searchServices(null, uuids, device, this);
searches.incrementAndGet();
} catch (BluetoothStateException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
示例14: bluetoothServer
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
/**
* start server creating an UUID and a connection String,
* then waiting for a device to connect
*/
private void bluetoothServer() {
if (sendReciveMessageThread.isAlive()) {
sendReciveMessageThread.interrupt();
}
try {
//Create a UUID for SPP
UUID uuid = new UUID("1101", true);
//Create the servicve url
String connectionString = "btspp://localhost:" + uuid + ";name=Sample SPP Server";
//open server url
streamConnNotifier = (StreamConnectionNotifier) Connector.open(connectionString);
//Wait for client connection
System.out.println("\nServer Started. Waiting for clients to connect...");
StreamConnection connection = streamConnNotifier.acceptAndOpen();
System.out.println("Remote device address: " + RemoteDevice.getRemoteDevice(connection).getBluetoothAddress());
System.out.println("Remote device name: " + RemoteDevice.getRemoteDevice(connection).getFriendlyName(true));
//the stream is opened both in and out
outStream = connection.openOutputStream();
inStream = connection.openInputStream();
connectionIsAvaible = true;
SingletonStaticGeneralStats.getInstance().setBluetoothServerCreated(true);
sendBluetoothMessage();
} catch (IOException e) {
e.printStackTrace();
//in case of problems, the connection is stopped
closeConnection();
}
}
示例15: deviceDiscovered
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
public void deviceDiscovered( RemoteDevice btDevice, DeviceClass cod )
{
Value dValue = Value.create();
dValue.getFirstChild( "address" ).setValue( btDevice.getBluetoothAddress() );
try {
dValue.getFirstChild( "name" ).setValue( btDevice.getFriendlyName( true ) );
} catch( IOException e ) {}
value.getChildren( "device" ).add( dValue );
}