-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I need to create an android application for communication purpose using Xbee device over USB.
I have created a simple program to open the device but it throws the exception Xbee Device Not Found.
Here is the code:
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
import com.digi.xbee.api.android.XBeeBLEDevice;
import com.digi.xbee.api.android.XBeeDevice;
import com.digi.xbee.api.exceptions.XBeeException;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Thread(new Runnable() {
@Override
public void run() {
XBeeDevice myXBeeDevice = new XBeeDevice(MainActivity.this, 115200);
try {
myXBeeDevice.open();
showToastMessage("Device Opened: ");
} catch (XBeeException e) {
showToastMessage("Could not open device: " + e.getMessage());
}
}
}).start();
}
private void showToastMessage(final String message) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show();
}
});
}
}
Metadata
Metadata
Assignees
Labels
No labels