/** ****************************************************************************** * @file LwIP/LwIP_HTTP_Server_Raw/Src/httpd_cg_ssi.c * @author MCD Application Team * @brief Webserver SSI and CGI handlers ****************************************************************************** * @attention * *

© Copyright (c) 2017 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license * SLA0044, the "License"; You may not use this file except in compliance with * the License. You may obtain a copy of the License at: * www.st.com/SLA0044 * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "bsp.h" #include "lwip/debug.h" #include "lwip/tcp.h" #include "lwip/apps/httpd.h" #include "http_cgi_ssi.h" #include #include tSSIHandler ADC_Page_SSI_Handler; uint32_t ADC_not_configured=1; /* we will use character "t" as tag for CGI */ char const* TAGCHAR="t"; char const** TAGS=&TAGCHAR; u16_t ADC_Handler(int iIndex, char *pcInsert, int iInsertLen); /* CGI handler for LED control */ const char * LEDS_CGI_Handler(int iIndex, int iNumParams, char *pcParam[], char *pcValue[]); void httpd_ssi_init(void); void httpd_cgi_init(void); /* Html request for "/leds.cgi" will start LEDS_CGI_Handler */ const tCGI LEDS_CGI={"/leds.cgi", LEDS_CGI_Handler}; /* Cgi call table, only one CGI used */ tCGI CGI_TAB[1]; /** * @brief ADC_Handler : SSI handler for ADC page */ u16_t ADC_Handler(int iIndex, char *pcInsert, int iInsertLen) { /* We have only one SSI handler iIndex = 0 */ if (iIndex ==0) { char Digit1=0, Digit2=0, Digit3=0, Digit4=0; uint32_t ADCVal = 0; ADCVal = 1234; //BSP_POTENTIOMETER_GetLevel(); /* convert to Voltage, step = 0.8 mV */ ADCVal = (uint32_t)(ADCVal * 0.8); /* get digits to display */ Digit1= ADCVal/1000; Digit2= (ADCVal-(Digit1*1000))/100; Digit3= (ADCVal-((Digit1*1000)+(Digit2*100)))/10; Digit4= ADCVal -((Digit1*1000)+(Digit2*100)+ (Digit3*10)); /* prepare data to be inserted in html */ *pcInsert = (char)(Digit1+0x30); *(pcInsert + 1) = (char)(Digit2+0x30); *(pcInsert + 2) = (char)(Digit3+0x30); *(pcInsert + 3) = (char)(Digit4+0x30); /* 4 characters need to be inserted in html*/ return 4; } return 0; } /** * @brief CGI handler for LEDs control */ const char * LEDS_CGI_Handler(int iIndex, int iNumParams, char *pcParam[], char *pcValue[]) { uint32_t i=0; /* We have only one SSI handler iIndex = 0 */ if (iIndex==0) { /* All LEDs off */ bsp_LedOff(1); bsp_LedOff(2); bsp_LedOff(3); bsp_LedOff(4); /* Check cgi parameter : application GET /leds.cgi?led=2&led=4 */ for (i=0; i