gre schrieb:
> das ist eher HTML
>
> du musst deinen string ändern
> also einen parameter per SSI einfügen
>
> <input type="checkbox" checked>
>
> wenn deine interne Variable ==1 ist musst du das checked absenden
>
> sonst eben nicht
HTML:
</p>
<form method="get" action="/leds.cgi">
<input value="1" name="led" type="checkbox">LED1<br>
<input value="2" name="led" type="checkbox">LED2<br>
<br>
<input value="Send" type="submit"> </form>
<p>
C:
const char * LedCGIhandler(int iIndex, int iNumParams, char *pcParam[],
char *pcValue[])
{
uint32_t i=0;
// index of the CGI within the theCGItable array passed to
http_set_cgi_handlers
// Given how this example is structured, this may be a redundant check.
// Here there is only one handler iIndex == 0
if (iIndex == 0)
{
// turn off the LEDs
HAL_GPIO_WritePin(LD3_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_RESET);
// Check the cgi parameters, e.g., GET /leds.cgi?led=1&led=2
for (i=0; i<iNumParams; i++)
{
//if pcParmeter contains "led", then one of the LED check boxes has been
set on
if (strcmp(pcParam[i], "led") == 0)
{
//see if checkbox for LED 1 has been set
if(strcmp(pcValue[i], "1") == 0)
{
// switch led 1 ON if 1
HAL_GPIO_WritePin(LD3_GPIO_Port, LD2_Pin, GPIO_PIN_SET);
}
//see if checkbox for LED 2 has been set
else if(strcmp(pcValue[i], "2") == 0)
{
// switch led 2 ON if 2
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_SET);
}
} //if
} //for
} //if
//uniform resource identifier to send after CGI call, i.e., path and
filename of the response
return "/index.html";
} //LedCGIhandler
Stehe grad etwas auf den schlauch.