简体   繁体   中英

Android Things - How do I connect to my Raspberry Pi when I don't know the IP address

I have successfully managed to install the Android Things Dev Preview onto my Raspberry Pi.

I have a problem though. When I first started installing my own applications I was able to connect to the Raspberry Pi through Ethernet, because it displayed the IP address on the TV when I booted up the Raspberry Pi.

Now because I have the Raspberry Pi already running an application, when I boot it up, it is automatically booting into my application without showing the initial screen with the IP address (and I forgot my IP address 🤔).

Is there an easy way to get the IP address of the Raspberry Pi, or connect to it when I don't know the IP address? Even a command to get a list of all available ADB devices on the network would help.

It would be great if when connected to a certain Wi-Fi, you could run something like:

adb network devices

Which could give a list of ADB devices on the network you are on.

The Raspberry PI Automatically broadcasts Android.local and should resolve to the IP address assigned to your Pi on port 5555. Running the following:

adb connect Android.local

The command above is effectively the same as running:

adb connect <ip-address>:5555

Note: This will only work if your host platform supports multicast DNS service discovery.

This information was found in the documentation here by step 7 https://developer.android.com/things/hardware/raspberrypi.html

You can scan your network for points with ports 5555/5554 open, for example,

nmap -p 5555,5554 192.168.0.2-100

will scan in range 2-100 for any IP addresses with those ports open.

或者您可以检查路由器连接的设备

On OS X you can scan for all devices that publish itself as Android.local

dns-sd -Q Android.local

I believe you need Bonjour on Windows/Linux to get something similar, but I'm still not familiar with them.

After figuring out the correct IP for the desired device you can connect as usual:

adb connect <ip-address>:5555

If multicast DNS is not supported on host platform and you have access to your router, you can simply log into it and view the list of connected devices. You will be able to view all the devices no matter if mDNS is available or if there are any ports opened on the device (or if you don't know which port is opened).

如何使用应用程序中的IP地址进入初始屏幕的最简单方法是将USB键盘连接到Raspberry Pi,然后按一下转义键:)

I had the very same problem recently and the easiest way in my opinion is that to just install a simple app on your phone (in my case Fing ) that shows all the connected devices to your local connection including th RPI with their ip address. So then you are good to go!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM