Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Using Push Setup With Arduino (ESP32) and DLMS Director

Using Push Setup with Arduino (ESP32) and DLMS director

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By bhatiasidharth.89 , 23 September, 2021
Forums
General discussion

Hi Mikko,

I am trying to get the push setup working for the Arduino server example on the ESP-32. I was able to connect the server to DLMS director over TCP/IP connection on a local WiFi network. I did this by using the following code in loop to handle client connection after connecting to WiFi and getting the assigned local IP in setup():
void loop() {
static unsigned char tmp[50];
uint32_t start = time_current();
int available;
//Execute invokes when needed.
if (executeTime <= start)
{
Server.run(start, &executeTime);
}

WiFiClient client = server.available(); // Listen for incoming clients

if (client)
{
GXTRACE("New Client.", NULL);
unsigned long currentTime = millis();
unsigned long previousTime = currentTime;
while (client.connected() && currentTime - previousTime <= timeoutTime)
{
available = client.available();
if (available > 0)
{
if (available > sizeof(tmp))
{
available = sizeof(tmp);
}

available = client.readBytes(tmp, available);
GXTRACE_INT("Bytes read = ", available);
if ((available = Server.handleRequest(tmp, available, &reply)) != 0)
{
GXTRACE_INT(PSTR("handleRequest failed:"), available);
bb_clear(&reply);
}
if (reply.size != 0)
{
//Send reply.
GXTRACE("Sending reply to client.", NULL);
client.write(reply.data, reply.size);
client.flush();
bb_clear(&reply);
}
}
}

// Close the connection
client.stop();
GXTRACE("Client disconnected.", NULL);
}
}

I am able to read/write data from/to the meter. But now I need to send push notifications from the meter to the DLMS director over the TCP/IP connection. In the DLMS Director I can see the default setting for push setup->send destination->Service is Hdlc. If I try to change this to Tcp I can not enter anything in the Destination field. Please let me know what do I need to do in the code and the DLMS Director settings to get the push working.

Regards
Sidharth

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi Sidharth,

Hi Sidharth,

This is just on testing. This is released in the next week.
You can't modify the Destination because you don't give the access rights for the client. You need to connect using High authentication and modify getPushSetupAttributeAccess to return DLMS_ACCESS_MODE_READ_WRITE for attribute index #3. That is not used in serial port communication.

BR,
Mikko

BR,
Mikko

bhatiasidharth.89

4 years 8 months ago

Thanks Mikko.

Thanks Mikko.
I tried this and now the Destination is editable for high authentication. But if I try to write this setting to the meter I get this error "Access Error: Device reports Read-Write denied".

Another thing that I noticed is that if the meter is connected over serial connection then the debug port shows the following lines at the set push intervals but doesn't show these lines when the connection is over TCP/IP:
.:svr_preAction: 40 0.0.25.9.0.255..:sendPush40 0.0.25.9.0.255..:svr_preRead: 1 0.0.42.0.0.255..:svr_postRead: 1 0.0.42.0.0.255..:svr_preRead: 40 0.0.25.9.0.255..:svr_postRead: 40 0.0.25.9.0.255.

Regards
Sidharth

Regards
Sidharth

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi,

Hi,

You need to allocate the memory for the destination in addPushSetup If you aren't using malloc.
Serial port communication doesn't use the Destination field and it's empty in the example.

BR,
Mikko

bhatiasidharth.89

4 years 8 months ago

In reply to Hi, by Kurumi

Hi Mikko,

Hi Mikko,

Can you please give me an example of how to do it. DLMS_IGNORE_MALLOC has been uncommented in gxignore.h.

Thanks

bhatiasidharth.89

4 years 8 months ago

Hi,

Hi,

I added the following lines to the addPushSetup after the line pushSetup.service = DLMS_SERVICE_TYPE_HDLC; and now I am able to write the destination address to the meter. Although, since currently the push is not actually working over TCP/IP I am not able to verify if this works.

unsigned char destination_data [20];
pushSetup.destination.data = destination_data;
pushSetup.destination.capacity = 20;

Is this the correct way to allocate the memory for the destination since DLMS_IGNORE_MALLOC has been uncommented in gxignore.h?

Also, as I mentioned in one of my comments above, another thing that I noticed is that if the meter is connected over serial connection then the debug port shows the following lines at the set push intervals but doesn't show these lines when the connection is over TCP/IP:
.:svr_preAction: 40 0.0.25.9.0.255..:sendPush40 0.0.25.9.0.255..:svr_preRead: 1 0.0.42.0.0.255..:svr_postRead: 1 0.0.42.0.0.255..:svr_preRead: 40 0.0.25.9.0.255..:svr_postRead: 40 0.0.25.9.0.255.

Is this expected behaviour?

Thanks
Sidharth

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi,

Hi,
You can do it like this:
static char DESTINATION[20] = { 0 };
INIT_OBJECT(pushSetup, DLMS_OBJECT_TYPE_PUSH_SETUP, ln));
BB_ATTACH(pushSetup.destination, DESTINATION, 0);

setup-method is called every time when you establish the connection using USB connection. Make sure that setup is called when you are using TCP/IP.

BR,
Mikko

bhatiasidharth.89

4 years 8 months ago

Hi Mikko,

Hi Mikko,

Thanks for the example. I have added this now.

Also, by putting a debug print in the addPushSetup I found out that this method and the setup() method are both getting called by default every time a connection is established using serial as well as TCP/IP. Is this what you mean?

If so then does this mean that I am all set for getting push notifications over TCP/IP connection when the code is released for this?

Thanks
Sidharth

bhatiasidharth.89

4 years 8 months ago

Hi Mikko,

Hi Mikko,

Awaiting your response on this please.

Regards
Sidharth

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi Sidharth.

Hi Sidharth.

That is what I mean. Yes, you need to generate a push message and sent it over TCP/IP connection.
The example will be released after the tests are over.

BR,
Mikko

bhatiasidharth.89

4 years 8 months ago

Hi Mikko,

Hi Mikko,

Any information on when this example will be released?

Thanks

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi,

Hi,

One of our clients asked for improvements in serialization. This is released after that.

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin