p2p命令行方式连线其他陪测设备(Ubuntu+其他设备(PC,手机))

  • p2p command connect

        有关Wi-Fi CERTIFIED Wi-Fi Direct® 请参考 http://www.wi-fi.org/discover-wi-fi/wi-fi-direct

        描述:在开发过程中,偶尔会遇到处理miracast 时遇到连线不上的问题,客户想排除是driver 本身就有问题还是其他原因导致连线不上,可能就会选择使用命令行方式来做p2p连线,如是是使用RTK 8723du 与手机连线为例

连线步骤参考如下:

使用命令行方式(以8723du与手机做连线为例)

     a. insmod 8723du.ko

         ifconfig wlan0 up

     b.wpa_supplicant -Dnl80211 -iwlan0 -c /data/misc/wifi/wpa_supplicant.conf -B  ==>起 wpa_supplicant,ps 并确认有wpa_supplicant

手动命令行方式起wpa_supplicant
rtk@rtk-Precision-M4800:~/peter/wpa_supplicant$ sudo ./wpa_supplicant -Dnl80211 -i wlan373 -c ./wpa_0_8.conf -B -dd
wpa_supplicant v2.3_rtw_r24600.20171025
random: Trying to read entropy from /dev/random
Successfully initialized wpa_supplicant
Initializing interface 'wlan373' conf './wpa_0_8.conf' driver 'nl80211' ctrl_interface 'N/A' bridge 'N/A'
Configuration file './wpa_0_8.conf' -> '/home/rtk/peter/wpa_supplicant/./wpa_0_8.conf'
Reading configuration file '/home/rtk/peter/wpa_supplicant/./wpa_0_8.conf'
ctrl_interface='/var/run/wpa_supplicant'
update_config=1
device_name='RTL8192CU'
manufacturer='Realtek'
model_name='RTW_STA'
model_number='WLAN_CU'
serial_number='12345'
os_version=01020300
config_methods='virtual_display virtual_push_button keypad'
persistent_reconnect=1
pmf=1
Line: 14 - start of a new network block
ssid - hexdump_ascii(len=9):
     74 65 73 74 5f 77 69 66 69                        test_wifi       
PSK (ASCII passphrase) - hexdump_ascii(len=8): [REMOVED]
key_mgmt: 0x2
disabled=1 (0x1)
PSK (from passphrase) - hexdump(len=32): [REMOVED]
Line: 21 - start of a new network block
ssid - hexdump_ascii(len=8):
     43 6e 4c 61 62 5f 32 67                           CnLab_2g        
PSK (ASCII passphrase) - hexdump_ascii(len=8): [REMOVED]
key_mgmt: 0x2
disabled=1 (0x1)
PSK (from passphrase) - hexdump(len=32): [REMOVED]
Priority group 0
   id=0 ssid='test_wifi'
   id=1 ssid='CnLab_2g'
rfkill: initial event: idx=1 type=1 op=0 soft=0 hard=0
rfkill: initial event: idx=2 type=2 op=0 soft=0 hard=0
rfkill: initial event: idx=3 type=1 op=0 soft=0 hard=0
rfkill: initial event: idx=4 type=1 op=0 soft=0 hard=0
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
nl80211: Supported cipher 00-0f-ac:2
nl80211: Supported cipher 00-0f-ac:4
nl80211: Supported vendor command: vendor_id=0x1a11 subcmd=4608
nl80211: Supported vendor command: vendor_id=0x1a11 subcmd=4609
nl80211: Supported vendor command: vendor_id=0x1a11 subcmd=4610
nl80211: Supported vendor command: vendor_id=0x1a11 subcmd=4106
nl80211: Supported vendor command: vendor_id=0x1a11 subcmd=4107
nl80211: interface wlan373 in phy phy1
nl80211: Set mode ifindex 5 iftype 2 (STATION)
nl80211: Subscribe to mgmt frames with non-AP handle 0x21aedc0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=0104
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=040a
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=040b
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=040c
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=040d
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=090a
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=090b
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=090c
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=090d
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=0409506f9a09
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=7f506f9a09
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=0801
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=06
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=0a07
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=0a11
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x21aedc0 match=0a1a
netlink: Operstate: ifindex=5 linkmode=1 (userspace-control), operstate=5 (IF_OPER_DORMANT)
nl80211: driver param='(null)'
Add interface wlan373 to a new radio phy1
nl80211: Regulatory information - country=00
nl80211: 2402-2472 @ 40 MHz 20 mBm
nl80211: 2457-2482 @ 40 MHz 20 mBm (no IR)
nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR)
nl80211: 5170-5250 @ 40 MHz 20 mBm (no IR)
nl80211: 5735-5835 @ 40 MHz 20 mBm (no IR)
nl80211: Added 802.11b mode based on 802.11g information
wlan373: Own MAC address: 3c:a3:15:03:06:8e
wpa_driver_nl80211_set_key: ifindex=5 (wlan373) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=5 (wlan373) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=5 (wlan373) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=5 (wlan373) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=5 (wlan373) alg=0 addr=(nil) key_idx=4 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=5 (wlan373) alg=0 addr=(nil) key_idx=5 set_tx=0 seq_len=0 key_len=0
wlan373: RSN: flushing PMKID list in the driver
nl80211: Flush PMKIDs
wlan373: No enabled networks (2 disabled networks)
wlan373: State: DISCONNECTED -> INACTIVE
TDLS: TDLS operation not supported by driver
TDLS: Driver uses internal link setup
wlan373: WPS: UUID based on MAC address: 33875c10-0690-5879-89ce-7bdc510de545
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: Supplicant port status: Unauthorized
nl80211: Skip set_supp_port(unauthorized) while not associated
EAPOL: KEY_RX entering state NO_KEY_RECEIVE
EAPOL: SUPP_BE entering state INITIALIZE
EAP: EAP entering state DISABLED
P2P: Add operating class 81
P2P: Channels - hexdump(len=11): 01 02 03 04 05 06 07 08 09 0a 0b
P2P: Own listen channel: 81:6
P2P: Random operating channel: 81:6
P2P: initialized
P2P: channels: 81:1,2,3,4,5,6,7,8,9,10,11
P2P: cli_channels:
wlan373: Added interface wlan373
wlan373: State: INACTIVE -> DISCONNECTED
nl80211: Set wlan373 operstate 0->0 (DORMANT)
netlink: Operstate: ifindex=5 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT)
Daemonize..

查看wpa_supplicant 进程
rtk@rtk-Precision-M4800:~/peter/wpa_supplicant$ ps aux | grep wpa_supp
root      1510  0.1  0.0  30772  5620 ?        Ss   16:12   0:00 /sbin/wpa_supplicant -B -P /run/sendsigs.omit.d/wpasupplicant.pid -u -s -O /var/run/wpa_supplicant
root      2997  0.0  0.0  15764   184 ?        Ss   16:16   0:00 ./wpa_supplicant -Dnl80211 -i wlan373 -c ./wpa_0_8.conf -B -dd
rtk       3005  0.0  0.0  15968  2624 pts/0    S+   16:16   0:00 grep --color=auto wpa_supp

     c.wpa_cli -iwlan0 ==>进行命令行输入状态

        

 wpa_cli 进入输入状态
rtk@rtk-Precision-M4800:~/peter/wpa_supplicant$ sudo wpa_cli 
wpa_cli v2.1
Copyright (c) 2004-2014, Jouni Malinen <j@w1.fi> and contributors

This software may be distributed under the terms of the BSD license.
See README for more details.


Selected interface 'wlan373'

Interactive mode
>

     d. enable wifi display

> set wifi_display 1
OK

    e. p2p_find 30 ==>之后会发现陪测设备(手机)的mac address 

p2p_find发现陪测设备的mac  address (f6:f5:db:76:23:8f )
> p2p_find 30
OK
<3>CTRL-EVENT-SCAN-STARTED 
<3>CTRL-EVENT-SCAN-STARTED 
<3>CTRL-EVENT-SCAN-STARTED 
<3>CTRL-EVENT-SCAN-STARTED 
<3>CTRL-EVENT-SCAN-STARTED 
<3>P2P-DEVICE-FOUND f6:f5:db:76:23:8f p2p_dev_addr=f6:f5:db:76:23:8f pri_dev_type=10-0050F204-5 name='xiaomi' config_methods=0x188 dev_capab=0x25 group_capab=0x0 wfd_dev_info=0x00101c440032
<3>CTRL-EVENT-SCAN-STARTED 
<3>CTRL-EVENT-SCAN-STARTED 
<3>CTRL-EVENT-SCAN-STARTED 
<3>P2P-FIND-STOPPED 

   f.p2p_peer f6:f5:db:76:23:8f ==》该mac address是所测试手机的mac address

     

> p2p_peer f6:f5:db:76:23:8f
f6:f5:db:76:23:8f
pri_dev_type=10-0050F204-5
device_name=xiaomi
manufacturer= 
model_name= 
model_number= 
serial_number= 
config_methods=0x188
dev_capab=0x25
group_capab=0x0
level=-42
age=28
listen_freq=2462
wps_method=not-ready
interface_addr=00:00:00:00:00:00
member_in_go_dev=00:00:00:00:00:00
member_in_go_iface=00:00:00:00:00:00
go_neg_req_sent=0
go_state=unknown
dialog_token=0
intended_addr=00:00:00:00:00:00
country=__
oper_freq=0
req_config_methods=0x0
flags=[REPORTED]
status=0
invitation_reqs=0
wfd_subelems=00000600101c440032

g.使用pcb 方式连线(p2p_connect f6:f5:db:76:23:8f pbc)

> p2p_connect f6:f5:db:76:23:8f pbc
OK
<3>P2P-GO-NEG-SUCCESS role=GO freq=2437 ht40=0 peer_dev=f6:f5:db:76:23:8f peer_iface=f6:f5:db:76:23:8f wps_method=PBC
<3>CTRL-EVENT-STATE-CHANGE id=-1 state=3 BSSID=00:00:00:00:00:00 SSID=
<3>AP-ENABLED 
<3>CTRL-EVENT-CONNECTED - Connection to 3c:a3:15:03:06:8e completed [id=2 id_str=]
<3>CTRL-EVENT-STATE-CHANGE id=2 state=9 BSSID=3c:a3:15:03:06:8e SSID=DIRECT-Ws
<3>WPS-PBC-ACTIVE 
<3>CTRL-EVENT-EAP-STARTED f6:f5:db:76:23:8f
<3>CTRL-EVENT-EAP-PROPOSED-METHOD vendor=0 method=1
<3>CTRL-EVENT-EAP-PROPOSED-METHOD vendor=14122 method=254
<3>WPS-REG-SUCCESS f6:f5:db:76:23:8f e65e3cd2-12b3-5b4f-9eae-49f0e3b732f1
<3>P2P-GROUP-FORMATION-SUCCESS 
<3>P2P-GROUP-STARTED wlan373 GO ssid="DIRECT-Ws" freq=2437 passphrase="1vd7KDXK" go_dev_addr=3c:a3:15:03:06:8e
<3>WPS-PBC-DISABLE 
<3>WPS-SUCCESS 
<3>CTRL-EVENT-EAP-FAILURE f6:f5:db:76:23:8f
<3>AP-STA-CONNECTED f6:f5:db:76:23:8f p2p_dev_addr=f6:f5:db:76:23:8f

h.查看连线状态

> status 
bssid=3c:a3:15:03:06:8e
freq=2437
ssid=DIRECT-Ws
id=2
mode=P2P GO
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
p2p_device_address=3c:a3:15:03:06:8e
address=3c:a3:15:03:06:8e
uuid=33875c10-0690-5879-89ce-7bdc510de545
<3>CTRL-EVENT-STATE-CHANGE id=2 state=9 BSSID=3c:a3:15:03:06:8e SSID=DIRECT-Ws
<3>CTRL-EVENT-CONNECTED - connection to 3c:a3:15:03:06:8e completed (auth) [id=2 id_str=]

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值