本文整理汇总了Java中javax.bluetooth.DiscoveryListener类的典型用法代码示例。如果您正苦于以下问题:Java DiscoveryListener类的具体用法?Java DiscoveryListener怎么用?Java DiscoveryListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DiscoveryListener类属于javax.bluetooth包,在下文中一共展示了DiscoveryListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inquiryCompleted
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
public void inquiryCompleted(int discType)
{
boolean error;
error = (discType != DiscoveryListener.INQUIRY_COMPLETED);
pass++;
logger.debug("Discovery " + pass + " completed: " + currentDevices); //$NON-NLS-1$ //$NON-NLS-2$
lastDiscoveryResult = new BluetoothDiscoveryResultImpl(
cloneCollection(currentDevices), error);
// only check if discovery was successful
if (!error && previousDevices != null)
{
checkDevices();
}
this.discoveryInProgress = false;
synchronized (this)
{
this.notifyAll();
}
}
示例2: inquiryCompleted
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
/**
* This callback method will be called when the device discovery is
* completed.
*/
public void inquiryCompleted(int discType) {
synchronized(lock){
lock.notify();
}
switch (discType) {
case DiscoveryListener.INQUIRY_COMPLETED :
System.out.println("INQUIRY_COMPLETED");
break;
case DiscoveryListener.INQUIRY_TERMINATED :
System.out.println("INQUIRY_TERMINATED");
break;
case DiscoveryListener.INQUIRY_ERROR :
System.out.println("INQUIRY_ERROR");
break;
default :
System.out.println("Unknown Response Code");
break;
}
}
示例3: cancelInquiry
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
public boolean cancelInquiry(DiscoveryListener listener) {
if (listener == null) {
throw new NullPointerException("null listener");
}
synchronized (d_lock) {
/* no inquiry was started */
if (d_listener == null) {
return false;
}
/* not valid listener */
if (d_listener != listener) {
return false;
}
/* process the inquiry in the device specific way */
cancelInquiry();
}
inquiryCompleted(DiscoveryListener.INQUIRY_TERMINATED);
return true;
}
示例4: searchService
import javax.bluetooth.DiscoveryListener; //导入依赖的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();
}
示例5: errorResponse
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
public void errorResponse(int errorCode, String info, int transactionID) {
if (DEBUG) {
System.out.println(cn + ".errorResponse: called");
}
stop();
if ((errorCode == SDP_INVALID_VERSION)
|| (errorCode == SDP_INVALID_SYNTAX)
|| (errorCode == SDP_INVALID_PDU_SIZE)
|| (errorCode == SDP_INVALID_CONTINUATION_STATE)
|| (errorCode == SDP_INSUFFICIENT_RESOURCES)) {
notifyListener(DiscoveryListener.SERVICE_SEARCH_ERROR);
System.err.println(info);
} else if (errorCode == SDP_INVALID_SR_HANDLE) {
notifyListener(DiscoveryListener.SERVICE_SEARCH_NO_RECORDS);
System.err.println(info);
} else if (errorCode == IO_ERROR) {
notifyListener(DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE);
} else if (errorCode == TERMINATED) {
new NotifyListenerRunner(
DiscoveryListener.SERVICE_SEARCH_TERMINATED);
}
}
示例6: servicesFoundCallback
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
public void servicesFoundCallback(SearchServicesThread startedNotify, DiscoveryListener listener,
RemoteDevice device, String serviceName, byte[] uuidValue, int channel, long recordHanlde) {
ServiceRecordImpl record = new ServiceRecordImpl(this, device, 0);
UUID uuid = new UUID(Utils.UUIDByteArrayToString(uuidValue), false);
record.populateRFCOMMAttributes(recordHanlde, channel, uuid, serviceName, BluetoothConsts.obexUUIDs
.contains(uuid));
DebugLog.debug("servicesFoundCallback", record);
RemoteDevice listedDevice = RemoteDeviceHelper.createRemoteDevice(this, device);
RemoteDeviceHelper.setStackAttributes(this, listedDevice, "RFCOMM_channel" + channel, uuid);
ServiceRecord[] records = new ServiceRecordImpl[1];
records[0] = record;
listener.servicesDiscovered(startedNotify.getTransID(), records);
}
示例7: startInquiry
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
/**
* Start DeviceInquiry and wait for startException or deviceInquiryStartedCallback
*/
static boolean startInquiry(BluetoothStack stack, DeviceInquiryRunnable inquiryRunnable, int accessCode,
DiscoveryListener listener) throws BluetoothStateException {
DeviceInquiryThread t = (new DeviceInquiryThread(stack, inquiryRunnable, accessCode, listener));
// In case the BTStack hangs, exit JVM anyway
UtilsJavaSE.threadSetDaemon(t);
synchronized (t.inquiryStartedEvent) {
t.start();
while (!t.started && !t.terminated) {
try {
t.inquiryStartedEvent.wait();
} catch (InterruptedException e) {
return false;
}
if (t.startException != null) {
throw t.startException;
}
}
}
DebugLog.debug("startInquiry return", t.started);
return t.started;
}
示例8: run
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
public void run() {
int respCode = DiscoveryListener.SERVICE_SEARCH_ERROR;
try {
BlueCoveImpl.setThreadBluetoothStack(stack);
respCode = serachRunnable.runSearchServices(this, attrSet, uuidSet, device, listener);
} catch (BluetoothStateException e) {
startException = e;
return;
} finally {
finished = true;
unregisterThread();
synchronized (serviceSearchStartedEvent) {
serviceSearchStartedEvent.notifyAll();
}
DebugLog.debug("runSearchServices ends", getTransID());
if (started) {
Utils.j2meUsagePatternDellay();
listener.serviceSearchCompleted(getTransID(), respCode);
}
}
}
示例9: inquiryCompleted
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
public void inquiryCompleted(int discType) {
if (discType == DiscoveryListener.INQUIRY_COMPLETED) {
if (log.isInfoEnabled()) {
log.info("inquiry completed");
}
}
if (discType == DiscoveryListener.INQUIRY_TERMINATED) {
if (log.isInfoEnabled()) {
log.info("inquiry terminated");
}
}
if (discType == DiscoveryListener.INQUIRY_ERROR) {
if (log.isInfoEnabled()) {
log.info("inquiry error");
}
}
}
示例10: serviceSearchResponseCodeToString
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
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";
}
}
示例11: inquiryResponseCodeToString
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
private static String inquiryResponseCodeToString(int code) {
if (code == DiscoveryListener.INQUIRY_COMPLETED) {
return "INQUIRY_COMPLETED";
} else if (code == DiscoveryListener.INQUIRY_ERROR) {
return "INQUIRY_ERROR";
} else if (code == DiscoveryListener.INQUIRY_TERMINATED) {
return "INQUIRY_TERMINATED";
} else {
return "Unknown";
}
}
示例12: inquiryCompleted
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
/**
*
* This method is called by the javax.bluetooth.DiscoveryAgent (agent) when the discovery process is completed
*
* @param discType The type of request that was completed; either INQUIRY_COMPLETED, INQUIRY_TERMINATED, or INQUIRY_ERROR
*
*/
public void inquiryCompleted(int discType) {
switch (discType) {
case DiscoveryListener.INQUIRY_COMPLETED:
if(devicesFound.size()==0){
log.logDebugInfo("BluetoothServiceDiscovery.inquiryCompleted()","No devices found");
// Send a message to the midlet
currentNetwork.serviceSearchCompleted();
}else{
try {
log.logDebugInfo("BluetoothServiceDiscovery.inquiryCompleted()","Found one or more devices");
// The discovery agent searches for services on the first 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);
}
}
log.logDebugInfo("BluetoothServiceDiscovery.inquiryCompleted()","Device inquiry completed");
break;
case DiscoveryListener.INQUIRY_ERROR:
log.logDebugInfo("BluetoothServiceDiscovery.inquiryCompleted()","Device inquiry error");
break;
case DiscoveryListener.INQUIRY_TERMINATED:
log.logDebugInfo("BluetoothServiceDiscovery.inquiryCompleted()","Device inquiry terminated");
break;
}
}
示例13: startInquiry
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
public boolean startInquiry(int accessCode, DiscoveryListener listener) {
if (discListener != null || listener == null) {
return false;
}
discListener = listener;
if (startInquiry(accessCode)) {
inquiryHistory.removeAllElements();
startPolling();
return true;
}
return false;
}
示例14: cancelInquiry
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
public boolean cancelInquiry(DiscoveryListener listener) {
if (discListener != listener) {
return false;
}
if (cancelInquiry()) {
stopPolling();
discListener = null;
return true;
}
return false;
}
示例15: onInquiryComplete
import javax.bluetooth.DiscoveryListener; //导入依赖的package包/类
void onInquiryComplete(boolean success) {
if (discListener == null) {
return;
}
stopPolling();
discListener = null;
inquiryHistory.removeAllElements();
int type = success ? DiscoveryListener.INQUIRY_COMPLETED :
DiscoveryListener.INQUIRY_ERROR;
DiscoveryAgentImpl.getInstance().inquiryCompleted(type);
}