Skip to main content
Home
for DLMS smart meters

Main navigation

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

Breadcrumb

  1. Home
  2. CPP Server Push Example - Push Method Shows NoAccess

CPP Server Push Example - Push method shows NoAccess

Profile picture for user jack 001
By jack 001, 29 September, 2025
Forums
Gurux DLMS for ANSI C++

Hi Mikko. In cpp server example, there is a code for creating a push object, like this:
 

///////////////////////////////////////////////////////////////////////
    //Add Push Setup object.
    CGXDLMSPushSetup* pPush = new CGXDLMSPushSetup();
    address += ":7000";
    pPush->SetDestination(address);
    GetItems().push_back(pPush);
    // Add push object itself. This is needed to tell structure of data to
    // the Push listener.
    
    // apparently words containing vettä are forbidden, so i change it to "vettä"
    pPush->GetPushObjectList().push_back(std::pvettä<CGXDLMSObject*, CGXDLMSCaptureObject>(pPush, CGXDLMSCaptureObject(2, 0)));
    //Add logical device name.
    pPush->GetPushObjectList().push_back(std::pvettä<CGXDLMSObject*, CGXDLMSCaptureObject>(ldn, CGXDLMSCaptureObject(2, 0)));
    // Add 0.0.25.1.0.255 Ch. 0 IPv4 setup IP address.
    pPush->GetPushObjectList().push_back(std::pvettä<CGXDLMSObject*, CGXDLMSCaptureObject>(pIp4, CGXDLMSCaptureObject(3, 0)));
    

(I changed the forbidden word to "vettä", the direct translation of that word to Finnish/Suomi language)

It compiled, and the server ran correctly. but when i want to do the Push, the button is greyed out. I try to set the method access to no avail. First i try index 0, then 1, then both as you can see below:

    pPush->SetMethodAccess(0, DLMS_METHOD_ACCESS_MODE_ACCESS);
    pPush->SetMethodAccess(1, DLMS_METHOD_ACCESS_MODE_ACCESS);

How to properly create push object and activate its push method?

Is it because i run it in my device, so it doesnt have proper IP settings (DLMS-wise) and therefore I need to set the IP first?

Thank you for the assistance.

jack

Profile picture for user Kurumi

Kurumi

3 months 2 weeks ago

Hi, Use GetMethodAccess to…

Hi,

Use GetMethodAccess to get server access rights.

https://github.com/Gurux/Gurux.DLMS.cpp/blob/96682d90ae2e6c44c0e90c4f62…

https://gurux.fi/Gurux.DLMS.Server

BR,
Mikko

Profile picture for user jack 001

jack 001

3 months 2 weeks ago

Hi, thanks for the prompt…

Hi, thanks for the prompt reply.

I modified it like this

DLMS_METHOD_ACCESS_MODE CGXDLMSBase::GetMethodAccess(CGXDLMSValueEventArg* arg)
{
    // Methods are not allowed.
    if (arg->GetSettings()->GetAuthentication() == DLMS_AUTHENTICATION_NONE)
    {
        return DLMS_METHOD_ACCESS_MODE_NONE;
    }
    // Only clock and profile generic methods are allowed.
    if (arg->GetSettings()->GetAuthentication() == DLMS_AUTHENTICATION_LOW)
    {
        if (arg->GetTarget()->GetObjectType() == DLMS_OBJECT_TYPE_CLOCK ||
            arg->GetTarget()->GetObjectType() == DLMS_OBJECT_TYPE_PROFILE_GENERIC ||
            arg->GetTarget()->GetObjectType() == DLMS_OBJECT_TYPE_PUSH_SETUP)
       {
            return DLMS_METHOD_ACCESS_MODE_ACCESS;
        }
        return DLMS_METHOD_ACCESS_MODE_NONE;
    }
    return DLMS_METHOD_ACCESS_MODE_ACCESS;
}

It works properly. It shows "127.0.1.1:7000" as "Destination". From that I run Python DLMS Push Listener Example on port 7000 :

python3 Gurux.DLMS.Push.Listener.Example.python/main.py -p 7000

gurux_dlms version: 1.0.191
gurux_net version: 1.0.19
gurux_serial version: 1.0.21
TCP Server public-proxy-m20:7000
Press any key to close the application.
trace:16:03:21  TraceTypes.INFO MediaState.OPENING
Media state changed. MediaState.OPENING
trace:16:03:21  TraceTypes.INFO MediaState.OPEN
Media state changed. MediaState.OPEN
Now there are two things:

- "Failed to sent push. Reason: 258." I don't find anything related to error code 258. Why is that?
- I can't make the attribute to read/write, even though i write this code:

    pPush->SetAccess(3, DLMS_ACCESS_MODE_READ_WRITE);
    pPush->SetAccess(2, DLMS_ACCESS_MODE_READ_WRITE);
    pPush->SetAccess(4, DLMS_ACCESS_MODE_READ_WRITE);

Initially i want to be able to edit attribute 3 (send destination and method) so i can try this push on another computer running the Push Listener (just in case there's anything wrong with my computer's networking). Since it didn't work, i tried other attributes, but didn't work either. I don't think this has anything to do with GetMethodAccess, doesnt it?

