Bluetooth Probe integration for DLMS meters

15 posts / 0 new
Last post
SarbjitSingh
Bluetooth Probe integration for DLMS meters

Hi,

I want to know how to perform a GXDLMSSecureClient and other functions through bluetooth socket in android.

Regards,
Sarbjit Singh

Kurumi
Kurumi's picture

Hi,

You need to send generated bytes over Bluetooth by your self. GXDLMSSecureClient doesn't care how you send or receive bytes.

BR,
Mikko

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

SarbjitSingh

Thanks for your quick response.

Actually I have my serial code as below:
public void readDLMSPacket(byte[] data, GXReplyData reply)
throws Exception {

if (data == null || data.length == 0) {
return;
}
reply.setError((short) 0);
Object eop = (byte) 0x7E;
Integer pos = 0;
boolean succeeded = false;
ReceiveParameters<byte[]> p = new ReceiveParameters<>(byte[].class);
p.setAllData(true);
p.setEop(eop);
p.setCount(5);
p.setWaitTime(WaitTime);
synchronized (serial.getSynchronous()) {
while (!succeeded) {
serial.send(data, null);
if (p.getEop() == null) {
p.setCount(1);
}
succeeded = serial.receive(p);
if (!succeeded) {
// Try to read again...
if (pos++ == 3) {
throw new RuntimeException(
"Failed to receive reply from the device in given time." + GXCommon.bytesToHex(p.getReply()));
}
Log.i("gurux.dlms", "Data send failed. Try to resend "
+ pos.toString() + "/3");
}
}
// Loop until whole DLMS packet is received.
while (!secureClient.getData(p.getReply(), reply)) {
if (p.getEop() == null) {
p.setCount(1);
}
if (!serial.receive(p)) {
// If echo.
if (reply.isEcho()) {
serial.send(data, null);
}
// Try to read again...
if (++pos == 3) {
throw new Exception(
"Failed to receive reply from the device in given time2." + GXCommon.bytesToHex(p.getReply()));
}
Log.i("gurux.dlms", "Data send failed. Try to resend "
+ pos.toString() + "/3");
}
}
}
if (reply.getError() != 0) {
if (reply.getError() == ErrorCode.REJECTED.getValue()) {
Thread.sleep(1000);
readDLMSPacket(data, reply);
} else {
throw new GXDLMSException(reply.getError());
}
}
}

There are a few functions which are serial specific. I am unable to convert them for socket. If I send the bytes directly to socket. I get the same response as the request.

Your help would be deeply appreciated.

Thanks & Regards,
Sarbjit Singh

Kurumi
Kurumi's picture

Hi,

It depends on what kind of BlueTooth device you are using. If Bluetooth device implements socket you can use network media. I believe that you need to make own media for Bluetooth.

BR,

Mikko

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

SarbjitSingh

Sir,

We are using BLE with the help of a bluetooth probe. We are using BluetoothGattCallback for sending and receiving request. Can you please give an example or any idea on how to implement GXDLMS with this.

Thanks !

Regards,
Sarbjit Singh

Kurumi
Kurumi's picture

Hi,

I believe best way to go is if you create new media. Select GXNet as template and change open, close, send and receive methods to communicate with your Bluetooth. In this way you don't need to change anything from the example. Othere option is that you made changes for the example for sending and receiving bytes over Bluetooth.

BR,

Mikko

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

SarbjitSingh

Hello Sir,

I am still stuck with the BLE communication with the DLMS meter. On sending the request to the BLE I am receiving junk hex values. Please help me with this.

Thanks !

Regards,
Sarbjit Singh

SarbjitSingh

Hello Sir,

I am still stuck with the BLE communication with the DLMS meter. On sending the request to the BLE I am receiving junk hex values. Please help me with this.

Thanks !

Regards,
Sarbjit Singh

Kurumi
Kurumi's picture

Hello Sir,

What kind of data you are sending and receiving? Can you paste sent and received hex strings here?

BR,

Mikko

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

SarbjitSingh

Sir,

This the authentication request:
7E A0 07 03 41 93 5A 64 7E

I am sending it through GXDLMSSecure client as:
secureClient = new GXDLMSSecureClient(true, 32, 1, Authentication.LOW, "lnt1", InterfaceType.HDLC);

I am giving you the converted response.

Regards,
Sarbjit Singh

Kurumi
Kurumi's picture

Hi,

The request is correct. What is the reply?

BR,
Mikko

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

SarbjitSingh

Sir,

Please see the attached screenshot after last 7E. I am receiving that response with error.

Thanks !

Regards,
Sarbjit Singh

Image: 
Kurumi
Kurumi's picture

Hi,

Can you print reply as hex string?

BR,

Mikko

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

SarbjitSingh

Sir,

Please see the response in hex below the error message in attached screenshot.

Regards,
Sarbjit SIngh

Image: 
Kurumi
Kurumi's picture

Hi,

This is the echo. This is not a reply from the meter. You have sent this data.

BR,

Mikko

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