本文整理汇总了Java中javax.bluetooth.DeviceClass类的典型用法代码示例。如果您正苦于以下问题:Java DeviceClass类的具体用法?Java DeviceClass怎么用?Java DeviceClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeviceClass类属于javax.bluetooth包,在下文中一共展示了DeviceClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deviceDiscovered
import javax.bluetooth.DeviceClass; //导入依赖的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.");
}
}
示例2: printRemoteDevice
import javax.bluetooth.DeviceClass; //导入依赖的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) {
}
}
示例3: printLocalDevice
import javax.bluetooth.DeviceClass; //导入依赖的package包/类
public static void printLocalDevice(LocalDevice dev) {
System.out.println("Print Local Device " + dev.getBluetoothAddress());
System.out.println("Name: " + dev.getFriendlyName());
DeviceClass devClass = dev.getDeviceClass();
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]);
}
}
}
示例4: deviceDiscovered
import javax.bluetooth.DeviceClass; //导入依赖的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);
}
}
示例5: deviceDiscovered
import javax.bluetooth.DeviceClass; //导入依赖的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 );
}
示例6: deviceDiscovered
import javax.bluetooth.DeviceClass; //导入依赖的package包/类
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);
}
}
示例7: deviceDiscovered
import javax.bluetooth.DeviceClass; //导入依赖的package包/类
public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod)
{
synchronized (currentDevices)
{
currentDevices.add(btDevice);
}
}
示例8: deviceDiscovered
import javax.bluetooth.DeviceClass; //导入依赖的package包/类
/**
* This call back method will be called for each discovered bluetooth devices.
*/
public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
System.out.println("Device discovered: "+btDevice.getBluetoothAddress());
//add the device to the vector
if(!vecDevices.contains(btDevice)){
vecDevices.addElement(btDevice);
}
}
示例9: deviceDiscovered
import javax.bluetooth.DeviceClass; //导入依赖的package包/类
/**
*
* This method is called by the javax.bluetooth.DiscoveryAgent (agent) whenever a bluetooth device is discovered
*
* @param remoteDevice The device discovered
* @param deviceClass The device class of the discovered device
*
*/
public void deviceDiscovered(RemoteDevice remoteDevice,DeviceClass deviceClass){
// The device class of the discovered device
int deviceclass = deviceClass.getMajorDeviceClass();
if(deviceclass==mobileDeviceClassCode){
// Adds the discovered device to the devicesFound Vector
devicesFound.addElement(remoteDevice);
}
}
示例10: deviceDiscovered
import javax.bluetooth.DeviceClass; //导入依赖的package包/类
public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
// if this bloototh device was found in preknown or
// cached devices skips it now.
if (btDevsHash.put(btDevice, btDevice) == null) {
btDevs.addElement(btDevice);
}
}
示例11: deviceDiscovered
import javax.bluetooth.DeviceClass; //导入依赖的package包/类
public void deviceDiscovered(RemoteDevice remoteDevice,
DeviceClass deviceClass) {
log("A remote Bluetooth device is discovered:");
Util.printRemoteDevice(remoteDevice, deviceClass);
devices.addElement(remoteDevice);
deviceClasses.addElement(deviceClass);
}
示例12: runDeviceInquiry
import javax.bluetooth.DeviceClass; //导入依赖的package包/类
public int runDeviceInquiry(DeviceInquiryThread startedNotify, int accessCode, DiscoveryListener listener)
throws BluetoothStateException {
try {
int discType = runDeviceInquiryImpl(startedNotify, accessCode, listener);
if (discType == DiscoveryListener.INQUIRY_COMPLETED) {
// Report found devices if any not reported
Hashtable previouslyFound = (Hashtable) deviceDiscoveryListenerFoundDevices.get(listener);
if (previouslyFound != null) {
Vector reported = (Vector) deviceDiscoveryListenerReportedDevices.get(listener);
for (Enumeration en = previouslyFound.keys(); en.hasMoreElements();) {
RemoteDevice remoteDevice = (RemoteDevice) en.nextElement();
if (reported.contains(remoteDevice)) {
continue;
}
reported.addElement(remoteDevice);
Integer deviceClassInt = (Integer) previouslyFound.get(remoteDevice);
DeviceClass deviceClass = new DeviceClass(deviceClassInt.intValue());
listener.deviceDiscovered(remoteDevice, deviceClass);
// If cancelInquiry has been called
if (!deviceDiscoveryListeners.contains(listener)) {
return DiscoveryListener.INQUIRY_TERMINATED;
}
}
}
}
return discType;
} finally {
deviceDiscoveryListeners.removeElement(listener);
deviceDiscoveryListenerFoundDevices.remove(listener);
deviceDiscoveryListenerReportedDevices.remove(listener);
}
}
示例13: deviceDiscoveredCallback
import javax.bluetooth.DeviceClass; //导入依赖的package包/类
public void deviceDiscoveredCallback(DiscoveryListener listener, long deviceAddr, int deviceClass,
String deviceName, boolean paired) {
// Copied directly from WIDCOMM driver
DebugLog.debug("deviceDiscoveredCallback deviceName", deviceName);
if (!deviceDiscoveryListeners.contains(listener)) {
return;
}
// Update name if name retrieved
RemoteDevice remoteDevice = RemoteDeviceHelper.createRemoteDevice(this, deviceAddr, deviceName, paired);
Vector reported = (Vector) deviceDiscoveryListenerReportedDevices.get(listener);
if (reported == null || (reported.contains(remoteDevice))) {
return;
}
// See -Dbluecove.inquiry.report_asap=false
Hashtable previouslyFound = (Hashtable) deviceDiscoveryListenerFoundDevices.get(listener);
if (previouslyFound != null) {
Integer deviceClassInt = (Integer) previouslyFound.get(remoteDevice);
if (deviceClassInt == null) {
previouslyFound.put(remoteDevice, new Integer(deviceClass));
} else if (deviceClass != 0) {
previouslyFound.put(remoteDevice, new Integer(deviceClass));
}
} else {
DeviceClass cod = new DeviceClass(deviceClass);
reported.addElement(remoteDevice);
DebugLog.debug("deviceDiscoveredCallback address", remoteDevice.getBluetoothAddress());
DebugLog.debug("deviceDiscoveredCallback deviceClass", cod);
listener.deviceDiscovered(remoteDevice, cod);
}
}
示例14: deviceDiscoveredCallback
import javax.bluetooth.DeviceClass; //导入依赖的package包/类
public void deviceDiscoveredCallback(DiscoveryListener listener, long deviceAddr, int deviceClass,
String deviceName, boolean paired) {
DebugLog.debug("deviceDiscoveredCallback", deviceName);
RemoteDevice remoteDevice = RemoteDeviceHelper.createRemoteDevice(this, deviceAddr, deviceName, paired);
if ((currentDeviceDiscoveryListener == null) || (currentDeviceDiscoveryListener != listener)) {
return;
}
listener.deviceDiscovered(remoteDevice, new DeviceClass(deviceClass));
}
示例15: deviceDiscovered
import javax.bluetooth.DeviceClass; //导入依赖的package包/类
public void deviceDiscovered(final RemoteDevice btDevice, DeviceClass cod) {
if (devicesProcessed.containsKey(btDevice)) {
return;
}
synchronized (serviceSearchDeviceQueue) {
serviceSearchDeviceQueue.addElement(btDevice);
serviceSearchDeviceQueue.notifyAll();
}
}