当前位置: 首页>>代码示例>>C++>>正文


C++ sl_WlanSetMode函数代码示例

本文整理汇总了C++中sl_WlanSetMode函数的典型用法代码示例。如果您正苦于以下问题:C++ sl_WlanSetMode函数的具体用法?C++ sl_WlanSetMode怎么用?C++ sl_WlanSetMode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sl_WlanSetMode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ConfigureMode

//****************************************************************************
//
//! Confgiures the mode in which the device will work
//!
//! \param iMode is the current mode of the device
//!
//! This function
//!    1. prompt user for desired configuration and accordingly configure the
//!          networking mode(STA or AP).
//!       2. also give the user the option to configure the ssid name in case of
//!       AP mode.
//!
//! \return 0: success, -ve: failure.
//
//****************************************************************************
long ConfigureMode(int iMode)
{
    char cCharacter = 'a';
    char pcSsidName[33];
    unsigned short   len;
    long lRetVal = -1;

    while(cCharacter != '1' && cCharacter != '2' && cCharacter != '3')
    {
        UART_PRINT("Do you Want to Switch Mode\n\r1. STA mode\n\r2. AP Mode\n\r"
                    "3. P2P Mode :");
        cCharacter = MAP_UARTCharGet(CONSOLE);
        MAP_UARTCharPut(CONSOLE,cCharacter);
        MAP_UARTCharPut(CONSOLE,'\n');
        MAP_UARTCharPut(CONSOLE,'\r');
    }
    if(cCharacter == '1')
    {
        lRetVal = sl_WlanSetMode(ROLE_STA);
        ASSERT_ON_ERROR(lRetVal);
        UART_PRINT("mode configured\n\r");
    }
    else if(cCharacter == '2')
    {
        UART_PRINT("Enter the SSID name: ");
        GetSsidName(pcSsidName,33);
        _SlNonOsMainLoopTask();
        lRetVal = sl_WlanSetMode(ROLE_AP);
        ASSERT_ON_ERROR(lRetVal);

        len = strlen(pcSsidName);
        lRetVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, len,
                                (unsigned char*) pcSsidName);
        ASSERT_ON_ERROR(lRetVal);

        UART_PRINT("mode configured\n\r");
    }
    else if(cCharacter == '3')
    {
        lRetVal = sl_WlanSetMode(ROLE_P2P);
        ASSERT_ON_ERROR(lRetVal);

        UART_PRINT("mode configured\n\r");
    }
    else
    {
       UART_PRINT("Wrong input\n\r");
    }
    return 0;
}
开发者ID:bigcat26,项目名称:cc3200-sdk,代码行数:65,代码来源:main.c

示例2: ConfigureMode

//****************************************************************************
//
//! Confgiures the mode in which the device will work
//!
//! \param iMode is the current mode of the device
//!
//! This function
//!    1. prompt user for desired configuration and accordingly configure the
//!          networking mode(STA or AP).
//!       2. also give the user the option to configure the ssid name in case of
//!       AP mode.
//!
//! \return sl_start return value(int).
//
//****************************************************************************
static int ConfigureMode(int iMode)
{
    char    pcSsidName[33];
    long   retVal = -1;

    UART_PRINT("Enter the AP SSID name: ");
    GetSsidName(pcSsidName,33);

    retVal = sl_WlanSetMode(ROLE_AP);
    ASSERT_ON_ERROR(__LINE__, retVal);

    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(pcSsidName),
                            (unsigned char*)pcSsidName);
    ASSERT_ON_ERROR(__LINE__, retVal);

    UART_PRINT("Device is configured in AP mode\n\r");

    /* Restart Network processor */
    retVal = sl_Stop(SL_STOP_TIMEOUT);
    ASSERT_ON_ERROR(__LINE__, retVal);

    // reset status bits
    CLR_STATUS_BIT_ALL(g_ulStatus);

    return sl_Start(NULL,NULL,NULL);
}
开发者ID:Balu1991,项目名称:Wifly_Light,代码行数:41,代码来源:main.c

示例3: init

