如何连接到运行Android Things的树莓派3,使用adb
进行连接?
针对树莓派的Android Things只支持使用以下命令使用adb-over-ip连接adb:
adb connect `<raspberry-pi-ip-address>`
您有多种选项可以找到您的IP地址,具体取决于您的Pi设置:
Android.local
if you have mDNS/Bonjour support, or see https://learn.pimoroni.com/tutorial/raspberry-pi/finding-your-raspberry-pi for info on how to find your Pi IP address using third-party tools.If you don't have any screen or Ethernet connection, you can connect a USB to TTL serial cable on the UART0 connector (see pinout and type the following command to connect to a WiFi network and get the Pi IP address:
am startservice -n com.google.wifisetup/.WifiSetupService \
-a WifiSetupService.Connect \
-e ssid '<NETWORK_SSID>' -e passphrase '<NETWORK PASSPHRASE>'
ifconfig
从Google Play下载一个终端仿真器(有很多是免费的)。确保您的Android设备已连接到Wi-Fi并获取Wi-Fi IP地址。打开终端程序并键入:
su setprop service.adb.tcp.port 5555 stop adbd start adbd 现在转到您的计算机(假设您正在使用Windows)并在桌面上为“cmd.exe”创建一个快捷方式(不带引号)。
右键单击cmd快捷方式,选择“以管理员身份运行”
更改为android-sdk-windows\tools文件夹
键入:
adb connect ***wifi.ip.address***:5555
(example: adb connect 192.168.0.105:5555)
现在adb应该显示您已连接。
注意:如果您太快地输入连接命令,可能会失败。因此,在您说这不起作用之前,请尝试至少两次间隔五秒钟。
按照以下步骤进行:
它适用于我的 Android 版本 [5.0]
安装 ConnectBot 在您的平板电脑上安装 ConnectBot,这是一个可从 Google Play 下载的 Android 终端模拟器。它允许 SSH 连接到 Raspberry Pi。
配置 Raspberry Pi 您可以通过任何方法连接到 Raspberry Pi 时执行这些更改。 将以下行添加到您的网络配置中:
vi /etc/network/interfaces
允许热插拔usb0 iface usb0 inet dhcp
当您已经连接了所有设备,并且不想重新启动时,只需重启网络:
/etc/init.d/networking restart
连接您的设备
使用微型 USB 电缆将 Android 平板电脑连接到 Raspberry Pi USB 端口。使用标准 USB 电源为 Raspberry Pi 提供电力。您可以使用任何 DC USB 电源。 **启用 Android USB 共享网络 在 Android 平板电脑上启用 USB 共享网络。
*设置 → 连接 → 共享网络和 Wi-Fi 热点 → USB 共享网络** 现在,Raspberry 将自动通过其 USB0 端口获取 IP 地址。Android 平板电脑表现得像 NAT 路由器。当您的平板电脑连接到 Wi-Fi 或移动 3G/4G 网络时,这应该都可以使用。
启动 SSH 登录 Raspberry Pi
在 Android 上启动 ConnectBot 应用
通过 SSH 登录 Raspberry Pi
唯一的问题是您必须知道 Raspberry Pi 的 IP 地址;它似乎是(总是?)192.168.42.159...
网络设置 此部分必须由您自己使用 SSH 和本地网络配置完成。