Exemplo n.º 1
0
 def __init__( self, aDomain, aName, aVersion, aDevice ):
     self.lib             = PyOhNet.lib
     self.handle          = self.lib.CpProxyCreate( aDomain, aName, aVersion, aDevice.handle )
     self.service         = self.lib.CpProxyService( self.handle )
     self._propertyAnyCb  = None
     self._propertyInitCb = None
     self.actions         = []
     self.properties      = []
     self.semaReady       = threading.Semaphore( 0 )   # Sema rather than Event as can be multiple
     CB = PyOhNet.makeCb( None, ctypes.c_void_p )      # actions ongoing at any time
     self._AnyEvent = CB( self._AnyEventCb )
     CB = PyOhNet.makeCb( None, ctypes.c_void_p )
     self._InitEvent = CB( self._InitEventCb )
     PyOhNet.cpProxies.append( self )
Exemplo n.º 2
0
 def __init__( self, aService, aAction, aCb ):
     global gAsyncCbs
     self.lib = PyOhNet.lib
     self.callersCb = aCb
     CB = PyOhNet.makeCb( None, ctypes.c_void_p, ctypes.c_void_p )
     asyncCb = CB( self.AsyncComplete )
     self.handle = self.lib.CpServiceInvocation( aService, aAction.handle, asyncCb, None )
     gAsyncCbs.append( {'handle':self.handle, 'cb':asyncCb} )    # keep CB in scope until called
Exemplo n.º 3
0
    def __init__(self,
                 aDevName,
                 aDevDomain,
                 aDevType,
                 aDevVersion,
                 aTimeout=10,
                 aInterface=None):
        """Initialise class data, start ohNet and UPnP discovery"""
        self.nameToFind = None
        self.failed = False
        self.evVarUint = 0
        self.evVarInt = 0
        self.evVarStr = 0
        self.evVarBin = 0
        self.nameFound = threading.Event()
        self.initEvent = threading.Event()
        self.uintChanged = threading.Event()
        self.intChanged = threading.Event()
        self.boolChanged = threading.Event()
        self.strChanged = threading.Event()
        self.binChanged = threading.Event()
        self.anyChanged = threading.Event()

        ohNet.Initialise()
        ohNet.Start('CP', aInterface)

        dev = self.FindDev(aDevName, aDevDomain, aDevType, aDevVersion,
                           aTimeout)
        if dev:
            dev.Start()
            print('\n' + str(dev) + '\n')
            self.testBasic = dev.OpenhomeOrgTestBasic
            self.TestBasicProxy()
            dev.Shutdown()
        else:
            print('FAILED to find %s' % aDevName)

        if self.failed:
            print('\n*** FAILED ***')
        else:
            print('\n*** PASSED ***')
        ohNet.Shutdown()
        # noinspection PyProtectedMember
        os._exit(0)
Exemplo n.º 4
0
 def __init__(self, aDomain, aName, aVersion, aDevice):
     self.lib = PyOhNet.lib
     self.lib.CpProxyCreate.restype = ctypes.c_void_p
     self.handle = ctypes.c_void_p(
         self.lib.CpProxyCreate(aDomain, aName, aVersion, aDevice.handle))
     self.lib.CpProxyService.restype = ctypes.c_void_p
     self.service = ctypes.c_void_p(self.lib.CpProxyService(self.handle))
     self._propertyAnyCb = None
     self._propertyInitCb = None
     self.actions = []
     self.properties = []
     self.semaReady = threading.Semaphore(
         0)  # Sema rather than Event as can be multiple
     CB = PyOhNet.makeCb(None,
                         ctypes.c_void_p)  # actions ongoing at any time
     self._AnyEvent = CB(self._AnyEventCb)
     CB = PyOhNet.makeCb(None, ctypes.c_void_p)
     self._InitEvent = CB(self._InitEventCb)
     PyOhNet.cpProxies.append(self)
