Esempio n. 1
0
//*****************************************************************************
//
//! This function gets triggered when HTTP Server receives Application
//! defined GET and POST HTTP Tokens.
//!
//! \param pSlHttpServerEvent Pointer indicating http server event
//! \param pSlHttpServerResponse Pointer indicating http server response
//!
//! \return None
//!
//*****************************************************************************
void sl_HttpServerCallback(SlHttpServerEvent_t *pSlHttpServerEvent, SlHttpServerResponse_t *pSlHttpServerResponse)
{
	switch (pSlHttpServerEvent->Event)
	{
		case SL_NETAPP_HTTPGETTOKENVALUE:
		{
			UINT8 *ptr;

			ptr = pSlHttpServerResponse->ResponseData.token_value.data;
			pSlHttpServerResponse->ResponseData.token_value.len = 0;
			if(memcmp(pSlHttpServerEvent->EventData.httpTokenName.data, GET_token_TEMP, strlen((const char *)GET_token_TEMP)) == 0)
			{
				float fCurrentTemp;
				TMP006DrvGetTemp(&fCurrentTemp);
				char cTemp = (char)fCurrentTemp;
				short sTempLen = itoa(cTemp,(char*)ptr);
				ptr[sTempLen++] = ' ';
				ptr[sTempLen++] = 'F';
				ptr[sTempLen] = '\0';
				pSlHttpServerResponse->ResponseData.token_value.len += sTempLen;

			}

			if(memcmp(pSlHttpServerEvent->EventData.httpTokenName.data, GET_token_UIC, strlen((const char *)GET_token_UIC)) == 0)
			{
				if(g_iInternetAccess==0)
					strcpy((char*)pSlHttpServerResponse->ResponseData.token_value.data,"1");
				else
					strcpy((char*)pSlHttpServerResponse->ResponseData.token_value.data,"0");
				pSlHttpServerResponse->ResponseData.token_value.len =  2;
			}

			if(memcmp(pSlHttpServerEvent->EventData.httpTokenName.data, GET_token_ACC, strlen((const char *)GET_token_ACC)) == 0)
			{

				ReadAccSensor();
				if(g_ucDryerRunning)
				{
					strcpy((char*)pSlHttpServerResponse->ResponseData.token_value.data,"Running");
					pSlHttpServerResponse->ResponseData.token_value.len += strlen("Running") + 1;
				}
				else
				{
					strcpy((char*)pSlHttpServerResponse->ResponseData.token_value.data,"Stopped");
					pSlHttpServerResponse->ResponseData.token_value.len += strlen("Stopped") + 1;
				}
			}



		}
			break;

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

			//g_ucLEDStatus = 0;
			if(memcmp(ptr, POST_token, strlen((const char *)POST_token)) == 0)
			{
				ptr = pSlHttpServerEvent->EventData.httpPostData.token_value.data;
				if(memcmp(ptr, "LED", 3) != 0)
					break;
				ptr += 3;
				led = *ptr;
				ptr += 2;
				if(led == '1')
				{
					if(memcmp(ptr, "ON", 2) == 0)
					{
						GPIO_IF_LedOn(MCU_RED_LED_GPIO);
                                                g_ucLEDStatus = LED_ON;

					}
					else if(memcmp(ptr, "Blink", 5) == 0)
					{
						GPIO_IF_LedOn(MCU_RED_LED_GPIO);
						g_ucLEDStatus = LED_BLINK;
					}
					else
					{
						GPIO_IF_LedOff(MCU_RED_LED_GPIO);
                                                g_ucLEDStatus = LED_OFF;
					}
				}
				else if(led == '2')
				{
					if(memcmp(ptr, "ON", 2) == 0)
					{
						GPIO_IF_LedOn(MCU_ORANGE_LED_GPIO);
					}
					else if(memcmp(ptr, "Blink", 5) == 0)
					{
						GPIO_IF_LedOn(MCU_ORANGE_LED_GPIO);
						g_ucLEDStatus = 1;
					}
					else
					{
						GPIO_IF_LedOff(MCU_ORANGE_LED_GPIO);
					}
				}

			}
		}
			break;
		default:
			break;
	}
}
Esempio n. 2
0
inline int getTemperature(float *temperature)
{
    return TMP006DrvGetTemp(temperature);
}