CC32xx/CC3100 的一些常见操作

修改发射功率:

_i8 TXPower = 0;
_u16 Option = WLAN_GENERAL_PARAM_OPT_STA_TX_POWER;
_u16 OptionLen = sizeof(_i8);
sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID ,&Option,&OptionLen,(_u8 *)&TXPower);

设置通道:

_i8 country[3];
_u16 len = 3;
_u16 config_opt = WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE;
_u8* str = (_u8 *) "EU";
lRetVal = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE, 2, str);
sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID, &config_opt, &len, (_u8* )country);

CC3200 MQTT:

http://processors.wiki.ti.com/index.php/CC3200_MQTT_Client


CC3200 debug常见问题 【Error -1170 Unable to access the DAP】:

processors.wiki.ti.com/.../Debugging_JTAG_Connectivity_Problems


wlan_sta和tcp_socket的差别:

是将CC3200设置为基本的Station模式

tcp_socket例程

CC3200通过Station模式下,与主机进行TCP的数据通信

如何将网页配置的WIFI密码等数据保存在CC3200中,以便下一次CC3200直接联网:

1. 首先在你程序的初始化中不要讲存储的WiFI 密码的profile删除,如下代码标黄出,

2. 当CC3200通过密码连接上AP后,会存储到Profile中,下次再次上电会自动从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
}


我的QQ群:639597049

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值