Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DiscoverDevicesSample #168

Open
shanif3 opened this issue Oct 12, 2023 · 0 comments
Open

DiscoverDevicesSample #168

shanif3 opened this issue Oct 12, 2023 · 0 comments

Comments

@shanif3
Copy link

shanif3 commented Oct 12, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant