如何设置Android和Linux之间的WiFi的直接连接 [英] How to set up a Wifi-Direct connection between Android and Linux

查看:4332
本文介绍了如何设置Android和Linux之间的WiFi的直接连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要连接使用WiFi的直接两台设备。
一个是与Linux的(我的测试中我使用的是Linux Mint的17.2)的PC,另一个是Android智能手机(三星Galaxy S3搭载Android 4.3。不生根不想根)。

I want to connect two devices using Wifi-Direct. One is a pc with Linux (during my test I'm using Linux Mint 17.2), the other is an Android smartphone (Samsung Galaxy S3 with Android 4.3. Not rooted and don't want to root).

阅读了一些互联网上的导游,我决定在Linux中使用wpa_supplicant并创建为Android的应用程序。
这是我发现的wpa_supplicant的最佳指南之一:
<一href=\"http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WiFi_Direct_Configuration_Scripts#p2p_group_add\" rel=\"nofollow\">http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WiFi_Direct_Configuration_Scripts#p2p_group_add

Reading a number of guides on the internet, I decided to use wpa_supplicant in Linux and to create an app for Android. This is one of the best guides I found for wpa_supplicant: http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WiFi_Direct_Configuration_Scripts#p2p_group_add

当我运行IW列表我看到支持的接口模式:让P2P_client和P2P_GO。
我的wpa_supplicant.conf包括:

When I run iw list I see that the "Supported interface modes:" allows P2P_client and P2P_GO. My wpa_supplicant.conf contains:

ctrl_interface=/var/run/wpa_supplicant
update_config=1 

ap_scan=1
device_name=My-pc
device_type=1-0050F204-1
driver_param=use_p2p_group_interface=1

p2p_go_intent=15
p2p_go_ht40=1

该应用程序是非常相似,这个例子(这是从一本书)<一个href=\"http://kurser.iha.dk/eit/itsmap/basic/MEIER/Professional%20Android%204%20All%20downloads/9781118102275%20PA4AD/$c$c%20Snippets/Chapter%2016/PA4AD_Ch16_WiFiDirect/src/com/paad/wifidirect/WiFiDirectActivity.java\" rel=\"nofollow\">http://kurser.iha.dk/eit/itsmap/basic/MEIER/Professional%20Android%204%20All%20downloads/9781118102275%20PA4AD/$c$c%20Snippets/Chapter%2016/PA4AD_Ch16_WiFiDirect/src/com/paad/wifidirect/WiFiDirectActivity.java
(我删除了整个插座部分)。

