16

I want to connect from an android phone to a RPI 3 over Wi-Fi direct.

I want to do it over Wi-Fi direct because the RPI will be a controller for one or more movable devices that will be used in buildings as well as out in the nature.

In buildings, it could just connect to the existing Wi-Fi, but in the nature there is no Wi-Fi. Therefore, the RPI would need to be its own AP, but then the phone controlling it could not be connected to the building's Wi-Fi at the same time. Also, it would get complicated with multiple RPIs, one would need to be the AP and the others would need to connect to it.

It would be cool if I just could power up the RPIs, withouth doing any configuration every time their setup changes, and connect to it regardless from where it's used.

So with Wi-FI direct being a requirement: How can I do this? Can someone provide me with an example (or a Link to an example)? Basically any hint that brings me closer to the target will help.

what i have so far

I've installed Arch Linux ARM on the PI using this guide:https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3

Then I've installed wpa_supplicant using "pacman -S wpa_supplicant"

Then I've created a small configuration for it under "/etc/wpa_supplicant/p2p.conf" that contains:

ctrl_interface=/var/run/wpa_supplicant
device_name=PI
update_config=1

then I've started wpa_supplicant using wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/p2p.conf

Then I've tested Wi-Fi direct using wpa_cli and then p2p_find which found my phone. So I assum driver-wise, everything's good.

I just need to figure out how to use wpa_supplicant to register a server-program running on my PI, and how find & connect to it from android.

Any ideas?

  • No luck with this one? I'm trying to do the same but connect from another pi3 using wifi-direct. – Roberto Andrade Jun 9 '16 at 3:18
  • @RobertoAndrade I managed to do it. I just forgot to update the question. I'll do so soon ;) – Van Coding Jun 9 '16 at 9:18
  • Some progress here, but erratic behaviour yet – albfan Jul 7 '16 at 20:06
  • @VanCoding Did you post your update anywhere? I have got to the same point as you - Android and Pi 3 can see eachother, but need to link it to an application. – LC1983 Jan 31 '17 at 16:17
  • @LC1983 no. Unfortunately, i programmed directly on the PI via sftp, which is in use as a whirlpool controller now. I forgot to copy over the files, before giving it away. I'm still waiting to get my hands on the code again :( – Van Coding Feb 1 '17 at 12:18
5

I configure /etc/wpa_supplicant/wpa_supplicant.conf as below for two RPi3:

ctrl_interface=DIR=/var/run/wpa_supplicant 
update_config=1

ap_scan=1
device_name=RPi_3
device_type=1-0050F204-1
driver_param=use_p2p_group_interface=1
driver_param=p2p_device=1
p2p_go_intent=10
p2p_go_ht40=1

Then start it with command:

$sudo wpa_supplicant -B -dd -iwlan0 -Dnl80211 -c /etc/wpa_supplicant/wpa_supplicant.conf

Then following this link, I connect two RPi3 via PIN authentication:

RPi3_1: (using sudo if neccessary)

wpa_cli p2p_find

RPi3_2: (using sudo if neccessary)

wpa_cli p2p_find
wpa_cli p2p_peers

Then they recognize each other the MAC address. Subsequently, one RPI will start connection with PIN generated:

RPi3_1 (using sudo if neccessary):

wpa_cli p2p_connect xx:xx:xx:xx:xx:xx pin auth
(pin_number will be issued)

RPi3_2:

wpa_cli p2p_connect yy:yy:yy:yy:yy:yy pin_number

Where xx:..:xx, and yy:..:yy are the MAC address of RPi3_2 and RPi3_1 respectively.

http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WiFi_Direct_Configuration_Scripts#Create_1:2_P2P_Group_-_Connect_with_PIN_code

Basically, two RPi3 connected with each other.

  • This answer is OK if you are using two devices which you can step through the commands individually, but when using a Pi3 and an Android device, as per the original question, it does not work reliably. – LC1983 Feb 6 '17 at 11:35
  • When you connect the 2 RPi3's this way, are they able to create a group successfully for connection? When I do it, the GO-NEG is successful but it fails to create a group for the connection. – shortstheory Jan 24 '18 at 19:20
-2

use the android as a hotspot and wifi to it from the PI 3, u will keep the android conneciton to the internet and have connection between both devices to share whatever

  • 1
    While possibly a solution, that was not what the OP wanted to achieve - it clearly states "I want to connect from an android phone to a RPI 3 over Wi-Fi direct.", not the other way around. – Bex Nov 16 '16 at 7:01
  • Using devicenet you can then use wifi direct with android hotspot. so its answers this 110%. it not only keeps "I want to connect from an android phone to a RPI 3 over Wi-Fi direct" in play, you can simplify this entire thing by just using android hotspot. – Paulie617 Nov 16 '16 at 19:28
  • This does not help the OP develop an ad-hoc network between the phone and the pi. – Sandor Dosa Feb 22 '17 at 5:50
  • 1
    I know this got downvoted to hell but just wanted to say thanks. I was trying to set up WiFi direct and just realized that for my specific use case I could do just this – nolanpro Mar 10 '18 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.