#!/usr/bin/env bash # Reconnect to the Quest 3 via SideQuest's ADB and expose its browser CDP on :9222 set -u ADB=${ADB:-/opt/SideQuest/resources/platform-tools/adb} CDP_PORT=${CDP_PORT:-9222} if ! [ -x "$ADB" ]; then echo "adb not found at $ADB" >&2; exit 1; fi echo "== devices ==" $ADB devices -l if ! $ADB devices | grep -qE '\bdevice$'; then echo "!! no authorized device. Reconnect SideQuest (wireless ADB) and retry." >&2 exit 2 fi echo "== forward tcp:$CDP_PORT ==" $ADB forward --remove-all >/dev/null 2>&1 $ADB forward "tcp:$CDP_PORT" localabstract:chrome_devtools_remote echo "== verify ==" for i in 1 2 3 4 5; do v=$(curl -s --max-time 3 "http://127.0.0.1:$CDP_PORT/json/version" || true) if [ -n "$v" ]; then echo "$v"; echo "OK: CDP ready on 127.0.0.1:$CDP_PORT"; exit 0; fi sleep 1 done echo "!! CDP not answering on $CDP_PORT" >&2 exit 3