Ramps
Ramps

Reputation: 5298

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?

Upvotes: 9

Views: 2461

Answers (2)

Fabio
Fabio

Reputation: 2824

I assume you're talking about the connections-quickstart sample. See this github issue here https://github.com/googlesamples/android-nearby/issues/6 . The API used on this sample relies on multicast apparently, which will be dependent certainly on your router and apparently also on your devices:

And apparently you have that on Nexus 7 but not Nexus 5: https://code.google.com/p/android/issues/detail?id=51195

[email protected] This is a show stopper for us on the Nexus 4. Our app relies on multicast and cannot be implemented any other way. It's interesting that the Nexus 7 actually does have this implemented, but not the 4.

Jan 8, 2014 #3 [email protected] The problem persists on the Nexus 5.

So I bet that on your current wifi you'be able to connect your nexus 7 to anything.

Just to be clear, you can have problems trying to RECEIVE multicast packets: Android can not receive multicast packet

Upvotes: 0

MahlerFive
MahlerFive

Reputation: 5279

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.

Upvotes: 1

Related Questions