I need to integrate DLMS meter communication into a React Native mobile application.
Here are a few specific questions I have:
React Native JS class Through i am opening Android Activity and getting data
but i need to do click functionality in React Native can any one help me out of this solution
Hi, Our clients are not…
Hi,
Our clients are not using React Native at the moment, so I can't help you with this.
BR,
Mikko
You'll need to include Gurux…
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:
implementation files('libs/gurux_dlms.aar')
implementation("org.gurux:Gurux.Common.Android:2.0.1")
implementation("org.gurux:gurux.serial.android:2.0.1")
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:
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.
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