本文整理汇总了C++中sl_WlanPolicySet函数的典型用法代码示例。如果您正苦于以下问题:C++ sl_WlanPolicySet函数的具体用法?C++ sl_WlanPolicySet怎么用?C++ sl_WlanPolicySet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sl_WlanPolicySet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ResetSimpleLink
int32_t ResetSimpleLink() {
int32_t i32Mode = -1, i32RetVal = -1;
uint8_t ui8Val = 1;
i32Mode = sl_Start(0, 0, 0);
i32RetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION,
SL_CONNECTION_POLICY(1, 0, 0, 0, 1), NULL, 0);
if (i32RetVal != 0) {
return -1;
}
i32RetVal = sl_WlanProfileDel(0xFF);
if (i32RetVal != 0) {
return -1;
}
if (ROLE_STA != i32Mode) {
if (ROLE_AP == i32Mode) {
while (!STATUS_GET(g_sSLCon.Status, STATUS_BIT_IP_ACQUIRED)) {
}
}
sl_WlanSetMode(ROLE_STA);
sl_Stop(0);
g_sSLCon.Status = 0;
i32RetVal = sl_Start(0, 0, 0);
if (ROLE_STA != i32RetVal) {
return -1;
}
}
i32RetVal = sl_WlanDisconnect();
if (i32RetVal == 0) {
while (STATUS_GET(g_sSLCon.Status, STATUS_BIT_CONNECTED)) {
}
}
sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE, 1, 1, &ui8Val);
sl_WlanPolicySet(SL_POLICY_SCAN, SL_SCAN_POLICY(0), NULL, NULL);
ui8Val = 0;
sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,
WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (unsigned char *) &ui8Val);
sl_WlanPolicySet(SL_POLICY_PM, SL_NORMAL_POLICY, NULL, 0);
sl_NetAppMDNSUnRegisterService(0, 0);
sl_Stop(0);
InitVariables();
return 0;
}
示例2: P2PConfiguration
//*****************************************************************************
//
//! Set all P2P Configuration to device
//!
//! \param None
//!
//! \return status code - Success:0, Failure:-ve
//
//*****************************************************************************
long P2PConfiguration()
{
unsigned char ucP2PParam[4];
long lRetVal = -1;
// Set any p2p option (SL_CONNECTION_POLICY(0,0,0,any_p2p,0)) to connect to
// first available p2p device
lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(1,0,0,0,0),NULL,0);
ASSERT_ON_ERROR(lRetVal);
// Set the negotiation role (SL_P2P_ROLE_NEGOTIATE).
// CC3200 will negotiate with remote device GO/client mode.
// Other valid options are:
// - SL_P2P_ROLE_GROUP_OWNER
// - SL_P2P_ROLE_CLIENT
lRetVal = sl_WlanPolicySet(SL_POLICY_P2P, SL_P2P_POLICY(SL_P2P_ROLE_NEGOTIATE,
SL_P2P_NEG_INITIATOR_ACTIVE),NULL,0);
ASSERT_ON_ERROR(lRetVal);
// Set P2P Device name
lRetVal = sl_NetAppSet(SL_NET_APP_DEVICE_CONFIG_ID, \
NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN,
strlen(P2P_DEVICE_NAME), (unsigned char *)P2P_DEVICE_NAME);
ASSERT_ON_ERROR(lRetVal);
// Set P2P device type
lRetVal = sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_DEV_TYPE,
strlen(P2P_CONFIG_VALUE), (unsigned char*)P2P_CONFIG_VALUE);
ASSERT_ON_ERROR(lRetVal);
// setting P2P channel parameters
ucP2PParam[0] = LISENING_CHANNEL;
ucP2PParam[1] = REGULATORY_CLASS;
ucP2PParam[2] = OPERATING_CHANNEL;
ucP2PParam[3] = REGULATORY_CLASS;
// Set P2P Device listen and open channel valid channels are 1/6/11
lRetVal = sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_CHANNEL_N_REGS,
sizeof(ucP2PParam), ucP2PParam);
ASSERT_ON_ERROR(lRetVal);
// Restart as P2P device
lRetVal = sl_Stop(SL_STOP_TIMEOUT);
lRetVal = sl_Start(NULL,NULL,NULL);
if(lRetVal < 0 || lRetVal != ROLE_P2P)
{
ASSERT_ON_ERROR(P2P_CONFIG_FAILED);
}
else
{
UART_PRINT("Connect to %s \n\r",P2P_DEVICE_NAME);
}
return SUCCESS;
}
示例3: init
//--tested, working--//
int8_t WiFiClass::scanNetworks()
{
if (!_initialized) {
init();
}
const int WLAN_SCAN_COUNT = 20;
int iRet;
unsigned char ucpolicyOpt;
union
{
unsigned char ucPolicy[4];
unsigned int uiPolicyLen;
}policyVal;
//
// make sure the connection policy is not set (so no scan is run in the background)
//
ucpolicyOpt = SL_CONNECTION_POLICY(0, 0, 0, 0, 0);
iRet = sl_WlanPolicySet(SL_POLICY_CONNECTION , ucpolicyOpt, NULL, 0);
if(iRet != 0)
{
return 0;
}
//
// set the scan policy for ten seconds. This starts the scan.
//
policyVal.uiPolicyLen = 10;
iRet = sl_WlanPolicySet(SL_POLICY_SCAN , SL_SCAN_POLICY(1), (UINT8*)(policyVal.ucPolicy), sizeof(policyVal));
if(iRet != 0)
{
return 0;
}
delay(300);
//
// get scan results - all 20 entries in one transaction
// this array isn't actually used, but you have to do this to get the count
//
Sl_WlanNetworkEntry_t found_networks[WLAN_SCAN_COUNT];
network_count = sl_WlanGetNetworkList(0, (unsigned char)WLAN_SCAN_COUNT, found_networks);
//
// disable scan
//
ucpolicyOpt = SL_SCAN_POLICY(0);
sl_WlanPolicySet(SL_POLICY_SCAN , ucpolicyOpt, NULL, 0);
return network_count;
}
示例4: SmartConfigConnect
//*****************************************************************************
//
//! \brief Connecting to a WLAN Accesspoint using SmartConfig provisioning
//!
//! Enables SmartConfig provisioning for adding a new connection profile
//! to CC3200. Since we have set the connection policy to Auto, once
//! SmartConfig is complete, CC3200 will connect automatically to the new
//! connection profile added by smartConfig.
//!
//! \param[in] None
//!
//! \return None
//!
//! \note
//!
//! \warning If the WLAN connection fails or we don't
//! acquire an IP address, We will be stuck in this
//! function forever.
//
//*****************************************************************************
int SmartConfigConnect()
{
unsigned char policyVal;
long lRetVal = -1;
// Clear all profiles
// This is of course not a must, it is used in this example to make sure
// we will connect to the new profile added by SmartConfig
//
lRetVal = sl_WlanProfileDel(WLAN_DEL_ALL_PROFILES);
ASSERT_ON_ERROR(lRetVal);
//set AUTO policy
lRetVal = sl_WlanPolicySet( SL_POLICY_CONNECTION,
SL_CONNECTION_POLICY(1,0,0,0,1),
&policyVal,
1 /*PolicyValLen*/);
ASSERT_ON_ERROR(lRetVal);
// Start SmartConfig
// This example uses the unsecured SmartConfig method
//
lRetVal = sl_WlanSmartConfigStart(0, /*groupIdBitmask*/
SMART_CONFIG_CIPHER_NONE, /*cipher*/
0, /*publicKeyLen*/
0, /*group1KeyLen*/
0, /*group2KeyLen */
NULL, /*publicKey */
NULL, /*group1Key */
NULL); /*group2Key*/
ASSERT_ON_ERROR(lRetVal);
// Wait for WLAN Event
while((!IS_CONNECTED(g_ulStatus)) || (!IS_IP_ACQUIRED(g_ulStatus)))
{
_SlNonOsMainLoopTask();
}
//
// Turn ON the RED LED to indicate connection success
//
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
//wait for few moments
MAP_UtilsDelay(80000000);
//reset to default AUTO policy
lRetVal = sl_WlanPolicySet( SL_POLICY_CONNECTION,
SL_CONNECTION_POLICY(1,0,0,0,0),
&policyVal,
1 /*PolicyValLen*/);
ASSERT_ON_ERROR(lRetVal);
return SUCCESS;
}
示例5: SmartConfigConnect
/*!
\brief Connecting to a WLAN Accesspoint using SmartConfig provisioning
This function enables SmartConfig provisioning for adding a new connection profile to CC3100.
Since we have set the connection policy to Auto, once SmartConfig is complete,
CC3100 will connect automatically to the new connection profile added by smartConfig.
\param[in] None
\return None
\note
\warning If the WLAN connection fails or we don't acquire an IP address,
We will be stuck in this function forever.
*/
void SmartConfigConnect()
{
unsigned char policyVal;
/* Clear all profiles */
/* This is of course not a must, it is used in this example to make sure
* we will connect to the new profile added by SmartConfig
*/
sl_WlanProfileDel(WLAN_DEL_ALL_PROFILES);
//set AUTO policy
sl_WlanPolicySet( SL_POLICY_CONNECTION,
SL_CONNECTION_POLICY(1,0,0,0,0),
&policyVal,
1 /*PolicyValLen*/);
/* Start SmartConfig
* This example uses the unsecured SmartConfig method
*/
sl_WlanSmartConfigStart(0, //groupIdBitmask
SMART_CONFIG_CIPHER_NONE, //cipher
0, //publicKeyLen
0, //group1KeyLen
0, //group2KeyLen
NULL, //publicKey
NULL, //group1Key
NULL); //group2Key
}
示例6: delay
int WiFiClass::begin()
{
int8_t name[32];
int16_t NameLen;
if(_connecting) {
delay(500);
return status();
}
bool init_success = init();
if (!init_success) {
return WL_CONNECT_FAILED;
}
int16_t ret = sl_WlanProfileGet(0, name, (short int*)&NameLen, NULL, NULL, NULL, NULL);
if(ret < 0) {
return WL_CONNECT_FAILED;
}
sl_WlanPolicySet(SL_POLICY_CONNECTION , SL_CONNECTION_POLICY(1,1,0,0,0), 0, 0);
_connecting = true;
return WL_IDLE_STATUS;
}
示例7: wlan_configure
void wlan_configure()
{
sl_Start(NULL, NULL, NULL);
//
// reset all network policies
//
unsigned char ucpolicyVal;
int ret;
ret = sl_WlanPolicySet(SL_POLICY_CONNECTION,
SL_CONNECTION_POLICY(0,0,0,0,0),
&ucpolicyVal,
1 /*PolicyValLen*/);
if(ret < 0)
{
LOOP_FOREVER();
}
sl_WlanSetMode(ROLE_STA);
sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 0, 0, 0, 1), NULL, 0);
sl_WlanProfileDel(0xFF);
sl_WlanDisconnect();
_WlanRxFilterOperationCommandBuff_t RxFilterIdMask;// = {0};
memset(&RxFilterIdMask, 0, sizeof(RxFilterIdMask));
unsigned char ucVal = 0;
unsigned char ucConfigOpt = 0;
// Enable DHCP client
sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&ucVal);
// Disable scan
ucConfigOpt = SL_SCAN_POLICY(0);
sl_WlanPolicySet(SL_POLICY_SCAN , ucConfigOpt, NULL, 0);
// Set Tx power level for station mode
// Number between 0-15, as dB offset from max power - 0 will set max power
unsigned char ucPower = 0;
sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (unsigned char *)&ucPower);
// Set PM policy to normal
sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL, 0);
// Unregister mDNS services
sl_NetAppMDNSUnRegisterService(0, 0);
// Remove all 64 filters (8*8)
memset(RxFilterIdMask.FilterIdMask, 0xFF, 8);
sl_WlanRxFilterSet(SL_REMOVE_RX_FILTER, (_u8 *)&RxFilterIdMask, sizeof(_WlanRxFilterOperationCommandBuff_t));
sl_Stop(SL_STOP_TIMEOUT);
}
示例8: ensure_role_sta
static int ensure_role_sta() {
if (s_current_role == ROLE_STA) return 1;
if (sl_WlanSetMode(ROLE_STA) != 0) return 0;
if (!restart_nwp()) return 0;
_u32 scan_interval = WIFI_SCAN_INTERVAL_SECONDS;
sl_WlanPolicySet(SL_POLICY_SCAN, 1 /* enable */, (_u8 *) &scan_interval,
sizeof(scan_interval));
return 1;
}
示例9: init
int WiFiClass::startSmartConfig()
{
unsigned char policyVal;
if (!_initialized) {
init();
}
if (sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1,0,0,0,1), &policyVal, 1 /*PolicyValLen*/) < 0) {
return -1;
}
if (sl_WlanProfileDel(WLAN_DEL_ALL_PROFILES) < 0) {
return -1;
}
sl_WlanSmartConfigStart(0, //groupIdBitmask
SMART_CONFIG_CIPHER_NONE, //cipher
0, //publicKeyLen
0, //group1KeyLen
0, //group2KeyLen
NULL, //publicKey
NULL, //group1Key
NULL); //group2Key
/* Block until connected */
while (WiFi.status() != WL_CONNECTED) {
#ifndef SL_PLATFORM_MULTI_THREADED
// TODO: this call appears unnecessary: status() already calls sl_Task
sl_Task();
#else
// TODO: is 10 appropriate? to save power, shouldn't we always delay?
delay(10);
#endif
}
if (sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1,0,0,0,0), &policyVal, 1 /*PolicyValLen*/) < 0) {
return -1;
}
return (0);
}
示例10: wlan_scan
static void wlan_scan()
{
unsigned char ucpolicyOpt;
union {
unsigned char ucPolicy[4];
unsigned int uiPolicyLen;
} policyVal;
ucpolicyOpt = SL_CONNECTION_POLICY(0, 0, 0, 0,0);
sl_WlanPolicySet(SL_POLICY_CONNECTION , ucpolicyOpt, NULL, 0);
ucpolicyOpt = SL_SCAN_POLICY(1);
policyVal.uiPolicyLen = 10;
sl_WlanPolicySet(SL_POLICY_SCAN , ucpolicyOpt, (unsigned char*)(policyVal.ucPolicy), sizeof(policyVal));
MAP_UtilsDelay(8000000);
Sl_WlanNetworkEntry_t netEntries[10];
_i16 resultsCount = sl_WlanGetNetworkList(0,10,&netEntries[0]);
for (int i=0; i< resultsCount; i++)
UART_PRINT("ssid: %s\trssi: %d\tsec-t: %u\r\n",netEntries[i].ssid, netEntries[i].rssi, netEntries[i].sec_type);
}
示例11: GetScanResult
//*****************************************************************************
//
//! \brief This function Get the Scan Result
//!
//! \param[in] none
//!
//! \return Size of Scan Result Array
//!
//! \note
//!
//
//*****************************************************************************
int GetScanResult(Sl_WlanNetworkEntry_t* netEntries )
{
UINT8 policyOpt;
UINT32 IntervalVal = 60;
int retVal;
policyOpt = SL_CONNECTION_POLICY(0, 0, 0, 0, 0);
retVal = sl_WlanPolicySet(SL_POLICY_CONNECTION , policyOpt, NULL, 0);
if(retVal < 0)
{
/* Error */
}
// enable scan
policyOpt = SL_SCAN_POLICY(1);
// set scan policy - this starts the scan
retVal = sl_WlanPolicySet(SL_POLICY_SCAN , policyOpt,
(UINT8 *)(IntervalVal), sizeof(IntervalVal));
// delay 1 second to verify scan is started
osi_Sleep(1000);
// retVal indicates the valid number of entries
// The scan results are occupied in netEntries[]
retVal = sl_WlanGetNetworkList(0, SCAN_TABLE_SIZE, netEntries);
// Disable scan
policyOpt = SL_SCAN_POLICY(0);
// set scan policy - this stops the scan
sl_WlanPolicySet(SL_POLICY_SCAN , policyOpt,
(UINT8 *)(IntervalVal), sizeof(IntervalVal));
return retVal;
}
示例12: wlan_scan
STATIC mp_obj_t wlan_scan(mp_obj_t self_in) {
STATIC const qstr wlan_scan_info_fields[] = {
MP_QSTR_ssid, MP_QSTR_bssid, MP_QSTR_sec, MP_QSTR_channel, MP_QSTR_rssi
};
// check for correct wlan mode
if (wlan_obj.mode == ROLE_AP) {
mp_raise_OSError(MP_EPERM);
}
Sl_WlanNetworkEntry_t wlanEntry;
mp_obj_t nets = mp_obj_new_list(0, NULL);
uint8_t _index = 0;
// trigger a new network scan
uint32_t scanSeconds = MODWLAN_SCAN_PERIOD_S;
ASSERT_ON_ERROR(sl_WlanPolicySet(SL_POLICY_SCAN , MODWLAN_SL_SCAN_ENABLE, (_u8 *)&scanSeconds, sizeof(scanSeconds)));
// wait for the scan to complete
mp_hal_delay_ms(MODWLAN_WAIT_FOR_SCAN_MS);
do {
if (sl_WlanGetNetworkList(_index++, 1, &wlanEntry) <= 0) {
break;
}
// we must skip any duplicated results
if (!wlan_scan_result_is_unique(nets, wlanEntry.bssid)) {
continue;
}
mp_obj_t tuple[5];
tuple[0] = mp_obj_new_str((const char *)wlanEntry.ssid, wlanEntry.ssid_len, false);
tuple[1] = mp_obj_new_bytes((const byte *)wlanEntry.bssid, SL_BSSID_LENGTH);
// 'normalize' the security type
if (wlanEntry.sec_type > 2) {
wlanEntry.sec_type = 2;
}
tuple[2] = mp_obj_new_int(wlanEntry.sec_type);
tuple[3] = mp_const_none;
tuple[4] = mp_obj_new_int(wlanEntry.rssi);
// add the network to the list
mp_obj_list_append(nets, mp_obj_new_attrtuple(wlan_scan_info_fields, 5, tuple));
} while (_index < MODWLAN_SL_MAX_NETWORKS);
return nets;
}
示例13: SmartConfigConnect
//*****************************************************************************
//
//! \brief Connecting to a WLAN Accesspoint using SmartConfig provisioning
//!
//! This function enables SmartConfig provisioning for adding a new
//! connection profile to CC3200. Since we have set the connection policy
//! to Auto, once SmartConfig is complete,CC3200 will connect
//! automatically to the new connection profile added by smartConfig.
//!
//! \param[in] None
//!
//! \return 0 - Success
//! -1 - Failure
//!
//! \warning If the WLAN connection fails or we don't acquire an
//! IP address,We will be stuck in this function forever.
//!
//*****************************************************************************
long SmartConfigConnect()
{
unsigned char policyVal;
long lRetVal = -1;
//
// Clear all profiles
// This is of course not a must, it is used in this example to make sure
// we will connect to the new profile added by SmartConfig
//
lRetVal = sl_WlanProfileDel(WLAN_DEL_ALL_PROFILES);
ASSERT_ON_ERROR(lRetVal);
//set AUTO policy
lRetVal = sl_WlanPolicySet( SL_POLICY_CONNECTION,
SL_CONNECTION_POLICY(1,0,0,0,0),
&policyVal,
1 /*PolicyValLen*/);
ASSERT_ON_ERROR(lRetVal);
//
// Start SmartConfig
// This example uses the unsecured SmartConfig method
//
lRetVal = sl_WlanSmartConfigStart(0, /*groupIdBitmask*/
SMART_CONFIG_CIPHER_NONE, /*cipher*/
0, /*publicKeyLen*/
0, /*group1KeyLen*/
0, /*group2KeyLen */
NULL, /*publicKey */
NULL, /*group1Key */
NULL); /*group2Key*/
ASSERT_ON_ERROR(lRetVal);
return SUCCESS;
}
示例14: SmartConfigConnect
/*!
\brief Connecting to a WLAN Access point using SmartConfig provisioning
This function enables SmartConfig provisioning for adding a new connection
profile to CC3100. Since we have set the connection policy to Auto, once
SmartConfig is complete, CC3100 will connect automatically to the new
connection profile added by smartConfig.
\param[in] None
\return 0 on success, negative error-code on error
\note
\warning If the WLAN connection fails or we don't acquire an IP
address, We will be stuck in this function forever.
*/
static _i32 SmartConfigConnect()
{
_u8 policyVal = 0;
_i32 retVal = -1;
/* Clear all profiles */
/* This is of course not a must, it is used in this example to make sure
* we will connect to the new profile added by SmartConfig
*/
retVal = sl_WlanProfileDel(WLAN_DEL_ALL_PROFILES);
ASSERT_ON_ERROR(retVal);
/* set AUTO policy */
retVal = sl_WlanPolicySet(SL_POLICY_CONNECTION,
SL_CONNECTION_POLICY(1, 0, 0, 0, 0),
&policyVal,
1); /*PolicyValLen*/
ASSERT_ON_ERROR(retVal);
/* Start SmartConfig
* This example uses the unsecured SmartConfig method
*/
retVal = sl_WlanSmartConfigStart(0, /* groupIdBitmask */
SMART_CONFIG_CIPHER_NONE, /* cipher */
0, /* publicKeyLen */
0, /* group1KeyLen */
0, /* group2KeyLen */
(const _u8 *)"", /* publicKey */
(const _u8 *)"", /* group1Key */
(const _u8 *)""); /* group2Key */
ASSERT_ON_ERROR(retVal);
/* Wait */
while((!IS_CONNECTED(g_Status)) || (!IS_IP_ACQUIRED(g_Status))) { _SlNonOsMainLoopTask(); }
return SUCCESS;
}
示例15: main
int main()
{
unsigned char ucP2PParam[4];
long lRetVal = -1;
//
// Initialize Board configurations
//
BoardInit();
//
// Pinmuxing for GPIO, UART
//
PinMuxConfig();
//
// configure LEDs
//
GPIO_IF_LedConfigure(LED1|LED2|LED3);
// off all LEDs
GPIO_IF_LedOff(MCU_ALL_LED_IND);
#ifndef NOTERM
//
// Configuring UART
//
InitTerm();
#endif
//
// Display the Application Banner
//
DisplayBanner(APP_NAME);
UART_PRINT("Scan Wi-FI direct device in your handheld device\n\r");
// Initializing the CC3200 device
lRetVal = StartDeviceInP2P();
if(lRetVal < 0)
{
LOOP_FOREVER(__LINE__);
}
// Set any p2p option (SL_CONNECTION_POLICY(0,0,0,any_p2p,0)) to connect to
// first available p2p device
sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(1,0,0,0,0),NULL,0);
// Set the negotiation role (SL_P2P_ROLE_NEGOTIATE).
// CC3200 will negotiate with remote device GO/client mode.
// Other valid options are:
// - SL_P2P_ROLE_GROUP_OWNER
// - SL_P2P_ROLE_CLIENT
sl_WlanPolicySet(SL_POLICY_P2P, SL_P2P_POLICY(SL_P2P_ROLE_NEGOTIATE,
SL_P2P_NEG_INITIATOR_ACTIVE),NULL,0);
// Set P2P Device name
sl_NetAppSet(SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN,
strlen(P2P_DEVICE_NAME), (unsigned char *)P2P_DEVICE_NAME);
// Set P2P device type
sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_DEV_TYPE,
strlen(P2P_CONFIG_VALUE), (unsigned char*)P2P_CONFIG_VALUE);
// setting P2P channel parameters
ucP2PParam[0] = LISENING_CHANNEL;
ucP2PParam[1] = REGULATORY_CLASS;
ucP2PParam[2] = OPERATING_CHANNEL;
ucP2PParam[3] = REGULATORY_CLASS;
// Set P2P Device listen and open channel valid channels are 1/6/11
sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_CHANNEL_N_REGS,
sizeof(ucP2PParam), ucP2PParam);
// Restart as P2P device
sl_Stop(SL_STOP_TIMEOUT);
lRetVal = sl_Start(NULL,NULL,NULL);
if(lRetVal < 0 || lRetVal != ROLE_P2P)
{
UART_PRINT("Failed to start the device \n\r");
LOOP_FOREVER(__LINE__);
}
else
{
UART_PRINT("Connect to %s \n\r",P2P_DEVICE_NAME);
}
/* Connect to configure P2P device */
lRetVal = WlanConnect();
if(lRetVal == 0)
{
GPIO_IF_LedOn(MCU_IP_ALLOC_IND);
}
else
{
//.........这里部分代码省略.........