def __init__(self, lan, addr1, net1, addr2, net2): if _debug: MQTT2IPRouter._debug("__init__ %r %r %r %r %r", lan, addr1, net1, addr2, net2) global args # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) #== First stack # create an MQTT client self.s1_msap = bacpypes_mqtt.MQTTClient(lan, addr1, args.host, port=args.port, keepalive=args.keepalive) # create a service element for the client self.s1_mse = bacpypes_mqtt.MQTTServiceElement() bind(self.s1_mse, self.s1_msap) # bind to the MQTT network self.nsap.bind(self.s1_msap, net1) #== Second stack # create a generic BIP stack, bound to the Annex J server # on the UDP multiplexer self.s2_bip = BIPSimple() self.s2_annexj = AnnexJCodec() self.s2_mux = UDPMultiplexer(addr2) # bind the bottom layers bind(self.s2_bip, self.s2_annexj, self.s2_mux.annexJ) # bind the BIP stack to the local network self.nsap.bind(self.s2_bip, net2)
def __init__(self, lan, addr1, net1): if _debug: VLANRouter._debug("__init__ %r %r %r", lan, addr1, net1) # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) # create an MQTT client self.msap = bacpypes_mqtt.MQTTClient( lan, addr1, args.host, port=args.port, keepalive=args.keepalive ) # create a service element for the client self.mse = bacpypes_mqtt.MQTTServiceElement() bind(self.mse, self.msap) # bind to the MQTT network self.nsap.bind(self.msap, net1)
def __init__(self, localDevice, lan, localAddress, deviceInfoCache=None, aseID=None): if _debug: MQTTApplication._debug( "__init__ %r %r %r deviceInfoCache=%r aseID=%r", localDevice, lan, localAddress, deviceInfoCache, aseID) ApplicationIOController.__init__(self, localDevice, localAddress, deviceInfoCache, aseID=aseID) global args # local address might be useful for subclasses if isinstance(localAddress, str): localAddress = Address(localAddress) if len(localAddress.addrAddr) != bacpypes_mqtt.ADDRESS_LENGTH: raise ValueError("local address must be %d octets" % (bacpypes_mqtt.ADDRESS_LENGTH, )) self.localAddress = localAddress # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(localDevice) # the segmentation state machines need access to the same device # information cache as the application self.smap.deviceInfoCache = self.deviceInfoCache # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # create an MQTT client self.msap = bacpypes_mqtt.MQTTClient(lan, localAddress, args.host, port=args.port, keepalive=args.keepalive) # create a service element for the client self.mse = bacpypes_mqtt.MQTTServiceElement() bind(self.mse, self.msap) # bind the stack to the virtual network, no network number self.nsap.bind(self.msap) # keep track of requests to line up responses self._request = None