I am trying to Disconnect and Reconnect DLMS smart meter(HPL) using Optical probe. Below log which one I am getting.
Invocation Counter: 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01
AARE Hex: 61 69 A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 0E A4 0A 04 08 48 50 4C 00 00 2E 9D 08 88 02 07 80 89 07 60 85 74 05 08 02 02 AA 12 80 10 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 BE 23 04 21 28 1F 30 00 00 00 00 A6 86 76 6C 80 E7 39 F8 47 C5 AC 8A CD DF 56 89 35 E2 9F 96 4E 39 0B 57 9C C8
TX: 7E A0 2C 03 61 32 AC BC E6 E6 00 C8 1E 30 DF 3F 19 7F 94 EF 1A F5 E3 1B 26 03 56 18 6C 9F 1A 83 72 83 CC 4A 3F 52 45 9F AF 84 80 B4 CA 7E
RX: 7E A0 07 61 03 51 67 44 7E
ASSO Hex:
Objects in meter: 0
Relay Output State: null
Control mode: null
Please guide me how to achieve.
Hi, You didn't share the…
Hi,
You didn't share the block cipher key, so I'm unable to verify this.
I believe that one of your settings is different from what the meter expects. Try to connect with GXDLMSDirector and then use the same settings in your Android app.
BR,
Mikko
client= new…
client= new GXDLMSSecureClient();
client.setUseLogicalNameReferencing(true);
client.setClientAddress(48);
client.getCiphering().setSecurity(Security.AUTHENTICATION_ENCRYPTION);
client.setAuthentication(Authentication.HIGH);
client.setInterfaceType(InterfaceType.HDLC);
client.getCiphering().setAuthenticationKey(hexStringToByteArray("31323334414243443132333441424344")); // 16 bytes
client.getCiphering().setBlockCipherKey(hexStringToByteArray("31323334414243443132333441424344")); // 16 bytes
client.getCiphering().setDedicatedKey(hexStringToByteArray("31323334414243443132333441424344"));
GXDLMSData invocationCounterObj = new GXDLMSData(OBIS_CONNECT);
invocationCounterObj.setObjectType(ObjectType.DATA);
Object value = client.read(invocationCounterObj, 2);
long counterValue = toLongFromInvocationCounter(value);
client.getCiphering().setInvocationCounter(counterValue+1);
client.getCiphering().setSystemTitle(hexStringToByteArray("48504C3732393938"));
// SNRM Code …
// SNRM Code
GXReplyData reply = new GXReplyData();
byte[] readRequest = client.snrmRequest();
byte[] replyBytes = sendAndReceive(readRequest);
client.getData(replyBytes, reply);
if (reply.getData() != null) {
System.out.println("Invocation Counter: " + reply.getData());/// print : Invocation Counter: 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01
client.parseUAResponse(reply.getData());
} else {
System.err.println("No data in reply");
}
// 4. Association: AARQ → AARE
byte[][] aarqFrames = null;
try {
aarqFrames = client.aarqRequest();
} catch (InvalidKeyException e) {
Toast.makeText(this, "InvalidKeyException", Toast.LENGTH_LONG).show();
throw new RuntimeException(e);
} catch (NoSuchAlgorithmException e) {
Toast.makeText(this, "NoSuchAlgorithmException", Toast.LENGTH_LONG).show();
throw new RuntimeException(e);
} catch (NoSuchPaddingException e) {
Toast.makeText(this, "NoSuchPaddingException", Toast.LENGTH_LONG).show();
throw new RuntimeException(e);
} catch (InvalidAlgorithmParameterException e) {
Toast.makeText(this, "InvalidAlgorithmParameterException", Toast.LENGTH_LONG).show();
throw new RuntimeException(e);
} catch (IllegalBlockSizeException e) {
Toast.makeText(this, "IllegalBlockSizeException", Toast.LENGTH_LONG).show();
throw new RuntimeException(e);
} catch (BadPaddingException e) {
Toast.makeText(this, "BadPaddingException", Toast.LENGTH_LONG).show();
throw new RuntimeException(e);
} catch (SignatureException e) {
Toast.makeText(this, "SignatureException", Toast.LENGTH_LONG).show();
throw new RuntimeException(e);
}
for (byte[] frame : aarqFrames) {
serialOutput.write(frame);
}
byte[] aare = readResponse();
GXReplyData repl1y = new GXReplyData();
client.getData(new GXByteBuffer(aare), repl1y);
System.out.println("AARE Hex: " + bytesToHex(repl1y.getData().array()));/// Print : AARE Hex: 61 69 A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 0E A4 0A 04 08 48 50 4C 00 00 2E 9D 08 88 02 07 80 89 07 60 85 74 05 08 02 02 AA 12 80 10 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 BE 23 04 21 28 1F 30 00 00 00 00 A6 86 76 6C 80 E7 39 F8 47 C5 AC 8A CD DF 56 89 35 E2 9F 96 4E 39 0B 57 9C C8
client.parseAareResponse(new GXByteBuffer(repl1y.getData()));
GXDLMSObject associationObject = new GXDLMSAssociationLogicalName();
associationObject.setObjectType(ObjectType.ASSOCIATION_LOGICAL_NAME);
associationObject.setLogicalName("0.0.43.1.3.255");
//associationObject.setLogicalName("0.0.40.0.0.255");
byte[][] requestFrames = client.read(associationObject, 2);
GXReplyData reply2 = new GXReplyData();
//readDLMSPacket(requestFrames,reply2);
for (byte[] frame : requestFrames) {
serialPort.write(frame,200);
do {
printTX(frame); /// Print : TX: 7E A0 2C 03 61 32 AC BC E6 E6 00 C8 1E 30 DF 3F 19 7F 94 EF 1A F5 E3 1B 26 03 56 18 6C 9F 1A 83 72 83 CC 4A 3F 52 45 9F AF 84 80 B4 CA 7E
byte[] frameResponse = sendAndReceive(frame);
printRX(frameResponse);/// Print : RX: 7E A0 07 61 03 51 67 44 7E
// Read and parse reply for each frame
reply = readDLMSReplyNew();//readDLMSReply(); // Your helper method
client.getData(new GXByteBuffer(reply.getData()), reply);
client.getData(new GXByteBuffer(frameResponse), reply2);
System.out.println("ASSO Hex: " + bytesToHex(reply2.getData().array())); /// Print : ASSO Hex:
// client.parseApplicationAssociationResponse(reply2.getData());
} while (reply2.isMoreData());
}
// Update object list in the client (only after last frame)
if (!reply2.isMoreData()) {
client.updateValue(associationObject, 2, reply2.getValue());
}
System.out.println("Objects in meter: " + client.getObjects().size());///Print : Objects in meter: 0
Hi, You don't send the…
Hi,
You don't send the generated bytes to the meter. Check this:
Object value = client.read(invocationCounterObj, 2);
Check the client example:
https://github.com/Gurux/Gurux.DLMS.Android/blob/651c824c9c39021d762388…
BR,
Mikko
Hello, I am trying to…
Hello,
I am trying to connect meter using optical probe through otg. So what should be below line:
IGXMedia media = mDevice.getMedia();
Hi, If you have connected…
Hi,
If you have connected the optical probe with OTG, it is shown as a serial port.
BR,
Mikko
Sir, How to get IGXMedia …
Sir,
How to get IGXMedia from USBSerialPort?
I am trying this one : public class AndroidSerialMedia implements IGXMedia but its Overridden method "properties" does not working as its need javax.swing.JFrame parent which is not present in android.
Can u please send me source code for Android to connect using OTG?
Hi, Use this: https://github…
Hi,
Use this:
https://github.com/Gurux/Gurux.DLMS.Android/
BR,
Mikko
Hi, The Gurux Android…
Hi,
The Gurux Android project setup and run successfully in below Android version 15. But in android 15 after Association view confirm pop up it will auto close the app due to ANR. Please suggest.
Hi, Can you add the error…
Hi,
Can you add the error that you are receiving? This is tested and it works without problems with multiple Android 15 phones.
BR,
Mikko
Hi Sir, Below error msg are…
Hi Sir,
Below error msg are coming in android log :
ANR in gurux.dlms.android (gurux.dlms.android/.MainActivity)
PID: 13094
Reason: Input dispatching timed out (b30bcc6 gurux.dlms.android/gurux.dlms.android.MainActivity (server) is not responding. Waited 5000ms for FocusEvent(hasFocus=true)).
Parent: gurux.dlms.android/.MainActivity
ErrorId: 48535856-eb90-4ce4-b1e4-a086cb234935
Dear Sir, We can't repeat…
Dear Sir,
We can't repeat this, but refresh is now moved to the backend thread.
Get the latest version and let me know if you have any issues.
BR,
Mikko
Hi, Getting following error…
Hi,
Getting following error after update latest code.
Process: gurux.dlms.android, PID: 19609
java.util.concurrent.RejectedExecutionException: Task gurux.dlms.android.ui.main.MainFragment$$ExternalSyntheticLambda8@d1e170d rejected from java.util.concurrent.ThreadPoolExecutor@1e3f6c2[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2100)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:851)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1389)
at java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:715)
at gurux.dlms.android.ui.main.MainFragment.readAssociationView(MainFragment.java:101)
at gurux.dlms.android.ui.main.MainFragment.lambda$onCreateView$7$gurux-dlms-android-ui-main-MainFragment(MainFragment.java:209)
at gurux.dlms.android.ui.main.MainFragment$$ExternalSyntheticLambda17.onClick(D8$$SyntheticClass:0)
at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loopOnce(Looper.java:282)
at android.os.Looper.loop(Looper.java:387)
at android.app.ActivityThread.main(ActivityThread.java:9500)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:600)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1005)
KillAction: find invalid process: gurux.dlms.android:19609:2
Hi, Get the latest version…
Hi,
Get the latest version. We were able to repeat this with one old Android phone.
BR,
Mikko
Hi Sir, Its working now…
Hi Sir,
Its working now.. Thank you very much.