在串口sscom中输入help,可得到相关的支持命令
通过串口输入相关命令,连接WiFi
wifi_sta_connect TP-LINK_6BE8 177381309xx
-
----- 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 TP-LINK_6BE8
-
ssid len 12
-
psk 17738130986
-
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 = TP-LINK_6BE8
-
result ssid index = -1
-
===end sm_get_bss_params===
-
[WF][SM] Entering connecting state
-
-
# [APP] [EVT] Connecting 880885
-
===start sm_get_bss_params===
-
bssid[0] = 0xffff
-
bssid[1] = 0xffff
-
bssid[2] = 0xffff
-
search ssid = TP-LINK_6BE8
-
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:1,tkip:0,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 884653
-
[ 890129][[32mINFO [0m: lf_adc.c: 260] offset = 2158
-
proc_hellow_entry: RISC-V rv32imafc
-
4-way handshake timeout failure, wlan 802.11 reason code = 15, try to transmit deauth frame
-
ind ix 0x4202303c, chan_ctxt is 0x420183f4
-
connect failure, ssid = TP-LINK_6BE8, index = 0
-
from sm_connect_ind to scanu_rm_exist_ssid
-
[RX] Connection Status
-
[RX] status_code 8
-
[RX] connect result: Passwd error, 4-way handshake timeout
-
[RX] MAC 74:05:A5:C3:6B:E8
-
[RX] vif_idx 0
-
[RX] ap_idx 0
-
[RX] ch_idx 0
-
[RX] qos 1
-
[RX] acm 0
-
[RX] assoc_req_ie_len 89
-
[RX] assoc_rsp_ie_len 196
-
[RX] aid 0
-
[RX] band 0
-
[RX] center_freq 2462
-
[RX] width 0
-
[RX] center_freq1 2462
-
[RX] center_freq2 0
-
[WF][SM] Exiting connecting state
-
[WF][SM] State Action ###connecting### --->>> ###disconnect###
-
[WF][SM] Entering disconnect state
-
[WF][SM] Will retry in 2000 ticks
-
[APP] [EVT] disconnect 894737, Reason: Passwd error, 4-way handshake timeout
-
[WF][PF] Using profile, idx is @0
-
[WF][SM] Retry Again --->>> retry connect
-
[WF][SM] Exiting disconnect state
-
Delete Timer.
-
[WF][SM] State Action ###disconnect### --->>> ###connecting###
-
[WF][SM] Action Connect
-
ssid TP-LINK_6BE8
-
ssid len 12
-
psk 17738130986
-
psk len 11
-
pmk
-
pmk len 0
-
mac 00:00:00:00:00:00
-
connecting using vif_idx 0
-
===start sm_get_bss_params===
-
bssid[0] = 0xffff
-
bssid[1] = 0xffff
-
bssid[2] = 0xffff
-
search ssid = TP-LINK_6BE8
-
result ssid index = -1
-
===end sm_get_bss_params===
-
[WF][SM] Entering connecting state
-
[APP] [EVT] Reconnect 896740
-
[APP] [EVT] Connecting 896740
-
===start sm_get_bss_params===
-
bssid[0] = 0xffff
-
bssid[1] = 0xffff
-
bssid[2] = 0xffff
-
search ssid = TP-LINK_6BE8
-
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:1,tkip:0,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 0x42018d40, key ptr 0x00000000
-
[APP] [EVT] SCAN On Join 900510
-
proc_hellow_entry: RISC-V rv32imafc
-
set key:sta_idx:1, 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:2,key_len:16
-
ind ix 0x42022e34, chan_ctxt is 0x42018410
-
[RX] Connection Status
-
[RX] status_code 0
-
[RX] connect result: sm connect ind ok
-
[RX] MAC 74:05:A5:C3:6B:E8
-
[RX] vif_idx 0
-
[RX] ap_idx 1
-
[RX] ch_idx 0
-
[RX] qos 1
-
[RX] acm 0
-
[RX] assoc_req_ie_len 89
-
[RX] assoc_rsp_ie_len 196
-
[RX] aid 0
-
[RX] band 0
-
[RX] center_freq 2462
-
[RX] width 0
-
[RX] center_freq1 2462
-
[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 900828
-
-----------------> 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.1.105
-
MK: 255.255.255.0
-
GW: 192.168.1.1
-
[WF][SM] Exiting wifiConnected_ipObtaining state
-
[WF][SM] IP GOT IP:192.168.1.105, MASK: 255.255.255.0, Gateway: 192.168.1.1, dns1: 172.16.16.16, dns2: 172.16.16.17
-
[WF][SM] State Action ###wifiConnected_ipObtaining### --->>> ###wifiConnected_IPOK###
-
[WF][SM] Entering wifiConnected_IPOK state
-
[APP] [EVT] GOT IP 903003
-
[SYS] Memory left is 133512 Bytes
复制代码
可以看到比较完整的WiFi连接信息,及其结果,IP地址详细信息
成功连接WiFi后,可以用ping命令测试是否联网成功
-
ping -c20 www.baidu.com
-
-
# 60 bytes from 182.61.200.7: icmp_seq=1 ttl=47 time=38 ms
-
60 bytes from 182.61.200.7: icmp_seq=2 ttl=47 time=34 ms
-
proc_hellow_entry: RISC-V rv32imafc
-
60 bytes from 182.61.200.7: icmp_seq=3 ttl=47 time=37 ms
-
60 bytes from 182.61.200.7: icmp_seq=5 ttl=47 time=36 ms
-
60 bytes from 182.61.200.7: icmp_seq=6 ttl=47 time=37 ms
-
60 bytes from 182.61.200.7: icmp_seq=7 ttl=47 time=38 ms
-
60 bytes from 182.61.200.7: icmp_seq=8 ttl=47 time=35 ms
-
The sequence number 4 timed out
-
60 bytes from 182.61.200.7: icmp_seq=9 ttl=47 time=39 ms
-
60 bytes from 182.61.200.7: icmp_seq=10 ttl=47 time=42 ms
-
60 bytes from 182.61.200.7: icmp_seq=11 ttl=47 time=36 ms
-
60 bytes from 182.61.200.7: icmp_seq=12 ttl=47 time=34 ms
-
proc_hellow_entry: RISC-V rv32imafc
-
60 bytes from 182.61.200.7: icmp_seq=13 ttl=47 time=36 ms
-
60 bytes from 182.61.200.7: icmp_seq=14 ttl=47 time=39 ms
-
60 bytes from 182.61.200.7: icmp_seq=15 ttl=47 time=39 ms
-
60 bytes from 182.61.200.7: icmp_seq=16 ttl=47 time=39 ms
-
60 bytes from 182.61.200.7: icmp_seq=17 ttl=47 time=40 ms
-
60 bytes from 182.61.200.7: icmp_seq=18 ttl=47 time=39 ms
-
60 bytes from 182.61.200.7: icmp_seq=19 ttl=47 time=34 ms
-
60 bytes from 182.61.200.7: icmp_seq=20 ttl=47 time=41 ms
复制代码
有个别丢包现象,应该是WiFi信号不够好
demo例程中提供了一个http下载的功能
-
static int client_demo(char *hostname)
-
{
-
int sockfd;
-
/* Get host address from the input name */
-
struct hostent *hostinfo = gethostbyname(hostname);
-
uint8_t *recv_buffer;
-
-
if (!hostinfo) {
-
printf("gethostbyname Failedrn");
-
return -1;
-
}
-
-
struct sockaddr_in dest;
-
-
char buffer[MAXBUF];
-
/* Create a socket */
-
/*---Open socket for streaming---*/
-
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-
printf("Error in socketrn");
-
return -1;
-
}
-
-
/*---Initialize server address/port struct---*/
-
memset(&dest, 0, sizeof(dest));
-
dest.sin_family = AF_INET;
-
dest.sin_port = htons(PORT);
-
dest.sin_addr = *((struct in_addr *) hostinfo->h_addr);
-
// char ip[16];
-
uint32_t address = dest.sin_addr.s_addr;
-
char *ip = inet_ntoa(address);
-
-
printf("Server ip Address : %srn", ip);
-
/*---Connect to server---*/
-
if (connect(sockfd,
-
(struct sockaddr *)&dest,
-
sizeof(dest)) != 0) {
-
printf("Error in connectrn");
-
return -1;
-
}
-
/*---Get "Hello?"---*/
-
memset(buffer, 0, MAXBUF);
-
char wbuf[]
-
= "GET /ddm/ContentResource/music/204.mp3 HTTP/1.1rnHost: nf.cr.dandanman.comrnUser-Agent: wmsdkrnAccept: */*rnrn";
-
write(sockfd, wbuf, sizeof(wbuf) - 1);
-
-
int ret = 0;
-
int total = 0;
-
int debug_counter = 0;
-
uint32_t ticks_start, ticks_end, time_consumed;
-
-
ticks_start = xTaskGetTickCount();
-
recv_buffer = pvPortMalloc(BUFFER_SIZE);
-
if (NULL == recv_buffer) {
-
goto out;
-
}
-
while (1) {
-
ret = read(sockfd, recv_buffer, BUFFER_SIZE);
-
if (ret == 0) {
-
printf("eofnr");
-
break;
-
} else if (ret < 0) {
-
printf("ret = %d, err = %dnr", ret, errno);
-
break;
-
} else {
-
total += ret;
-
/*use less debug*/
-
if (0 == ((debug_counter++) & 0xFF)) {
-
printf("total = %d, ret = %dnr", total, ret);
-
}
-
//vTaskDelay(2);
-
if (total > 82050000) {
-
ticks_end = xTaskGetTickCount();
-
time_consumed = ((uint32_t)(((int32_t)ticks_end) - ((int32_t)ticks_start))) / 1000;
-
printf("Download comlete, total time %u s, speed %u Kbpsrn",
-
(unsigned int)time_consumed,
-
(unsigned int)(total / time_consumed * 8 / 1000)
-
);
-
break;
-
}
-
}
-
}
-
-
vPortFree(recv_buffer);
-
out:
-
close(sockfd);
-
return 0;
-
}
-
复制代码
对应的命令是http,可以看到其下载的过程
-
http
-
Server ip Address : 60.255.154.100
-
total = 688, ret = 688
-
proc_hellow_entry: RISC-V rv32imafc
-
total = 234608, ret = 688
-
total = 468528, ret = 688
-
proc_hellow_entry: RISC-V rv32imafc
-
total = 695568, ret = 1376
-
total = 920544, ret = 688
-
proc_hellow_entry: RISC-V rv32imafc
-
total = 1157216, ret = 688
-
total = 1490896, ret = 1376
-
proc_hellow_entry: RISC-V rv32imafc
-
total = 1885808, ret = 2064
-
proc_hellow_entry: RISC-V rv32imafc
-
proc_hellow_entry: RISC-V rv32imafc
-
proc_hellow_entry: RISC-V rv32imafc
-
proc_hellow_entry: RISC-V rv32imafc
-
eof
复制代码
total的值,应该就是下载的字节数值。
三、心得体会
BF2的开发板提供了很多的demo,还是比较丰富的,只是其代码风格和公司的规定,可能有些特殊,感觉使用起来束缚感比较重,代码方面也感觉不够简单易用,想开发符合自己要求的应用,感觉难度不小,相对其他厂家的同类产品,如ESP32等,易用性以及性价比方面感觉存在不小的差距。最后,还是感觉跃昉科技和发烧友提供的评测机会!