Skip to content

Commit

Permalink
create start scripts for cli and device
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed Feb 16, 2023
1 parent d0ffdb4 commit f6df4fa
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
1 change: 0 additions & 1 deletion BACpypes.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[BACpypes]
objectName: AlfalfaProxy
address: 172.24.0.3
objectIdentifier: 599
maxApduLengthAccepted: 1024
segmentationSupported: segmentedBoth
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ RUN ln -sf /usr/bin/python3 /usr/bin/python \

COPY alfalfa_bacnet_bridge alfalfa_bacnet_bridge
COPY BACpypes.ini .
COPY Discover.py .
COPY cli_setup.py .

ENV TERM=xterm
2 changes: 1 addition & 1 deletion alfalfa_bacnet_bridge/alfalfa_bacnet_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, host, site_id: SiteID) -> None:
args = parser.parse_args()

self.device = LocalDeviceObject(ini=args.ini)
self.application = AlfalfaBACnetApplication(self.device, args.ini.address)
self.application = AlfalfaBACnetApplication(self.device, "0.0.0.0")

self.points = {}

Expand Down
7 changes: 7 additions & 0 deletions cli_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import BAC0
import subprocess

result = subprocess.run(["hostname", "-I"], capture_output=True)
address = result.stdout.decode("utf-8").strip()

network = BAC0.connect(f"{address}/16")
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: "3.4"
services:
device:
container_name: device
build:
dockerfile: Dockerfile
networks:
Expand All @@ -14,13 +13,12 @@ services:
- "47808:47808/udp"
command: "poetry run python alfalfa_bacnet_bridge/alfalfa_bacnet_bridge.py"
cli:
container_name: cli
build:
dockerfile: Dockerfile
networks:
bacnet:
ipv4_address: 172.24.0.4
command: "watch -n 5 poetry run python alfalfa_bacnet_bridge/discover_points.py"
command: "tail -f /dev/null"
networks:
bacnet:
ipam:
Expand Down
4 changes: 4 additions & 0 deletions start_cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docker stop cli
docker rm cli
docker build -t alfalfa-bacnet-bridge .
docker run -it --name="cli" -h cli alfalfa-bacnet-bridge poetry run python -i cli_setup.py
4 changes: 4 additions & 0 deletions start_device.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docker stop device
docker rm device
docker build -t alfalfa-bacnet-bridge .
docker run -it --env-file=.env -p 47808:47808/udp --name="device" -h device alfalfa-bacnet-bridge poetry run python alfalfa_bacnet_bridge/alfalfa_bacnet_bridge.py

0 comments on commit f6df4fa

Please sign in to comment.