Ejemplo n.º 1
0
    def addDevicesToFilter(self):
        try:
            deviceIDs = getDeviceIDs()
            if len(deviceIDs) == 0:
                print('No device to add')
                return

            filter = self.connectSvc.getAcceptFilter()
            filter.allowAll = False

            for devID in deviceIDs:
                existing = False
                for existingDevID in filter.deviceIDs:
                    if devID == existingDevID:
                        existing = True
                        break

                if not existing:
                    filter.deviceIDs.append(devID)

            self.connectSvc.setAcceptFilter(filter)
            self.showAcceptFilter()

        except grpc.RpcError as e:
            print(f'Cannot add devices to the filter: {e}')
Ejemplo n.º 2
0
    def disableSSL(self):
        deviceIDs = getDeviceIDs()

        if len(deviceIDs) == 0:
            print('No device to disable', flush=True)
            return

        try:
            self.connectSvc.disableSSL(deviceIDs)
        except grpc.RpcError:
            pass
Ejemplo n.º 3
0
    def deleteAsyncConnection(self):
        deviceIDs = getDeviceIDs()

        if len(deviceIDs) == 0:
            print('No device to delete', flush=True)
            return

        try:
            self.connectSvc.deleteAsyncConnection(deviceIDs)
            self.showAsyncConnection()

        except grpc.RpcError as e:
            print(f'Cannot delete async connections: {e}')
Ejemplo n.º 4
0
    def setConnectionMode(self):
        deviceIDs = getDeviceIDs()

        if len(deviceIDs) == 0:
            print('No device to set', flush=True)
            return

        modeStr = input(
            '>> Select the connection mode (0: Gateway to Device(default), 1: Device to Gateway): '
        )
        mode = connect_pb2.SERVER_TO_DEVICE
        if modeStr.strip() == '1':
            mode = connect_pb2.DEVICE_TO_SERVER

        try:
            self.connectSvc.setConnectionMode(deviceIDs, mode)
        except grpc.RpcError:
            pass
Ejemplo n.º 5
0
    def deleteDevicesFromFilter(self):
        try:
            deviceIDs = getDeviceIDs()
            if len(deviceIDs) == 0:
                print('No device to delete')
                return

            filter = self.connectSvc.getAcceptFilter()
            filter.allowAll = False

            for devID in deviceIDs:
                try:
                    filter.deviceIDs.remove(devID)
                except ValueError:
                    pass

            self.connectSvc.setAcceptFilter(filter)
            self.showAcceptFilter()

        except grpc.RpcError as e:
            print(f'Cannot add devices to the filter: {e}')