int WiFiClass::beginNetwork(char *ssid, char *passphrase)
{
    long   retVal = -1;
    int i;

    if (!_initialized) {
        init();
    }

    // Initialize the AP-mode Connected Device array
    WiFiClass::_connectedDeviceCount = 0;
    _latestConnect = 0;
    for (i = 0; i < MAX_AP_DEVICE_REGISTRY; i++) {
        _connectedDevices[i].in_use = false;
        memset((uint8_t *)_connectedDevices[i].ipAddress, 0, 4);
        memset((uint8_t *)_connectedDevices[i].mac, 0, 6);
    }

    retVal = sl_WlanSetMode(ROLE_AP);

    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(ssid),
                            (unsigned char *)ssid);

    unsigned char  val = SL_SEC_TYPE_WPA;
    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (unsigned char *)&val);

    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, strlen(passphrase),
                            (unsigned char *)passphrase);

    /* Restart Network processor */
    retVal = sl_Stop(30);

    role = ROLE_AP;
    return (retVal == 0 ? sl_Start(NULL, NULL, NULL) : retVal);
}
开发者ID:ArduCAM,项目名称:Energia,代码行数:35,代码来源:WiFi.cpp

示例4: init

int WiFiClass::beginNetwork(char *ssid, char *passphrase)
{
    long   retVal = -1;

    if (!_initialized) {
        init();
    }

    retVal = sl_WlanSetMode(ROLE_AP);

    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(ssid),
                            (unsigned char *)ssid);

    unsigned char  val = SL_SEC_TYPE_WPA;
    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (unsigned char *)&val);

    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, strlen(passphrase),
                            (unsigned char *)passphrase);

    /* Restart Network processor */
    retVal = sl_Stop(30);

    role = ROLE_AP;
    return sl_Start(NULL,NULL,NULL);
}
开发者ID:LCPINAGE,项目名称:Energia,代码行数:25,代码来源:WiFi.cpp

示例5: StartDeviceInP2P

//*****************************************************************************
//
//! Check the device mode and switch to P2P mode
//! restart the NWP to activate P2P mode
//!
//! \param  None
//!
//! \return status code - Success:0, Failure:-ve
//
//*****************************************************************************
long StartDeviceInP2P()
{
    long lRetVal = -1;
    // Reset CC3200 Network State Machine
    InitializeAppVariables();

    //
    // Following function configure the device to default state by cleaning
    // the persistent settings stored in NVMEM (viz. connection profiles &
    // policies, power policy etc)
    //
    // Applications may choose to skip this step if the developer is sure
    // that the device is in its default state at start of application
    //
    // Note that all profiles and persistent settings that were done on the
    // device will be lost
    //
    lRetVal = ConfigureSimpleLinkToDefaultState();
    if(lRetVal < 0)
    {
        if (DEVICE_NOT_IN_STATION_MODE == lRetVal)
            UART_PRINT("Failed to configure the device in its default state \n\r");

        LOOP_FOREVER();
    }

    UART_PRINT("Device is configured in default state \n\r");

    //
    // Assumption is that the device is configured in station mode already
    // and it is in its default state
    //

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

    if(lRetVal != ROLE_P2P)
    {
        lRetVal = sl_WlanSetMode(ROLE_P2P);
        ASSERT_ON_ERROR(lRetVal);

        lRetVal = sl_Stop(0xFF);

        // reset the Status bits
        CLR_STATUS_BIT_ALL(g_ulStatus);

        lRetVal = sl_Start(NULL,NULL,NULL);
        if(lRetVal < 0 || lRetVal != ROLE_P2P)
        {
            ASSERT_ON_ERROR(P2P_MODE_START_FAILED);
        }
        else
        {
            UART_PRINT("Started SimpleLink Device: P2P Mode\n\r");
            return SUCCESS;
        }
    }

    return SUCCESS;
}
开发者ID:dlugaz,项目名称:All,代码行数:70,代码来源:main.c

示例6: cc3200helpers_startIn

