HTTP Response codes quicklist reference for RestAPI

Method Method
200 OK 201 Created
202 Accepted 203 Not authorized
204 No content 205 Reset content
206 Partial content
300 Multiple choice 301 Moved permanently
302 Found 303 See other
304 Not modified 306 (unused)
307 Temporary redirect
400 Bad request 401 Unauthorized
402 Payment required 403 Forbidden
404 Not found 405 Method not allowed
406 Not acceptable 407 Proxy auth required
408 Timeout 409 Conflict
410 Gone 411 Length required
412 Preconditions failed 413 Request entity too large
414 Requested URI too long 415 Unsupported media
416 Bad request range 417 Expectation failed
500 Server error 501 Not implemented
502 Bad gateway 503 Service unavailable
504 Gateway timeout 505 Bad HTTP version

IOT SOM options

Linux onboard

RT5350

VoCore: http://vocore.io/store/index

Ingenic M150

Halley Development kit

http://www.ingenic.com/en/?newton/id/7.html

MTK MT7620N

http://wrtnode.com/

Qualcomm Atheros AR9331 SoC

http://www.black-swift.com/


Non OS

ESP2866

An interesting option based on negligible pricing.

Restricted in sockets, but still possibly useful.

Interesting firmware options, either download to unit itself (SDK available) or for simple applications/ 2 x Node Lua variants:

Example apps, seems to fit a lot into ESP2866:

http://harizanov.com/2015/02/wifi-thermostat-with-weekly-scheduler/

http://harizanov.com/wiki/wiki-home/three-channel-wifi-relaythermostat-board/

http://nodelua.org/

http://www.electrodragon.com/?s=esp8266&post_type=product

So, have some ordered and will see what can be done with these.

EMW3165

Looks very good on paper just waiting for GCC support

Limited toolsets available, limited information.

Ordered a couple + dev board

Wine

Blackmarket 20190503

Order summary

The Shy Pig Shiraz 2017 (Australia)
1 x 6 Btl Case

$47.94

The Shy Pig Merlot 2017 (Australia)
1 x 6 Btl Case

$47.94

Table Mountain Western Cape Cabernet Sauvignon 2018 (South Africa)
1 x 6 Btl Case

$53.94

Mystery Marlborough Merlot 2015
2 x 12 Btl Case

$239.76

Gold Medal Portuguese Collection (Portugal)
1 x 12 Btl Case

$143.88

Silky Smooth Spanish Gold Medal Mix (3) (Spain)
1 x 12 Btl Case

$119.88

Southern French Treasure Trove (France)
1 x 12 Btl Case

$119.88

Subtotal

$773.22

Delivery

$37.70

Total (inc. GST)

$810.92

CC3200 HTTPserver demo with hardcoded default Access Point

Getting started with CC3200 Launchpad, CCSc & SDK 1.0.0

Followed Project0 and CC3200 launchpad is pinging gateway & TI site.

Want to look at HTTPServer demo, but it is expecting me to use a smartphone to connect and set the target access point. ¬†But I only have a windows phone. ūüėČ

It will be a good exercise to look into how the Project0 used a hardcoded access point and incorporate that into the HTPServer.

This will force me to start becoming familiar with the CCS IDE as well as the CC3x00 libraries & use of the embedded simplelink wifi device.

References: http://software-dl.ti.com/ecs/cc31xx/APIs/public/cc32xx_simplelink/latest/html/index.html

Project wlan_station

per the docs we put our own access point details into ~/cc3200-sdk/example/common/common.h

// Values for below macros shall be modified as per access-point(AP) properties
// SimpleLink device will connect to following AP when application is executed
//
#define SSID_NAME           "Orcon-Wireless"    /* AP SSID */
#define SECURITY_TYPE       SL_SEC_TYPE_WPA/* Security type (OPEN or WEP or WPA*/
#define SECURITY_KEY        "A120OGL402931"              /* Password of the secured AP */
#define SSID_LEN_MAX        32
#define BSSID_LEN_MAX       6

And then where is it used? If I double click on ‘SID_NAME’ and then References->Project, it takes me to main.c, WlanConnect():

