Example #1
0
/*!
    \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
        
        

}
Example #2
0
/*!
    \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;

	//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
        
        

}
Example #3
0
//*****************************************************************************
//
//! \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;
}
Example #4
0
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);
}
Example #5
0
//*****************************************************************************
//
//!   \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;

}
Example #6
0
/*!
    \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;
}
Example #7
0
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 */

    uint8_t iCount;
    while(WiFi.status() != WL_CONNECTED) {
        _SlNonOsMainLoopTask();
    }

    if(sl_WlanPolicySet(SL_POLICY_CONNECTION,
        SL_CONNECTION_POLICY(1,0,0,0,0),
        &policyVal,
        1 /*PolicyValLen*/) < 0) return -1;
}