全志A40I tina系统蓝牙wifi调试方法
全志A40I tina系统蓝牙wifi调试方法用的是xr829,那么要用到4个功能,分别是wifi做ap, wifi做station;蓝牙做source,也就是主,蓝牙做sink,也就是从1. wifi做station, 先运行wifi_scan_results_test,扫描到wifi列表:root@TinaLinux:/# wifi_scan_results_test*************
全志A40I tina3.51系统,内核3.10, 蓝牙wifi调试方法
用的是xr829,那么要用到4个功能,分别是wifi做ap, wifi做station;蓝牙做source,也就是主,蓝牙做sink,也就是从
1. wifi做station, 先运行wifi_scan_results_test,扫描到wifi列表:
root@TinaLinux:/# wifi_scan_results_test
*********************************
***Start scan!***
*********************************
bssid / frequency / signal level / flags / ssid
20:6b:e7:8c:e0:c9 2472 -50 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] xxxxx_GeGe
80:89:17:94:29:5e 2437 -57 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] 406
88:c3:97:3e:da:3a 2457 -51 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS] gsd
d0:76:e7:e4:7d:f5 2462 -57 [WPA-PSK-CCMP+TKIP][WPA2-PSK+FT/PSK-CCMP+TKIP][ESS] \xe5\x98\x89\xe9\xb8\xbf\xe9\xa1\xba
a8:ad:3d:f4:d0:e8 2412 -61 [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] ChinaNet-diPD
10:32:7e:ad:26:50 2412 -67 [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] \xe7\xa6\x85\xe6\xad\xa6\xe4\xb8\x96\xe5\xae\xb6
10:32:7e:ad:26:55 2412 -70 [WPA2-PSK-CCMP][WPS][ESS]
d0:76:e7:79:59:a3 2462 -66 [WPA-PSK-CCMP+TKIP][WPA2-PSK+FT/PSK-CCMP+TKIP][ESS] \xe5\x98\x89\xe9\xb8\xbf\xe9\xa1\xba
10:32:7e:ad:26:51 2412 -71 [WPA2-PSK-CCMP][WPS][ESS]
e8:c4:17:f6:93:8d 2462 -68 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] ChinaNet-wNtx
24:da:33:4c:41:30 2437 -77 [WPA2-PSK-CCMP][WPS][ESS] CHANWUSHIJIA666
24:da:33:4c:41:31 2437 -77 [WPA2-PSK-CCMP][ESS] \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
34:46:ec:26:a5:90 2437 -78 [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] \xe7\xa7\x81\xe6\x95\x99\xe7\xae\xa1\xe7\x90\x86\xe4\xb8\xad\xe5\xbf\x83
04:f0:21:2d:4e:4b 2412 -74 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] ChinaNet-fd9c
34:46:ec:26:a5:95 2437 -79 [WPA2-PSK-CCMP][WPS][ESS]
c8:f8:6d:3f:44:e9 2427 -75 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS] ChinaNet-kjrw
16:f0:21:2d:4e:4b 2412 -75 [WPA-PSK-CCMP][ESS] aWiFi-945b
d0:76:e7:e4:7f:67 2462 -75 [WPA-PSK-CCMP+TKIP][WPA2-PSK+FT/PSK-CCMP+TKIP][ESS] \xe5\x98\x89\xe9\xb8\xbf\xe9\xa1\xba
e8:c4:17:f5:29:5d 2437 -78 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] ChinaNet-MkTY
f8:af:db:15:77:0d 2462 -78 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] ChinaNet-naea
f4:a5:9d:6d:b5:55 2412 -81 [WPA2-PSK-CCMP][WPS][ESS]
******************************
Wifi get_scan_results: Success!
******************************
root@TinaLinux:/#
然后用wifi_connect_ap_test即可连接:
root@TinaLinux:/# wifi_connect_ap_test xxxxx_GeGe windowsxxxxx
==================================
Connecting to the network(xxxxx_GeGe)......
Connected to the AP(xxxxx_GeGe)
Getting ip address(xxxxx_GeGe)......
Wifi connect ap : Success!
==================================
root@TinaLinux:/# ifconfig
eth0 Link encap:Ethernet HWaddr 06:17:C6:99:C6:B5
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:117
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:240 errors:0 dropped:0 overruns:0 frame:0
TX packets:240 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:18720 (18.2 KiB) TX bytes:18720 (18.2 KiB)
wlan0 Link encap:Ethernet HWaddr 7C:BF:FD:85:1F:99
inet addr:192.168.1.111 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1550 (1.5 KiB) TX bytes:1012 (1012.0 B)
root@TinaLinux:/#
2. wifi做ap,需要用到hostapd工具,还有两个配置文件hostapd.conf和udhcpd.conf,然后运行hostapd -d /etc/wifi/hostapd.conf && udhcpd /etc/wifi/udhcpd.conf 即可连接:
hostapd.conf内如:
interface=wlan0
driver=nl80211
ssid=aw_ap001
channel=6
hw_mode=g
ignore_broadcast_ssid=0
auth_algs=1
wpa=3
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
udhcpd.conf内容:
# Sample udhcpd configuration file (/etc/udhcpd.conf)
# Values shown are defaults
# The start and end of the IP lease block
start 192.168.43.20
end 192.168.43.254
# The interface that udhcpd will use
interface wlan0
# The maximum number of leases (includes addresses reserved
# by OFFER's, DECLINE's, and ARP conflicts). Will be corrected
# if it's bigger than IP lease block, but it ok to make it
# smaller than lease block.
#max_leases 254
# The amount of time that an IP will be reserved (leased to nobody)
# if a DHCP decline message is received (seconds)
#decline_time 3600
# The amount of time that an IP will be reserved
# if an ARP conflict occurs (seconds)
#conflict_time 3600
# How long an offered address is reserved (seconds)
#offer_time 60
# If client asks for lease below this value, it will be rounded up
# to this value (seconds)
#min_lease 60
# The location of the pid file
#pidfile /var/run/udhcpd.pid
# The location of the leases file
#lease_file /var/lib/misc/udhcpd.leases
# The time period at which udhcpd will write out leases file.
# If this is 0, udhcpd will never automatically write leases file.
# Specified in seconds.
#auto_time 7200
# Every time udhcpd writes a leases file, the below script will be called
#notify_file # default: no script
#notify_file dumpleases # useful for debugging
# The following are bootp specific options
# next server to use in bootstrap
#siaddr 192.168.0.22 # default: 0.0.0.0 (none)
# tftp server name
#sname zorak # default: none
# tftp file to download (e.g. kernel image)
#boot_file /var/nfs_root # default: none
# Static leases map
#static_lease 00:60:08:11:CE:4E 192.168.0.54
#static_lease 00:60:08:11:CE:3E 192.168.0.44
# The remainder of options are DHCP options and can be specified with the
# keyword 'opt' or 'option'. If an option can take multiple items, such
# as the dns option, they can be listed on the same line, or multiple
# lines.
# Examples:
opt dns 192.168.10.2 192.168.10.10
option subnet 255.255.255.0
opt router 192.168.10.2
opt wins 192.168.10.10
option dns 129.219.13.81 # appended to above DNS servers for a total of 3
option domain local
option lease 864000 # default: 10 days
option msstaticroutes 10.0.0.0/8 10.127.0.1 # single static route
option staticroutes 10.0.0.0/8 10.127.0.1, 10.11.12.0/24 10.11.12.1
# Arbitrary option in hex form:
option 0x08 01020304 # option 8: "cookie server IP addr: 1.2.3.4"
# Currently supported options (for more info, see options.c):
#opt lease NUM
#opt subnet IP
#opt broadcast IP
#opt router IP_LIST
#opt ipttl NUM
#opt mtu NUM
#opt hostname STRING # client's hostname
#opt domain STRING # client's domain suffix
#opt search STRING_LIST # search domains
#opt nisdomain STRING
#opt timezone NUM # (localtime - UTC_time) in seconds. signed
#opt tftp STRING # tftp server name
#opt bootfile STRING # tftp file to download (e.g. kernel image)
#opt bootsize NUM # size of that file
#opt rootpath STRING # (NFS) path to mount as root fs
#opt wpad STRING
#opt serverid IP # default: server's IP
#opt message STRING # error message (udhcpd sends it on success too)
#opt vlanid NUM # 802.1P VLAN ID
#opt vlanpriority NUM # 802.1Q VLAN priority
# Options specifying server(s)
#opt dns IP_LIST
#opt wins IP_LIST
#opt nissrv IP_LIST
#opt ntpsrv IP_LIST
#opt lprsrv IP_LIST
#opt swapsrv IP
# Options specifying routes
#opt routes IP_PAIR_LIST
#opt staticroutes STATIC_ROUTES # RFC 3442 classless static route option
#opt msstaticroutes STATIC_ROUTES # same, using MS option number
# Obsolete options, no longer supported
#opt logsrv IP_LIST # 704/UDP log server (not syslog!)
#opt namesrv IP_LIST # IEN 116 name server, obsolete (August 1979!!!)
#opt cookiesrv IP_LIST # RFC 865 "quote of the day" server, rarely (never?) used
#opt timesrv IP_LIST # RFC 868 time server, rarely (never?) used
# TODO: in development
#opt userclass STRING # RFC 3004. set of LASCII strings. "I am a printer" etc
#opt sipserv STRING LIST # RFC 3361. flag byte, then: 0: domain names, 1: IP addrs
运行顺序如下:
root@TinaLinux:/# ifconfig wlan0 down
root@TinaLinux:/# ifconfig wlan0 up
root@TinaLinux:/# hostapd -d /etc/wifi/hostapd.conf
Configuration file: /etc/wifi/hostapd.conf
Using interface wlan0 with hwaddr 60:c2:38:a9:23:5f and ssid "aw_ap001"
VLAN: vlan_set_name_type: SET_VLAN_NAME_TYPE_CMD name_type=2 failed: No error information
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
wlan0: STA 20:6b:e7:8c:e0:c9 IEEE 802.11: disassociated
wlan0: STA 20:6b:e7:8c:e0:c9 IEEE 802.11: disassociated
这时候由于当前终端阻塞了, 在另一个终端adb shell登录,继续运行命令:
root@TinaLinux:/# ifconfig wlan0 192.168.43.1 netmask 255.255.255.0
root@TinaLinux:/# /usr/sbin/udhcpd /etc/wifi/udhcpd.conf
root@TinaLinux:/#
root@TinaLinux:/# ifconfig
eth0 Link encap:Ethernet HWaddr 06:17:C6:99:C6:B5
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:117
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:192 errors:0 dropped:0 overruns:0 frame:0
TX packets:192 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:14976 (14.6 KiB) TX bytes:14976 (14.6 KiB)
mon.wlan0 Link encap:UNSPEC HWaddr 60-C2-38-A9-23-5F-49-77-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:190 (190.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr 60:C2:38:A9:23:5F
inet addr:192.168.43.1 Bcast:192.168.43.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:198 errors:0 dropped:29 overruns:0 frame:0
TX packets:65 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:25255 (24.6 KiB) TX bytes:7032 (6.8 KiB)
到这里,我们手机上就搜索到了一个名字为aw_ap001的wifi,连接它,这时候第一个终端会打印连接信息:
wlan0: STA 98:ca:33:4d:0d:40 IEEE 802.11: authentication OK (open system)
wlan0: STA 98:ca:33:4d:0d:40 MLME: MLME-AUTHENTICATE.indication(98:ca:33:4d:0d:40, OPEN_SYSTEM)
wlan0: STA 98:ca:33:4d:0d:40 MLME: MLME-DELETEKEYS.request(98:ca:33:4d:0d:40)
wlan0: STA 98:ca:33:4d:0d:40 IEEE 802.11: authenticated
wlan0: STA 98:ca:33:4d:0d:40 IEEE 802.11: association OK (aid 1)
wlan0: STA 98:ca:33:4d:0d:40 WPA: event 7 notification
wlan0: STA 98:ca:33:4d:0d:40 IEEE 802.11: associated (aid 1)
wlan0: STA 98:ca:33:4d:0d:40 MLME: MLME-ASSOCIATE.indication(98:ca:33:4d:0d:40)
wlan0: STA 98:ca:33:4d:0d:40 MLME: MLME-DELETEKEYS.request(98:ca:33:4d:0d:40)
wlan0: STA 98:ca:33:4d:0d:40 IEEE 802.11: binding station to interface 'wlan0'
wlan0: STA 98:ca:33:4d:0d:40 WPA: event 1 notification
wlan0: STA 98:ca:33:4d:0d:40 WPA: start authentication
wlan0: STA 98:ca:33:4d:0d:40 IEEE 802.1X: unauthorizing port
wlan0: STA 98:ca:33:4d:0d:40 WPA: sending 1/4 msg of 4-Way Handshake
wlan0: STA 98:ca:33:4d:0d:40 WPA: received EAPOL-Key frame (2/4 Pairwise)
wlan0: STA 98:ca:33:4d:0d:40 WPA: sending 3/4 msg of 4-Way Handshake
wlan0: STA 98:ca:33:4d:0d:40 WPA: received EAPOL-Key frame (4/4 Pairwise)
wlan0: AP-STA-CONNECTED 98:ca:33:4d:0d:40
wlan0: STA 98:ca:33:4d:0d:40 IEEE 802.1X: authorizing port
wlan0: STA 98:ca:33:4d:0d:40 RADIUS: starting accounting session 8B8E1245306355D1
wlan0: STA 98:ca:33:4d:0d:40 WPA: pairwise key handshake completed (RSN)
连接上后,查看手机的ip地址是192.168.43.20, 我们在第二中终端就可以ping通该地址:
root@TinaLinux:/# ping 192.168.43.20
PING 192.168.43.20 (192.168.43.20): 56 data bytes
64 bytes from 192.168.43.20: seq=0 ttl=64 time=206.783 ms
64 bytes from 192.168.43.20: seq=1 ttl=64 time=19.898 ms
64 bytes from 192.168.43.20: seq=2 ttl=64 time=48.866 ms
64 bytes from 192.168.43.20: seq=3 ttl=64 time=75.581 ms
3. 蓝牙做source:
先adb push一个测试文件到tmp目录,这个路径是原厂官方tina sdk包 btmanager中写好的,也可以自己改:
lsc@lsc:~/newDisk2/CH4_MB2$ adb push package/testtools/testdata/audio_wav/common/44100-stereo-s16_le-10s.wav /tmp/
[100%] /tmp/44100-stereo-s16_le-10s.wav
lsc@lsc:~/newDisk2/CH4_MB2$
接着运行bt_test -i -p a2dp-source进入交互模式,然后scan 1开始扫描, 扫描到自己的蓝牙耳机后, scan 0关闭扫描,
connect 蓝牙mac地址,连接上后a2dp_src_start ,蓝牙耳机就能听到前面push进去的wav音乐了,整个命令如下:
root@TinaLinux:/# bt_test -i -p a2dp-source
[bt_manager_enable:373]: bt manager version:Version:3.0.1.202009221456,builed time:Sep 23 2020-02:23:52
[bt_test_status_cb:71]: bt is turnning on.
hcidump_xr start
bluetooth
[bt_profile_global_init:330]: start bluealsa :1 times
[bt_test_adapter_power_state_cb:41]: Turn on bt successfully
[bt_test_status_cb:61]: BT is ON
[bt]#scan 1
[bt]#[bt_test_discovery_status_cb:80]: bt start scanning.
[btmg_gap_bluez_callback:1143]: Discovery started
[bt_test_dev_add_cb:104]: address:E0:DC:FF:D8:8E:7C,name:月下旅行者的Redmi K20 Pro,class:5898764,icon:phone,address type:(null),rssi:-53
[bt_test_dev_add_cb:104]: address:3C:85:36:07:69:1C,name:PEG301,class:2360328,icon:audio-card,address type:(null),rssi:-81
[bt_test_dev_add_cb:104]: address:1C:48:F9:5B:0E:6E,name:Jabra Classic v0.5.3,class:2360324,icon:audio-card,address type:(null),rssi:-58
scan 0
[bt]#[btmg_gap_bluez_callback:1147]: Discovery Stopped due to user input
[bt_test_discovery_status_cb:86]: stop scan by user.
[bt]#connect 1C:48:F9:5B:0E:6E
[bt_test_a2dp_source_connection_state_cb:292]: A2DP source connecting with device: 1C:48:F9:5B:0E:6E
[bt]#[bt_test_a2dp_source_connection_state_cb:294]: A2DP source connected with device: 1C:48:F9:5B:0E:6E
addr:1C:48:F9:5B:0E:6E,name:Jabra Classic v0.5.3,state:CONNECTED
[bt_test_a2dp_source_connection_state_cb:294]: A2DP source connected with device: 1C:48:F9:5B:0E:6E
[bt]#a2dp_src_start
[bt]#[_a2dp_source_thread_func:355]: start a2dp src loop,data size:1764000,ch:2,sample:44100
[bt_test_dev_remove_cb:118]: address:52:06:30:22:2C:6D,name:(null),class:0,address type:(null)
4.蓝牙做sink:
直接在终端运行bt_test -p a2dp-sink即可,然后手机就搜索到一个aw-bt-test开头的蓝牙设备, 点击连接即可,log如下:
root@TinaLinux:/# bt_test -p a2dp-sink
[bt_manager_enable:373]: bt manager version:Version:3.0.1.202009221456,builed time:Sep 23 2020-02:23:52
[bt_test_status_cb:71]: bt is turnning on.
root@TinaLinux:/# hcidump_xr start
bluetooth
[bt_profile_global_init:330]: start bluealsa :1 times
[bt_test_dev_add_cb:104]: address:1C:48:F9:5B:0E:6E,name:Jabra Classic v0.5.3,class:2360324,icon:audio-card,address type:(null),rssi:0
[bt_test_adapter_power_state_cb:41]: Turn on bt successfully
[bt_test_status_cb:61]: BT is ON
[bt_test_dev_add_cb:104]: address:98:CA:33:4D:0B:05,name:lushengchuiphone,class:7995916,icon:phone,address type:(null),rssi:0
[bt_test_a2dp_sink_connection_state_cb:268]: A2DP sink connected with device: 98:CA:33:4D:0B:05
AGENT: Authorize Service (98:CA:33:4D:0B:05, 0000110d-0000-1000-8000-00805f9b34fb)
AGENT: Authorize Service (98:CA:33:4D:0B:05, 0000110e-0000-1000-8000-00805f9b34fb)
[bt_test_avrcp_play_state_cb:318]: BT playing music stopped with device: 98:CA:33:4D:0B:05
[bt_test_a2dp_sink_audio_state_cb:279]: A2DP sink audio stopped with device: 98:CA:33:4D:0B:05
[_mediaplayer_track:499]: iterm value: /org/bluez/hci0/dev_98_CA_33_4D_0B_05/player0/NowPlaying/item18446744073709551615
最后手机播放一首音乐, 板子的喇叭就能听到了,而且有如下log提示音乐开始播放了:
root@TinaLinux:/# [bt_a2dp_sink_start:512]: a2dp sink start transmit.
[bt_test_avrcp_play_state_cb:320]: BT palying music playing with device: 98:CA:33:4D:0B:05
[bt_test_a2dp_sink_audio_state_cb:281]: A2DP sink audio started with device: 98:CA:33:4D:0B:05
[bt_test_dev_remove_cb:118]: address:98:CA:33:4D:0B:05,name:(null),class:0,address type:(null)
[bt_test_dev_remove_cb:118]: address:98:CA:33:4D:0B:05,name:(null),class:0,address type:(null)
[bt_test_dev_remove_cb:118]: address:98:CA:33:4D:0B:05,name:(null),class:0,address type:(null)
[bt_test_dev_remove_cb:118]: address:98:CA:33:4D:0B:05,name:(null),class:0,address type:(null)
更多推荐
所有评论(0)