Skip to content

Commit 48e50cd

Browse files
Merge branch 'main' into develop
2 parents 66310aa + 6158c5c commit 48e50cd

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

BAC0/core/functions/Alias.py

+36
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
from typing import List, Tuple, Optional, Union
23

34
from bacpypes3.app import Application
45
from bacpypes3.npdu import RejectMessageToNetwork
@@ -8,6 +9,11 @@
89

910
from ...core.utils.notes import note_and_log
1011

12+
ROUTER_TUPLE_TYPE = Union[
13+
Tuple[Union[Address, str], Union[int, List[int]]],
14+
Tuple[Union[Address, str], Union[int, List[int]], Optional[int]],
15+
]
16+
1117

1218
@note_and_log
1319
class Alias:
@@ -111,6 +117,36 @@ async def init_routing_table(self, address):
111117
_app: Application = _this_application.app
112118
await _app.nse.initialize_routing_table()
113119

120+
async def use_router(
121+
self,
122+
router_infos: Union[
123+
Tuple[Union[Address, str], Union[int, List[int]]],
124+
Tuple[Union[Address, str], Union[int, List[int]], Optional[int]],
125+
] = (None, None, None),
126+
):
127+
address, dnets = router_infos[:2]
128+
try:
129+
snet = router_infos[2]
130+
except IndexError:
131+
snet = None
132+
_this_application: BAC0Application = self.this_application
133+
_app: Application = _this_application.app
134+
if not isinstance(address, Address):
135+
address = Address(address)
136+
if not isinstance(dnets, list):
137+
dnets = [dnets]
138+
response = await self.who_is(address=address)
139+
if response:
140+
self._log.info(f"Router found at {address}")
141+
self._log.info(
142+
f"Adding router reference -> Snet : {snet} Addr : {address} dnets : {dnets}"
143+
)
144+
await _app.nsap.update_router_references(
145+
snet=snet, address=address, dnets=dnets
146+
)
147+
else:
148+
self._log.warning(f"Router not found at {address}")
149+
114150
async def what_is_network_number(self, destination=None, timeout=3):
115151
"""
116152
winn [ <addr> ]

BAC0/infos.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
__email__ = "[email protected]"
1313
__url__ = "https://github.com/ChristianTremblay/BAC0"
1414
__download_url__ = "https://github.com/ChristianTremblay/BAC0/archive/master.zip"
15-
__version__ = "2024.09.08"
15+
__version__ = "2024.09.10"
1616
__license__ = "LGPLv3"

BAC0/scripts/Base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class Base:
7878

7979
def __init__(
8080
self,
81-
localIPAddr: str = "127.0.0.1",
81+
localIPAddr: Address = Address("127.0.0.1/24"),
8282
networkNumber: int = None,
8383
localObjName: str = "BAC0",
8484
deviceId: int = None,

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "BAC0"
3-
version = "2024.09.13dev"
3+
version = "2024.09.15dev"
44
description = "BACnet Scripting Framework for testing DDC Controls"
55
authors = [{name = "Christian Tremblay", email = "[email protected]"}]
66
readme = "README.md"

0 commit comments

Comments
 (0)