除了显示驱动,其余全部测试通过
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
#include "wifi_sta.h"
|
||||
|
||||
#include "system/includes.h"
|
||||
#include "app_log.h"
|
||||
#include <string.h>
|
||||
#include "wifi/wifi_connect.h"
|
||||
|
||||
#define WIFI_STA_CONNECT_TIMEOUT_SEC 30
|
||||
|
||||
int wifi_sta_configure(void)
|
||||
{
|
||||
/* 1. 设置STA连接超时 */
|
||||
wifi_set_sta_connect_timeout(WIFI_STA_CONNECT_TIMEOUT_SEC);
|
||||
|
||||
/* 2.设置 STA非阻塞连接 */
|
||||
wifi_set_connect_sta_block(0);
|
||||
|
||||
APP_LOG(
|
||||
"[WIFI_STA] configure success timeout=%u sec block=0\n",
|
||||
WIFI_STA_CONNECT_TIMEOUT_SEC
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wifi_sta_connect(const char *ssid,const char *password)
|
||||
{
|
||||
u32 ssid_len;
|
||||
u32 password_len;
|
||||
int ret;
|
||||
|
||||
if (!ssid || !password) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssid_len = (u32)strlen(ssid);
|
||||
password_len = (u32)strlen(password);
|
||||
|
||||
|
||||
if (ssid_len == 0 ||
|
||||
ssid_len > 32) {
|
||||
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
if (password_len > 63) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
/*
|
||||
* 手动连接指定 SSID 时,
|
||||
* 不启用 SDK 的“从已保存网络里选择最佳 SSID”策略。
|
||||
*/
|
||||
wifi_set_sta_connect_best_ssid(0);
|
||||
|
||||
/*
|
||||
* wifi_enter_sta_mode() 只是提交 STA 连接请求。
|
||||
* ret == 0 也不能理解为已经联网。
|
||||
*/
|
||||
ret = wifi_enter_sta_mode((char *)ssid,(char *)password);
|
||||
|
||||
APP_LOG(
|
||||
"[WIFI_STA] connect request ssid=%s ret=%d\n",
|
||||
ssid,
|
||||
ret
|
||||
);
|
||||
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user