9

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?

Ramps
  • 5,190
  • 1
  • 45
  • 47

2 Answers2

1

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.

MahlerFive
  • 5,159
  • 5
  • 30
  • 40
  • Unfortunatelty it's not that. Both devices are connected to the same WiFi. As mentioned, the code works fine for some devices, but for other it is not. – Ramps Nov 19 '15 at 21:05
  • You may want to submit an issue on their [sample app repo](https://github.com/googlesamples/android-nearby/issues) – MahlerFive Nov 20 '15 at 14:46
  • Thanks for suggestion. I've raised an issue. – Ramps Nov 20 '15 at 16:37
0

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

chuckd73...@gmail.com 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 jan.zibu...@gmail.com 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

Community
  • 1
  • 1
Fabio
  • 2,654
  • 16
  • 31
  • The docs clearly state the multicast need here: https://developers.google.com/nearby/connections/android/get-started "Connect multiple Android devices to the same network with multicast enabled" – Fabio Nov 25 '15 at 17:49
  • @Ramps did you get any progress on this? I'm still stuck with similar problems – Fabio Dec 16 '15 at 13:12