Tool/software: TI-RTOS
I Just started to work on HTTP server for Tm4c1294 board by looking into . I created a simple Application to create a HTTP webserver . I have a code which I am posting
#include <xdc/std.h>
#include <xdc/runtime/System.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
/* TI-RTOS Header files */
// #include <ti/drivers/EMAC.h>
#include <ti/drivers/GPIO.h>
// #include <ti/drivers/I2C.h>
// #include <ti/drivers/SDSPI.h>
// #include <ti/drivers/SPI.h>
// #include <ti/drivers/UART.h>
// #include <ti/drivers/USBMSCHFatFs.h>
// #include <ti/drivers/Watchdog.h>
// #include <ti/drivers/WiFi.h>
/* Board Header file */
#include "Board.h"
#include <ti/ndk/inc/netmain.h>
//#include "index_withCGI.h"
//#include "greetings.h"
//#include "chip.h"
#include "myprog.h"
#define TASKSTACKSIZE 512
Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];
Int LEDON(SOCKET s, UArg arg2)
{
GPIO_write(Board_LED1, Board_LED_ON);
Char buf[200];
httpSendStatusLine(s, HTTP_OK, CONTENT_TYPE_HTML);
httpSendClientStr(s, CRLF);
httpSendClientStr(s,
"<html><head><title>LED ON "\
"LED</title></head><body><h1>Time</h1>\n");
System_sprintf(buf, "<p>LED TURNED ON </p>\n");
httpSendClientStr(s, buf);
httpSendClientStr(s, "</table></body></html>");
return (1);
}
Int LEDOFF(SOCKET s1, UArg arg3)
{
GPIO_write(Board_LED1, Board_LED_OFF);
Char buf[200];
httpSendStatusLine(s1, HTTP_OK, CONTENT_TYPE_HTML);
httpSendClientStr(s1, CRLF);
httpSendClientStr(s1,
"<html><head><title>LED ON "\
"LED</title></head><body><h1>Time</h1>\n");
System_sprintf(buf, "<p>LED TURNED OFF </p>\n");
httpSendClientStr(s1, buf);
httpSendClientStr(s1, "</table></body></html>");
return (1);
}
Void AddWebFiles(Void)
{
efs_createfile("LEDON.cgi", 0, (UINT8 *)&LEDON);
efs_createfile("LEDOFF.cgi", 0, (UINT8 *)&LEDOFF);
efs_createfile("myprog.html", MYPROG_SIZE, (UINT8 *)MYPROG);
}
Void RemoveWebFiles(Void)
{
efs_destroyfile("LEDON.cgi");
efs_destroyfile("myprog.html");
}
/*
* ======== heartBeatFxn ========
* Toggle the Board_LED0. The Task_sleep is determined by arg0 which
* is configured for the heartBeat Task instance.
*/
Void heartBeatFxn(UArg arg0, UArg arg1)
{
while (1) {
Task_sleep((unsigned int)arg0);
// GPIO_toggle(Board_LED0);
}
}
/*
* ======== main ========
*/
int main(void)
{
Task_Params taskParams;
/* Call board init functions */
Board_initGeneral();
Board_initEMAC();
Board_initGPIO();
// Board_initI2C();
// Board_initSDSPI();
// Board_initSPI();
// Board_initUART();
// Board_initUSB(Board_USBDEVICE);
// Board_initUSBMSCHFatFs();
// Board_initWatchdog();
// Board_initWiFi();
/* Construct heartBeat Task thread */
Task_Params_init(&taskParams);
taskParams.arg0 = 1000;
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)heartBeatFxn, &taskParams, NULL);
/* Turn on user LED */
GPIO_write(Board_LED0, Board_LED_ON);
System_printf("Starting the example\nSystem provider is set to SysMin. "
"Halt the target to view any SysMin contents in ROV.\n");
/* SysMin will only print to the console when you call flush or exit */
System_flush();
/* Start BIOS */
BIOS_start();
return (0);
}
I have added the two cgis for turning the LED on and OFF.
My html code is in below
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "www.w3.org/.../strict.dtd"> <html><head><meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>Concerto HTTP Server</title></head> <body>Hello World<br> <br>Click To Turn LED ON <a href="LEDON.cgi">LEDON.cgi</a><br> <br>Click To Turn OFF <a href="LEDOFF.cgi">LEDOFF.cgi</a><br> </body></html>
Here is my webserver. Now i want to create a webserver with ON and OFF buttons rather than this.. I dont want to go to next webpage which is happening here. What to refer to achieve this ..I mean button creation .