def connect(self, address, adapter='hci0'):
        if self.conn is None:
            self.address = address
            cmd = ' '.join(['gatttool', '-b', address, '-i', adapter, '-I'])
            self.conn = pexpect.spawn(cmd)
            self.conn.expect(r'\[LE\]>', timeout=1)
            self.conn.sendline('connect')
            try:
                self.conn.expect(r'Connection successful', timeout=10)
                print("Connected to " + address)
            except pexpect.TIMEOUT:
                raise Exception("Unable to connect to device")
        else:
            raise Exception("Device already connected! Call disconnect before attempting a new connection")
Open an interactive connection to a bluetooth device
dataset/ETHPy150Open ALPSquid/thebutton-monitor/src/gatt.py/connect.connect