u9n / dlms-cosem

A Python library for DLMS/COSEM
Other
80 stars 41 forks source link

Make it simpler to switch between context (clients) #41

Closed Krolken closed 3 years ago

Krolken commented 3 years ago

The API as of now is more focused on for one connection to only connect to a meter with on type of client. For example the public or the management client.

But when reading an "unknown" meter we might not know the invocation counter to be used for encryption by the management client and it has to be read by the public client first.

As of now that would involve creating a connection to the meter with the managment client, getting and error and disconnecting. Then creating a new connection to the meter with the public client, getting the invocation counter and disconnecting. Then creating another connection to the meter with the management client and correct invocation counter.

This introduces delays and it can also lead to locking a modem of some meters.

There is no real need to disconnect a transport between switching context (client types). Since that is handled by the association and associon release in the DLMS communication. So it is way more efficient to keep the socket open and reuse it for each client type.

Or actually we would like to be able to change the client into a new type instead of having several objects that share the transport object. This could lead to calls from different clients on the transport and might mess stuff up.

But when we change the clients logical address we need to update the transports too.