Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Integrating Gurux.DLMS.Android Library Into React Native App

Integrating Gurux.DLMS.Android Library into React Native App

By piyushupadhyay, 4 April, 2024
Forums
Gurux DLMS for Android

I need to integrate DLMS/COSEM meter communication into a React Native mobile application. I came across the Gurux.DLMS.Android library, which seems to provide the functionality I need.

However, as someone relatively new to Java and unfamiliar with the inner workings of the Gurux library, I'm seeking advice and guidance on how to integrate it into my React Native project.

Here are a few specific questions I have:

1. Which classes/functions within the Gurux.DLMS.Android library should I focus on bridging for meter communication and data reading functionalities?

2. Are there any best practices or recommended approaches for bridging Java/Kotlin functionalities to React Native, especially for someone with limited Java experience?

3. How can I ensure compatibility and seamless interaction between the Gurux library and my React Native app.

Any tips or advice from those who have experience with similar integrations would be greatly appreciated. Also, If there are any resources that could help me better understand the usage of the Gurux library within a React Native context, please share them.

I can do the BLE part in the react native app itself.

Thank you in advance for your assistance!

Akash

1 year 2 months ago

hi piyushupadhyay i am…

hi piyushupadhyay i am facing same problem
form React Native JS class Through i am opening Android Activity and getting data
but i need to do click functionality in React Native

Profile picture for user Kurumi

Kurumi

1 year 2 months ago

Hi, You need all classes…

Hi,

You need all classes. DLMS is not a very simple protocol and it's offering lots of features.

Our clients are not using React Native, so I can't help you with this.

BR,
Mikko

delanou

1 year 1 month ago

Include Gurux DLMS library …

You'll need to include Gurux DLMS Android library as Native Module in React Native (v0.62.3):

1. Generate the Gurux DLMS client library (.aar file)*. (Change default name "app-debug" to something meaningful)
2. Copy .aar file into /YOUR_REACT_NATIVE_APP/android/app/libs
(If you don't have libs folder, create a new one)
3. Add the following dependencies to android/app/build.gradle:

```gradle
implementation files('libs/gurux_dlms.aar')
implementation 'com.github.gurux:gurux.common.android:-SNAPSHOT'
implementation 'com.github.gurux:gurux.serial.android:-SNAPSHOT'
```

4. Modify the minSdkVersion in the android/build.gradle file from 21 to 28.
5. Modify android:allowBackup="false" to android:allowBackup="true" in the android/app/src/main/AndroidManifest.xml file.
6. Copy and paste the GXDevice.java file from Gurux DLMS Android repo -> https://github.com/Gurux/Gurux.DLMS.Android/blob/master/Java/app/src/ma… to android/app/src/main/java/com/YOUR_PROJECT/GXDevice.java.
7. Create the files DLMSClientModule.java, DLMSClientPackage.java (or name those files to anything you like), and modify MainApplication.java to include DLMSClientPackage. (Read this: https://reactnative.dev/docs/native-modules-android)
8. In the file where you'll use the native methods, add:

```javascript
import {
NativeModules,
} from 'react-native';
const MyNativeModule = NativeModules.YOUR_MODULE_NAME_HERE;
```

*To generate a .aar file in Android Studio, follow these steps:

1. Clone the GitHub repository - Gurux/Gurux.DLMS.Android: Gurux DLMS library for Android.
2. Open it with Android Studio.
3. Verify/wait for Gradle to download all necessary dependencies for the project.
4. Go to Build > Clean Project.
5. Go to Build > Rebuild Project.
6. Find the generated file (.aar) in ./AndroidStudioProjects/guruxDLMS/guruxlibrary/build/outputs.

Profile picture for user Kurumi

Kurumi

1 year 1 month ago

Hi delanou, Thank you for…

Hi delanou,

Thank you for this information. It's interesting if Java packages can be used from React Native without any changes. This means that you can use builds from Maven Central and you only need to add those components for your grade like this:

implementation 'org.gurux:Gurux.Common.Android:2.0.2'
implementation 'org.gurux:gurux.serial.android:2.0.3'
implementation 'org.gurux:gurux.dlms.android:2.0.4'

BR,
Mikko

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Thu, 06/19/2025 - 09:33
    Gurux.DLMS.Python 1.0.185
  • Wed, 06/18/2025 - 15:11
    Gurux.DLMS.Python 1.0.184
  • Wed, 06/18/2025 - 10:05
    Gurux.DLMS.Python 1.0.183
  • Wed, 06/18/2025 - 09:06
    GXDLMSDirector 9.0.2506.1801
  • Wed, 06/18/2025 - 08:41
    Gurux.DLMS.Net 9.0.2506.1801

New forum topics

  • Unable to read parameter values from Landis+Gyr E550 meter using GXDLMSDirector - NoAccess status
  • data.SetComplete(false); But all data recieved
  • Crash (endless loop)
  • Server is not able to download object list with maxPduSize 64 or 128 (or anything below 156-bytes PDU size)
  • Day profile action item add error (String is not recognized as valid DateTime value)
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin