描述
第一个指令是(wifi_scan)。
以下指令的输入以及信息的输出均在串口助手sscom中进行。
-
wifi_scan
-
------>>>>>> Scan CMD
-
# [WIFI] [IND] SCAN Done
-
wifi_mgmr_scan_complete_callback: scan complete
-
[APP] [EVT] SCAN Done 69207
-
cached scan list
-
****************************************************************************************************
-
index[00]: empty
-
index[01]: empty
-
index[02]: empty
-
index[03]: empty
-
index[04]: empty
-
index[05]: empty
-
index[06]: empty
-
index[07]: empty
-
index[08]: empty
-
index[09]: empty
-
index[10]: empty
-
index[11]: empty
-
index[12]: empty
-
index[13]: empty
-
index[14]: empty
-
index[15]: empty
-
index[16]: empty
-
index[17]: empty
-
index[18]: empty
-
index[19]: empty
-
index[20]: empty
-
index[21]: empty
-
index[22]: empty
-
index[23]: empty
-
index[24]: empty
-
index[25]: empty
-
index[26]: empty
-
index[27]: empty
-
index[28]: empty
-
index[29]: empty
-
index[30]: empty
-
index[31]: channel 13, bssid 16:E9:B2:91:AD:E7, rssi -98, ppm abs:rel 0 : 0, auth WPA2-PSK/WPA-PSK, cipher: AES, SSID CMCC-uWN6-2
-
index[32]: channel 13, bssid 14:E9:B2:91:AD:E7, rssi -87, ppm abs:rel 0 : 0, auth WPA2-PSK/WPA-PSK, cipher: AES, SSID CMCC-uWN6
-
index[33]: channel 11, bssid 64:6E:97:C9:5A:D7, rssi -98, ppm abs:rel 0 : 0, auth WPA2-PSK/WPA-PSK, cipher: AES, SSID 3205
-
index[34]: channel 11, bssid EC:17:2F:68:27:D4, rssi -84, ppm abs:rel 5 : 5, auth WPA2-PSK/WPA-PSK, cipher: AES, SSID TP-LINK_6827D4
-
index[35]: channel 11, bssid 70:85:40:2B:AB:B7, rssi -79, ppm abs:rel 2 : 2, auth WPA2-PSK/WPA-PSK, cipher: TKIP/AES, SSID 468
-
index[36]: channel 10, bssid 74:7D:24:48:97:62, rssi -98, ppm abs:rel 0 : 0, auth WPA2-PSK/WPA-PSK, cipher: TKIP/AES, SSID @PHICOMM_60
-
index[37]: channel 10, bssid 92:3F:7B:61:27:AF, rssi -85, ppm abs:rel 2 : 2, auth WPA2-PSK/WPA-PSK, cipher: TKIP/AES, SSID iTV-iaLX
-
index[38]: channel 11, bssid D0:76:E7:EF:03:71, rssi -98, ppm abs:rel 10 : 10, auth WPA2-PSK/WPA-PSK, cipher: AES, SSID ChinaNet-sefN
-
index[39]: channel 10, bssid 68:DB:54:DF:35:E2, rssi -98, ppm abs:rel 0 : 0, auth WPA2-PSK/WPA-PSK, cipher: TKIP/AES, SSID 钂嬪
-
index[40]: channel 10, bssid 30:3F:7B:61:27:AE, rssi -98, ppm abs:rel 4 : 4, auth WPA2-PSK/WPA-PSK, cipher: TKIP/AES, SSID ChinaNet-iaLX
-
index[41]: channel 10, bssid 30:5F:77:80:93:DE, rssi -85, ppm abs:rel 0 : 0, auth WPA2-PSK, cipher: AES, SSID 鍖椾含鐑ら腑
-
index[42]: channel 08, bssid 38:21:87:41:89:1D, rssi -98, ppm abs:rel 35 : 35, auth WPA2-PSK, cipher: AES, SSID midea_ac_0404
-
index[43]: channel 08, bssid 24:8B:E0:5C:E0:D9, rssi -96, ppm abs:rel 7 : 7, auth WPA2-PSK/WPA-PSK, cipher: TKIP/AES, SSID liao150829
-
index[44]: channel 10, bssid 50:D2:F5:74:BA:C2, rssi -61, ppm abs:rel 0 : 0, auth WPA2-PSK/WPA-PSK, cipher: TKIP/AES, SSID CYMY
-
index[45]: channel 05, bssid 70:85:40:2B:AB:48, rssi -79, ppm abs:rel 0 : 0, auth WPA2-PSK/WPA-PSK, cipher: TKIP/AES, SSID 168
-
index[46]: channel 05, bssid 70:85:40:2B:AB:FC, rssi -73, ppm abs:rel 2 : 2, auth WPA2-PSK/WPA-PSK, cipher: TKIP/AES, SSID 288
-
index[47]: channel 03, bssid 2C:B2:1A:D0:3B:82, rssi -97, ppm abs:rel 0 : 0, auth WPA2-PSK/WPA-PSK, cipher: TKIP/AES, SSID fei
-
index[48]: channel 03, bssid 70:85:40:2B:AB:45, rssi -52, ppm abs:rel 5 : 5, auth WPA2-PSK/WPA-PSK, cipher: TKIP/AES, SSID 368
-
index[49]: channel 03, bssid 70:85:40:2B:AB:EF, rssi -43, ppm abs:rel 13 : 13, auth WPA2-PSK/WPA-PSK, cipher: TKIP/AES, SSID 268
-
----------------------------------------------------------------------------------------------------
-
proc_hellow_entry: RISC-V rv32imafc.gj_lf686_demo_wifi
复制代码
找到一个可以连接的无线路由器,ssid=268
使用这个项目提供的命令:(wifi_sta_connect )
-
wifi_sta_connect 268 07342596999
-
wifi_sta_connect 268 07342596999
-
----- BUG FIXME? NOT do STA enable again
-
[WF] MM_ADD_IF_REQ Sending: STA
-
歵d_start idx=0
-
[WF] MM_ADD_IF_REQ Done
-
[WF] vif_index from LAMC is 0
-
[WF][SM] Entering idle state
-
[WF][SM] Action Connect
-
ssid 268
-
ssid len 3
-
psk 07342596999
-
psk len 11
-
pmk
-
pmk len 0
-
channel band 0
-
channel freq 0
-
mac 00:00:00:00:00:00
-
dhcp status: true
-
[WF][SM] State Action ###idle### --->>> ###connecting###
-
connecting using vif_idx 0
-
===start sm_get_bss_params===
-
bssid[0] = 0xffff
-
bssid[1] = 0xffff
-
bssid[2] = 0xffff
-
search ssid = 268
-
result ssid index = -1
-
===end sm_get_bss_params===
-
[WF][SM] Entering connecting state
-
# [APP] [EVT] Connecting 707891
-
Probe Response
-
timestamp = 0x30ef47b10
-
Probe Response
-
timestamp = 0x30ef84cbd
-
Probe Response
-
timestamp = 0x30efc2998
-
Probe Response
-
timestamp = 0x30f03c5d3
-
[ 710128][[32mINFO [0m: lf_adc.c: 260] offset = 2108
-
proc_hellow_entry: RISC-V rv32imafc.gj_lf686_demo_wifi
-
===start sm_get_bss_params===
-
bssid[0] = 0xffff
-
bssid[1] = 0xffff
-
bssid[2] = 0xffff
-
search ssid = 268
-
result ssid index = 0
-
===end sm_get_bss_params===
-
wpa2/wpa3 pairwise ccmp:1,tkip:0,wep104:0,wep:40:0
-
wpa2/wpa3 group ccmp:0,tkip:1,wep104:0,wep:40:0
-
wpa2/wpa3 is_pmf_required:0
-
AP Security mode: wep:0,wpa:1,wpa2:1,wpa3:0
-
Probe Response
-
timestamp = 0x30f26308d
-
wpa2/wpa3 pairwise ccmp:1,tkip:0,wep104:0,wep:40:0
-
wpa2/wpa3 group ccmp:0,tkip:1,wep104:0,wep:40:0
-
wpa2/wpa3 is_pmf_required:0
-
AP Security mode: wep:0,wpa:1,wpa2:1,wpa3:0
-
wpa2/wpa3 pairwise ccmp:1,tkip:0,wep104:0,wep:40:0
-
wpa2/wpa3 group ccmp:0,tkip:1,wep104:0,wep:40:0
-
wpa2/wpa3 is_pmf_required:0
-
AP Security mode: wep:0,wpa:1,wpa2:1,wpa3:0
-
------ 247 set default key 0x42018c08, key ptr 0x00000000
-
[APP] [EVT] SCAN On Join 711659
-
set key:sta_idx:0, inst_nbr:0, key_idx:0,cipher_suite:2,key_len:16
-
set key:sta_idx:255, inst_nbr:0, key_idx:1,cipher_suite:1,key_len:32
-
ind ix 0x4201eddc, chan_ctxt is 0x420183f4
-
[RX] Connection Status
-
[RX] status_code 0
-
[RX] connect result: sm connect ind ok
-
[RX] MAC 70:85:40:2B:AB:EF
-
[RX] vif_idx 0
-
[RX] ap_idx 0
-
[RX] ch_idx 0
-
[RX] qos 1
-
[RX] acm 0
-
[RX] assoc_req_ie_len 80
-
[RX] assoc_rsp_ie_len 172
-
[RX] aid 0
-
[RX] band 0
-
[RX] center_freq 2422
-
[RX] width 0
-
[RX] center_freq1 2422
-
[RX] center_freq2 0
-
[WF][SM] Exiting connecting state
-
[WF][SM] State Action ###connecting### --->>> ###wifiConnected_ipObtaining###
-
[WF][SM] Entering wifiConnected_ipObtaining state
-
[WF][SM] DHCP Starting...0x42019e24
-
[APP] [EVT] connected 711685
-
-----------------> AABA Request:
-
A-MSDU: Not Permitted
-
Block Ack Policy: Immediate Block Ack
-
TID: 0
-
Number of Buffers: 64
-
-----------------> AABA Response:
-
A-MSDU: Not Permitted
-
Block Ack Policy: Immediate Block Ack
-
TID: 0
-
Number of Buffers: 8
-
[lwip] netif status callback
-
IP: 192.168.88.7
-
MK: 255.255.255.0
-
GW: 192.168.88.254
-
[WF][SM] Exiting wifiConnected_ipObtaining state
-
[WF][SM] IP GOT IP:192.168.88.7, MASK: 255.255.255.0, Gateway: 192.168.88.254, dns1: 192.168.88.254, dns2: 0.0.0.0
-
[WF][SM] State Action ###wifiConnected_ipObtaining### --->>> ###wifiConnected_IPOK###
-
[WF][SM] Entering wifiConnected_IPOK state
-
[APP] [EVT] GOT IP 715004
-
[SYS] Memory left is 150312 Bytes
-
proc_hellow_entry: RISC-V rv32imafc.gj_lf686_demo_wifi
复制代码
在这些信息中,可以看见一条信息:
-
[WF][SM] Exiting wifiConnected_ipObtaining state
-
[WF][SM] IP GOT IP:192.168.88.7, MASK: 255.255.255.0, Gateway: 192.168.88.254, dns1: 192.168.88.254, dns2: 0.0.0.0
复制代码
这标识已经连上路由器,并通过dhcp分配了IP地址为192.168.88.7。
电脑中打开一个cmd窗口,查看本机的ip地址。
-
无线局域网适配器 WLAN:
-
连接特定的 DNS 后缀 . . . . . . . : Realtek
-
IPv4 地址 . . . . . . . . . . . . : 192.168.88.6
-
子网掩码 . . . . . . . . . . . . : 255.255.255.0
-
默认网关. . . . . . . . . . . . . : 192.168.88.254
-
以太网适配器 蓝牙网络连接:
-
媒体状态 . . . . . . . . . . . . : 媒体已断开连接
-
连接特定的 DNS 后缀 . . . . . . . :
-
复制代码
-
C:Usersjohn>ping 192.168.88.7
-
正在 Ping 192.168.88.7 具有 32 字节的数据:
-
来自 192.168.88.7 的回复: 字节=32 时间=5ms TTL=255
-
来自 192.168.88.7 的回复: 字节=32 时间=2ms TTL=255
-
来自 192.168.88.7 的回复: 字节=32 时间=4ms TTL=255
-
来自 192.168.88.7 的回复: 字节=32 时间=9ms TTL=255
-
192.168.88.7 的 Ping 统计信息:
-
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
-
往返行程的估计时间(以毫秒为单位):
-
最短 = 2ms,最长 = 9ms,平均 = 5ms
复制代码
可以看见已经能ping通开发板。说明开发板已经挂在无线网络上,并且项目提供了被ping通的功能。这在windows中被称呼为文件和打印机共享(回显请求 - ICMPv4-In)。windows中需要在防火墙中设置才能开启这个功能。这个项目应该没有防火墙吧。但是直接就提供了回显请求功能了。这个功能应该能使得外部设备能知道这个开发板是否在线。
*********************************************************************************************
至此,初步探索结束。应该下一步可以在此基础上开展工作了?
可惜理想很丰满,现实很骨感。
首先,功能实现之前,先实现对功能得触发。去看看项目得指令wifi_sta_connect 是如何触发?
找到wifi_sta_connect 函数定义:
-
static void wifi_sta_connect(char *ssid, char *password)
-
{
-
wifi_interface_t wifi_interface;
-
-
wifi_interface = wifi_mgmr_sta_enable();
-
wifi_mgmr_sta_connect(wifi_interface, ssid, password, NULL, NULL, 0, 0);
-
}
复制代码
以及函数引用
-
case CODE_WIFI_ON_PROV_CONNECT:
-
{
-
printf("[APP] [EVT] [PROV] [CONNECT] %lldrn", aos_now_ms());
-
printf("connecting to %s:%s...rn", ssid, password);
-
wifi_sta_connect(ssid, password);
-
}
复制代码
这个引用在函数static void event_cb_wifi_event(input_event_t *event, void *private_data)里。。。这是什么鬼。命令行不是在以下数据结构里吗?
-
const static struct cli_command cmds_user[] STATIC_CLI_CMD_ATTRIBUTE = {
-
{ "aws", "aws iot demo", cmd_aws},
-
{ "pka", "pka iot demo", cmd_pka},
-
{ "wifi", "wifi", cmd_wifi},
-
{ "sha", "sha iot demo", cmd_sha},
-
{ "trng", "trng test", cmd_trng},
-
{ "aes", "trng test", cmd_aes},
-
{ "cks", "cks test", cmd_cks},
-
{ "dma", "dma test", cmd_dma},
-
{ "exception_load", "exception load test", cmd_exception_load},
-
{ "exception_l_illegal", "exception load test", cmd_exception_l_illegal},
-
{ "exception_store", "exception store test", cmd_exception_store},
-
{ "exception_inst_illegal", "exception illegal instruction", cmd_exception_illegal_ins},
-
/*Stack Command*/
-
{ "stack_wifi", "Wi-Fi Stack", cmd_stack_wifi},
-
/*TCP/IP network test*/
-
{"http", "http client download test based on socket", http_test_cmd},
-
{"httpc", "http client download test based on RAW TCP", cmd_httpc_test},
-
};
复制代码
然后,全文件查找cli
-
fd_console = aos_open("/dev/ttyS0", 0);
-
if (fd_console >= 0) {
-
printf("Init CLI with event Drivenrn");
-
aos_cli_init(0);
-
aos_poll_read_fd(fd_console, aos_cli_event_cb_read_get(), (void*)0x12345678);
-
_cli_init();
-
}
复制代码
原来命令行有两种模式,一种是直接解码,一种是消息发送或者说事件方式。以上函数中fd_console 应该是默认的,烧录代码的串口吧?看样子在实现自己的功能代码之前,还得有#include 的相关知识。特别提醒。这点一定注意。如果有相关知识会很顺利学习这个开发板。*******************************************************************************************************如果板子还在我手上的话,也许下一步借助这个板子,先开始一段FreeRTOS的学习吧。
打开APP阅读更多精彩内容