本文整理汇总了Java中javax.bluetooth.RemoteDevice类的典型用法代码示例。如果您正苦于以下问题:Java RemoteDevice类的具体用法?Java RemoteDevice怎么用?Java RemoteDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoteDevice类属于javax.bluetooth包,在下文中一共展示了RemoteDevice类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
开发者ID:Ardulink,项目名称:Ardulink-1,代码行数:27,代码来源:ArdulinkDiscoveryListener.java
示例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);
}
开发者ID:awvalenti,项目名称:bauhinia,代码行数:22,代码来源:IdentifyNextDeviceState.java
示例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);
}
开发者ID:rhamnett,项目名称:dazzl,代码行数:18,代码来源:MonitoringThreadImpl.java
示例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);
}
}
}
开发者ID:rhamnett,项目名称:dazzl,代码行数:24,代码来源:MonitoringThreadImpl.java
示例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);
}
}
}
开发者ID:rhamnett,项目名称:dazzl,代码行数:24,代码来源:MonitoringThreadImpl.java
示例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());
}
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:20,代码来源:BluetoothStack.java
示例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);
}
}
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:23,代码来源:DiscoveryAgentImpl.java
示例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;
}
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:22,代码来源:SelectServiceHandler.java
示例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();
}
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:17,代码来源:ServiceSearcher.java
示例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.");
}
}
开发者ID:jdelacroix,项目名称:sphero-bluecove,代码行数:17,代码来源:SpheroDiscovery.java
示例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);
}
}
开发者ID:cli,项目名称:worldmap-classic,代码行数:25,代码来源:RemoteDeviceUI.java
示例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) {
}
}
开发者ID:cli,项目名称:worldmap-classic,代码行数:22,代码来源:Util.java
示例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);
}
}
开发者ID:rafjordao,项目名称:Nird2,代码行数:12,代码来源:InvitationListener.java
示例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();
}
}
开发者ID:andrea9293,项目名称:pcstatus,代码行数:38,代码来源:BluetoothSPPServer.java
示例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 );
}
开发者ID:jolie,项目名称:jolie,代码行数:10,代码来源:BluetoothService.java
示例16: 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);
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:18,代码来源:BTDeviceDiscoveryService.java
示例17: servicesDiscovered
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
@Override
public void servicesDiscovered(int transID, ServiceRecord[] serviceRecords) {
for(ServiceRecord serviceRecord : serviceRecords) {
RemoteDevice currentDevice = serviceRecord.getHostDevice();
services.put(currentDevice, serviceRecords);
}
}
开发者ID:Ardulink,项目名称:Ardulink-1,代码行数:8,代码来源:ArdulinkDiscoveryListener.java
示例18: initCommunication
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
@Override
public void initCommunication() throws Exception {
this.dataInputStream = new ObjectInputStream(
connection.openDataInputStream());
this.dataOutputStream = new ObjectOutputStream(
connection.openDataOutputStream());
this.idA = RemoteDevice.getRemoteDevice(connection)
.getBluetoothAddress();
this.idB = LocalDevice.getLocalDevice().getBluetoothAddress();
}
开发者ID:Rohde-Schwarz-Cybersecurity,项目名称:PanBox,代码行数:11,代码来源:PAKBluetoothPairingHandler.java
示例19: main
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException,
IOException {
List<RemoteDevice> devices = RemoteDeviceDiscovery.discover();
for (RemoteDevice device : devices) {
System.out.println("ADDR: " + device.getBluetoothAddress()
+ ", NAME: " + device.getFriendlyName(false));
}
}
开发者ID:Rohde-Schwarz-Cybersecurity,项目名称:PanBox,代码行数:10,代码来源:RemoveDeviceDiscoveryTest.java
示例20: startserver
import javax.bluetooth.RemoteDevice; //导入依赖的package包/类
public void startserver() {
try {
String url = "btspp://localhost:" + uuid +
// new UUID( 0x1101 ).toString() +
";name=File Server";
StreamConnectionNotifier service = (StreamConnectionNotifier) Connector.open(url);
StreamConnection con = service.acceptAndOpen();
OutputStream dos = con.openOutputStream();
InputStream dis = con.openInputStream();
InputStreamReader daf = new InputStreamReader(System.in);
BufferedReader sd = new BufferedReader(daf);
RemoteDevice dev = RemoteDevice.getRemoteDevice(con);
String greeting = "hi";
dos.write(greeting.getBytes(Charset.forName("utf-8")));
dos.flush();
byte buffer[] = new byte[1024];
int bytes_read = dis.read(buffer);
String received = new String(buffer, 0, bytes_read, Charset.forName("utf-8"));
System.out.println
("Message:" + received + "From:"
+ dev.getBluetoothAddress());
// con.close();
} catch (IOException e) {
System.err.print(e.toString());
}
}
开发者ID:Blaubot,项目名称:Blaubot,代码行数:30,代码来源:rfcommserver.java
注:本文中的javax.bluetooth.RemoteDevice类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论