@@ -63,7 +63,10 @@ def resolve_role(value: Union[str, int]) -> int:
6363
6464
6565class VirtualNode :
66+ RAW_PACKET_TOPIC = "mesh.rx.packet"
6667 PACKET_TOPIC = "mesh.rx.unique_packet"
68+ ACK_TOPIC = "mesh.rx.ack"
69+ NAK_TOPIC = "mesh.rx.nak"
6770 DUPLICATE_TOPIC = "mesh.rx.duplicate"
6871 RECEIVE_TOPIC = "meshtastic.receive"
6972
@@ -142,11 +145,11 @@ def _configure_mudp_globals(self) -> None:
142145 def start (self ) -> None :
143146 if self .stream is not None :
144147 return
145- pub .subscribe (self ._handle_raw_packet , "mesh.rx.packet" )
148+ pub .subscribe (self ._handle_raw_packet , self . RAW_PACKET_TOPIC )
146149 pub .subscribe (self ._handle_unique_packet , self .PACKET_TOPIC )
147150 pub .subscribe (self ._handle_compat_response_packet , self .RECEIVE_TOPIC )
148- pub .subscribe (self ._handle_compat_ack , "mesh.rx.ack" )
149- pub .subscribe (self ._handle_compat_nak , "mesh.rx.nak" )
151+ pub .subscribe (self ._handle_compat_ack , self . ACK_TOPIC )
152+ pub .subscribe (self ._handle_compat_nak , self . NAK_TOPIC )
150153 self .stream = UDPPacketStream (
151154 self .config .udp .mcast_group ,
152155 int (self .config .udp .mcast_port ),
@@ -169,7 +172,7 @@ def stop(self) -> None:
169172 self .stream .stop ()
170173 self .stream = None
171174 try :
172- pub .unsubscribe (self ._handle_raw_packet , "mesh.rx.packet" )
175+ pub .unsubscribe (self ._handle_raw_packet , self . RAW_PACKET_TOPIC )
173176 except KeyError :
174177 pass
175178 try :
@@ -178,8 +181,8 @@ def stop(self) -> None:
178181 pass
179182 for topic , listener in (
180183 (self .RECEIVE_TOPIC , self ._handle_compat_response_packet ),
181- ("mesh.rx.ack" , self ._handle_compat_ack ),
182- ("mesh.rx.nak" , self ._handle_compat_nak ),
184+ (self . ACK_TOPIC , self ._handle_compat_ack ),
185+ (self . NAK_TOPIC , self ._handle_compat_nak ),
183186 ):
184187 try :
185188 pub .unsubscribe (listener , topic )
0 commit comments