使用ap模式,调用WlanAPMode函数,一定要用osi_task_creat 操作系统吗?
想利用ap模式,让手机端在无网络情况下输入路由器账号及密码给板子,可是历程里面是利用osi_task_creat 操作系统调用WlanAPMode函数。
我想移植这个作为功能模块之一,可以直接调用WlanAPMode函数吗?我尝试直接全部移植代码,
可是运行到了lRetVal=IS_IP_LEASED(g_ulStatus); 这个函数的时候,发现手机端可以得到分配的ip,但是程序就一直跳不出循环,按原例程,函数成功返回值是1,不成功是0,而且原例程中再分配过程中,函数是堵塞的,一直等到分配成功才返回值,但是移植后发现一直有返回值
求问究竟是为什么,怎么解决?
那你现在的g_ulStatus是什么值,你看一下有收到IP LEASED的事件吗?
void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent)
{
switch(pNetAppEvent->Event)
{
case SL_NETAPP_IPV4_IPACQUIRED_EVENT:
case SL_NETAPP_IPV6_IPACQUIRED_EVENT:
{
SET_STATUS_BIT(g_ulStatus, STATUS_BIT_IP_AQUIRED);
}
break;
case SL_NETAPP_IP_LEASED_EVENT:
{
SET_STATUS_BIT(g_ulStatus, STATUS_BIT_IP_LEASED);
g_ulStaIp = (pNetAppEvent)->EventData.ipLeased.ip_address;
UART_PRINT("[NETAPP EVENT] IP Leased to Client: IP=%d.%d.%d.%d , ",
SL_IPV4_BYTE(g_ulStaIp,3), SL_IPV4_BYTE(g_ulStaIp,2),
SL_IPV4_BYTE(g_ulStaIp,1), SL_IPV4_BYTE(g_ulStaIp,0));
}
break;
case SL_NETAPP_IP_RELEASED_EVENT:
{
CLR_STATUS_BIT(g_ulStatus, STATUS_BIT_IP_LEASED);
UART_PRINT("[NETAPP EVENT] IP Released for Client: IP=%d.%d.%d.%d , ",
SL_IPV4_BYTE(g_ulStaIp,3), SL_IPV4_BYTE(g_ulStaIp,2),
SL_IPV4_BYTE(g_ulStaIp,1), SL_IPV4_BYTE(g_ulStaIp,0));
}
break;
default:
{
UART_PRINT("[NETAPP EVENT] Unexpected event [0x%x] \n\r",
pNetAppEvent->Event);
}
break;
}
}
g_ulStatus是0; 按原例程,ip分配不成功就会堵塞,不会又返回值,可是移植后一直返回0