//****************************************************************************
//
//! \brief Connecting to a WLAN Accesspoint
//!
//!  This function connects to the required AP (SSID_NAME) with Security
//!  parameters specified in te form of macros at the top of this file
//!
//! \param  None
//!
//! \return  None
//!
//! \warning    If the WLAN connection fails or we don't aquire an IP 
//!            address, It will be stuck in this function forever.
//
//****************************************************************************
static long WlanConnect()
{
    SlSecParams_t secParams = {0};
    long lRetVal = 0;

    secParams.Key = (signed char*)SECURITY_KEY;
    secParams.KeyLen = strlen(SECURITY_KEY);
    secParams.Type = SECURITY_TYPE;

   lRetVal = sl_WlanConnect((signed char*)SSID_NAME, strlen(SSID_NAME), 0, &secParams, 0);
    ASSERT_ON_ERROR(lRetVal);

    // Wait for WLAN Event
    while((!IS_CONNECTED(g_ulStatus)) || (!IS_IP_ACQUIRED(g_ulStatus))) 
    { 
        // Toggle LEDs to Indicate Connection Progress
        GPIO_IF_LedOff(MCU_IP_ALLOC_IND);
        MAP_UtilsDelay(800000);
        GPIO_IF_LedOn(MCU_IP_ALLOC_IND);
        MAP_UtilsDelay(800000);
    }

    return SUCCESS;
   
}

And WlanConnect is called in WlanStationMode():

//****************************************************************************
//
//! \brief Start simplelink, connect to the ap and run the ping test
//!
//! This function starts the simplelink, connect to the ap and start the ping
//! test on the default gateway for the ap
//!
//! \param[in]  pvParameters - Pointer to the list of parameters that 
//!             can bepassed to the task while creating it
//!
//! \return  None
//
//****************************************************************************
void WlanStationMode( void *pvParameters )
{

    long lRetVal = -1;
    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 applicaton
    //
    // 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(0, 0, 0);
    if (lRetVal < 0 || ROLE_STA != lRetVal)
    {
        UART_PRINT("Failed to start the device \n\r");
        LOOP_FOREVER();
    }

    UART_PRINT("Device started as STATION \n\r");

    //
    //Connecting to WLAN AP
    //
    lRetVal = WlanConnect();
    if(lRetVal < 0)
    {
        UART_PRINT("Failed to establish connection w/ an AP \n\r");
        LOOP_FOREVER();
    }

    UART_PRINT("Connection established w/ AP and IP is aquired \n\r");
    UART_PRINT("Pinging...! \n\r");

    //
    // Checking the Lan connection by pinging to AP gateway
    //
    lRetVal = CheckLanConnection();
    if(lRetVal < 0)
    {
        UART_PRINT("Device couldn't ping the gateway \n\r");
        LOOP_FOREVER();
    }
    
    // Turn on GREEN LED when device gets PING response from AP
    GPIO_IF_LedOn(MCU_EXECUTE_SUCCESS_IND);

    //
    // Checking the internet connection by pinging to external host
    //
    lRetVal = CheckInternetConnection();
    if(lRetVal < 0)
    {
        UART_PRINT("Device couldn't ping the external host \n\r");
        LOOP_FOREVER();
    }

    // Turn on ORAGE LED when device gets PING response from AP
    GPIO_IF_LedOn(MCU_ORANGE_LED_GPIO);

    UART_PRINT("Device pinged both the gateway and the external host \n\r");

    UART_PRINT("WLAN STATION example executed successfully \n\r");

    //
    // power off the network processor
    //
    lRetVal = sl_Stop(SL_STOP_TIMEOUT);

    LOOP_FOREVER();
    
}

And finally, WlanStationMode is passed? to the RTOS in main.c. main():

//*****************************************************************************
//
//! \brief  Board Initialization & Configuration
//!
//! \param  None
//!
//! \return None
//
//*****************************************************************************
static void
BoardInit(void)
{
// In case of TI-RTOS vector table is initialize by OS itself
#ifndef USE_TIRTOS
    //
    // Set vector table base
    //
#if defined(ccs) || defined(gcc)
    MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
#endif
#if defined(ewarm)
    MAP_IntVTableBaseSet((unsigned long)&__vector_table);
#endif
#endif //USE_TIRTOS

    //
    // Enable Processor
    //
    MAP_IntMasterEnable();
    MAP_IntEnable(FAULT_SYSTICK);

    PRCMCC3200MCUInit();
}