The app is very similar to this example (it's from a book) http://kurser.iha.dk/eit/itsmap/basic/MEIER/Professional%20Android%204%20All%20downloads/9781118102275%20PA4AD/Code%20Snippets/Chapter%2016/PA4AD_Ch16_WiFiDirect/src/com/paad/wifidirect/WiFiDirectActivity.java (I removed the whole "socket part").

据按预期工作。当我有两个Android设备尝试一下,就可以看到对方,并连接(它出现在WiFi的直接图标)。

It works as expected. When I try it with two Android devices, they can see each other and connect (it appear the Wifi-Direct icon).

现在我试图连接的Andr​​oid和Linux,但我想我真的不知道如何的wpa_supplicant工作。
我也看到了这个问题,这是非常相似,我问过,但它并没有真正回答我的疑惑...
<一href=\"http://stackoverflow.com/questions/17793254/direct-wifi-communication-between-android-smartphone-and-other-devices\">Direct Android智能手机和其他设备之间的通信的WiFi

Now I am trying to connect Android and Linux, but I guess I don't really understand how wpa_supplicant works. I also saw this question that is very similar to what I asked, but it doesn't really answer my doubts... Direct Wifi Communication between android smartphone and other devices

我的问题是,我不明白怎么做两台设备之间如何握手建立网络。

My problem is that I can't understand how to do the handshake between the two devices and how to set up the network.

wpa_supplicant是我的问题。我运行:

Wpa_supplicant is my problem. I run:

sudo wpa_supplicant -wlan0 -Dnl80211 -c/etc/wpa_supplicant.conf
sudo wpa_cli

不过,我有很多的问题:
- 该设备名(以及其他参数)未设置为我.conf文件中specifiend
- 的wpa_supplicant继续尝试连接到所有的网络
- p2p_find真的很慢...

But I had a lot of problems: - The device_name (and other parameters) weren't set as I specifiend in the .conf file - wpa_supplicant continues to try to connect to all the networks - p2p_find was really slow...

让我去到/ usr /共享/的dbus-1 /系统服务,并搬走了这两个文件

so I went into /usr/share/dbus-1/system-services and moved away the two files

fi.epitest.hostap.WPASupplicant.service
fi.w1.wpa_supplicant1.service

现在我可以

sudo killall wpa_supplicant

和它真的死了,从无线断开我无需重新连接第二个以下。
现在,我可以启动的wpa_supplicant和三个问题都解决了。

and it really dies, disconnecting me from Wifi without reconnecting the following second. Now I can launch wpa_supplicant and the three problems are resolved.

我进入wpa_cli,推出p2p_find,并在同一时间,我能够从应用程序内进行搜索。

I go into wpa_cli, launch "p2p_find" and at the same time, I enable the search from within the app.

Android和Linux现在可以看到对方。

Android and Linux can now see each other.

P2P-DEVICE-FOUND 00:11:22:44:88:ff p2p_dev_addr=00:11:22:44:88:ff
pri_dev_type=10-0050F204-5 name='GT-I9300' config_methods=0x188
dev_capab=0x24 group_capab=0x0 vendor_elems=1 new=0

使用p2p_peers我可以看到手机的MAC。

With "p2p_peers" I can see the cellphone MAC.

> aa:bb:cc:dd:ee:ff

在这里我不能下去。我尝试过各种可能性,但没有一次成功。我的目标是让Linux作为组所有者。

Here I can't go ahead. I tried various possibilities, but none of them worked. My objective is to have Linux as Group Owner.


  • 问题1.1:这是握手两个设备的正确方法

  • 问题1.2:当我尝试p2p_connect我经常得到的结果之间的检测迈克尔MIC失败,这是什么意思在本次大赛

  • 问题1.3:Android系统目前尝试与PBC连接。还有就是用PIN连接方式?

看见我无法连接的Andr​​oid / Linux的,我试着做一些练习使用Linux / Linux操作系统(Linux Mint的是GO,Ubuntu的作为客户端),下面像在第一个链接的那些从互联网上的例子。
我有一些问题,甚至在这里。

Seeing that I couldn't connect Android/Linux, I tried to do some practice with Linux/Linux (Linux Mint as GO, Ubuntu as Client), following examples from internet like the ones in the first link. I have a number of problems even here.

在薄荷我尝试

p2p_connect MAC_UBUNTU pin auth

在Ubuntu中我尝试

in Ubuntu I try

p2p_connect MAC_MINT PIN_GENERATED_BY_MINT

当我写在铸币局psp_connect,它会创建一个新的接口p2p_wlan0 _0,并将其返回

When I write the psp_connect in Mint, it creates a new interface p2p_wlan0 _0, and it returns

P2P-DEVICE-LOST p2p_dev_addr=MAC_UBUNTU

然后从Ubuntu的推出p2p_connect失败。

then the p2p_connect launched from Ubuntu fails.


  • 问题2.1为什么创建组时?
  • 切换界面
  • 问题2.2什么是处理这一变化的正确方法?变更后我不能p2p_find Ubuntu的了(我必须等待一段时间或重新启动一切)

  • 问题2.3 Ubuntu的应该改变它的界面?

  • 问题2.3在新的界面,我应该设置IP为Ubuntu和薄荷......我应该怎么办?这跟静态IP地址?

  • 问题2.4如果我想建立例如DHCP服务器和客户端?

  • Question 2.1 Why it switches interface when creating the group?
  • Question 2.2 What is the correct way to handle this change? After the change I can't p2p_find Ubuntu anymore (I have to wait some time or restart everything)
  • Question 2.3 Should Ubuntu change it's interface?
  • Question 2.3 In the new interface I should set the IP for both Ubuntu and Mint... how should I do this with static IPs?
  • Question 2.4 If I want to set up for example a DHCP server and client?

问题1.4与Android(客户端)/ Linux操作系统(GO)?

Question 1.4 And with Android(client) / Linux(GO)?

推荐答案

(可能不是一个完整的答案,但方向正确)

(May not be a complete answer, but right direction)

问题是在Linux端。我遇到的CyanogenMod(Android的5)和Fedora 22之间类似的问题,尝试使用Wi-Fi直连(无线P2P)为Linux操作系统(WDS),英特尔无线显示软件。

The issue is on the Linux side. I'm encountering similar issues between a Cyanogenmod (Android 5) and Fedora 22, attempting to use Wifi Direct (Wifi P2P) for Intel's Wireless Display Software for Linux OS (WDS).

具体来说,英特尔的康曼分歧从什么已经在Linux中,NetworkManager的标准在2009年(重新编写)回来。康曼似乎是Wi-Fi直连(无线P2P)用于Linux的唯一实现,并已为嵌入式(移动)市场写的。

Specifically, Intel's connman diverged (written from scratch) back in 2009 from what had been standard in Linux, NetworkManager. Connman appears to be the only implementation of Wifi Direct (Wifi P2P) for Linux, and had been written for the embedded (mobile) market.

由于一个RPM问题,康曼还有待验证我的系统上,但该软件应提供DBUS通信Linux需要。

Due to an RPM issue, connman remains untested on my system, but the software should provide the dbus communications Linux needs.

网站: https://01.org/connman

这篇关于如何设置Android和Linux之间的WiFi的直接连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