WIFI AP 模式总是创建失败

发布于 2022-05-18 10: 47: 10

无论使用 staap 还是使用 softap, AP 总是创建失败

image. png

image. png

int demo_create_softap (u8 ssid, u8 key, int chan, int encrypt, int format)
{

struct tls_softap_info_t *apinfo; 
struct tls_ip_info_t *ipinfo; 
u8 ret = 0; 
u8 ssid_set = 0; 
u8 wireless_protocol = 0; 

u8 ssid_len = 0; 
if  (! ssid) 
{
    return WM_FAILED; 
}

ipinfo = tls_mem_alloc (sizeof (struct tls_ip_info_t) ) ; 
if  (! ipinfo) 
{
    return WM_FAILED; 
}
apinfo = tls_mem_alloc (sizeof (struct tls_softap_info_t) ) ; 
if  (! apinfo) 
{
    tls_mem_free (ipinfo) ; 
    return WM_FAILED; 
}

tls_param_get (TLS_PARAM_ID_WPROTOCOL,   (void *)  &wireless_protocol,  TRUE) ; 
if  (TLS_PARAM_IEEE80211_SOFTAP ! = wireless_protocol) 
{
    wireless_protocol = TLS_PARAM_IEEE80211_SOFTAP; 
    tls_param_set (TLS_PARAM_ID_WPROTOCOL,   (void *)  &wireless_protocol,  FALSE) ; 
}

tls_wifi_set_oneshot_flag (0) ;           /*disable oneshot*/

tls_param_get (TLS_PARAM_ID_BRDSSID,   (void *) &ssid_set,   (bool) 0) ; 
if  (0 == ssid_set) 
{
    ssid_set = 1; 
    tls_param_set (TLS_PARAM_ID_BRDSSID,   (void *) &ssid_set,   (bool) 1) ;  /*set bssid broadcast flag*/
}


tls_wifi_disconnect () ; 

ssid_len = strlen ( (const char *) ssid) ; 
MEMCPY (apinfo- ssid,  ssid,  ssid_len) ; 
apinfo- ssid[ssid_len] = '\0'; 

apinfo- encrypt = encrypt;   /*0: open,  1: wep64,  2: wep128, 3: TKIP WPA , 4:  CCMP WPA,  5: TKIP WPA2 , 6:  CCMP WPA2*/
apinfo- channel = chan;  /*channel*/
apinfo- keyinfo. format = format;  /*key's format: 0-HEX,  1-ASCII*/
apinfo- keyinfo. index = 1;   /*wep key index*/
apinfo- keyinfo. key_len = strlen ( (const char *) key) ;  /*key length*/
MEMCPY (apinfo- keyinfo. key,  key,  apinfo- keyinfo. key_len) ; 
/*ip info: ipaddress,  netmask,  dns*/
ipinfo- ip_addr[0] = 192; 
ipinfo- ip_addr[1] = 168; 
ipinfo- ip_addr[2] = 1; 
ipinfo- ip_addr[3] = 1; 
ipinfo- netmask[0] = 255; 
ipinfo- netmask[1] = 255; 
ipinfo- netmask[2] = 255; 
ipinfo- netmask[3] = 0; 
MEMCPY (ipinfo- dnsname,  "local. wm",  sizeof ("local. wm") ) ; 

ret = tls_wifi_softap_create (apinfo,  ipinfo) ; 
wm_printf ("\n ap create %s !  \n",   (ret == WM_SUCCESS)  ?  "Successfully" :  "Error") ; 

if  (WM_SUCCESS == ret) 
{
    if  (sta_monitor_tim) 
    {
        tls_os_timer_delete (sta_monitor_tim) ; 
        sta_monitor_tim = NULL; 
    }
    tls_os_timer_create (&sta_monitor_tim,  demo_monitor_stalist_tim,  NULL,  500,  TRUE,  NULL) ; 
    tls_os_timer_start (sta_monitor_tim) ; 
}

tls_mem_free (ipinfo) ; 
tls_mem_free (apinfo) ; 
return ret; 

}

查看更多

关注者
0
被浏览
1. 7k
2 个回答
大信
大信 认证专家 2022-05-19
硬件开发, 软件开发, 系统开发, 工程架构, 方案设计

你的参数不正确.

测试 w801 wifi 各功能时, 最好把 wifi 部分的 demo 开关全部打开. 测试 softap 先测试, t-connect , t-scanf 就是保证你的板子能连上路由器, 能扫描到周边的热点.

然后再测试, 热点模式 (板子成为一个热点, 手机可以连上它)
命令为: t-softap= ("ssid", "pwd", channel, encrypt, format) ;

一个实际的参数如下:
t-softap= ("w801_Ap", "12345678", 1, 5, 1) ;

然后打开手机, 在 wifi 热点列表里, 点搜索即可以看到这个热点了.

worldy
worldy 2022-05-19
这家伙很懒, 什么也没写!

按 t-softap= ("w801_Ap", "12345678", 1, encrypt, 1) 这个命令格式, 确实能连上, 但是 encrypt 参数只能是 0 和 1, 其它的参数组合都连不上, 不知道你们是否能连上? 另外, 连上之后, 好像是否开启 AP 就不受控, 我把电路硬件复位, 甚至断电再重新上电, 在手机上, 最后命名的 AP 将会一直存在, 不知道是什么原因?

撰写答案

请登录后再发布答案, 点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览