//*****************************************************************************
//                            MAIN FUNCTION
//*****************************************************************************
void main()
{
    long lRetVal = -1;

    //
    // Board Initialization
    //
    BoardInit();
    
    //
    // configure the GPIO pins for LEDs,UART
    //
    PinMuxConfig();

    //
    // Configure the UART
    //
#ifndef NOTERM
    InitTerm();
#endif  //NOTERM
    
    //
    // Display Application Banner
    //
    DisplayBanner(APPLICATION_NAME);
    
    //
    // Configure all 3 LEDs
    //
    GPIO_IF_LedConfigure(LED1|LED2|LED3);

    // switch off all LEDs
    GPIO_IF_LedOff(MCU_ALL_LED_IND);
    
    //
    // Start the SimpleLink Host
    //
    lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY);
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }

    //
    // Start the WlanStationMode task
    //
    lRetVal = osi_TaskCreate( WlanStationMode, \
                                (const signed char*)"Wlan Station Task", \
                                OSI_STACK_SIZE, NULL, 1, NULL );
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }
     
    //
    // Start the task scheduler
    //
    osi_start();
  }

Project httpserver

Now lets see what HTTPServer demo does, but working back in the other direction this time..

main.c, main() we see RTOS task HTTPServerTask added:

//****************************************************************************
//                            MAIN FUNCTION
//****************************************************************************
void main()
{
    long lRetVal = -1;
  
    //Board Initialization
    BoardInit();
    
    //Pin Configuration
    PinMuxConfig();
    
    //Change Pin 58 Configuration from Default to Pull Down
    MAP_PinConfigSet(PIN_58,PIN_STRENGTH_2MA|PIN_STRENGTH_4MA,PIN_TYPE_STD_PD);
    
    //
    // Initialize GREEN and ORANGE LED
    //
    GPIO_IF_LedConfigure(LED1|LED2|LED3);
    //Turn Off the LEDs
    GPIO_IF_LedOff(MCU_ALL_LED_IND);

    //UART Initialization
    MAP_PRCMPeripheralReset(PRCM_UARTA0);

    MAP_UARTConfigSetExpClk(CONSOLE,MAP_PRCMPeripheralClockGet(CONSOLE_PERIPH),
                            UART_BAUD_RATE,(UART_CONFIG_WLEN_8 | 
                              UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

    //Display Application Banner on UART Terminal
    DisplayBanner(APPLICATION_NAME);
    
    //
    // Simplelinkspawntask
    //
    lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY);    
    if(lRetVal < 0)
    {
        UART_PRINT("Unable to start simpelink spawn task\n\r");
        LOOP_FOREVER();
    }
    //
    // Create HTTP Server Task
    //
    lRetVal = osi_TaskCreate(HTTPServerTask, (signed char*)"HTTPServerTask",
                         OSI_STACK_SIZE, NULL, OOB_TASK_PRIORITY, NULL );    
    if(lRetVal < 0)
    {
        UART_PRINT("Unable to create task\n\r");
        LOOP_FOREVER();
    }

    //
    // Start OS Scheduler
    //
    osi_start();

    while (1)
    {

    }

}

Right click on HTTPServerTask  and search for declarations takes us to main.c HTTPServerTask();

//****************************************************************************
//
//!  \brief                     Handles HTTP Server Task
//!                                              
//! \param[in]                  pvParameters is the data passed to the Task
//!
//! \return                        None
//
//****************************************************************************
static void HTTPServerTask(void *pvParameters)
{
    long lRetVal = -1;
    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 applicaton
    //
    // 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");  
  
    memset(g_ucSSID,'\0',AP_SSID_LEN_MAX);
    
    //Read Device Mode Configuration
    ReadDeviceConfiguration();

    //Connect to Network
    lRetVal = ConnectToNetwork();

    //Stop Internal HTTP Server
    lRetVal = sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID);
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }

    //Start Internal HTTP Server
    lRetVal = sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID);
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }

    //Handle Async Events
    while(1)
    {
         
    }
}

We see that in HTTPServerTask(), ConfigureSimpleLinkToDefaultState()  is called above:

    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();
    }

The comments for ConfigureSimpleLinkToDefaultState():

//*****************************************************************************
//! \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
//*****************************************************************************

Seems irrelevant to this task.. next called is ReadDeviceConfiguration():

    //Read Device Mode Configuration
    ReadDeviceConfiguration();

Which is:

