Repository navigation
Replies: 1 comment 7 replies
|
Starting by the end, any instance of BAC0 is a BACnet device. You can then use this instance to talk with other devices and you can also add BACnet objects to the instance itself and it becomes the device you want (let say, a weather station... or any other thing you want it to be). The sample folder in the repo needs some love.... but a good example to create multiple devices would be here Now, about discovery, BACnet highly depends on broadcast as you probably figured out. But here is a sample that may get you close to what you want import asyncio
import BAC0
from BAC0.scripts.script_runner import run
bacnet = None
async def main():
# Configuration
# # Initialize BACnet
print(BAC0.infos.__version__)
#async with BAC0.start(ip="127.0.0.1/24") as bacnet:
async with BAC0.start(ip="192.168.211.208/24", deviceId=111) as bacnet:
async with BAC0.start(ip="192.168.211.16/24", deviceId=222) as fakedevice:
await bacnet._discover(global_broadcast=True)
lst = await bacnet._devices(_return_list=True)
print(lst)
if __name__ == "__main__":
# run(main, bacnet) # Run the script and deals with SIGINT and SIGTERM, useful for long time runnign scripts.
asyncio.run(main())I used my wifi NIC + wired NIC to define 2 different devices.... but you could define multiple IPs on 1 NIC and get the same result. Here you can see my fakedevice appear amongst other device of my lab |
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm trying to work out a means of testing the abilty to discover and retrieve information from a mock device using BAC0 for both ends. One can create a second IP address on an existing interface so you have 2 bind points for each, however I'm having an issue with the broadcast address. In my case, I'm playing with a mock device running on 192.168.86.180/24 and connecting to it from 192.168.86.80/24. Unfortunately discovery is not finding the device and I currently believe it is due to the subnet broadcast IP being in use:
I'm similarly seeing churn when my discovery process exits, which I think corroberates my assumption:
But ultimately, I'm trying to figure out a way to simulate a device and client on the same machine for testing purposes. Curious if anyone else has approached this. I guess the worst case would be docker containers?
EDIT: Upon further investigation, I don't think that BAC0 provides functionality for simulating a bacnet device, I was misreading the examples which was explicitly adding a remote device to a controller, not declaring a device to be emulated by a locally defined controller.
All reactions