static unsigned long cc3200helpers_startIn(SlWlanMode_t eWlanMode)
{
  int iMode = 0;
  unsigned long dwResult = 0;

  s_flWLANConnected = 0;
  s_flAcquiredIP = 0;
  SlWlanMode_t s_eRequestedWlanMode = eWlanMode;

  dwResult = cc3200helpers_start(&iMode);

  if ( dwResult )
  {
    return dwResult;
  }

  if ( eWlanMode == iMode )
  {
    return cc3200Helpers_OK;
  }

  if (ROLE_AP == iMode)
  {
      // If the device is in AP mode, we need to wait for this event
      // before doing anything
      TRACE("Waiting for AP to initialize\n\r");
      while(!s_flAcquiredIP)
      {
#ifndef SL_PLATFORM_MULTI_THREADED
        _SlNonOsMainLoopTask();
#endif
      }
      s_flAcquiredIP = 0;
      TRACE("AP ready\n\r");
  }

  if ( sl_WlanSetMode(eWlanMode) )
  {
    return cc3200Helpers_SwitchFailed | cc3200Helpers_SetModeFailed;
  }

  if ( sl_Stop(0) )
  {
    return cc3200Helpers_SwitchFailed | cc3200Helpers_StopFailed;
  }

 dwResult = cc3200helpers_start(&iMode);

 if ( dwResult )
 {
   return cc3200Helpers_SwitchFailed | dwResult;
 }

 if ( iMode != eWlanMode )
 {
   return cc3200Helpers_SwitchFailed;
 }
  return cc3200Helpers_OK;
}
开发者ID:eeapai,项目名称:CC3200EclipseGCCTemplate,代码行数:59,代码来源:CC3200Helpers.c

示例7: 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;
}
开发者ID:yajun0601,项目名称:CC3200,代码行数:58,代码来源:ControlServer.c

示例8: wifi_setup_ap

bool wifi_setup_ap(const char *ssid, const char *pass, int channel) {
    uint8_t v;
    if (sl_WlanSetMode(ROLE_AP) != 0) {
        return false;
    }
    if (sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(ssid),
                   (const uint8_t *) ssid) != 0) {
        return false;
    }
    v = strlen(pass) > 0 ? SL_SEC_TYPE_WPA : SL_SEC_TYPE_OPEN;
    if (sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, &v) != 0) {
        return false;
    }
    if (v == SL_SEC_TYPE_WPA &&
            sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, strlen(pass),
                       (const uint8_t *) pass) != 0) {
        return false;
    }
    v = channel;
    if (sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_CHANNEL, 1, &v) != 0) {
        return false;
    }
    sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID);
    {
        SlNetCfgIpV4Args_t ipcfg;
        memset(&ipcfg, 0, sizeof(ipcfg));
        if (!inet_pton(AF_INET, "192.168.4.1", &ipcfg.ipV4) ||
                !inet_pton(AF_INET, "255.255.255.0", &ipcfg.ipV4Mask) ||
                /* This means "disable". 0.0.0.0 won't do. */
                !inet_pton(AF_INET, "255.255.255.255", &ipcfg.ipV4DnsServer) ||
                /* We'd like to disable gateway too, but DHCP server refuses to start.
                   */
                !inet_pton(AF_INET, "192.168.4.1", &ipcfg.ipV4Gateway) ||
                sl_NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE, IPCONFIG_MODE_ENABLE_IPV4,
                             sizeof(ipcfg), (uint8_t *) &ipcfg) != 0) {
            return false;
        }
    }
    {
        SlNetAppDhcpServerBasicOpt_t dhcpcfg;
        memset(&dhcpcfg, 0, sizeof(dhcpcfg));
        dhcpcfg.lease_time = 900;
        if (!inet_pton(AF_INET, "192.168.4.20", &dhcpcfg.ipv4_addr_start) ||
                !inet_pton(AF_INET, "192.168.4.200", &dhcpcfg.ipv4_addr_last) ||
                sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT,
                             sizeof(dhcpcfg), (uint8_t *) &dhcpcfg) != 0) {
            return false;
        }
    }
    sl_Stop(0);
    sl_Start(NULL, NULL, NULL);
    if (sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID) != 0) {
        LOG(LL_ERROR, ("DHCP server failed to start"));
        return false;
    }
    LOG(LL_INFO, ("WiFi: AP %s configured", ssid));
    return true;
}
开发者ID:LorDClockaN,项目名称:AdAway,代码行数:58,代码来源:wifi.c

示例9: 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;
}
开发者ID:gas19,项目名称:mongoose-iot,代码行数:9,代码来源:cc3200_wifi.c

示例10: UDMAInit

//--tested, working--//
bool WiFiClass::init()
{
    //
    //only initialize once
    //
    if (_initialized) {
        return true;
    }

    //
    //Initialize the UDMA
    //
    UDMAInit();

    //
    //start the SimpleLink driver (no callback)
    //
    int iRet = sl_Start(NULL, NULL, NULL);
    
    //
    //check if sl_start failed
    //
    if (iRet==ROLE_STA_ERR || iRet==ROLE_AP_ERR || iRet==ROLE_P2P_ERR) {
        return false;
    }
    
    //
    //set the mode to station if it's not already in station mode
    //
    if (iRet != ROLE_STA) {
        sl_WlanSetMode(ROLE_STA);
        sl_Stop(0);
        sl_Start(NULL, NULL, NULL);
    }
    
    //
    //Delete all profiles$
    //
    sl_WlanProfileDel(0xff);

    //
    //disconnect from anything if for some reason it's connected
    //
    sl_WlanDisconnect();
    
    sl_NetAppMDNSUnRegisterService(0, 0);

    _initialized = true;
    
    //
    // Start collecting statistics
    //
    sl_WlanRxStatStart();

    return true;
}
开发者ID:ArduCAM,项目名称:Energia,代码行数:57,代码来源:WiFi.cpp

示例11: SwitchToStaMode

//*****************************************************************************
//
//! Check the device mode and switch to STATION(STA) mode
//! restart the NWP to activate STATION mode
//!
//! \param  iMode (device mode)
//!
//! \return None
//
//*****************************************************************************
void SwitchToStaMode(int iMode)
{
    if(iMode != ROLE_STA)
    {
        sl_WlanSetMode(ROLE_STA);
        MAP_UtilsDelay(80000);
        sl_Stop(10);
        MAP_UtilsDelay(80000);
        sl_Start(0,0,0);
    }

}
开发者ID:bigcat26,项目名称:cc3200-sdk,代码行数:22,代码来源:main.c

示例12: ConfigureMode

//****************************************************************************
//
//! Confgiures the mode in which the device will work
//!
//! \param iMode is the current mode of the device
//!
//!
//! \return   SlWlanMode_t
//!                        
//
//****************************************************************************
static int ConfigureMode(int iMode)
{
    long   lRetVal = -1;

    lRetVal = sl_WlanSetMode(iMode);
    ASSERT_ON_ERROR(lRetVal);

    /* Restart Network processor */
    lRetVal = sl_Stop(SL_STOP_TIMEOUT);

    // reset status bits
    CLR_STATUS_BIT_ALL(g_ulStatus);

    return sl_Start(NULL,NULL,NULL);
}
开发者ID:bigcat26,项目名称:cc3200-sdk,代码行数:26,代码来源:network.c

示例13: wifi_setup_sta

bool wifi_setup_sta(const char *ssid, const char *pass) {
    SlSecParams_t sp;
    LOG(LL_INFO, ("WiFi: connecting to %s", ssid));
    if (sl_WlanSetMode(ROLE_STA) != 0) return false;
    sl_Stop(0);
    sl_Start(NULL, NULL, NULL);
    sl_WlanDisconnect();
    sp.Key = (_i8 *) pass;
    sp.KeyLen = strlen(pass);
    sp.Type = sp.KeyLen ? SL_SEC_TYPE_WPA : SL_SEC_TYPE_OPEN;
    if (sl_WlanConnect((const _i8 *) ssid, strlen(ssid), 0, &sp, 0) != 0) {
        return false;
    }
    return true;
}
开发者ID:LorDClockaN,项目名称:AdAway,代码行数:15,代码来源:wifi.c

示例14: 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);
}
开发者ID:BillTheBest,项目名称:sample-apps,代码行数:46,代码来源:cc32xx_support.c

示例15: WifiSetModeAP

static int WifiSetModeAP()
{
    long retval;

    if((retval = sl_WlanSetMode(ROLE_AP)) < 0) {
        RETURN_ERROR(ERROR_UNKNOWN, "WLAN mode fail");
    }

    if((retval = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(WIFI_AP_SSID), (unsigned char*)WIFI_AP_SSID)) < 0) {
        RETURN_ERROR((int)retval, "Wifi: AP Name Set Failed");
    }

    //restart
    if((retval = sl_Stop(SL_STOP_TIMEOUT)) < 0) {
        RETURN_ERROR(ERROR_UNKNOWN, "SL stop fail");
    }
    CLR_STATUS_BIT_ALL(wifi_state.status);
    return sl_Start(0,0,0);
}
开发者ID:Mindtribe,项目名称:Leash-Debugger,代码行数:19,代码来源:wifi.c


注:本文中的sl_WlanSetMode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。