18

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?

Van Coding
  • 309
  • 1
  • 2
  • 5

2 Answers2

6

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.

Ghanima
  • 15,958
  • 17
  • 65
  • 125
ngovanmao
  • 161
  • 1
  • 4
-1

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

Paulie617
  • 31
  • 3