/** * Initialize CGI handlers */ void httpd_cgi_init(void) { /* configure CGI handlers (LEDs control CGI) */ CGI_TAB[0] = LEDS_CGI; CGI_TAB[1] = StartUsb_CGI; http_set_cgi_handlers(CGI_TAB, NB_CGI_HANDLER); }
//初始化ssi和cgi void init_ssi_cgi(void){ http_set_cgi_handlers(ppcURLs , NUM_CONFIG_CGI_URIS); http_set_ssi_handler (SSIHandler, ppcTags, NUM_CONFIG_SSI_TAGS ); }
/** Initialize the CGI environment * This function registers the pairs of file's name and CGI function for the HTTPD server * @returns nothing*/ void initCGIs( void) { http_set_cgi_handlers(cgi_handlers, (sizeof (cgi_handlers) / sizeof (tCGI) ) ); DEBUGSTR("httpCGIHandlers registered...............[OK]\r\n"); return; }
/*..........................................................................*/ QState LwIPMgr_initial(LwIPMgr *me, QEvent const *e) { uint8_t macaddr[NETIF_MAX_HWADDR_LEN]; (void)e; /* suppress the compiler warning about unused parameter */ /* Configure the hardware MAC address for the Ethernet Controller */ /* * Set up the MAC address and make sure it's not all FF values * TODO: This will evetually be read somewhere */ /* the MAC address must have been programmed! */ Q_ASSERT((STATIC_IPADDR0 != 0xFF) && (STATIC_IPADDR1 != 0xFF) && (STATIC_IPADDR2 != 0xFF) && (STATIC_IPADDR3 != 0xFF)); macaddr[0] = DEF_MAC_ADDR0; macaddr[1] = DEF_MAC_ADDR1; macaddr[2] = DEF_MAC_ADDR2; macaddr[3] = DEF_MAC_ADDR3; macaddr[4] = DEF_MAC_ADDR4; macaddr[5] = DEF_MAC_ADDR5; /* initialize the Ethernet Driver */ me->netif = eth_driver_init((QActive *)me, macaddr); me->ip_addr = 0xFFFFFFFF; /* initialize to impossible value */ /* initialize the lwIP applications... */ httpd_init(); /* initialize the simple HTTP-Deamon (web server) */ http_set_ssi_handler(&ssi_handler, ssi_tags, Q_DIM(ssi_tags)); http_set_cgi_handlers(cgi_handlers, Q_DIM(cgi_handlers)); me->upcb = udp_new(); udp_bind(me->upcb, IP_ADDR_ANY, 777); /* use port 777 for UDP */ udp_recv(me->upcb, &udp_rx_handler, me); QS_OBJ_DICTIONARY(&l_lwIPMgr); QS_OBJ_DICTIONARY(&l_lwIPMgr.te_LWIP_SLOW_TICK); QS_FUN_DICTIONARY(&QHsm_top); QS_FUN_DICTIONARY(&LwIPMgr_initial); QS_FUN_DICTIONARY(&LwIPMgr_running); QS_SIG_DICTIONARY(SEND_UDP_SIG, (QActive *)me); QS_SIG_DICTIONARY(LWIP_SLOW_TICK_SIG, (QActive *)me); QS_SIG_DICTIONARY(LWIP_RX_READY_SIG, (QActive *)me); QS_SIG_DICTIONARY(LWIP_TX_READY_SIG, (QActive *)me); QS_SIG_DICTIONARY(LWIP_RX_OVERRUN_SIG,(QActive *)me); return Q_TRAN(&LwIPMgr_running); }
//Initialise cgi environment int CGIinit( void) { // cgi_handler.pcCGIName = "/actuadores.cgi"; // // cgi_handler.pfnCGIHandler = actuatorsHandler; http_set_cgi_handlers(cgi_handlers, 2); DEBUGSTR("httpCGIHandler initialized............[OK]\r\n"); return 0; }
void httpd_task(void *pvParameters) { xTaskCreate(battery_task, "Battery task", 256, NULL, uxTaskPriorityGet(NULL), NULL); tCGI pCGIs[] = { {"/pid", [](int, int, char*[], char*[]) { return "/pid.html"; }} }; http_set_cgi_handlers(pCGIs, sizeof (pCGIs) / sizeof (pCGIs[0])); httpd_websocket_register_callbacks(NULL, (tWsHandler) httpd_websocket_cb); httpd_init(); for (;;); }
/** * * Initialize IO and SSI Handlers * */ void io_init(void) { #ifdef INCLUDE_HTTPD_SSI // // Pass our tag information to the HTTP server. // #if DEBUG_SSI printf("io_init NUM_CONFIG TAGS = %d\n", NUM_CONFIG_TAGS); #endif http_set_ssi_handler(SSIHandler); #endif #ifdef INCLUDE_HTTPD_CGI // // Pass our CGI handlers to the HTTP server. // http_set_cgi_handlers(g_psConfigCGIURIs, NUM_CONFIG_CGI_URIS); #endif }
/*..........................................................................*/ QState LwIPMgr_initial(LwIPMgr *me, QEvt const *e) { uint8_t macaddr[NETIF_MAX_HWADDR_LEN]; (void)e; /* suppress the compiler warning about unused parameter */ /* Configure the hardware MAC address for the Ethernet Controller */ macaddr[0] = MAC_ADDR0; macaddr[1] = MAC_ADDR1; macaddr[2] = MAC_ADDR2; macaddr[3] = MAC_ADDR3; macaddr[4] = MAC_ADDR4; macaddr[5] = MAC_ADDR5; /* initialize the Ethernet Driver */ me->netif = eth_driver_init((QActive *)me, macaddr); me->ip_addr = 0x00000000U; /* initialize to impossible value */ /* initialize the lwIP applications... */ httpd_init(); /* initialize the simple HTTP-Deamon (web server) */ http_set_ssi_handler(&ssi_handler, ssi_tags, Q_DIM(ssi_tags)); http_set_cgi_handlers(cgi_handlers, Q_DIM(cgi_handlers)); me->upcb = udp_new(); udp_bind(me->upcb, IP_ADDR_ANY, 777U); /* use port 777 for UDP */ udp_recv(me->upcb, &udp_rx_handler, me); QS_OBJ_DICTIONARY(&l_lwIPMgr); QS_OBJ_DICTIONARY(&l_lwIPMgr.te_LWIP_SLOW_TICK); QS_FUN_DICTIONARY(&QHsm_top); QS_FUN_DICTIONARY(&LwIPMgr_initial); QS_FUN_DICTIONARY(&LwIPMgr_running); QS_SIG_DICTIONARY(SEND_UDP_SIG, (QActive *)me); QS_SIG_DICTIONARY(LWIP_SLOW_TICK_SIG, (QActive *)me); QS_SIG_DICTIONARY(LWIP_RX_READY_SIG, (QActive *)me); QS_SIG_DICTIONARY(LWIP_TX_READY_SIG, (QActive *)me); QS_SIG_DICTIONARY(LWIP_RX_OVERRUN_SIG,(QActive *)me); return Q_TRAN(&LwIPMgr_connecting); }
/** * Initialize CGI handlers */ void httpd_cgi_init(void) { /* configure CGI handlers (LEDs control CGI) */ CGI_TAB[0] = LEDS_CGI; http_set_cgi_handlers(CGI_TAB, 1); }