Wifi direct connection disconnects automatically after a few seconds in Raspberry Pi

旧城冷巷雨未停 提交于 2019-12-05 12:24:16

Your Raspberry Pi is probably in the P2P Group Owner (GO) role since you are manually creating a group with the p2p_group_add command (autonomous GO) rather than letting the devices negotiate based on their GO intent values. p2p_go_intent=1 in your config would likely have no effect in this case.

The device in the GO role should run a DHCP server in order to assign IP addresses to the connecting P2P Clients. Correspondingly, each client should run a DHCP client in order to receive an IP address.

Excerpt from Section 3.2.6.1 of the Wi-Fi P2P Technical Spec:

Higher-layer data services may use IP. The P2P Group Owner shall act as a DHCP server to provide IP addresses to the connected P2P Clients that use IP. The DHCP Server shall at a minimum support Internet Protocol version 4 (IPv4) and assignment of an IP address, subnet mask...

...A P2P Client that uses IP shall be capable of acting as a DHCP Client.

Note — While a P2P Device can select distinct IP subnets for each P2P Group for which it is P2P Group Owner, it is possible that a P2P Device connected to more than one P2P Group may end up with colliding subnets. Use of a random component in the selection of IP subnet may reduce the probability of (but not eliminate) this situation occurring

I think you will find that the Android device is waiting to receive an IP configuration via DHCP before moving on to a connected state, timing out if that does not happen.

To make the connection persistent the group needs to be created as a persistent group. You should be able to do that in the autonomous GO scenario with p2p_group_add persistent. In the negotiated GO scenario you should be able to do something like p2p_connect <peer device address> <pbc|pin|PIN#|p2ps> [display|keypad|p2ps] persistent go_intent=15. See the wpa_supplicant README-P2P for further details: https://w1.fi/cgit/hostap/plain/wpa_supplicant/README-P2P.

Finally, the command wps_pin any <PIN> allows any device to connect using the provided PIN but restricts the PIN to one-time-use. Either use the wps_pin <address> <PIN> form or set a new PIN by running wps_pin any <PIN> again.

I am running almost the very same scenario at the moment, follow the first section

Setting up a Raspberry Pi as an access point in a standalone network (NAT)

at this link in order to install/comfigure DHCP service on the Pi:

https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

Btw, if it works for you, can you please share the order of running dhcp and enabling wifi p2p as I am sort of having trouble with p2p after enabling dhcp.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!