Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Connect Wireless Debug from Terminal on Android11
#!/usr/bin/env python3
Pair and connect devices for wireless debug on terminal
python-zeroconf: A pure python implementation of multicast DNS service discovery
import subprocess
from zeroconf import ServiceBrowser, Zeroconf
TYPE = "_adb-tls-pairing._tcp.local."
NAME = "debug"
PASS = "123456"
FORMAT_QR = "WIFI:T:ADB;S:%s;P:%s;;"
CMD_SHOW = "qrencode -t UTF8 '%s'"
CMD_PAIR = "adb pair %s:%s %s"
CMD_DEVICES = "adb devices -l"
class MyListener:
def remove_service(self, zeroconf, type, name):
print("Service %s removed." % name)
print("Press enter to exit...\n")
def add_service(self, zeroconf, type, name):
info = zeroconf.get_service_info(type, name)
print("Service %s added." % name)
print("service info: %s\n" % info)
def pair(self, info):
cmd = CMD_PAIR % (info.server, info.port, PASS)
print(cmd), shell=True)
def main():
text = FORMAT_QR % (NAME, PASS) % text, shell=True)
print("Scan QR code to pair new devices.")
print("[Developer options]-[Wireless debugging]-[Pair device with QR code]")
zeroconf = Zeroconf()
listener = MyListener()
browser = ServiceBrowser(zeroconf, TYPE, listener)
input("Press enter to exit...\n\n")
zeroconf.close(), shell=True)
if __name__ == '__main__':

This comment has been minimized.

Copy link
Owner Author

@benigumocom benigumocom commented Sep 20, 2020

【謎?】QRコードによるデバイスのペア設定 – Android11


This comment has been minimized.

Copy link

@AfzalivE AfzalivE commented Oct 29, 2020

Thank you for writing this script!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment