Pitter
Posts: 8
Joined: Wed May 11, 2016 2:36 pm

Get IP of the access point

Wed May 11, 2016 2:48 pm

Hello everyone,

i want to use my rpi to deliver the camera pictures using wifi broadcast to my android phone.
If background information is needed:

https://befinitiv.wordpress.com/wifibro ... ideo-data/

http://fpv-community.de/showthread.php? ... OpenSource

In short: the RPI sends camera data to my phone. Therefore i need to create a wlan hotspot with my mobile phone (see App description). Everytime i start the hotspot, the IP of my phone changes => i have to manually correct the command which sends the picture data. Not possible (at least not comfortable) while on the field with my quadrocopter.

I want to automate the whole process so that i only have to power my Rpi, and the data is send as soon as the Rpi is booted up. Therefore i need to know: how can i retrieve the IP of my mobile phone ?? And how to integrate this into a bootscript (the images for the rpi are prebuilt, i have little knowledge of linux).

Thanks in advance

mutley
Posts: 61
Joined: Sat Jan 02, 2016 8:06 pm

Re: Get IP of the access point

Wed May 11, 2016 5:20 pm

If your phone is the WiFi hotspot and the RPI the WiFi client, then the default gateway on the PI should be the IP of the phone.

This command will give you the IP (Listed under gateway)
route -n
--or--
netstat -r -n

This will just print the IP if the above works
route -n | awk 'match($2,/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/) {print $2}'

Depending on the configuration of the hotspot, you may also find the ip in your resolve.conf file on the PI. `cat /etc/resolve.conf`

If your RPI is the WiFi hotspot the the phone the client, then that's more complicated.

Pitter
Posts: 8
Joined: Wed May 11, 2016 2:36 pm

Re: Get IP of the access point

Wed May 11, 2016 7:20 pm

Thank you very much. Gonna test this tommorow. Your code already worked for me, but atm my rpi is connected only to my router, so i cant say if your solution works for RPI >> Phone-Hotspot. Report back later.

Further question: where can i find information about the start sequence of the rpi? I mean, which processes start etc. Something like "msconfig" for Windows.

mutley
Posts: 61
Joined: Sat Jan 02, 2016 8:06 pm

Re: Get IP of the access point

Wed May 11, 2016 8:52 pm

Depending on what you have installed, this can be a pain with the current Jessie distribution. Linux usually has either sysvinit jobs or upstart jobs that do this. Jessie has a mix of both depending on what else you may have installed. I don't have access to anything to check at the moment, but below are the commands that should point you in the right direction.
service --status-all
--and--
initctl list

Return to “General discussion”