Skip to content

Commit

Permalink
Improving discover to be compatible with the new feature use_router t…
Browse files Browse the repository at this point in the history
…hat allows to manually add a router to the app (this fix the troubles I have connecting to network using the CWT from JCI)
  • Loading branch information
ChristianTremblay committed Sep 15, 2024
1 parent 48e50cd commit cc69ef7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions BAC0/core/functions/Alias.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import asyncio
from typing import List, Tuple, Optional, Union
from typing import List, Optional, Tuple, Union

from bacpypes3.app import Application
from bacpypes3.netservice import RouterEntryStatus
from bacpypes3.npdu import RejectMessageToNetwork
from bacpypes3.pdu import Address, GlobalBroadcast

Expand Down Expand Up @@ -144,6 +145,15 @@ async def use_router(
await _app.nsap.update_router_references(
snet=snet, address=address, dnets=dnets
)
self._ric = self.this_application.app.nsap.router_info_cache
self._log.info(
f"Updating router info cache -> Snet : {snet} Addr : {address} dnets : {dnets}"
)
for each in dnets:
await self._ric.set_path_info(
snet, each, address, RouterEntryStatus.available
)
_this_application._learnedNetworks.add(each)
else:
self._log.warning(f"Router not found at {address}")

Expand All @@ -163,8 +173,7 @@ async def what_is_network_number(self, destination=None, timeout=3):
_app.nse.what_is_network_number(), timeout
)
return network_number
except RejectMessageToNetwork as error:
self._log.warning(f"Reject Network Number : {error}")

except asyncio.TimeoutError:
# Handle the timeout error
self.log(
Expand Down
3 changes: 2 additions & 1 deletion BAC0/core/functions/Discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ async def _discover(
if reset:
self.discoveredDevices = {}
found = []
_networks = []

_this_application: BAC0Application = self.this_application
_app: Application = _this_application.app

_networks = _this_application._learnedNetworks

deviceInstanceRangeLowLimit, deviceInstanceRangeHighLimit = limits
# Try to find on which network we are
_this_network = await self.what_is_network_number()
Expand Down

0 comments on commit cc69ef7

Please sign in to comment.