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);
}
// 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.
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.
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.
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.
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.
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.
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.
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?
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.
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
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
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
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
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
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
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
Hi Mikko,
Hi Mikko,
Awaiting your response on this please.
Regards
Sidharth
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
Hi Mikko,
Hi Mikko,
Any information on when this example will be released?
Thanks
Hi,
Hi,
One of our clients asked for improvements in serialization. This is released after that.