Import Gurux DLMS into my Android project

8 posts / 0 new
Last post
dataco
Import Gurux DLMS into my Android project

Hi,

How can I import Gurux DLMS library into my Android project.

I don't have found the JAR or AAR file on GitHub

Thank you

Massimo

Kurumi
Kurumi's picture

Hi Massimo,

You can do it by add this to dependencies:

implementation 'com.github.gurux:gurux.dlms.android:-SNAPSHOT'

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

dataco

Thanks Mikko !

The communcation is ok in my app. I communicate with the meter using BT probe

Wich functions must I call to decrypt the response of the DLMS meter ?
For example to decrypt the register 1

GXDLMSDirector 8.2.2104.2901
Log created 14:29:31
14:29:34 Read object type Register index: 1
7E A0 11 03 03 30 26 0E E6 E6 00 05 01 02 6D 60 03 25 7E
14:29:34
7E A0 17 03 03 32 AE 66 E6 E7 00 0C 01 00 09 06 01 01 01 08 01 FF 7A 30 7E
14:29:34 Read object type Register index: 3
7E A0 11 03 03 52 32 4E E6 E6 00 05 01 02 6D 70 82 35 7E
14:29:35
7E A0 15 03 03 54 E8 59 E6 E7 00 0C 01 00 02 02 0F 00 16 1E CC 34 7E
14:29:35 Read object type Register index: 2
7E A0 11 03 03 74 06 0A E6 E6 00 05 01 02 6D 68 4B A9 7E
14:29:35
7E A0 14 03 03 76 43 47 E6 E7 00 0C 01 00 06 00 00 26 90 80 60 7E

Kurumi
Kurumi's picture

Hi,

You create an object like this:
GXDLMSRegister reg = new GXDLMSRegister("LOGICAL_NAME");
//Read scaler and unit.
readObject(reg, 3);
//Read value.
readObject(reg, 2);
Objec value = reg.getValue();
You can find readObject from GXMain.java.

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

dataco

Thanks.

In my developer tool(Windev mobile), I must integrate a jar or aar file. I can't directly integrate java file.

I dont't see any jar file into you library. Do you have one ?

Kurumi
Kurumi's picture

Hi,

You need to compile android lib or add this to dependencies:

implementation 'com.github.gurux:gurux.dlms.android:-SNAPSHOT'

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

delanou

Hey Mikko! I've added the dependency you point out in the comment above into build.gradle file on a new Empty Activity Project (Android Studio) like this:

plugins {
id 'com.android.application'
}

android {
compileSdk 30

defaultConfig {
applicationId "com.example.myapplication"
minSdk 21
targetSdk 30
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.github.gurux:gurux.dlms.android:-SNAPSHOT'

testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

but when I try to sync I get the following message: "Failed to resolve: com.github.gurux:gurux.dlms.android:-SNAPSHOT".

- The version of Android Studio I am using is 2020.3.1 Patch 3 (SDK 21, Android 5.0 +) and the version of Gradle is 7.0.2 -

Am I doing something wrong?

Thanks,
Nico.

Kurumi
Kurumi's picture

Hi Nico,

Please, create a new topic if you have a new question. Create a new topic and I'll answer this.
http://www.gurux.fi/ForumRules

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi