微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI WIFI设计交流 > CC3200 sl_WlanProfileAdd后,运行一段时间后再次连接wifi连不上

CC3200 sl_WlanProfileAdd后,运行一段时间后再次连接wifi连不上

时间:10-02 整理:3721RD 点击:

工程师们,你们好,CC3200 sl_WlanProfileAdd后可以正常连接到AP,断电重启、休眠唤醒后,可以正常连接到AP,但板子这样运行一段时间后后出现连接不上AP的情况,请问出现上述现象的原因是什么?

有没有可能是死机了,你弄个LED作为正常运行的指示灯,让它定时闪烁,看看断线后程序是否死机了。

没有死机,程序运行指示灯一直在闪烁

建议用串口打印出连接AP的信息,首先是连接到哪个AP,其次是获取IP地址,看看是哪一步的问题。

好的,谢谢

我也发现这样的问题了,刚开始连接没有问题,自动连接效果也挺好。但是工作一段时间后,断开AP就再也连不上了,并且串口一直打印WiFi从AP上断开的信息,但是电脑就可以连接上AP,WiFi就是搜不到而且,不能连不上。 有没有好的解决办法,保证100%连接。

注意在应用程序中,不要删除Profile,如下操作

//*****************************************************************************
//! \brief This function puts the device in its default state. It:
//! - Set the mode to STATION
//! - Configures connection policy to Auto and AutoSmartConfig
//! - Deletes all the stored profiles
//! - Enables DHCP
//! - Disables Scan policy
//! - Sets Tx power to maximum
//! - Sets power policy to normal
//! - Unregister mDNS services
//! - Remove all filters
//!
//! \param none
//! \return On success, zero is returned. On error, negative is returned
//*****************************************************************************
static long ConfigureSimpleLinkToDefaultState()
{
SlVersionFull ver = {0};
_WlanRxFilterOperationCommandBuff_t RxFilterIdMask = {0};

unsigned char ucVal = 1;
unsigned char ucConfigOpt = 0;
unsigned char ucConfigLen = 0;
unsigned char ucPower = 0;

long lRetVal = -1;
long lMode = -1;

lMode = sl_Start(0, 0, 0);
ASSERT_ON_ERROR(lMode);

// If the device is not in station-mode, try configuring it in station-mode
if (ROLE_STA != lMode)
{
if (ROLE_AP == lMode)
{
// If the device is in AP mode, we need to wait for this event
// before doing anything
while(!IS_IP_ACQUIRED(g_ulStatus))
{
#ifndef SL_PLATFORM_MULTI_THREADED
_SlNonOsMainLoopTask();
#endif
}
}

// Switch to STA role and restart
lRetVal = sl_WlanSetMode(ROLE_STA);
ASSERT_ON_ERROR(lRetVal);

lRetVal = sl_Stop(0xFF);
ASSERT_ON_ERROR(lRetVal);

lRetVal = sl_Start(0, 0, 0);
ASSERT_ON_ERROR(lRetVal);

// Check if the device is in station again
if (ROLE_STA != lRetVal)
{
// We don't want to proceed if the device is not coming up in STA-mode
return DEVICE_NOT_IN_STATION_MODE;
}
}

// Get the device's version-information
ucConfigOpt = SL_DEVICE_GENERAL_VERSION;
ucConfigLen = sizeof(ver);
lRetVal = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &ucConfigOpt,
&ucConfigLen, (unsigned char *)(&ver));
ASSERT_ON_ERROR(lRetVal);

UART_PRINT("Host Driver Version: %s\n\r",SL_DRIVER_VERSION);
UART_PRINT("Build Version %d.%d.%d.%d.31.%d.%d.%d.%d.%d.%d.%d.%d\n\r",
ver.NwpVersion[0],ver.NwpVersion[1],ver.NwpVersion[2],ver.NwpVersion[3],
ver.ChipFwAndPhyVersion.FwVersion[0],ver.ChipFwAndPhyVersion.FwVersion[1],
ver.ChipFwAndPhyVersion.FwVersion[2],ver.ChipFwAndPhyVersion.FwVersion[3],
ver.ChipFwAndPhyVersion.PhyVersion[0],ver.ChipFwAndPhyVersion.PhyVersion[1],
ver.ChipFwAndPhyVersion.PhyVersion[2],ver.ChipFwAndPhyVersion.PhyVersion[3]);

// Set connection policy to Auto + SmartConfig
// (Device's default connection policy)
lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION,
SL_CONNECTION_POLICY(1, 0, 0, 0, 1), NULL, 0);
ASSERT_ON_ERROR(lRetVal);

// Remove all profiles
lRetVal = sl_WlanProfileDel(0xFF);
ASSERT_ON_ERROR(lRetVal);

//
// Device in station-mode. Disconnect previous connection if any
// The function returns 0 if 'Disconnected done', negative number if already
// disconnected Wait for 'disconnection' event if 0 is returned, Ignore
// other return-codes
//
lRetVal = sl_WlanDisconnect();
if(0 == lRetVal)
{
// Wait
while(IS_CONNECTED(g_ulStatus))
{
#ifndef SL_PLATFORM_MULTI_THREADED
_SlNonOsMainLoopTask();
#endif
}
}

// Enable DHCP client
lRetVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&ucVal);
ASSERT_ON_ERROR(lRetVal);

// Disable scan
ucConfigOpt = SL_SCAN_POLICY(0);
lRetVal = sl_WlanPolicySet(SL_POLICY_SCAN , ucConfigOpt, NULL, 0);
ASSERT_ON_ERROR(lRetVal);

// Set Tx power level for station mode
// Number between 0-15, as dB offset from max power - 0 will set max power
ucPower = 0;
lRetVal = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,
WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (unsigned char *)&ucPower);
ASSERT_ON_ERROR(lRetVal);

// Set PM policy to normal
lRetVal = sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL, 0);
ASSERT_ON_ERROR(lRetVal);

// Unregister mDNS services
lRetVal = sl_NetAppMDNSUnRegisterService(0, 0);
ASSERT_ON_ERROR(lRetVal);

// Remove all 64 filters (8*8)
memset(RxFilterIdMask.FilterIdMask, 0xFF, 8);
lRetVal = sl_WlanRxFilterSet(SL_REMOVE_RX_FILTER, (_u8 *)&RxFilterIdMask,
sizeof(_WlanRxFilterOperationCommandBuff_t));
ASSERT_ON_ERROR(lRetVal);

lRetVal = sl_Stop(SL_STOP_TIMEOUT);
ASSERT_ON_ERROR(lRetVal);

InitializeAppVariables();

return lRetVal; // Success
}

// Remove all profiles
lRetVal = sl_WlanProfileDel(0xFF);

这一段代码,我程序没有添加。

排查一下射频端,连接不上的情况是否发生在无线的信号较弱的地方,CC3200由于信号太差导致连接不上wifi 并非是profile 的问题,或者是在增加Profile时会不会超过了最大的Profile个数导致之前的数据丢失。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top