Пример #1
0
//****************************************************************************
//
//! 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);
}
Пример #2
0
//****************************************************************************
//
//! 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;
}