Skip to content

Xbee Device Not Found #14

@shubham9436

Description

@shubham9436

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions