Permalink
Browse files

cleanup

little refactor for clarity
  • Loading branch information...
1 parent fcd75ff commit 89d8dbc46cc2f86b2cd2ad77fbe3b2b1e7c92630 @mjkoster mjkoster committed Oct 26, 2014
Showing with 6 additions and 3 deletions.
  1. +6 −3 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:

0 comments on commit 89d8dbc

Please sign in to comment.