Skip to content

Commit a3a4ebb

Browse files
committed
feat: updated quickstart scripts to add interface option and create LLM config override if missing
1 parent c014bb7 commit a3a4ebb

File tree

2 files changed

+54
-9
lines changed

2 files changed

+54
-9
lines changed

mobile-use.ps1

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
[CmdletBinding(PositionalBinding=$false)]
2+
param (
3+
[string]$Interface = "",
4+
[Parameter(ValueFromRemainingArguments)]
5+
[string[]]$RemainingArgs
6+
)
7+
8+
19
$ErrorActionPreference = "Stop"
210
Set-StrictMode -Version Latest
311

@@ -105,16 +113,22 @@ if ($tcp_devices) {
105113
if (Is-EmulatorDevice -DeviceSerial "$selected_device_serial") {
106114
$device_ip_only = "host.docker.internal"
107115
} else {
108-
# Try different common Wi-Fi interface names
109-
$wifi_interfaces = @("wlan0", "wlan1", "wifi0", "wifi1", "rmnet_data1")
110116
$device_ip_only = $null
117+
$wifi_interfaces = @()
118+
if (-not [string]::IsNullOrEmpty($Interface)) {
119+
Write-Host "Using specified network interface: $Interface"
120+
$wifi_interfaces = @($Interface)
121+
} else {
122+
# Try different common Wi-Fi interface names
123+
$wifi_interfaces = @("wlan0", "wlan1", "wifi0", "wifi1", "rmnet_data1", "swlan0", "swlan1")
124+
}
111125

112-
foreach ($interface in $wifi_interfaces) {
113-
$ADB_COMMAND = "ip -f inet addr show $interface | grep 'inet ' | awk '{print `$2}' | cut -d/ -f1"
126+
foreach ($interface_item in $wifi_interfaces) {
127+
$ADB_COMMAND = "ip -f inet addr show $interface_item | grep 'inet ' | awk '{print `$2}' | cut -d/ -f1"
114128
$ip_result = adb -s $selected_device_serial shell $ADB_COMMAND
115129
if ($ip_result -and $ip_result.Trim() -ne "") {
116130
$device_ip_only = $ip_result.Trim()
117-
Write-Host "Found IP on interface $interface`: $device_ip_only"
131+
Write-Host "Found IP on interface $interface_item`: $device_ip_only"
118132
break
119133
}
120134
}
@@ -133,4 +147,8 @@ if ($tcp_devices) {
133147
Write-Output "Device IP is: $device_ip"
134148
$env:ADB_CONNECT_ADDR = "$device_ip"
135149

136-
docker compose run --build --rm --remove-orphans -it mobile-use-full-ip $args
150+
if (-not (Test-Path "./llm-config.override.jsonc")) {
151+
[System.IO.File]::WriteAllText("./llm-config.override.jsonc", "{}")
152+
}
153+
154+
docker compose run --build --rm --remove-orphans -it mobile-use-full-ip $RemainingArgs

mobile-use.sh

100644100755
Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
set -eu
44

5+
network_interface=""
6+
7+
# All arguments that are not script options will be passed to docker compose
8+
docker_args=()
9+
10+
while [[ $# -gt 0 ]]; do
11+
case "$1" in
12+
-i|--interface)
13+
network_interface="$2"
14+
shift 2
15+
;;
16+
*)
17+
docker_args+=("$1")
18+
shift
19+
;;
20+
esac
21+
done
22+
523
select_usb_device() {
624
local serials
725
serials=($(adb devices | grep -w "device" | awk '{print $1}'))
@@ -87,9 +105,14 @@ else
87105
if is_emulator_device "$selected_device_serial"; then
88106
device_ip_only="host.docker.internal"
89107
else
90-
# Try different common Wi-Fi interface names
91-
wifi_interfaces=("wlan0" "wlan1" "wifi0" "wifi1" "rmnet_data1")
92108
device_ip_only=""
109+
if [ -n "$network_interface" ]; then
110+
echo "Using specified network interface: $network_interface"
111+
wifi_interfaces=("$network_interface")
112+
else
113+
# Try different common Wi-Fi interface names
114+
wifi_interfaces=("wlan0" "wlan1" "wifi0" "wifi1" "rmnet_data1", "swlan0", "swlan1")
115+
fi
93116

94117
for interface in "${wifi_interfaces[@]}"; do
95118
ADB_COMMAND="ip -f inet addr show $interface | grep 'inet ' | awk '{print \$2}' | cut -d/ -f1"
@@ -114,4 +137,8 @@ fi
114137
echo "Device IP is: $device_ip"
115138
export ADB_CONNECT_ADDR="$device_ip"
116139

117-
docker compose run --build --rm --remove-orphans -it mobile-use-full-ip "$@"
140+
if [ ! -f "./llm-config.override.jsonc" ]; then
141+
echo "{}" > "./llm-config.override.jsonc"
142+
fi
143+
144+
docker compose run --build --rm --remove-orphans -it mobile-use-full-ip "${docker_args[@]}"

0 commit comments

Comments
 (0)