10 创建自定自定义任务wifi连不上问题(问题打在图片上了)

发布于 2022-08-05 14:57:10
关注者
0
被浏览
1.1k
ZYQ
ZYQ 2022-08-05
我已不再支持W80X任何相关问题的回复,请大家不要私信,有问题找 isme 谢谢

你这个调用 demo_connect_net之后 得判断 是否连接上了,连接上之后再进行往下走任务,参考下这个
image.png

2 个回答
isme
isme 认证专家 2022-08-06
冰镇大西瓜

检查下你新建的任务有没有加延时函数

while(1)
{
    tls_os_time_delay(HZ/1000)
}

建议用法

// 可以在网络状态回调函数中发送信号量
static void con_net_status_changed_event(u8 status )
{
    switch(status)
    {
    case NETIF_WIFI_JOIN_SUCCESS:
        printf("--->NETIF_WIFI_JOIN_SUCCESS\n");
        break;
    case NETIF_WIFI_JOIN_FAILED:
        printf("--->NETIF_WIFI_JOIN_FAILED\n");
        light_off(&led0);
        break;
    case NETIF_WIFI_DISCONNECTED:
        printf("--->NETIF_WIFI_DISCONNECTED\n");
        break;
    case NETIF_IP_NET_UP:
    {
        struct tls_ethif *tmpethif = tls_netif_get_ethif();
        print_ipaddr(&tmpethif->ip_addr);
#if TLS_CONFIG_IPV6
        print_ipaddr(&tmpethif->ip6_addr[0]);
        print_ipaddr(&tmpethif->ip6_addr[1]);
        print_ipaddr(&tmpethif->ip6_addr[2]);
#endif
    }
    break;
    default:
        //printf("UNKONWN STATE:%d\n", status);
        break;
    }
}

void UserMain(void)
{
    printf("\n user task \n");
    u8 auto_reconnect = 0xff;
    tls_wifi_auto_connect_flag(WIFI_AUTO_CNT_FLAG_GET, &auto_reconnect);
    if(auto_reconnect != WIFI_AUTO_CNT_ON)
    {
        auto_reconnect = WIFI_AUTO_CNT_ON;
        tls_wifi_auto_connect_flag(WIFI_AUTO_CNT_FLAG_SET, &auto_reconnect); 
        tls_wifi_connect((u8 *)"w600", strlen("w600"), (u8 *)"12345678", strlen("12345678"));
        printf("--->WIFI_AUTO_CNT_FLAG_SET ON\n");
    }
    // 注册网络状态回调
    tls_netif_add_status_event(con_net_status_changed_event);

#if DEMO_CONSOLE
    CreateDemoTask();
#endif
//用户自己的task
}

撰写答案

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

发布
问题

分享
好友

手机
浏览

扫码手机浏览