//****************************************************************************
//
//!    \brief Read Force AP GPIO and Configure Mode - 1(Access Point Mode)
//!                                                  - 0 (Station Mode)
//!
//! \return                        None
//
//****************************************************************************
static void ReadDeviceConfiguration()
{
    unsigned int uiGPIOPort;
    unsigned char pucGPIOPin;
    unsigned char ucPinValue;
        
        //Read GPIO
    GPIO_IF_GetPortNPin(SH_GPIO_3,&uiGPIOPort,&pucGPIOPin);
    ucPinValue = GPIO_IF_Get(SH_GPIO_3,uiGPIOPort,pucGPIOPin);
        
        //If Connected to VCC, Mode is AP
    if(ucPinValue == 1)
    {
            //AP Mode
            g_uiDeviceModeConfig = ROLE_AP;
    }
    else
    {
            //STA Mode
            g_uiDeviceModeConfig = ROLE_STA;
    }

}

Ok, so we expect this:

g_uiDeviceModeConfig = ROLE_STA;

So lets look into this call as its fairly evident this is where we want to focus:

    //Connect to Network
    lRetVal = ConnectToNetwork();

Main.c, ConnectToNetWork():

//****************************************************************************
//
//!    \brief Connects to the Network in AP or STA Mode - If ForceAP Jumper is
//!                                             Placed, Force it to AP mode
//!
//! \return                        0 on success else error code
//
//****************************************************************************
long ConnectToNetwork()
{
    char ucAPSSID[32];
    unsigned short len, config_opt;
    long lRetVal = -1;

    // staring simplelink
    g_uiSimplelinkRole =  sl_Start(NULL,NULL,NULL);

    // Device is not in STA mode and Force AP Jumper is not Connected 
    //- Switch to STA mode
    if(g_uiSimplelinkRole != ROLE_STA && g_uiDeviceModeConfig == ROLE_STA )
    {
        //Switch to STA Mode
        lRetVal = sl_WlanSetMode(ROLE_STA);
        ASSERT_ON_ERROR(lRetVal);
        
        lRetVal = sl_Stop(SL_STOP_TIMEOUT);
        
        g_usMCNetworkUstate = 0;
        g_uiSimplelinkRole =  sl_Start(NULL,NULL,NULL);
    }

    //Device is not in AP mode and Force AP Jumper is Connected - 
    //Switch to AP mode
    if(g_uiSimplelinkRole != ROLE_AP && g_uiDeviceModeConfig == ROLE_AP )
    {
         //Switch to AP Mode
        lRetVal = sl_WlanSetMode(ROLE_AP);
        ASSERT_ON_ERROR(lRetVal);
        
        lRetVal = sl_Stop(SL_STOP_TIMEOUT);
        
        g_usMCNetworkUstate = 0;
        g_uiSimplelinkRole =  sl_Start(NULL,NULL,NULL);
    }

    //No Mode Change Required
    if(g_uiSimplelinkRole == ROLE_AP)
    {
       //waiting for the AP to acquire IP address from Internal DHCP Server
       while(!IS_IP_ACQUIRED(g_ulStatus))
       {

       }

       //Stop Internal HTTP Server
       lRetVal = sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID);
       ASSERT_ON_ERROR( lRetVal);

       //Start Internal HTTP Server
       lRetVal = sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID);
       ASSERT_ON_ERROR( lRetVal);

       char iCount=0;
       //Read the AP SSID
       memset(ucAPSSID,'\0',AP_SSID_LEN_MAX);
       len = AP_SSID_LEN_MAX;
       config_opt = WLAN_AP_OPT_SSID;
       lRetVal = sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt , &len,
                                              (unsigned char*) ucAPSSID);
        ASSERT_ON_ERROR(lRetVal);
        
       Report("\n\rDevice is in AP Mode, Please Connect to AP [%s] and"
          "type [mysimplelink.net] in the browser \n\r",ucAPSSID);
       
       //Blink LED 3 times to Indicate AP Mode
       for(iCount=0;iCount<3;iCount++)
       {
           //Turn RED LED On
           GPIO_IF_LedOn(MCU_RED_LED_GPIO);
           osi_Sleep(400);
           
           //Turn RED LED Off
           GPIO_IF_LedOff(MCU_RED_LED_GPIO);
           osi_Sleep(400);
       }

    }
    else
    {
        //Stop Internal HTTP Server
        lRetVal = sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID);
        ASSERT_ON_ERROR( lRetVal);

        //Start Internal HTTP Server
        lRetVal = sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID);
        ASSERT_ON_ERROR( lRetVal);
        
		//waiting for the device to Auto Connect
		while ( (!IS_IP_ACQUIRED(g_ulStatus))&&
			   g_ucConnectTimeout < AUTO_CONNECTION_TIMEOUT_COUNT)
		{
			//Turn RED LED On
			GPIO_IF_LedOn(MCU_RED_LED_GPIO);
			osi_Sleep(50);

			//Turn RED LED Off
			GPIO_IF_LedOff(MCU_RED_LED_GPIO);
			osi_Sleep(50);

			g_ucConnectTimeout++;
		}
		//Couldn't connect Using Auto Profile
		if(g_ucConnectTimeout == AUTO_CONNECTION_TIMEOUT_COUNT)
		{
			//Blink Red LED to Indicate Connection Error
			GPIO_IF_LedOn(MCU_RED_LED_GPIO);

			CLR_STATUS_BIT_ALL(g_ulStatus);

			Report("Use Smart Config Application to configure the device.\n\r");
			//Connect Using Smart Config
			lRetVal = SmartConfigConnect();
			ASSERT_ON_ERROR(lRetVal);

			//Waiting for the device to Auto Connect
			while(!IS_IP_ACQUIRED(g_ulStatus))
			{
				MAP_UtilsDelay(500);
			}

		}
    //Turn RED LED Off
    GPIO_IF_LedOff(MCU_RED_LED_GPIO);
    UART_PRINT("\n\rDevice is in STA Mode, Connect to the AP[%s] and type"
          "IP address [%d.%d.%d.%d] in the browser \n\r",g_ucConnectionSSID,
          SL_IPV4_BYTE(g_uiIpAddress,3),SL_IPV4_BYTE(g_uiIpAddress,2),
          SL_IPV4_BYTE(g_uiIpAddress,1),SL_IPV4_BYTE(g_uiIpAddress,0));

    }
    return SUCCESS;
}

