# HG changeset patch # User Edouard Tisserant # Date 1731535836 -3600 # Node ID 4127c64df073c3689397e44f91c05e46bae9633b # Parent 45532de22b7531ef0e94972272ebcb09ea3116b8 python runtime: update ServicePublisher to current Zeroconf API diff -r 45532de22b75 -r 4127c64df073 runtime/ServicePublisher.py --- a/runtime/ServicePublisher.py Wed Oct 16 12:18:14 2024 +0200 +++ b/runtime/ServicePublisher.py Wed Nov 13 23:10:36 2024 +0100 @@ -34,7 +34,6 @@ class ServicePublisher(object): def __init__(self, protocol): - # type: fully qualified service type name self.serviceproperties = { 'description': 'Beremiz remote PLC', 'protocol': protocol @@ -50,12 +49,12 @@ def RegisterService(self, name, ip, port): try: self._RegisterService(name, ip, port) - except Exception: + except Exception as e: + print(f"Failed to register service ({str(e)}), retrying in 2 seconds") self.retrytimer = threading.Timer(2, self.RegisterService, [name, ip, port]) self.retrytimer.start() def _RegisterService(self, name, ip, port): - # name: fully qualified service name self.service_name = '%s.%s' % (name, service_type) self.name = name self.port = port @@ -75,8 +74,8 @@ self.server.register_service( zeroconf.ServiceInfo(service_type, self.service_name, - self.ip_32b, self.port, + addresses=[self.ip_32b], properties=self.serviceproperties)) self.retrytimer = None diff -r 45532de22b75 -r 4127c64df073 runtime/eRPCServer.py --- a/runtime/eRPCServer.py Wed Oct 16 12:18:14 2024 +0200 +++ b/runtime/eRPCServer.py Wed Nov 13 23:10:36 2024 +0100 @@ -85,7 +85,7 @@ self.transport = None self.servicename = servicename self.ip_addr = ip_addr - self.port = port + self.port = int(port) self.servicepublisher = None def _to_be_published(self): @@ -118,7 +118,7 @@ # transport = erpc.transport.SerialTransport(device, baudrate) # initialize TCP transport layer - self.transport = erpc.transport.TCPTransport(self.ip_addr, int(self.port), True) + self.transport = erpc.transport.TCPTransport(self.ip_addr, self.port, True) self.server = erpc.simple_server.SimpleServer(self.transport, erpc.basic_codec.BasicCodec) self.server.add_service(service)