Skip to content

Commit cc69ef7

Browse files
Improving discover to be compatible with the new feature use_router that allows to manually add a router to the app (this fix the troubles I have connecting to network using the CWT from JCI)
1 parent 48e50cd commit cc69ef7

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

BAC0/core/functions/Alias.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import asyncio
2-
from typing import List, Tuple, Optional, Union
2+
from typing import List, Optional, Tuple, Union
33

44
from bacpypes3.app import Application
5+
from bacpypes3.netservice import RouterEntryStatus
56
from bacpypes3.npdu import RejectMessageToNetwork
67
from bacpypes3.pdu import Address, GlobalBroadcast
78

@@ -144,6 +145,15 @@ async def use_router(
144145
await _app.nsap.update_router_references(
145146
snet=snet, address=address, dnets=dnets
146147
)
148+
self._ric = self.this_application.app.nsap.router_info_cache
149+
self._log.info(
150+
f"Updating router info cache -> Snet : {snet} Addr : {address} dnets : {dnets}"
151+
)
152+
for each in dnets:
153+
await self._ric.set_path_info(
154+
snet, each, address, RouterEntryStatus.available
155+
)
156+
_this_application._learnedNetworks.add(each)
147157
else:
148158
self._log.warning(f"Router not found at {address}")
149159

@@ -163,8 +173,7 @@ async def what_is_network_number(self, destination=None, timeout=3):
163173
_app.nse.what_is_network_number(), timeout
164174
)
165175
return network_number
166-
except RejectMessageToNetwork as error:
167-
self._log.warning(f"Reject Network Number : {error}")
176+
168177
except asyncio.TimeoutError:
169178
# Handle the timeout error
170179
self.log(

BAC0/core/functions/Discover.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,12 @@ async def _discover(
8484
if reset:
8585
self.discoveredDevices = {}
8686
found = []
87-
_networks = []
8887

8988
_this_application: BAC0Application = self.this_application
9089
_app: Application = _this_application.app
9190

91+
_networks = _this_application._learnedNetworks
92+
9293
deviceInstanceRangeLowLimit, deviceInstanceRangeHighLimit = limits
9394
# Try to find on which network we are
9495
_this_network = await self.what_is_network_number()

0 commit comments

Comments
 (0)