JoelBender / bacpypes

BACpypes provides a BACnet application layer and network layer written in Python for daemons, scripting, and graphical interfaces.
MIT License
303 stars 129 forks source link

Configure BBMD by writing broadcast distribution table #451

Closed mosterme1003 closed 2 years ago

mosterme1003 commented 2 years ago

Hey! In response to my question in issue #446 you wrote a sample script which let me read the broadcast distribution table (BDT) of a device to show whether or not it's configured as a BBMD in the subnet. Now I wondered if you can extend this sample script by also adding a function for writing the BDT in order to configure the device as a BBMD. I struggled while trying to add this functionality by my self. Could you help me with that? Is is also possible to call your sample functions without the console and simply return the read packages?

Thank you very much. You really do great work here!

JoelBender commented 2 years ago

There is now a writebdt command, first parameter is the destination address the rest are broadcast distribution table entries:

> writebdt 10.0.1.99 1.2.3.4/32

Those entries are 10-octets, the first 6 are the BACnet/IPv4 address and the next 4 are the subnet mask. Each BBMD should at least have its own address in the table, so the example above is wrong, but if you turn on UDP debugging you can see that the packet being sent out is correct:

DEBUG:bacpypes.udp.UDPActor:indication <bacpypes.pdu.PDU object at 0x7f168daef690>
    <bacpypes.pdu.PDU object at 0x7f168daef690>
        pduDestination = ('10.0.1.99', 47808)
        pduExpectingReply = 0
        pduNetworkPriority = 0
        pduData = x'81.01.00.0e.01.02.03.04.ba.c0.ff.ff.ff.ff'

Note that if you get these entries wrong you'll at least break broadcast propagation and device-address-binding!