Giter VIP home page Giter VIP logo

xbee-android's Introduction

XBee Library for Android Maven Central

This project contains the source code of the XBee Library for Android, an easy-to-use API built on top of the XBee Java Library.

The XBee Library for Android allows you to create Android applications that interact with Digi International's XBee radio frequency (RF) modules. The connection with XBee modules can be wireless (through the Bluetooth Low Energy interface) or serial (through the USB host serial port or Digi's serial port). In either case, the library facilitates the development of Android applications that interact with XBee modules.

The project includes the source code and examples that show how to create Android applications that communicate with XBee devices using the available APIs. The examples are also available in source code format. The source of the project has been contributed by Digi International.

The main features of the library include:

  • Support for ZigBee, 802.15.4, DigiMesh, Point-to-Multipoint, Wi-Fi, Cellular and Thread XBee devices.
  • Support for API and API escaped operating modes.
  • Support for different communication interfaces with the XBee device. These include:
    • Bluetooth Low Energy.
    • USB host.
    • Digi's serial port.
  • Management of local (attached to the Android device) and remote XBee device objects.
  • Discovery of remote XBee devices associated with the same network as the local device.
  • Configuration of local and remote XBee devices:
    • Configure common parameters with specific setters and getters.
    • Configure any other parameter with generic methods.
    • Execute AT commands.
    • Apply configuration changes.
    • Write configuration changes.
    • Reset the device.
  • Transmission of data to all the XBee devices on the network or to a specific device.
  • Reception of data from remote XBee devices:
    • Data polling.
    • Data reception callback.
  • Transmission and reception of IP, IPv6, CoAP and SMS messages.
  • Reception of network status changes related to the local XBee device.
  • IO lines management:
    • Configure IO lines.
    • Set IO line value.
    • Read IO line value.
    • Receive IO data samples from any remote XBee device on the network.
  • Support for explicit frames and application layer fields (Source endpoint, Destination endpoint, Profile ID, and Cluster ID).
  • Support for User Data Relay frames, allowing the communication between different interfaces (Serial, Bluetooth Low Energy and MicroPython).

Start Here

As the XBee Library for Android is a layer of the Java one, it is documented as part of the XBee Java Library. So, the best place to get started is the XBee Java Library documentation.

How to Contribute

The contributing guidelines are in the CONTRIBUTING.md document.

License

Copyright 2019-2021, Digi International Inc.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, you can obtain one at http://mozilla.org/MPL/2.0/.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

xbee-android's People

Contributors

diescalo avatar digientmgmt avatar dotkokott avatar rubenmoral avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xbee-android's Issues

SERIAL PORT INTERFACE CAUSE ERROR

Actually, I am using your Xbee3 module via UART serial port.

I am getting error and therefore "Use Serial Port Interface" radio option gets disable so i cannot select it.

Error is as below:

01-21 17:29:24.338 15870-15870/? E/XBeeConnectActivity: fillSerialPorts() | NoClassDefFoundError
    java.lang.NoClassDefFoundError: Failed resolution of: Landroid/serial/SerialPortHandler;
        at com.digi.android.serial.SerialPortManager.<init>(Unknown Source)
        at com.digi.xbee.sample.android.xbeemanager.XBeeConnectActivity.fillSerialPorts(XBeeConnectActivity.java:222)
        at com.digi.xbee.sample.android.xbeemanager.XBeeConnectActivity.onCreate(XBeeConnectActivity.java:126)
        at android.app.Activity.performCreate(Activity.java:6251)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2370)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2477)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1345)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5453)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.serial.SerialPortHandler" on path: DexPathList[[zip file "/data/app/com.digi.xbee.sample.android.xbeemanager-2/base.apk"],nativeLibraryDirectories=[/data/app/com.digi.xbee.sample.android.xbeemanager-2/lib/arm, /vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
        at com.digi.android.serial.SerialPortManager.<init>(Unknown Sourceat com.digi.xbee.sample.android.xbeemanager.XBeeConnectActivity.fillSerialPorts(XBeeConnectActivity.java:222at com.digi.xbee.sample.android.xbeemanager.XBeeConnectActivity.onCreate(XBeeConnectActivity.java:126at android.app.Activity.performCreate(Activity.java:6251at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2370at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2477at android.app.ActivityThread.-wrap11(ActivityThread.javaat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1345at android.os.Handler.dispatchMessage(Handler.java:102at android.os.Looper.loop(Looper.java:148at android.app.ActivityThread.main(ActivityThread.java:5453at java.lang.reflect.Method.invoke(Native Methodat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616Suppressed: java.lang.ClassNotFoundException: android.serial.SerialPortHandler
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
        		... 16 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Invalid Bluetooth Address

I am using the code from https://www.digi.com/resources/documentation/digidocs/90001438/tasks/t_create_xb_android_app_scratch.htm

I am assuming that the format of the MAC address expected is 08:6B:D7:52:B3:7B
And the Xbee device that I have has a MAC address of 0013A20041A7A7ED
I have tried with the following formats 0013A20041A7A7ED and 00:13:A2:00:41:A7:A7:ED
both give the same error

Process: com.ats.digixbee, PID: 576
java.lang.IllegalArgumentException: Invalid Bluetooth address.
at com.digi.xbee.api.android.connection.bluetooth.AndroidBluetoothInterface.(AndroidBluetoothInterface.java:124)
at com.digi.xbee.api.android.XBee.createConnectionInterface(XBee.java:164)
at com.digi.xbee.api.android.XBeeBLEDevice.(XBeeBLEDevice.java:83)
at com.ats.digixbee.MainActivity$2.run(MainActivity.java:49)
at java.lang.Thread.run(Thread.java:764)

Bluetooth Serial communication slow

I am working on implementing your library into an android app but I am facing a performance issue.
When I use your app (xbee on google play) I can send at least 10 commands per second through the serial interface
However, when I use your library, I can only send 5 commands per seconds with this method :

mXBeeDevice.sendUserDataRelay(
XBeeLocalInterface.SERIAL,
data
)

I followed your github example so I have no idea where the issue comes from.

Can you give me a clue about what happened please?

ftp1.digi.com server can not handle some resources.

Could you check ftp1.digi.com server? It's maybe server configuration issues.

Some resources are not downloadable:

# gradle build log
Selected primary task 'buildDependents' from project :
Resource missing. [HTTP GET: https://dl.google.com/dl/android/maven2/com/digi/android-sdk-addon/3/android-sdk-addon-3.pom]
Resource missing. [HTTP GET: https://repo.jfrog.org/artifactory/libs-release-bintray/com/digi/android-sdk-addon/3/android-sdk-addon-3.pom?referrer]
Resource missing. [HTTP GET: http://ftp1.digi.com/support/m-repo/com/digi/android-sdk-addon/3/android-sdk-addon-3.pom]
Resource missing. [HTTP GET: https://dl.google.com/dl/android/maven2/org/rxtx/rxtx/2.2/rxtx-2.2.pom]
Resource missing. [HTTP GET: https://repo.jfrog.org/artifactory/libs-release-bintray/org/rxtx/rxtx/2.2/rxtx-2.2.pom?referrer]
Resource missing. [HTTP GET: http://ftp1.digi.com/support/m-repo/org/rxtx/rxtx/2.2/rxtx-2.2.pom]
Resource missing. [HTTP GET: https://dl.google.com/dl/android/maven2/org/rxtx/rxtx-native/2.2/rxtx-native-2.2.pom]
Resource missing. [HTTP GET: https://repo.jfrog.org/artifactory/libs-release-bintray/org/rxtx/rxtx-native/2.2/rxtx-native-2.2.pom?referrer]
Resource missing. [HTTP GET: http://ftp1.digi.com/support/m-repo/org/rxtx/rxtx-native/2.2/rxtx-native-2.2.pom]
Could not execute [class org.jetbrains.kotlin.gradle.plugin.statistics.DefaultKotlinBuildStatsService.buildFinished]

Related issues: #16

ble_micropython_sample

Hi,
this sample is running MicroPython application that is running on the XBee to read and send the temperature and humidity values.
I want to do the same thing on Network discovery Mictopython application. ( I have the code from the samples of Digi xbee)
How can I do it? what i need to change on android studio?
thanks!

How to create .jar of this library

I am not sure how to package this project into a .jar file.

Is there already a configuration for this? (I am new to Gradle, so I am not sure if I am missing something)

Thanks!

Xbee Device Not Found

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();
            }
        });
    }
}

XBee Android Application from scratch doesn't work anymore

It worked great on Android Studio (Chipmunk on Windows 10).
I upgraded to Android Studio (Iguana on Windows 11), and now it doesn't work anymore.

The problem has something to do with the declarations for the Digi Maven Repository and the XBee Library for Android in the build.gradle files. Android Studio says that the Manifest merger failed with multiple errors.

It's easy to try on Android Studio.

Here is the link on Digi.com:
https://www.digi.com/resources/documentation/digidocs/90001438/tasks/t_create_xb_android_app_scratch.htm?TocPath=User%20Guide%7CAndroid%20integration%7CCreate%20an%20XBee%20Android%20application%7C_____1

USB Device Not Found

Iam using xbee_manager_sample for XBEE3 in Android USB Host Mode with Vendor ID =0x10C4 and PID = 0xEA60 which is not given in the AndroidUSBInterface class of the library. However on adding the device and product ID, the application says "could not determine operating mode".
Kindly suggest the remedial action.

Unable connect device by serial port

The following error message is displayed when a serial port is used to connect the device:
FATAL EXCEPTION: Thread-4
Process: com.digi.xbee.sample.android.xbeemanager, PID: 14513
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/serial/SerialPortHandler;
at com.digi.android.serial.SerialPortManager.(Unknown Source:13)
at com.digi.xbee.api.android.connection.serial.SerialPortDigiAndroid.open(SerialPortDigiAndroid.java:177)
at com.digi.xbee.api.AbstractXBeeDevice.open(AbstractXBeeDevice.java:3109)
at com.digi.xbee.api.XBeeDevice.open(XBeeDevice.java:135)
at com.digi.xbee.sample.android.xbeemanager.managers.XBeeManager.openConnection(XBeeManager.java:329)
at com.digi.xbee.sample.android.xbeemanager.XBeeConnectActivity$4.run(XBeeConnectActivity.java:199)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.serial.SerialPortHandler" on path: DexPathList[[dex file "/data/data/com.digi.xbee.sample.android.xbeemanager/code_cache/.overlay/base.apk/classes2.dex", zip file "/data/app/~~NEbohlZRTc84Hgulhau7jQ==/com.digi.xbee.sample.android.xbeemanager-BdWWHJzsDXviPL_GEic6XA==/base.apk"],nativeLibraryDirectories=[/data/app/~~NEbohlZRTc84Hgulhau7jQ==/com.digi.xbee.sample.android.xbeemanager-BdWWHJzsDXviPL_GEic6XA==/lib/arm64, /system/lib64, /system/system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.digi.android.serial.SerialPortManager.(Unknown Source:13) 
at com.digi.xbee.api.android.connection.serial.SerialPortDigiAndroid.open(SerialPortDigiAndroid.java:177) 
at com.digi.xbee.api.AbstractXBeeDevice.open(AbstractXBeeDevice.java:3109) 
at com.digi.xbee.api.XBeeDevice.open(XBeeDevice.java:135) 
at com.digi.xbee.sample.android.xbeemanager.managers.XBeeManager.openConnection(XBeeManager.java:329) 
at com.digi.xbee.sample.android.xbeemanager.XBeeConnectActivity$4.run(XBeeConnectActivity.java:199) 
at java.lang.Thread.run(Thread.java:1012) 

TimeoutException while using xbee-android library and sample application with XBEE3 USB module using Android USB host interface

Hi,

I am trying to use a XBEE3 dongle loaded with Zigbee 3.0 firmware with xbee-android library and xbee-manager sample application. I am always getting receive timeout exception from the dongle while opening the connection. The USB serial interface connection using Android USB manager seems to be fine and there is no error while writing the packet. However, it seems I am not getting the response back in the expected format.
For example, while trying to determine the operating mode, it tries to get the value of "AP" parameter, the response for that is never received. The same thing happens with other parameters in readDeviceInfo().
I tried changing the operating mode using XCTU app on desktop as well. No success.

I also checked that my dongle FT232R is included in the list of supported devices.
I am not sure what is it I am missing here. Could anybody help?

react-native support

Hello,

I did not find library which can be used by react-native to enable Xbee ble. I did start my own package which is wrapping this library and can be used there. For someone who wants to use it check it here react-native-xbee-ble.

Cheers,
Dan

build failed

Hi,
I want to build and run the exmaple "ble_configuration_sample".
Build failed bc: The specified Android SDK Build Tools version (29.0.0) is ignored, as it is below the minimum supported version (29.0.2) for Android Gradle Plugin 4.0.0.
i changed it to 29.0.2 but it still make the same error
image

Thanks in advance!

XBee Android Application from scratch doesn't work anymore

I built a XBee Android Application from scratch for a XBee3 Cellular AT&T module.

It worked great on Android Studio (Chipmunk on Windows 10).
I upgraded to Android Studio (Iguana on Windows 11), and now it doesn't work anymore.

The problem has something to do with the declarations for the Digi Maven Repository and the XBee Library for Android in the build.gradle files. Android Studio says that the Manifest merger failed with multiple errors.

It's easy to try on Android Studio.

Here is the link on Digi.com:
https://www.digi.com/resources/documentation/digidocs/90001438/tasks/t_create_xb_android_app_scratch.htm?TocPath=User%20Guide%7CAndroid%20integration%7CCreate%20an%20XBee%20Android%20application%7C_____1

Thanks
Bryan

email: [email protected]

Add support for UART XR21V1410 USB-UART IC

File affected: /xbee_android_library/src/main/java/com/digi/xbee/api/android/connection/usb/AndroidUSBInterface.java

Please add support for XR21V1410 USB-UART IC:

Vendor ID: 0x04E2
Product ID: 0x1410

Is it possible to connect to multiple XbeeDevices (USB) on a normal Android device?

Hello,

I was wondering if it is possible to connect to multiple XbeeDevices on one Android device? The XbeeDevices are connected via USB using a USB-Hub.

I was looking through the documentation & found that you anticipate using multiple devices when using Digi Embedded device however I was wondering if it is also possible using a simple USB-Hub connected directly to the Android device?

I am using an Xbee SX 868 & Xbee3 connected to a Samsung Galaxy Tab (SM-T515).

The USB-Hub is powered externally.

Thank you!

Rxtx Native not working with last version of Gradle

I'm trying to use the library with last version of android, wrapper and android gradle plugin but I cannot import the dependency because rxtx and rxtx-native 2.2 are not found. The versions are the following:

Gradle Wrapper: 6.1.1
Android gradle plugin: 4.0.0
buildToolsVersion = 29.0.2
targetVersion = 29
compileVersion = 29

In order to work I changed my configuration to:

Gradle Wrapper: 5.5.1
Android gradle plugin: 3.5.0
buildToolsVersion = 29.0.0
targetVersion = 28
compileVersion = 28

Listener Error While Receiving Data from Two Xbees at Once Via Bluetooth

Hi, I'm fairly new to Kotlin and Android so this might end up being a silly mistake.

I'm trying to design an app which will connect to two XBee3 modules at once via Bluetooth and continuously receive User Data Relay messages from them. I also use Kotlin coroutines to help with threading and preventing the app from being blocked.

I define both device variables and two IUserDataRelayReceiveListeners like this:

@Volatile var xBeeDevice1: XBeeBLEDevice? = null
@Volatile var xBeeDevice2: XBeeBLEDevice? = null

private val xBeeUserDataListener1 = IUserDataRelayReceiveListener {

        GlobalScope.launch {

                  //receive and process User Data Relay string
             
        }
}

private val xBeeUserDataListener2 = IUserDataRelayReceiveListener {

        GlobalScope.launch {

                  //receive and process User Data Relay string
             
        }
}

I then created two functions which connect to each XBee in the background (I'm just showing the connect function for xBeeDevice1):

private fun xBee1Connect() {

    val device = XBeeBLEDevice(this, xBee1MacAddress, xBeePassword)

    xBeeConnectJob = GlobalScope.launch(Dispatchers.IO){

        //try connecting to the XBee
        try {

            // Open the connection with the device.
            device.open()

            // If the open method did not throw an exception, the connection is open.
            runOnUiThread {
                Toast.makeText(applicationContext, "XBEE connection successful!", Toast.LENGTH_SHORT).show()

                xBeeDevice1 = device

                //if thread finished successfully then send the connected device to the main UI
                xBeeDevice1!!.addUserDataRelayListener(xBeeUserDataListener1)

            }

        } catch (e: BluetoothAuthenticationException) {
            // There was a problem in the Bluetooth authentication process, so ask for the password again.
            e.printStackTrace()

        } catch (e: XBeeException) {
            e.printStackTrace()

        }

        if (!device.isOpen) {
        }

    }
}

Everything works great, and both Listener functions receive and process the data concurrently. I also have a Broadcast Receiver which will detect when they disconnect, and it will run the disconnect() function on the proper XBee device.

I believe I have discovered a bug when I turn off one of the XBees while they are both actively connected. Sometimes (not all the time) the Listener for the other XBee will stop receiving data and not work, so then I'll have to reconnect to get it working again.

So, for example, if I shut power off of xBeeDevice1 then xBeeUserDataListener2 will sometimes stop receiving data, even though xBeeDevice2 is still active.

Do you have any idea how this might be happening? Are the two separate UserDataRelayListeners somehow linked together?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.