Skip to main content
Home
for DLMS smart meters

Main navigation

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

Breadcrumb

  1. Home
  2. Gurux.DLMS with Dynamic IP addresses.
GPRS

Read basic information from Gurux.DLMS component before you start to create DLMS client. Source codes of this example are available on GitHub.

Reading meters using Dynamic IP addresses in GPRS connection

If you want to read your meters using GPRS connection you must have static IP addresses on your meters (SIM card). If you have dynamic IP addresses, your meter must always start the connection to the server. This means that your meter can send example scheduled push messages, but you can't read your meter when you want to. In public GPRS networks, connections are always established from modem to GPRS network, and never from GPRS network to modem. It is not possible for a client application to open a connection.
  • Static IP address: Meter or reading system can start the connection.
  • Dynamic IP address: Meter always starts the connection.
In this document I'll go through the reading meters with dynamic IP addresses superficially and purpose is explain how to get data from the meter when meter uses dynamic IP address. When meters are using dynamic IP addresses or firewall blocks access to the meter, it's possible that meter is scheduled to make connection to the server using TCP/IP connection with given time interval.
Note! All meters do not support this.

In this simple example server waits TCP/IP connections from the meters and when new TCP/IP connection is established it will start to act like DLMS Client. In this example I only show how to establish connection to the meter after meter has made TCP/IP connection. We have used meter that only makes connection to the server. Some meters are first sending some initializing information. Because this is manufacturer depending, I do'y go it through here.

Build

If you want to build source codes you need Nuget package manager for Visual Studio. You can get it here.

Simple example

First we create TCP/IP server what listens given port. We are using GXNet as TCP/IP server.
  • C#
  • Java
GXNet server = new GXNet(NetworkType.Tcp, 1234);
server.OnClientConnected += OnClientConnected;
server.Open();
GXNet server = new GXNet(NetworkType.TCP, 1000);
GXListener listener = new GXListener();
server.addListener(listener);
server.open();

//implement listener class
public class GXListener extends Thread implements IGXMediaListener, IGXNetListener {
}
Main idea is listen incoming connections. When connection is established, we attach connection from server and use connection what meter has made.
  • C#
  • Java
/// <summary>New client is connected. </summary>
/// <param name="sender">Server component.</param>
/// <param name="e">Connection parameters,</param>
private static void OnClientConnected(object sender, Common.ConnectionEventArgs e)
{
    Console.WriteLine("Client {0} is connected.", e.Info);
    GXNet server = (GXNet)sender;
    try
    {
        using (GXNet cl = server.Attach(e.Info))
        {
            GXDLMSReader cl = new Net.GXDLMSReader(media);
            cl.ReadAll();
            //Create own thread for each meter if you are handling multiple meters simultaneously.
            //new Thread(new ThreadStart(cl.ReadAll));
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
}
@Override
public void onClientConnected(Object sender, ConnectionEventArgs e) {
    System.out.println(String.format("Client '%1$s' is connected.", e.getInfo()));
    GXNet server = (GXNet) sender;
    try {
        try (GXNet cl = server.attach(e.getInfo())) {
            readMeter(cl);
        }
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
    }
}
In ReadAll function we initialize connection and read data from the meter. You can access meter as normal client. You can find more information how to read your meter from Gurux web page.

Note! This is only an example. If you want to read multiple meters at the same time you need to create own thread for each meter.
Thats it. If you have any questions or ideas how to improve Gurux.DLMS component let us know or ask question in a Forum

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

Fri, 03/24/2023 - 14:22
gurux.dlms.c 20230324.1
Thu, 03/23/2023 - 11:01
GXDLMSDirector 9.0.2303.2301
Thu, 03/23/2023 - 09:10
Gurux.DLMS.Python 1.0.142
Wed, 03/22/2023 - 13:51
Gurux.DLMS.Net 9.0.2303.2201
Wed, 03/22/2023 - 10:15
gurux.dlms.c 20230322.1

Open bugs

Gurux.DLMS.AMI4
1
Gurux.DLMS.Android
1
gurux.dlms.c
3
gurux.dlms.cpp
3
gurux.dlms.delphi
1
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin