From 89d8dbc46cc2f86b2cd2ad77fbe3b2b1e7c92630 Mon Sep 17 00:00:00 2001 From: mjkoster Date: Sun, 26 Oct 2014 08:36:50 -0700 Subject: [PATCH] cleanup little refactor for clarity --- lwm2m/MdsNotificationDemo.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lwm2m/MdsNotificationDemo.py b/lwm2m/MdsNotificationDemo.py index e1f5c66..afe38c9 100644 --- a/lwm2m/MdsNotificationDemo.py +++ b/lwm2m/MdsNotificationDemo.py @@ -48,6 +48,7 @@ def discoverEndpoints(basePath): return ep_names def discoverResources(endpoint, uri_path): + resources = [] uriObject = urlparse(baseURL + '/' + endpoint) print 'discoverRES : ' + endpoint httpConnection = httplib.HTTPConnection(uriObject.netloc) @@ -63,7 +64,8 @@ def discoverResources(endpoint, uri_path): if resource['uri'] == uri_path: print 'resource: ' + resource['uri'] return resource['uri'] - return 0 + else: + return 0 def subscribe(resourceURI): for ep in ep_names: @@ -89,9 +91,9 @@ def longPoll(channelPath): if response.status == 200: httpBody = response.read() if len(httpBody) > 0: - handleEvents(json.loads(httpBody)) + handleNotifications(json.loads(httpBody)) - def handleEvents(events): + def handleNotifications(events): if 'notifications' in events: for notification in events['notifications']: if (notification['ep'] in ep_names) and (notification['path'] == subscribeURI): @@ -126,6 +128,7 @@ def actuateLEDbar(ledString = '0000000000'): print "Started" discoverEndpoints(baseURL) + subscribe(subscribeURI) try: