Example #1
0
    def connect(klass, address, channel=1, method="RFCOMM"):
        if klass.isConnected(address):
            raise Exception("All ready connected to %s" % address)

        if klass.isPending(address):
            raise Exception("Connection to %s is pending" % address)

        klass.pending.append(address)
        settings = klass.getCamera(address, True)
        method = getattr(settings, "transport", method)
        c = getattr(twisted_bluetooth, "connect%s" % method)

        if klass.FACTORY == None:
            klass.FACTORY = klass()

        if method == "RFCOMM":
            channel = 1
        elif method == "L2CAP":
            channel = 0x1001
        log.msg("Connecting to %s using %s channel %s" %
                (address, method, channel))

        from airi.api import UpdateManager
        UpdateManager.propagate(address, {"status": "Connecting"})
        c(reactor, address, channel, klass.FACTORY)
Example #2
0
    def connect(klass, address, channel=1, method="RFCOMM"):
        if klass.isConnected(address):
            raise Exception("All ready connected to %s" % address)

        if klass.isPending(address):
            raise Exception("Connection to %s is pending" % address)

        klass.pending.append(address)
        settings = klass.getCamera(address, True)
        method = getattr(settings, "transport", method)
        c = getattr(twisted_bluetooth, "connect%s" % method)

        if klass.FACTORY == None:
            klass.FACTORY = klass()

        if method == "RFCOMM":
            channel = 1
        elif method == "L2CAP":
            channel = 0x1001
        log.msg("Connecting to %s using %s channel %s" %
                (address, method, channel))

        from airi.api import UpdateManager
        UpdateManager.propagate(address, {"status": "Connecting"})
        c(reactor, address, channel, klass.FACTORY)
Example #3
0
 def set(self, option, value):
   dbg("set %s->%s" % (option, value) )
   if option=="size":
       self.doSetSize(value)
       from airi.api import UpdateManager
       UpdateManager.propagate(self.address, {"size": value})
   else:
       dbg("ignored")
Example #4
0
 def set(self, option, value):
     dbg("set %s->%s" % (option, value) )
     if option=="size":
             self.doSetSize(value)
             from airi.api import UpdateManager
             UpdateManager.propagate(self.address, {"size": value})
     else:
             dbg("ignored")
Example #5
0
 def buildProtocol(self, addr):
     log.msg("Connected %s" % str(addr))
     if addr in CameraFactory.pending:
         CameraFactory.pending.remove(addr)
     from airi.api import UpdateManager
     UpdateManager.propagate(addr[0], {"status": True})
     CameraFactory.clients[addr[0]] = Camera(addr[0])
     CameraFactory.clients[addr[0]].gotFrame = partial(
         CameraFactory.gotFrame, addr[0])
     return CameraFactory.clients[addr[0]]
Example #6
0
 def buildProtocol(self, addr):
     log.msg("Connected %s" % str(addr))
     if addr in CameraFactory.pending:
         CameraFactory.pending.remove(addr)
     from airi.api import UpdateManager
     UpdateManager.propagate(addr[0], {"status": True})
     CameraFactory.clients[addr[0]] = Camera(addr[0])
     CameraFactory.clients[addr[0]].gotFrame = partial(
         CameraFactory.gotFrame, addr[0])
     return CameraFactory.clients[addr[0]]
Example #7
0
    def setCamera(self, configuration):
        if "address" not in configuration:
            raise Exception("You need to set address")

        section = self.getCameraSection(configuration["address"], True)

        for key, value in configuration.iteritems():
            self.setCameraSetting(configuration["address"], key, value, section=section)
        self.save()
        from airi.api import UpdateManager

        UpdateManager.propagate(configuration["address"], configuration)
Example #8
0
    def __lostConnection(self, addr, reason, failed):
        rep = False

        if addr in CameraFactory.pending:
            CameraFactory.pending.remove(addr)

        if addr in CameraFactory.listeners:
            for listener in CameraFactory.listeners[addr]:
                rep = rep or listener.lostConnection(reason, failed,
                                    address=addr)

        if not rep:
            CameraFactory.__cleanup(addr)
        from airi.api import UpdateManager
        UpdateManager.propagate(addr, {"status": False})

        if __name__ == '__main__' and reactor.running:
            reactor.stop()
Example #9
0
    def __lostConnection(self, addr, reason, failed):
        rep = False

        if addr in CameraFactory.pending:
            CameraFactory.pending.remove(addr)

        if addr in CameraFactory.listeners:
            for listener in CameraFactory.listeners[addr]:
                rep = rep or listener.lostConnection(reason, failed,
                                    address=addr)

        if not rep:
            CameraFactory.__cleanup(addr)
        from airi.api import UpdateManager
        UpdateManager.propagate(addr, {"status": False})

        if __name__ == '__main__' and reactor.running:
            reactor.stop()
Example #10
0
    def delPIN(self, block):
        self._remove_option("pin", block.replace(":", "_"))
        from airi.api import UpdateManager

        UpdateManager.propagate(block.replace(":", "_"), {"pin": None})
Example #11
0
    def setPIN(self, npin, block="default"):
        self._set("pin", block.replace(":", "_"), str(npin))
        from airi.api import UpdateManager

        UpdateManager.propagate(block.replace(":", "_"), {"pin": npin})
Example #12
0
 def tellClientCount(klass, address):
     from airi.api import UpdateManager
     UpdateManager.propagate(
         address, {"client_count": len(klass.getClients(address))})
Example #13
0
 def tellClientCount(klass, address):
     from airi.api import UpdateManager
     UpdateManager.propagate(address, {
         "client_count": len(klass.getClients(address))})