Here's my complete push code, barely changed from the example code:

    //Add Push Setup object.
    CGXDLMSPushSetup* pPush = new CGXDLMSPushSetup();
    address += ":7000";
    // address = "10.10.1.3:7000"; // 2nd computer, different network, does not work
    pPush->SetDestination(address);
    GetItems().push_back(pPush);
    // Add push object itself. This is needed to tell structure of data to
    // the Push listener.
    pPush->GetPushObjectList().push_back(std::pair<CGXDLMSObject*, CGXDLMSCaptureObject>(pPush, CGXDLMSCaptureObject(2, 0)));
    //Add logical device name.
    pPush->GetPushObjectList().push_back(std::pair<CGXDLMSObject*, CGXDLMSCaptureObject>(ldn, CGXDLMSCaptureObject(2, 0)));
    // Add 0.0.25.1.0.255 Ch. 0 IPv4 setup IP address.
    pPush->GetPushObjectList().push_back(std::pair<CGXDLMSObject*, CGXDLMSCaptureObject>(pIp4, CGXDLMSCaptureObject(3, 0)));

    // get method acceess and set method access
    // std::cout << "pPush method access before set: " << pPush->GetMethodAccess(1) << std::endl;

    pPush->SetMethodAccess(0, DLMS_METHOD_ACCESS_MODE_ACCESS);
    pPush->SetMethodAccess(1, DLMS_METHOD_ACCESS_MODE_ACCESS);
    pPush->SetAccess(3, DLMS_ACCESS_MODE_READ_WRITE);
    pPush->SetAccess(2, DLMS_ACCESS_MODE_READ_WRITE);
    pPush->SetAccess(4, DLMS_ACCESS_MODE_READ_WRITE);
    // AddPushSetup(GetItems(), pRegister_curr, "0.8.25.9.0.255");

 
Profile picture for user Kurumi

Kurumi

3 months 2 weeks ago

Hi, SetAccess is used on the…

Hi,

SetAccess is used on the client side to set the correct access rights. Use GetMethodAccess on the server side. Access rights vary between authentication levels and/or client address.

258 is DLMS_ERROR_CODE_INVALID_PARAMETER.

GetMethodAccess tells the access rights and you can remove SetMethodAccess and SetAccess in the meter side.

Check SendPush. Is that called? I believe that the reason is in the destination. You need to check that.

https://github.com/Gurux/Gurux.DLMS.cpp/blob/96682d90ae2e6c44c0e90c4f62…

BR,
Mikko

Profile picture for user jack 001

jack 001

3 months 2 weeks ago

Thank you for the reply. I…

Thank you for the reply. I think the SendPush is called, because i write it like this:

	std::cout << "PreAction ln: " << ln << std::endl;
	if ((*it)->GetTarget()->GetObjectType() == DLMS_OBJECT_TYPE_PUSH_SETUP)
        {
            int ret = SendPush((CGXDLMSPushSetup*)(*it)->GetTarget());
            if (ret != 0)
            {
                std::cout << "failed to sent push. Reason: " << ret << std::endl;
            }
            (*it)->SetHandled(true);
        }

and it returned the 258 error code:

PreAction ln: 0.7.25.9.0.255
failed to sent push. Reason: 258

I tried running the python push listener on another computer, and change the IP address and port accordingly, for example i run it on my other computer with IP address 10.10.1.3 on port 7000. It gets stuck, and the server hangs. I also tried with more generic IP, 192.168.1.3 port 7000, but the result is the same. Here's the server debug output and the hex trace:

// server debug output
PreAction ln: 0.7.25.9.0.255


// hex trace
16:44:29 Method object 0.7.25.9.0.255, interface PushSetup
TX:	 7E A0 1B 17 15 FE 4F DA E6 E6 00 C3 01 C1 00 28 00 07 19 09 00 FF 01 01 0F 00 FB CD 7E
16:44:34 Data send failed. Try to resend 1/3 
16:44:39 Data send failed. Try to resend 2/3 
16:44:44 Failed to receive reply from the device in given time. 

 It can't even response to any read request, be it register read, clock read, etc. If that happens, all i do is stop the program and re-run it. It eventually respond to request after the push process completed:

PreAction ln: 0.7.25.9.0.255
// wait x seconds, i haven't measured it
failed to sent push. Reason: 258

Oh yeah almost forgot, I use Low authentication

 

Regarding the GetMethodAccess, why should i add the code inside that block if the "Send Destination" is of an Attribute type (not Method type)? Do i need to set the Attribute access inside the GetMethodAccess?

Thank you

jack 

Profile picture for user Kurumi

Kurumi

3 months 1 week ago

Hi, Remove this: (*it)-…

Hi,

Remove this:
(*it)->SetHandled(true);

The meter doesn't send ACK to the client.

When you press the push button, it ACTION request is sent, not the read/write.

GetMethodAccess is used for actions, and GetAccess is for read/write.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Mon, 12/29/2025 - 10:38
    Gurux.Serial.Android 3.0.5
  • Mon, 12/15/2025 - 08:11
    Gurux.DLMS.Net 4.0.87
  • Fri, 12/12/2025 - 08:38
    Gurux.DLMS.Python 1.0.195
  • Thu, 12/11/2025 - 13:22
    Gurux.DLMS.Python 1.0.194
  • Thu, 12/11/2025 - 11:01
    gurux.dlms.java 4.0.88

New forum topics

  • Gurux DLMS Android App
  • AMR support for bidirectional meters.
  • addition of new object in object list, meter not working
  • old meter take to much time(l&t)
  • Unable to connect L&T ER300P Meter
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin