diff --git a/py34/bacpypes/service/cov.py b/py34/bacpypes/service/cov.py index a506bf24..160223b9 100644 --- a/py34/bacpypes/service/cov.py +++ b/py34/bacpypes/service/cov.py @@ -90,8 +90,8 @@ class Subscription(OneShotTask, DebugContents): 'lifetime', ) - def __init__(self, obj_ref, client_addr, proc_id, obj_id, confirmed, lifetime=0): - if _debug: Subscription._debug("__init__ %r %r %r %r %r %r", obj_ref, client_addr, proc_id, obj_id, confirmed, lifetime) + def __init__(self, obj_ref, client_addr, proc_id, obj_id, confirmed, lifetime, cov_inc): + if _debug: Subscription._debug("__init__ %r %r %r %r %r %r %r", obj_ref, client_addr, proc_id, obj_id, confirmed, lifetime, cov_inc) OneShotTask.__init__(self) # save the reference to the related object @@ -102,10 +102,12 @@ def __init__(self, obj_ref, client_addr, proc_id, obj_id, confirmed, lifetime=0) self.proc_id = proc_id self.obj_id = obj_id self.confirmed = confirmed + self.lifetime = lifetime + self.covIncrement = cov_inc - # if lifetime is none, consider permanent subscription (0) - self.lifetime = 0 if lifetime is None else lifetime - self.install_task(delta=self.lifetime) + # if lifetime is zero this is a permanent subscription + if lifetime > 0: + self.install_task(delta=self.lifetime) def cancel_subscription(self): if _debug: Subscription._debug("cancel_subscription") @@ -678,8 +680,8 @@ def cov_abort(self, cov, request, response): ### delete the rest of the pending requests for this client - def do_SubscribeCOVRequest(self, apdu): - if _debug: ChangeOfValueServices._debug("do_SubscribeCOVRequest %r", apdu) + def do_SubscribeCOVPropertyRequest(self, apdu): + if _debug: ChangeOfValueServices._debug("do_SubscribeCOVPropertyRequest %r", apdu) # extract the pieces client_addr = apdu.pduSource @@ -687,6 +689,8 @@ def do_SubscribeCOVRequest(self, apdu): obj_id = apdu.monitoredObjectIdentifier confirmed = apdu.issueConfirmedNotifications lifetime = apdu.lifetime + prop_id = apdu.monitoredPropertyIdentifier + cov_inc = apdu.covIncrement # request is to cancel the subscription cancel_subscription = (confirmed is None) and (lifetime is None) @@ -737,7 +741,8 @@ def do_SubscribeCOVRequest(self, apdu): if _debug: ChangeOfValueServices._debug(" - create a subscription") # make a subscription - cov = Subscription(obj, client_addr, proc_id, obj_id, confirmed, lifetime) + cov = Subscription(obj, client_addr, proc_id, obj_id, + confirmed, lifetime, cov_inc) if _debug: ChangeOfValueServices._debug(" - cov: %r", cov) # add it to our subscriptions lists @@ -754,4 +759,3 @@ def do_SubscribeCOVRequest(self, apdu): if not cancel_subscription: if _debug: ChangeOfValueServices._debug(" - send a notification") deferred(cov_detection.send_cov_notifications, cov) - diff --git a/samples/COVClient.py b/samples/COVClient.py index 41673e79..012c8e52 100755 --- a/samples/COVClient.py +++ b/samples/COVClient.py @@ -15,11 +15,12 @@ from bacpypes.iocb import IOCB from bacpypes.pdu import Address -from bacpypes.apdu import SubscribeCOVRequest, SimpleAckPDU, RejectPDU, AbortPDU +from bacpypes.apdu import SubscribeCOVRequest, SimpleAckPDU, RejectPDU, AbortPDU, SubscribeCOVPropertyRequest from bacpypes.primitivedata import ObjectIdentifier from bacpypes.app import BIPSimpleApplication from bacpypes.local.device import LocalDeviceObject +from bacpypes.basetypes import PropertyReference # some debugging _debug = 0 @@ -145,8 +146,14 @@ def do_subscribe(self, args): lifetime = None # build a request - request = SubscribeCOVRequest( - subscriberProcessIdentifier=proc_id, monitoredObjectIdentifier=obj_id + # request = SubscribeCOVRequest( + # subscriberProcessIdentifier=proc_id, monitoredObjectIdentifier=obj_id + # ) + request = SubscribeCOVPropertyRequest( + subscriberProcessIdentifier=proc_id, + monitoredObjectIdentifier=obj_id, + monitoredPropertyIdentifier=PropertyReference(propertyIdentifier=85), + covIncrement=2 ) request.pduDestination = Address(addr) diff --git a/samples/WhoIsRouterForeign.py b/samples/WhoIsRouterForeign.py index 8e97d6c1..8cac728c 100755 --- a/samples/WhoIsRouterForeign.py +++ b/samples/WhoIsRouterForeign.py @@ -120,8 +120,8 @@ def main(): # make a simple application this_application = WhoIsRouterApplication( args.ini.address, - bbmdAddress=Address(args.ini.foreignbbmd), - bbmdTTL=int(args.ini.foreignttl), + bbmdAddress=Address(args.ini.foreignbbmd), + bbmdTTL=int(args.ini.foreignttl) ) if _debug: _log.debug(" - this_application: %r", this_application)