This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

cc3200 http server example

Other Parts Discussed in Thread: CC3200

Hi guys,

I want some explanation about this code from the HTTP server example on CC3200.Can anybody help me with it

void SimpleLinkHttpServerCallback(SlHttpServerEvent_t *pSlHttpServerEvent,
SlHttpServerResponse_t *pSlHttpServerResponse)
{
UINT8 strLenVal = 0;
switch (pSlHttpServerEvent->Event)
{
case SL_NETAPP_HTTPGETTOKENVALUE:
{
UINT8 status, *ptr;

ptr = pSlHttpServerResponse->ResponseData.token_value.data;
pSlHttpServerResponse->ResponseData.token_value.len = 0;
if(memcmp(pSlHttpServerEvent->EventData.httpTokenName.data, GET_token,
strlen((const char *)GET_token)) == 0)
{
status = GPIO_IF_LedStatus(MCU_RED_LED_GPIO);
strLenVal = strlen(LED1_STRING);
memcpy(ptr, LED1_STRING, strLenVal);
ptr += strLenVal;
pSlHttpServerResponse->ResponseData.token_value.len += strLenVal;
if(status & 0x01)
{
strLenVal = strlen(LED_ON_STRING);
memcpy(ptr, LED_ON_STRING, strLenVal);
ptr += strLenVal;
pSlHttpServerResponse->ResponseData.token_value.len += strLenVal;
}
else
{
strLenVal = strlen(LED_OFF_STRING);
memcpy(ptr, LED_OFF_STRING, strLenVal);
ptr += strLenVal;
pSlHttpServerResponse->ResponseData.token_value.len += strLenVal;
}
status = GPIO_IF_LedStatus(MCU_GREEN_LED_GPIO);
strLenVal = strlen(LED2_STRING);
memcpy(ptr, LED2_STRING, strLenVal);
ptr += strLenVal;
pSlHttpServerResponse->ResponseData.token_value.len += strLenVal;
if(status & 0x01)
{
strLenVal = strlen(LED_ON_STRING);
memcpy(ptr, LED_ON_STRING, strLenVal);
ptr += strLenVal;
pSlHttpServerResponse->ResponseData.token_value.len += strLenVal;
}
else
{
strLenVal = strlen(LED_OFF_STRING);
memcpy(ptr, LED_OFF_STRING, strLenVal);
ptr += strLenVal;
pSlHttpServerResponse->ResponseData.token_value.len += strLenVal;
}
*ptr = '\0';
}

}
break;

case SL_NETAPP_HTTPPOSTTOKENVALUE:
{
UINT8 led;
UINT8 *ptr = pSlHttpServerEvent->EventData.httpPostData.token_name.data;

if(memcmp(ptr, POST_token, strlen((const char *)POST_token)) == 0)
{
ptr = pSlHttpServerEvent->EventData.httpPostData.token_value.data;
strLenVal = strlen(LED_STRING);
if(memcmp(ptr, LED_STRING, strLenVal) != 0)
break;
ptr += strLenVal;
led = *ptr;
strLenVal = strlen(LED_ON_STRING);
ptr += strLenVal;
if(led == '1')
{
if(memcmp(ptr, LED_ON_STRING, strLenVal) == 0)
{
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
}
else
{
GPIO_IF_LedOff(MCU_RED_LED_GPIO);
}
}
else if(led == '2')
{
if(memcmp(ptr, LED_ON_STRING, strLenVal) == 0)
{
GPIO_IF_LedOn(MCU_GREEN_LED_GPIO);
}
else
{
GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);
}
}

}
}
break;
default:
break;
}
}