openatx / adbutils

pure python adb library for google adb service.
MIT License
761 stars 175 forks source link

How do I connect 2 devices at once ? #32

Closed Liquid72 closed 3 years ago

Liquid72 commented 3 years ago

Hello, I want to ask if there is a way to connect 2 devices at once?

liurui1515 commented 3 years ago

I have the same issue

iforvard commented 3 years ago

You need to create a connection for each device.

from adbutils import adb

def connect_adb_device(serial='127.0.0.1:21503'):
    """
    serial default:
    MEmu - '127.0.0.1:21503'
    BlueStacks - 'emulator-5554'
    """
    connect_device = adb.device(serial)
    return connect_device

def scan_adb_device():
    s_list = []
    for index, d in enumerate(adb.device_list()):
        print(f' № {index} - ', d.serial[-2:])  # print device serial
        s_list.append(d.serial)
    return s_list

devices = scan_adb_device()
id_emulator = int(input('Enter number emulator '))
CONN_D = connect_adb_device(devices[id_emulator])