digidotcom/xbee-java

DiscoverDevicesSample

shanif3 opened this issue · 0 comments

Hi,
I added the code to my android studio app like this:

part of the code where i add the relvant part of discovering:

try {

// Open the connection with the device.
xbeeDevice.open();
try{
    XBeeNetwork myXBeeNetwork = xbeeDevice.getNetwork();
    myXBeeNetwork.setDiscoveryTimeout(15000);
    myXBeeNetwork.addDiscoveryListener(new MyDiscoveryListener());
    myXBeeNetwork.startDiscoveryProcess();
    Log.d("yes", "\n>> Discovering remote XBee devices...");

}catch (Exception e) {
    e.printStackTrace();
    throw new RuntimeException(e); }

package com.digi.xbee.sample.android.bleconfiguration;

import android.util.Log;

import com.digi.xbee.api.RemoteXBeeDevice;
import com.digi.xbee.api.listeners.IDiscoveryListener;

public class MyDiscoveryListener implements IDiscoveryListener {

@Override
public void deviceDiscovered(RemoteXBeeDevice discoveredDevice) {
    Log.d("see",">> Device discovered: %s%n"+discoveredDevice.toString());
}

@Override
public void discoveryError(String error) {
    Log.d("see",">> There was an error discovering devices: " + error);
}

@Override
public void discoveryFinished(String error) {
    if (error == null)
       Log.d("see",">> Discovery process finished successfully.");
    else
        Log.d("see",">> Discovery process finished due to the following error: " + error);

    System.exit(0);
}

}

but it discovers only himself- why? all the other devices are in the same network.
Thanks in advance!