Exemplo n.º 5
0
 def ShowAdapters( ):
     adapterList = ohNet.AdapterList()
     print '\n %d network adapters detected' % adapterList.size
     for adapter in adapterList.adapters:
         print ''
         print '    FullName:       %s' % adapter.fullName
         print '    Name:           %s' % adapter.name
         print '    Address:        %d' % adapter.address
         print '    Address (str):  %s' % adapter.addressStr
         print '    Subnet:         %d' % adapter.subnet
         print '    Subnet (str):   %s' % adapter.subnetStr
         print '    Net Mask:       %d' % adapter.mask
         print '    Net Mask (str): %s' % adapter.maskStr
Exemplo n.º 6
0
 def ShowAdapters( ):
     adapterList = ohNet.AdapterList()
     print( '\n %d network adapters detected' % adapterList.size )
     for adapter in adapterList.adapters:
         print( '' )
         print( '    FullName:       %s' % adapter.fullName )
         print( '    Name:           %s' % adapter.name )
         print( '    Address:        %d' % adapter.address )
         print( '    Address (str):  %s' % adapter.addressStr )
         print( '    Subnet:         %d' % adapter.subnet )
         print( '    Subnet (str):   %s' % adapter.subnetStr )
         print( '    Net Mask:       %d' % adapter.mask )
         print( '    Net Mask (str): %s' % adapter.maskStr )
Exemplo n.º 7
0
 def __init__(self, aService, aAction, aCb):
     global gAsyncCbs
     self.lib = PyOhNet.lib
     self.callersCb = aCb
     CB = PyOhNet.makeCb(None, ctypes.c_void_p, ctypes.c_void_p)
     asyncCb = CB(self.AsyncComplete)
     self.lib.CpServiceInvocation.restype = ctypes.c_void_p
     self.handle = ctypes.c_void_p(
         self.lib.CpServiceInvocation(aService, aAction.handle, asyncCb,
                                      None))
     gAsyncCbs.append({
         'handle': self.handle,
         'cb': asyncCb
     })  # keep CB in scope until called
Exemplo n.º 8
0
    def __init__(self, aAddedCb, aRemovedCb):
        self.lib = PyOhNet.lib
        self.handle = None
        self.devices = []
        self.addedCbs = []
        self.removedCbs = []

        if aAddedCb:
            self.addedCbs.append(aAddedCb)
        if aRemovedCb:
            self.removedCbs.append(aRemovedCb)

        CB = PyOhNet.makeCb(None, ctypes.c_void_p, ctypes.c_void_p)
        self._PrimaryAddedCb = CB(self._Added)
        self._PrimaryRemovedCb = CB(self._Removed)
        PyOhNet.devLists.append(self)
Exemplo n.º 9
0
 def __init__( self, aAddedCb, aRemovedCb ):
     self.lib        = PyOhNet.lib
     self.handle     = None
     self.devices    = []
     self.addedCbs   = []
     self.removedCbs = []
     
     if aAddedCb:
         self.addedCbs.append( aAddedCb )
     if aRemovedCb:
         self.removedCbs.append( aRemovedCb )
     
     CB = PyOhNet.makeCb( None, ctypes.c_void_p, ctypes.c_void_p )
     self._PrimaryAddedCb = CB( self._Added )
     self._PrimaryRemovedCb = CB( self._Removed )
     PyOhNet.devLists.append( self )
Exemplo n.º 10
0
 def __init__( self ):
     ohNet.Initialise()
Exemplo n.º 11
0
 def Shutdown( ):
     ohNet.Shutdown()
Exemplo n.º 12
0
 def __init__( self, aName, aCb ):
     self.lib = PyOhNet.lib
     self.handle = None
     self.name = aName
     CB = PyOhNet.makeCb( None, ctypes.c_void_p )
     self.callback = CB( aCb )
Exemplo n.º 13
0
 def __init__(self, aAdapter=None):
     ohNet.Initialise()
     ohNet.Start('CP', aAdapter)
     self.devList = None
Exemplo n.º 14
0
 def __init__( self, aName, aCb ):
     self.lib = PyOhNet.lib
     self.handle = None
     self.name = aName
     CB = PyOhNet.makeCb( None, ctypes.c_void_p )
     self.callback = CB( aCb )