本文整理汇总了Java中javax.bluetooth.DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE属性的典型用法代码示例。如果您正苦于以下问题:Java DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE属性的具体用法?Java DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE怎么用?Java DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.bluetooth.DiscoveryListener
的用法示例。
在下文中一共展示了DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serviceSearchResponseCodeToString
private static String serviceSearchResponseCodeToString(int code) {
if (code == DiscoveryListener.SERVICE_SEARCH_COMPLETED) {
return "SERVICE_SEARCH_COMPLETED";
} else if (code == DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE) {
return "SERVICE_SEARCH_DEVICE_NOT_REACHABLE";
} else if (code == DiscoveryListener.SERVICE_SEARCH_ERROR) {
return "SERVICE_SEARCH_ERROR";
} else if (code == DiscoveryListener.SERVICE_SEARCH_NO_RECORDS) {
return "SERVICE_SEARCH_NO_RECORDS";
} else if (code == DiscoveryListener.SERVICE_SEARCH_TERMINATED) {
return "SERVICE_SEARCH_TERMINATED";
} else {
return "Unknown";
}
}
示例2: serviceSearchCompleted
/**
*
* This method is called by the javax.bluetooth.DiscoveryAgent (agent) when the search for services (read: Peer2Me framework) is completed
*
* @param transID The transaction ID of the service search that is posting the result
* @param respCode The response code that indicates the status of the transaction
*
*/
public void serviceSearchCompleted(int transID, int respCode){
switch(respCode) {
case DiscoveryListener.SERVICE_SEARCH_COMPLETED:
log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","Service search completed");
break;
case DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE:
log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","Service search device not reachable");
// If a searchServices() call is made on a specific device, the devices found table will contain no devices
// In this case the network must be notified about the error.
// In the initial doDeviceDiscovery() these errors are ignored because devices not running the framework can interfere the discovery process.
if(devicesFound.size()==0) currentNetwork.serviceDiscoveryError();
break;
case DiscoveryListener.SERVICE_SEARCH_ERROR:
log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","Service search error");
if(devicesFound.size()==0) currentNetwork.serviceDiscoveryError();
break;
case DiscoveryListener.SERVICE_SEARCH_NO_RECORDS:
log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","No bluetooth devices running the same service (application) found");
if(devicesFound.size()==0) currentNetwork.serviceDiscoveryError();
break;
case DiscoveryListener.SERVICE_SEARCH_TERMINATED:
log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","Service search terminated");
if(devicesFound.size()==0) currentNetwork.serviceDiscoveryError();
break;
}
// Searches further on the next device
if(devicesFound.size()>0){
try {
// The discovery agent searches for services on the next device stored in the devicesFound Vector
agent.searchServices(attributes,uuids,(RemoteDevice)devicesFound.firstElement(),this);
devicesFound.removeElementAt(0);
} catch (BluetoothStateException bse) {
log.logException("BluetoothServiceDiscovery.serviceSearchCompleted", bse, true);
currentNetwork.serviceDiscoveryError();
}
}
else{
if(servicesFound.size()==0){
log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","No services found");
}else{
log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","Found the desired service running on one or more nodes");
// For each element in servicesFound the serviceFound method is called on currentNetwork
for(int i=0;i<servicesFound.size();i++){
currentNetwork.nodeFound((ServiceRecord)servicesFound.elementAt(i));
}
currentNetwork.serviceSearchCompleted();
}
}
}
示例3: start
private int start() throws BluetoothStateException {
if (DEBUG) {
System.out.println("- serviceSearcher: start");
}
synchronized (ServiceSearcher.class) {
if (requestCounter == ServiceRecordImpl.TRANS_MAX) {
throw new BluetoothStateException(
"Too much concurrent requests");
}
requestCounter++;
}
transactionID = SDPClientTransaction.newTransactionID();
searchers.put(new Integer(transactionID), this);
synchronized (this) {
notified = false;
}
handles = null;
processedHandle = 0;
try {
sdp = new JavaSDPClient(btDev.getBluetoothAddress());
sdp.serviceSearchAttributeRequest(attrSet, uuidSet, transactionID,
this);
// sdp.serviceSearchRequest(uuidSet, transactionID, this);
} catch (IOException ioe) {
if (DEBUG) {
ioe.printStackTrace();
}
synchronized (this) {
stop();
new NotifyListenerRunner(
DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE);
}
}
if (DEBUG) {
System.out.println("- serviceSearch: started with transaction: "
+ transactionID);
}
return transactionID;
}
示例4: notifyListener
private void notifyListener(int respCode) {
// guard against multiple notification calls
synchronized (this) {
if (!notified) {
notified = true;
} else {
return;
}
}
if (DEBUG) {
String codeStr = "Undefined";
switch (respCode) {
case DiscoveryListener.SERVICE_SEARCH_COMPLETED:
codeStr = "SERVICE_SEARCH_COMPLETED";
break;
case DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE:
codeStr = "SERVICE_SEARCH_DEVICE_NOT_REACHABLE";
break;
case DiscoveryListener.SERVICE_SEARCH_ERROR:
codeStr = "SERVICE_SEARCH_ERROR";
break;
case DiscoveryListener.SERVICE_SEARCH_NO_RECORDS:
codeStr = "SERVICE_SEARCH_NO_RECORDS";
break;
case DiscoveryListener.SERVICE_SEARCH_TERMINATED:
codeStr = "SERVICE_SEARCH_TERMINATED";
break;
default:
}
if (DEBUG) {
System.out.println("serviceSearchCompleted:");
System.out.println("\ttransID=" + transactionID);
System.out.println("\trespCode=" + codeStr);
System.out.println("\tinactive=" + inactive);
}
}
try {
discListener.serviceSearchCompleted(transactionID, respCode);
} catch (Throwable e) {
e.printStackTrace();
}
}