Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated resolver to report the port of a service

  • Loading branch information...
commit 2f954dd9ed6340fffdd7ca63a0ed985f847fb0ac 1 parent fa97c94
@schneider42 schneider42 authored
View
8 software/pythonexamples/discover.py
@@ -3,10 +3,10 @@
import gobject
class Resolver(uberbus.moodlamp.MoodlampResolver):
- def newNode(self, node, address, multicast):
- print node, address, multicast
- if multicast == True:
- m = uberbus.moodlamp.Moodlamp(address, udp=True)
+ def newNode(self, nodeinfo):
+ print 'resolved: ', nodeinfo.node, nodeinfo.address, nodeinfo.port, nodeinfo.multicast
+ if nodeinfo.multicast == True:
+ m = uberbus.moodlamp.Moodlamp(nodeinfo.address, udp=True)
m.connect()
m.setcolor(0,0,255)
View
15 software/pythonlib/uberbus/digitaloutput.py
@@ -1,9 +1,6 @@
import ubnode
class DigitalOutput(ubnode.UBNode):
- udptype = '_digitaloutput._udp'
- tcptype = '_digitaloutput._tcp'
-
def __init__(self, address):
ubnode.UBNode.__init__(self,address,2311)
@@ -14,15 +11,3 @@ def set(self, pin):
def clear(self, pin):
cmd = "s %s 0"%pin
return self.sendCommand(cmd)
-
- def get(self, pin):
- cmd = "g %s"%pin
- if self.sendCommand(cmd):
- return self.getMessage()
- else:
- return False
-
-class DigitalOutputResolver(ubresolver.UBResolver):
- def __init__(self, udp=False):
- ubresolver.UBResolver.__init__(self, DigitalOutput, udp)
-
View
2  software/pythonlib/uberbus/ubnode.py
@@ -293,4 +293,6 @@ def setID(self, id):
self.closeMgtSocket()
return ret
+class UBNodeInfo:
+ pass
View
19 software/pythonlib/uberbus/ubresolver.py
@@ -2,7 +2,7 @@
from dbus import DBusException
from dbus.mainloop.glib import DBusGMainLoop
import os
-
+from ubnode import UBNodeInfo
class UBResolver:
def __init__(self, ubclass, udp = False):
self.loop = DBusGMainLoop()
@@ -31,19 +31,20 @@ def service_resolved(self, *args):
#print 'address:', args[7]
#print 'port:', args[8]
- address = args[7]
name = args[2]
domain = 'local'
-
node = name + '.' + domain
#print 'node',node
+ nodeinfo = UBNodeInfo()
+
+ nodeinfo.address = args[7]
+ nodeinfo.port = args[8]
+ nodeinfo.node = node
if node not in self.nodes:
self.nodes.append(node)
- multicast = False
- if address[0:2] == 'ff':
- multicast = True
- self.newNode(node, address, multicast)
+ nodeinfo.multicast = nodeinfo.address[0:2] == 'ff'
+ self.newNode(nodeinfo)
def print_error(self, *args):
print 'error_handler'
@@ -53,9 +54,11 @@ def removehandler(self, interface, protocol, name, stype, domain, flags):
print "Removed service '%s' type '%s' domain '%s' " % (name, stype, domain)
print interface, protocol, name, stype, domain, flags
node = name + '.' + domain
+ nodeinfo = {}
+ nodeinfo['node'] = node
if node in self.nodes:
self.nodes.remove(node)
- self.removedNode(node)
+ self.removedNode(nodeinfo)
def newhandler(self, interface, protocol, name, stype, domain, flags):
#print "Found service '%s' type '%s' domain '%s' " % (name, stype, domain)
Please sign in to comment.
Something went wrong with that request. Please try again.