Quite  a lot going on in here so lets follow it through:

There is a call to sl_Start():

    // staring simplelink
    g_uiSimplelinkRole =  sl_Start(NULL,NULL,NULL);

Looking at docs for sl_start, not all makes sense yet:


 

_i16 sl_Start ( const void * pIfHdl,
_i8 * pDevName,
const P_INIT_CALLBACK pInitCallBack
)

Start the SimpleLink device.

This function initialize the communication interface, set the enable pin of the device, and call to the init complete callback.

Parameters
[in] pIfHdl Opened Interface Object. In case the interface must be opened outside the SimpleLink Driver, the user might give the handler to be used in
any access of the communication interface with the device (UART/SPI).
The SimpleLink driver will open an interface port only if this parameter is null!
[in] pDevName The name of the device to open. Could be used when the pIfHdl is null, to transfer information to the open interface function
This pointer could be used to pass additional information to sl_IfOpen in case it is required (e.g. UART com port name)
[in] pInitCallBack Pointer to function that would be called on completion of the initialization process.
If this parameter is NULL the function is blocked until the device initialization is completed, otherwise the function returns immediately.
Returns
Returns the current active role (STA/AP/P2P) or an error code:

  • ROLE_STA, ROLE_AP, ROLE_P2P in case of success, otherwise in failure one of the following is return:
  • ROLE_STA_ERR (Failure to load MAC/PHY in STA role)
  • ROLE_AP_ERR (Failure to load MAC/PHY in AP role)
  • ROLE_P2P_ERR (Failure to load MAC/PHY in P2P role)

 


But we can see that the function is blocked until startup is complete as the third param is NULL, and that this does not appear to initiate a wifi connection.

However it does return a mode per g_uiSimplelinkRole which it expects to be ROLE_STA which is checked along with g_uiDeviceModeConfig from which we can trace where we end when g_uiSimplelinkRole == ROLE_STA && g_uiDeviceModeConfig == ROLE_STA as this is our expected state.

Which brings us to this point in project httpserver, main.c, ConnectToNetwork():

		//Couldn't connect Using Auto Profile
		if(g_ucConnectTimeout == AUTO_CONNECTION_TIMEOUT_COUNT)
		{
			//Blink Red LED to Indicate Connection Error
			GPIO_IF_LedOn(MCU_RED_LED_GPIO);

			CLR_STATUS_BIT_ALL(g_ulStatus);

			Report("Use Smart Config Application to configure the device.\n\r");
			//Connect Using Smart Config
			lRetVal = SmartConfigConnect();
			ASSERT_ON_ERROR(lRetVal);

			//Waiting for the device to Auto Connect
			while(!IS_IP_ACQUIRED(g_ulStatus))
			{
				MAP_UtilsDelay(500);
			}

		}

