Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ This tool is particularly useful for developers building web-based building auto

## Build

To build the `bacnet-scan-tool`, ensure you have Python 3.10 or higher installed, then run the following commands:
To build the `bacnet-scan-api`, ensure you have Python 3.10 or higher installed, then run the following commands:

```bash
# Clone the repository
git clone https://github.com/your-repo/bacnet-scan-tool.git
git clone https://github.com/eclipse-volttron/bacnet-scan-tool.git
cd bacnet-scan-tool
```

Expand Down Expand Up @@ -66,7 +66,7 @@ poetry install
Start the server with Poetry:

```bash
poetry run uvicorn bacnet_scan_tool.main:app --reload
poetry run uvicorn bacnet_scan_api.main:app --reload
```

The server will be available at [http://127.0.0.1:8000](http://127.0.0.1:8000).
Expand Down
21 changes: 12 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "bacnet-scan-tool"
version = "0.1.0rc0"
name = "bacnet-scan-api"
version = "0.1.0rc2"
description = ""
authors = [
{name = "C. Allwardt",email = "3979063+craig8@users.noreply.github.com"}
Expand All @@ -11,7 +11,7 @@ requires-python = ">=3.10,<4.0"

[tool.poetry]
packages = [
{include="bacnet_scan_tool", from="src"}]
{include="bacnet_scan_api", from="src"}]

[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
Expand All @@ -24,16 +24,19 @@ pydantic = ">=2.10.6,<3.0.0"
sqlmodel = ">=0.0.8,<1.0.0"
click = ">=8.1.8,<9.0.0"
uvicorn = ">=0.34.0,<0.35.0"
#protocol-proxy = { git = "https://github.com/riley206-pnnl/lib-protocol-proxy.git", rev = "bacnet-async-upgrade" }
#protocol-proxy-bacnet = { git = "https://github.com/riley206-pnnl/lib-protocol-proxy-bacnet.git", rev = "main" }
#protocol-proxy-bacnet = { path = "../lib-protocol-proxy-bacnet" }
#protocol-proxy = { path = "../lib-protocol-proxy" }
protocol-proxy-bacnet = ">=v2.0.0rc2"
protocol-proxy = ">=v2.0.0rc1"
protocol-proxy = ">=2.0.0rc2"
protocol-proxy-bacnet = ">=2.0.0rc2,<3.0.0"
bacpypes3 = "^0.0.102"
psutil = "^7.0.0"
gevent = "^25.5.1"
python-multipart = "^0.0.20"
netifaces = "^0.11.0"
bac0 = "^2025.6.10"
rdflib = "^6.0"

[dependency-groups]
dev = [
"pytest (>=8.4.2,<9.0.0)",
"pytest-asyncio (>=1.2.0,<2.0.0)",
"httpx (>=0.28.1,<0.29.0)"
]
File renamed without changes.
30 changes: 21 additions & 9 deletions src/bacnet_scan_tool/main.py → src/bacnet_scan_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,31 @@ async def start_proxy(local_device_address: Optional[str] = Form(None)):
Returns status and address.
"""
try:
print(f"[start_proxy] Received local_device_address: {local_device_address}")
if not local_device_address:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
local_device_address = s.getsockname()[0]
s.close()
except Exception:
print(f"[start_proxy] Auto-detected IP: {local_device_address}")
except Exception as e:
print(f"[start_proxy] Auto-detection failed: {e}")
return ProxyResponse(
status="error",
error=
"Could not auto-detect local IP address. Please specify manually."
error=f"Could not auto-detect local IP address. Please specify manually. Error: {str(e)}"
)

# Validate we have a valid IP address
if not local_device_address:
print("[start_proxy] No IP address after detection")
return ProxyResponse(
status="error",
error="No IP address provided or detected."
)

print(f"[start_proxy] Using IP address: {local_device_address}")

if hasattr(app.state, "bacnet_manager") and app.state.bacnet_manager:
await app.state.bacnet_manager.stop()
if hasattr(app.state,
Expand All @@ -58,14 +71,13 @@ async def start_proxy(local_device_address: Optional[str] = Form(None)):
app.state.bacnet_manager.inbound_server.serve_forever())

app.state.bacnet_proxy_peer = await app.state.bacnet_manager.get_proxy(
(local_device_address, 0),
(local_device_address, 0),
local_device_address=local_device_address)
app.state.bacnet_proxy_local_address = local_device_address

asyncio.create_task(
app.state.bacnet_manager.wait_peer_registered(
peer=app.state.bacnet_proxy_peer, timeout=5))
await asyncio.sleep(1)
await app.state.bacnet_manager.wait_peer_registered(
peer=app.state.bacnet_proxy_peer, timeout=5)

return ProxyResponse(status="done", address=local_device_address)
except Exception as e:
return ProxyResponse(status="error", error=str(e))
Expand Down Expand Up @@ -548,7 +560,7 @@ async def discover_networks(verbose: bool = Query(
custom_networks = []
try:
from pathlib import Path
cache_dir = Path.home() / '.bacnet_scan_tool'
cache_dir = Path.home() / '.bacnet_scan_api'
custom_networks_file = cache_dir / 'custom_networks.json'

if custom_networks_file.exists():
Expand Down
File renamed without changes.
Loading
Loading