Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nearby connection API for Android - not working for some devices

I'm testing Nearby connection API with the sample application available here: https://github.com/googlesamples/android-nearby It seems that this is not working for some devices. I successfully connected Samsung Galaxy S3 with Nexus 7, in both directions (S3 as host, N7 as slave and vice versa). However, when I try to connect Samusung Galaxy S3 to Nexus 5, the connection ALWAYS fails, with status code 8005.

Below you can see the method invoked by slave (discovering device) in order to connect to host (advertising device).

private void connectTo(String endpointId, final String endpointName) {
    debugLog("connectTo:" + endpointId + ":" + endpointName);

    // Send a connection request to a remote endpoint. By passing 'null' for the name,
    // the Nearby Connections API will construct a default name based on device model
    // such as 'LGE Nexus 5'.
    String myName = null;
    byte[] myPayload = null;
    Nearby.Connections.sendConnectionRequest(mGoogleApiClient, myName, endpointId, myPayload,
            new Connections.ConnectionResponseCallback() {
                @Override
                public void onConnectionResponse(String endpointId, Status status,
                                                 byte[] bytes) {
                    Log.d(TAG, "onConnectionResponse:" + endpointId + ":" + status);
                    if (status.isSuccess()) {
                        debugLog("onConnectionResponse: " + endpointName + " SUCCESS");
                        Toast.makeText(MainActivity.this, "Connected to " + endpointName,
                                Toast.LENGTH_SHORT).show();

                        mOtherEndpointId = endpointId;
                        updateViewVisibility(STATE_CONNECTED);
                    } else {
                        debugLog("onConnectionResponse: " + endpointName + " FAILURE. ResponseCode=" + status.getStatusCode() + " statusMessage=" + status.getStatusMessage() );
                    }
                }
            }, this);
}

The result I always get is :
11-17 18:48:50.678 11133-11133/com.google.example.connectionsquickstart D/MainActivity: onConnectionResponse: Samsung GT-I9300 FAILURE. ResponseCode=8005 statusMessage=null

Any clue what is going on?

like image 509
Ramps Avatar asked Nov 17 '15 17:11

Ramps


People also ask

What is nearby connection settings?

Nearby Connections enables advertising, discovery, and connections between nearby devices in a fully-offline peer-to-peer manner. Connections between devices are high-bandwidth, low-latency, and fully encrypted to enable fast, secure data transfers.

What is nearby devices app?

The Nearby platform makes it easy to discover nearby devices and establish communication with them. It uses technologies such as Bluetooth, Wi-Fi, IP, and audio.


1 Answers

The error you're getting is STATUS_NOT_CONNECTED_TO_ENDPOINT (from Reference docs). Both devices need to be connected to the same WiFi which has internet access.

like image 66
MahlerFive Avatar answered Oct 11 '22 09:10

MahlerFive