Java Code Examples for javax.bluetooth.DiscoveryListener#SERVICE_SEARCH_TERMINATED

The following examples show how to use javax.bluetooth.DiscoveryListener#SERVICE_SEARCH_TERMINATED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceSearcher.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example 2
Source File: ServiceSearcher.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
boolean cancel() {
    synchronized (this) {
        if (inactive) {
            return false;
        }
        inactive = true;

        if (sdp == null) {
            return false;
        }

        if (canceled) {
            return false;
        }
        canceled = true;
    }

    // cancel running effective transaction if any.
    // if sdp.cancelServiceSearch returns false (there is no running
    // transactions) then call the notification directly.
    if (!sdp.cancelServiceSearch(transactionID)) {
        new NotifyListenerRunner(
                DiscoveryListener.SERVICE_SEARCH_TERMINATED);
    }

    return true;
}
 
Example 3
Source File: ServiceSearcher.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
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();
    }
}