ChristianTremblay / BAC0

BAC0 - Library depending on BACpypes3 (Python 3) to build automation script for BACnet applications
GNU Lesser General Public License v3.0
174 stars 99 forks source link

How to disconnect only one device #454

Closed DubarryXavier closed 5 months ago

DubarryXavier commented 6 months ago

Hello, I'm trying to use BACnet to simulate 300 devices. However, I would like to disconnect some and reconnect them later. The issue is that when I disconnect one device, all the devices get disconnected. I'm using device_name.disconnect(). I tried assigning individual IP addresses to each device or giving them the same IP address. They all used different ports and IDs.

def disconnect_device(device_name): global devices if device_name in devices: device = devices[device_name] device.disconnect() # Déconnexion du périphérique del devices[device_name] # Suppression du périphérique de la liste des périphériques connectés print(f"Device {device_name} disconnected.") else: print(f"Device {device_name} not found.")

Thank you for your time

ChristianTremblay commented 5 months ago

What if you don't delete it ? and when you are ready to reconnect you use the old instance.... you connect(network=bacnet)

Have you tried the async branch ?

DubarryXavier commented 5 months ago

Hello thanks for the answer, I will try the async branch.