Content of the push notification packet can be anything. Content is not defined on the DLMS standard. If OBIS code is added to the Push message, it can be read from there.
You need to read PushObjectList from the meter and save it somewhere. You can parse received data when you know the push objects. See more from the push listener example.
Hi,
1.Can you direct me how exactly i can get the push object list , like before my listener actually receives the push notification or is it something like the listener needs to know the set of values that might come in push notification.
2.Also the second approach that is mentioned in the sample code where like meter describes the content, can you give some reference on how exactly i can write that.Below is a sample code snippet on how i am creating the push notification and sending it, if you can suggest the changes for below that would be really help full.
List<GXSimpleEntry<GXDLMSObject, GXDLMSCaptureObject>> objects = new ArrayList<>();
GXDLMSRegister VOLTAGE_REGISTER = new GXDLMSRegister();
VOLTAGE_REGISTER.setObjectType(ObjectType.REGISTER);
VOLTAGE_REGISTER.setDescription(Unit.VOLTAGE.toString());
VOLTAGE_REGISTER.setLogicalName(Unit.VOLTAGE.toString());
VOLTAGE_REGISTER.setScaler(1);
VOLTAGE_REGISTER.setUnit(Unit.VOLTAGE);
VOLTAGE_REGISTER.setValue(60);
VOLTAGE_REGISTER.setDataType(2, DataType.INT8);
1. If push object is not part of the push messages you need to know what objects are sent in the push message and you need to add them to the push object list. You can get the list if you read the Push object list from the meter.
Hi,
Thank you for the quick reply.So I understood the parsing of push messages, but i am not able to understand how exactly i can make push objects a part of push message.Like for reference the code snippet i shared above is simulating the meter.So here when i am adding the push object list and sending the push notification to a listener.Now when i try to get the push object list at listener side it throws an error because its expecting a description i.e a sort of list of push objects.
For ref : (This is taken from the push listener example)
Now if send the push notification as shown in the above reply, the notification is received at listener side but it fails for me when i call client.parsePushObjects() method on the listener side.So i want to understand how can change the meter sample code to add that data description when i am sending the push notification.
You can use parsePushObjects if you have added push object as a first item for the push objects. Like this:
objects.add(new GXSimpleEntry<GXDLMSObject, GXDLMSCaptureObject>(p, new GXDLMSCaptureObject(2, 0)));
The objects is a collection from your code.
If the push object list is not sent in the part of the Push message, you need to add push objects for the push object list and use getPushValues to update values.
Hi ,
I had another question ,say there is single push listener and there are n no of meter trying to send push notification to the listener. so from meter side is there any specific value that i need to set in order to differentiate between meters.
It's always good to add the Logical Name of the meter first and the Logical Name of the push object second for all push messages. In that way, you will know the sender and sent push object before you start to parse it.
Hi,
Hi,
Content of the push notification packet can be anything. Content is not defined on the DLMS standard. If OBIS code is added to the Push message, it can be read from there.
BR,
Mikko
Hi,
Hi,
If the push notification packet doesn't have any information about OBIS, is there any way we can get it, as part of the connection/message.
Hi,
Hi,
You need to read PushObjectList from the meter and save it somewhere. You can parse received data when you know the push objects. See more from the push listener example.
https://github.com/Gurux/Gurux.DLMS.Net/blob/ee85ea5c64a84372c0d96237bf…
BR,
Mikko
Hi,
Hi,
1.Can you direct me how exactly i can get the push object list , like before my listener actually receives the push notification or is it something like the listener needs to know the set of values that might come in push notification.
2.Also the second approach that is mentioned in the sample code where like meter describes the content, can you give some reference on how exactly i can write that.Below is a sample code snippet on how i am creating the push notification and sending it, if you can suggest the changes for below that would be really help full.
List<GXSimpleEntry<GXDLMSObject, GXDLMSCaptureObject>> objects = new ArrayList<>();
GXDLMSRegister VOLTAGE_REGISTER = new GXDLMSRegister();
VOLTAGE_REGISTER.setObjectType(ObjectType.REGISTER);
VOLTAGE_REGISTER.setDescription(Unit.VOLTAGE.toString());
VOLTAGE_REGISTER.setLogicalName(Unit.VOLTAGE.toString());
VOLTAGE_REGISTER.setScaler(1);
VOLTAGE_REGISTER.setUnit(Unit.VOLTAGE);
VOLTAGE_REGISTER.setValue(60);
VOLTAGE_REGISTER.setDataType(2, DataType.INT8);
GXDLMSRegister ELECTRIC_CHARGE_REGISTER = new GXDLMSRegister();
ELECTRIC_CHARGE_REGISTER.setObjectType(ObjectType.REGISTER);
ELECTRIC_CHARGE_REGISTER.setDescription(Unit.ELECTRICAL_CHARGE.toString());
ELECTRIC_CHARGE_REGISTER.setLogicalName(Unit.ELECTRICAL_CHARGE.toString());
ELECTRIC_CHARGE_REGISTER.setScaler(1);
ELECTRIC_CHARGE_REGISTER.setUnit(Unit.ELECTRICAL_CHARGE);
ELECTRIC_CHARGE_REGISTER.setValue(10);
ELECTRIC_CHARGE_REGISTER.setDataType(2, DataType.INT8);
objects.add(new GXSimpleEntry<>(VOLTAGE_REGISTER, new GXDLMSCaptureObject(2, 0x11)));
objects.add(new GXSimpleEntry<>(ELECTRIC_CHARGE_REGISTER, new GXDLMSCaptureObject(2, 0x11)));
gxdlmsPushSetup.getPushObjectList().addAll(objects);
gxdlmsPushSetup.getAttributeIndexToRead(true);
try (GXNet conn = new GXNet(NetworkType.TCP, host, port)) {
conn.open();
byte[][] data = notify.generatePushSetupMessages(null, gxdlmsPushSetup);
for (byte[] p : data) {
log.info("{}",p);
log.info("{}", GXCommon.bytesToHex(p));
conn.send(p, null);
}
log.info("Push notification sent successfully");
} catch (Exception e) {
log.error("Unable to send push notification : {}", e);
}
Hi,
Hi,
1. If push object is not part of the push messages you need to know what objects are sent in the push message and you need to add them to the push object list. You can get the list if you read the Push object list from the meter.
https://www.gurux.fi/Gurux.DLMS.Objects.GXDLMSPushSetup
2. You can parse data if you know the push object list. Something like this:
gxdlmsPushSetup.GetPushValues(client, (List<object>)notify.Value);
Now you have DLMS COSEM objects and values saved to the Push object list of the gxdlmsPushSetup.
BR,
Mikko
Hi,
Hi,
Thank you for the quick reply.So I understood the parsing of push messages, but i am not able to understand how exactly i can make push objects a part of push message.Like for reference the code snippet i shared above is simulating the meter.So here when i am adding the push object list and sending the push notification to a listener.Now when i try to get the push object list at listener side it throws an error because its expecting a description i.e a sort of list of push objects.
For ref : (This is taken from the push listener example)
List<Object> tmp = (List<Object>) notify.getValue();
List<Entry<GXDLMSObject, Integer>> objects = client
.parsePushObjects((List<?>) tmp.get(0));
Now if send the push notification as shown in the above reply, the notification is received at listener side but it fails for me when i call client.parsePushObjects() method on the listener side.So i want to understand how can change the meter sample code to add that data description when i am sending the push notification.
Hi,
Hi,
You can use parsePushObjects if you have added push object as a first item for the push objects. Like this:
objects.add(new GXSimpleEntry<GXDLMSObject, GXDLMSCaptureObject>(p, new GXDLMSCaptureObject(2, 0)));
The objects is a collection from your code.
If the push object list is not sent in the part of the Push message, you need to add push objects for the push object list and use getPushValues to update values.
BR,
Mikko
Hi ,
Hi ,
As you suggested it worked perfectly for me .Just wanted to thank you for the quick replies and your help.
Thank you
Hi ,
Hi ,
I had another question ,say there is single push listener and there are n no of meter trying to send push notification to the listener. so from meter side is there any specific value that i need to set in order to differentiate between meters.
Hi,
Hi,
It's always good to add the Logical Name of the meter first and the Logical Name of the push object second for all push messages. In that way, you will know the sender and sent push object before you start to parse it.
https://www.gurux.fi/Gurux.DLMS.Objects.GXDLMSPushSetup
BR,
Mikko