which calls smartconfig.c, 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.
//!
//*****************************************************************************

The key thing in these comments appears to be that that this function makes an AP for the smartphone app to communicate with after which it either ends in error, or a valid connection is established per the smartphone app provided settings.

So from that it would seem that we can prior to this attempt a connection using our common.h ssid etc. ¬†And we will make this conditional on there being no connection, as if there was a valid profile it would’ve connected already.

Also worth noting is the use in both the above projects of this sort of call to determine if we have a connection, per the current mode:

while(!IS_IP_ACQUIRED(g_ulStatus))

So it seems we can reuse the connect function from project wlan_station, main.c by adding a conditional call, like the current smartconfig one here in in main.c, ConnectToNetwork():

		//Couldn't connect Using Auto Profile
		if(g_ucConnectTimeout == AUTO_CONNECTION_TIMEOUT_COUNT)

Function from project wlan_station, main.c added to project httpserver, main.c

//****************************************************************************
//
//! \brief Connecting to a WLAN Accesspoint
//!
//!  This function connects to the required AP (SSID_NAME) with Security
//!  parameters specified in te form of macros at the top of this file
//!
//! \param  None
//!
//! \return  None
//!
//! \warning    If the WLAN connection fails or we don't aquire an IP 
//!            address, It will be stuck in this function forever.
//
//****************************************************************************
static long WlanConnect()
{
    SlSecParams_t secParams = {0};
    long lRetVal = 0;

    secParams.Key = (signed char*)SECURITY_KEY;
    secParams.KeyLen = strlen(SECURITY_KEY);
    secParams.Type = SECURITY_TYPE;

   lRetVal = sl_WlanConnect((signed char*)SSID_NAME, strlen(SSID_NAME), 0, &secParams, 0);
    ASSERT_ON_ERROR(lRetVal);

    // Wait for WLAN Event
    while((!IS_CONNECTED(g_ulStatus)) || (!IS_IP_ACQUIRED(g_ulStatus))) 
    { 
        // Toggle LEDs to Indicate Connection Progress
        GPIO_IF_LedOff(MCU_IP_ALLOC_IND);
        MAP_UtilsDelay(800000);
        GPIO_IF_LedOn(MCU_IP_ALLOC_IND);
        MAP_UtilsDelay(800000);
    }

    return SUCCESS;
   
}

And changes to project httpserver, main.c, ConnectToNetwork();

This:

		//Couldn't connect Using Auto Profile
		if(g_ucConnectTimeout == AUTO_CONNECTION_TIMEOUT_COUNT)
		{
			//Blink Red LED to Indicate Connection Error
			GPIO_IF_LedOn(MCU_RED_LED_GPIO);

			CLR_STATUS_BIT_ALL(g_ulStatus);

			Report("Use Smart Config Application to configure the device.\n\r");
			//Connect Using Smart Config
			lRetVal = SmartConfigConnect();
			ASSERT_ON_ERROR(lRetVal);

			//Waiting for the device to Auto Connect
			while(!IS_IP_ACQUIRED(g_ulStatus))
			{
				MAP_UtilsDelay(500);
			}

		}

becomes this:

		//Couldn't connect Using Auto Profile
		if(g_ucConnectTimeout == AUTO_CONNECTION_TIMEOUT_COUNT)
		{
		    lRetVal = WlanConnect();
		    if(lRetVal < 0)
		    {	// didn't connect

				//Blink Red LED to Indicate Connection Error
				GPIO_IF_LedOn(MCU_RED_LED_GPIO);
	
				CLR_STATUS_BIT_ALL(g_ulStatus);
	
				Report("Use Smart Config Application to configure the device.\n\r");
				//Connect Using Smart Config
				lRetVal = SmartConfigConnect();
				ASSERT_ON_ERROR(lRetVal);
	
				//Waiting for the device to Auto Connect
				while(!IS_IP_ACQUIRED(g_ulStatus))
				{
					MAP_UtilsDelay(500);
				}
		    }
		}

Ok, hit debug in CCS.. yay it worked.