工程提交
This commit is contained in:
36
Core/LWIP/App/httpd_cgi.c
Normal file
36
Core/LWIP/App/httpd_cgi.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "httpd_cgi.h"
|
||||
#include "lwip/apps/httpd.h"
|
||||
#include "main.h"
|
||||
|
||||
// ????(?????? ADC?????)
|
||||
volatile float g_temperature = 25.5f;
|
||||
volatile uint8_t g_led_state = 0;
|
||||
|
||||
#define LED_PIN GPIO_PIN_14
|
||||
#define LED_PORT GPIOB
|
||||
|
||||
static const char* api_status_handler(int iIndex, int iNumParams, char *pcParam[], char *pcValue[])
|
||||
{
|
||||
static char json[64];
|
||||
snprintf(json, sizeof(json), "{\"temp\":%.1f,\"led\":%d}", g_temperature, g_led_state);
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
static const char* api_success_handler(int iIndex, int iNumParams, char *pcParam[], char *pcValue[])
|
||||
{
|
||||
return ""; // ?????
|
||||
}
|
||||
|
||||
void setup_web_api(void)
|
||||
{
|
||||
const tCGI handlers[] = {
|
||||
{ "/api/status", api_status_handler },
|
||||
{ "/api/success", api_success_handler }
|
||||
};
|
||||
http_set_cgi_handlers(handlers, 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
2
Core/LWIP/App/httpd_cgi.h
Normal file
2
Core/LWIP/App/httpd_cgi.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "httpd.h"
|
||||
void setup_web_api(void);
|
||||
206
Core/LWIP/App/lwip.c
Normal file
206
Core/LWIP/App/lwip.c
Normal file
@@ -0,0 +1,206 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : LWIP.c
|
||||
* Description : This file provides initialization code for LWIP
|
||||
* middleWare.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "lwip.h"
|
||||
#include "lwip/init.h"
|
||||
#include "lwip/netif.h"
|
||||
#if defined ( __CC_ARM ) /* MDK ARM Compiler */
|
||||
#include "lwip/sio.h"
|
||||
#endif /* MDK ARM Compiler */
|
||||
#include "ethernetif.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
static void ethernet_link_status_updated(struct netif *netif);
|
||||
/* ETH Variables initialization ----------------------------------------------*/
|
||||
void Error_Handler(void);
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/* Variables Initialization */
|
||||
struct netif gnetif;
|
||||
ip4_addr_t ipaddr;
|
||||
ip4_addr_t netmask;
|
||||
ip4_addr_t gw;
|
||||
uint8_t IP_ADDRESS[4];
|
||||
uint8_t NETMASK_ADDRESS[4];
|
||||
uint8_t GATEWAY_ADDRESS[4];
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/**
|
||||
* LwIP initialization function
|
||||
*/
|
||||
void MX_LWIP_Init(void)
|
||||
{
|
||||
/* IP addresses initialization */
|
||||
IP_ADDRESS[0] = 10;
|
||||
IP_ADDRESS[1] = 12;
|
||||
IP_ADDRESS[2] = 19;
|
||||
IP_ADDRESS[3] = 100;
|
||||
NETMASK_ADDRESS[0] = 255;
|
||||
NETMASK_ADDRESS[1] = 255;
|
||||
NETMASK_ADDRESS[2] = 255;
|
||||
NETMASK_ADDRESS[3] = 0;
|
||||
GATEWAY_ADDRESS[0] = 10;
|
||||
GATEWAY_ADDRESS[1] = 12;
|
||||
GATEWAY_ADDRESS[2] = 19;
|
||||
GATEWAY_ADDRESS[3] = 1;
|
||||
|
||||
/* USER CODE BEGIN IP_ADDRESSES */
|
||||
/* USER CODE END IP_ADDRESSES */
|
||||
|
||||
/* Initialize the LwIP stack with RTOS */
|
||||
tcpip_init( NULL, NULL );
|
||||
|
||||
/* IP addresses initialization without DHCP (IPv4) */
|
||||
IP4_ADDR(&ipaddr, IP_ADDRESS[0], IP_ADDRESS[1], IP_ADDRESS[2], IP_ADDRESS[3]);
|
||||
IP4_ADDR(&netmask, NETMASK_ADDRESS[0], NETMASK_ADDRESS[1] , NETMASK_ADDRESS[2], NETMASK_ADDRESS[3]);
|
||||
IP4_ADDR(&gw, GATEWAY_ADDRESS[0], GATEWAY_ADDRESS[1], GATEWAY_ADDRESS[2], GATEWAY_ADDRESS[3]);
|
||||
|
||||
/* add the network interface (IPv4/IPv6) with RTOS */
|
||||
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input);
|
||||
|
||||
/* Registers the default network interface */
|
||||
netif_set_default(&gnetif);
|
||||
|
||||
/* We must always bring the network interface up connection or not... */
|
||||
netif_set_up(&gnetif);
|
||||
|
||||
/* Set the link callback function, this function is called on change of link status*/
|
||||
netif_set_link_callback(&gnetif, ethernet_link_status_updated);
|
||||
|
||||
/* Create the Ethernet link handler thread */
|
||||
/* USER CODE BEGIN H7_OS_THREAD_DEF_CREATE_CMSIS_RTOS_V1 */
|
||||
osThreadDef(EthLink, ethernet_link_thread, osPriorityBelowNormal, 0, configMINIMAL_STACK_SIZE *2);
|
||||
osThreadCreate (osThread(EthLink), &gnetif);
|
||||
/* USER CODE END H7_OS_THREAD_DEF_CREATE_CMSIS_RTOS_V1 */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
|
||||
/* USER CODE END 3 */
|
||||
}
|
||||
|
||||
#ifdef USE_OBSOLETE_USER_CODE_SECTION_4
|
||||
/* Kept to help code migration. (See new 4_1, 4_2... sections) */
|
||||
/* Avoid to use this user section which will become obsolete. */
|
||||
/* USER CODE BEGIN 4 */
|
||||
/* USER CODE END 4 */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Notify the User about the network interface config status
|
||||
* @param netif: the network interface
|
||||
* @retval None
|
||||
*/
|
||||
static void ethernet_link_status_updated(struct netif *netif)
|
||||
{
|
||||
if (netif_is_up(netif))
|
||||
{
|
||||
/* USER CODE BEGIN 5 */
|
||||
/* USER CODE END 5 */
|
||||
}
|
||||
else /* netif is down */
|
||||
{
|
||||
/* USER CODE BEGIN 6 */
|
||||
/* USER CODE END 6 */
|
||||
}
|
||||
}
|
||||
|
||||
#if defined ( __CC_ARM ) /* MDK ARM Compiler */
|
||||
/**
|
||||
* Opens a serial device for communication.
|
||||
*
|
||||
* @param devnum device number
|
||||
* @return handle to serial device if successful, NULL otherwise
|
||||
*/
|
||||
sio_fd_t sio_open(u8_t devnum)
|
||||
{
|
||||
sio_fd_t sd;
|
||||
|
||||
/* USER CODE BEGIN 7 */
|
||||
sd = 0; // dummy code
|
||||
/* USER CODE END 7 */
|
||||
|
||||
return sd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a single character to the serial device.
|
||||
*
|
||||
* @param c character to send
|
||||
* @param fd serial device handle
|
||||
*
|
||||
* @note This function will block until the character can be sent.
|
||||
*/
|
||||
void sio_send(u8_t c, sio_fd_t fd)
|
||||
{
|
||||
/* USER CODE BEGIN 8 */
|
||||
/* USER CODE END 8 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads from the serial device.
|
||||
*
|
||||
* @param fd serial device handle
|
||||
* @param data pointer to data buffer for receiving
|
||||
* @param len maximum length (in bytes) of data to receive
|
||||
* @return number of bytes actually received - may be 0 if aborted by sio_read_abort
|
||||
*
|
||||
* @note This function will block until data can be received. The blocking
|
||||
* can be cancelled by calling sio_read_abort().
|
||||
*/
|
||||
u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len)
|
||||
{
|
||||
u32_t recved_bytes;
|
||||
|
||||
/* USER CODE BEGIN 9 */
|
||||
recved_bytes = 0; // dummy code
|
||||
/* USER CODE END 9 */
|
||||
return recved_bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to read from the serial device. Same as sio_read but returns
|
||||
* immediately if no data is available and never blocks.
|
||||
*
|
||||
* @param fd serial device handle
|
||||
* @param data pointer to data buffer for receiving
|
||||
* @param len maximum length (in bytes) of data to receive
|
||||
* @return number of bytes actually received
|
||||
*/
|
||||
u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len)
|
||||
{
|
||||
u32_t recved_bytes;
|
||||
|
||||
/* USER CODE BEGIN 10 */
|
||||
recved_bytes = 0; // dummy code
|
||||
/* USER CODE END 10 */
|
||||
return recved_bytes;
|
||||
}
|
||||
#endif /* MDK ARM Compiler */
|
||||
|
||||
76
Core/LWIP/App/lwip.h
Normal file
76
Core/LWIP/App/lwip.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : LWIP.h
|
||||
* Description : This file provides code for the configuration
|
||||
* of the LWIP.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*************************************************************************
|
||||
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __mx_lwip_H
|
||||
#define __mx_lwip_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "netif/etharp.h"
|
||||
#include "lwip/dhcp.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/timeouts.h"
|
||||
#include "ethernetif.h"
|
||||
|
||||
/* Includes for RTOS ---------------------------------------------------------*/
|
||||
#if WITH_RTOS
|
||||
#include "lwip/tcpip.h"
|
||||
#endif /* WITH_RTOS */
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/* Global Variables ----------------------------------------------------------*/
|
||||
extern ETH_HandleTypeDef heth;
|
||||
|
||||
/* LWIP init function */
|
||||
void MX_LWIP_Init(void);
|
||||
|
||||
#if !WITH_RTOS
|
||||
/* USER CODE BEGIN 1 */
|
||||
/* Function defined in lwip.c to:
|
||||
* - Read a received packet from the Ethernet buffers
|
||||
* - Send it to the lwIP stack for handling
|
||||
* - Handle timeouts if NO_SYS_NO_TIMERS not set
|
||||
*/
|
||||
void MX_LWIP_Process(void);
|
||||
|
||||
/* USER CODE END 1 */
|
||||
#endif /* WITH_RTOS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /*__ mx_lwip_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
288
Core/LWIP/App/ssi_cgi_handle.c
Normal file
288
Core/LWIP/App/ssi_cgi_handle.c
Normal file
@@ -0,0 +1,288 @@
|
||||
#include "ssi_cgi_handle.h"
|
||||
#include "httpd.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
#include "fs.h"
|
||||
|
||||
|
||||
#define INDEX_PAGE_SET_CGI_RSP_URL "/index.html"
|
||||
|
||||
#define RESPONSE_PAGE_SET_CGI_RSP_URL "/response.ssi"
|
||||
|
||||
|
||||
#define NUM_CONFIG_CGI_URIS (sizeof(ppcURLs ) / sizeof(tCGI))
|
||||
#define NUM_CONFIG_SSI_TAGS (sizeof(ppcTags) / sizeof (char *))
|
||||
|
||||
|
||||
static char *LED0_CGIHandler( int iIndex, int iNumParams, char *pcParam[], char *pcValue[] );
|
||||
static char *LED1_CGIHandler( int iIndex, int iNumParams, char *pcParam[], char *pcValue[] );
|
||||
static char *LED2_CGIHandler( int iIndex, int iNumParams, char *pcParam[], char *pcValue[] );
|
||||
static char *LED3_CGIHandler( int iIndex, int iNumParams, char *pcParam[], char *pcValue[] );
|
||||
static char *LED4_CGIHandler( int iIndex, int iNumParams, char *pcParam[], char *pcValue[] );
|
||||
|
||||
static char *Orther_CGIHandler( int iIndex, int iNumParams, char *pcParam[], char *pcValue[] );
|
||||
|
||||
|
||||
static int SSIHandler ( int iIndex, char *pcInsert, int iInsertLen );
|
||||
|
||||
|
||||
// typedef struct{
|
||||
// unsigned char *bufptr; //指向响应缓冲区的指针
|
||||
// int buf_user; //指向缓冲区的使用情况
|
||||
// }RESPONSE_BUF;
|
||||
|
||||
// RESPONSE_BUF response_buf;
|
||||
|
||||
static const tCGI ppcURLs[] =
|
||||
{
|
||||
{ "/led0.cgi", LED0_CGIHandler },
|
||||
{ "/led1.cgi", LED1_CGIHandler },
|
||||
{ "/led2.cgi", LED2_CGIHandler },
|
||||
{ "/led3.cgi", LED3_CGIHandler },
|
||||
{ "/led4.cgi", LED4_CGIHandler },
|
||||
{ "/orther.cgi", Orther_CGIHandler },
|
||||
// { "/led_red.cgi", LED_RED_CGIHandler },
|
||||
// { "/led_green.cgi", LED_GREEN_CGIHandler },
|
||||
// { "/orther.cgi", Orther_CGIHandler },
|
||||
};
|
||||
|
||||
static const char *ppcTags[] =
|
||||
{
|
||||
"onetree",
|
||||
"filest"
|
||||
};
|
||||
|
||||
enum ssi_index_s
|
||||
{
|
||||
SSI_INDEX_ONETREE_GET = 0, //该表对应ppcTags[]的排序
|
||||
SSI_INDEX_FILEST_GET
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
//初始化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 );
|
||||
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This CGI handler is called whenever the web browser requests iocontrol.cgi.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static int FindCGIParameter(const char *pcToFind, char *pcParam[], int iNumParams)
|
||||
{
|
||||
int iLoop;
|
||||
|
||||
for(iLoop = 0; iLoop < iNumParams; iLoop++)
|
||||
{
|
||||
if(strcmp(pcToFind, pcParam[iLoop]) == 0)
|
||||
{
|
||||
return(iLoop);
|
||||
}
|
||||
}
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//清除缓冲区的内容
|
||||
void clear_response_bufer(unsigned char *buffer){
|
||||
memset(buffer,0,strlen((const char*)buffer));
|
||||
}
|
||||
int num=100;
|
||||
|
||||
//led0处理函数
|
||||
static char *LED0_CGIHandler( int iIndex, int iNumParams, char *pcParam[], char *pcValue[] )
|
||||
{
|
||||
int index;
|
||||
index = FindCGIParameter ( "led0_0", pcParam, iNumParams ); //没找到返回-1
|
||||
if(index != -1)
|
||||
{
|
||||
clear_response_bufer(data_response_buf); //清除缓冲区的内容
|
||||
printf("LED0\r\n");
|
||||
strcat((char *)(data_response_buf),"/img/red.gif");
|
||||
}
|
||||
else
|
||||
{
|
||||
index = FindCGIParameter ( "led0_1", pcParam, iNumParams );
|
||||
if(index != -1)
|
||||
{
|
||||
clear_response_bufer(data_response_buf); //清除缓冲区的内容
|
||||
printf("LED0\r\n");
|
||||
strcat((char *)(data_response_buf),"/img/black.gif");
|
||||
}
|
||||
}
|
||||
return RESPONSE_PAGE_SET_CGI_RSP_URL;
|
||||
}
|
||||
|
||||
|
||||
//led1处理函数
|
||||
static char *LED1_CGIHandler( int iIndex, int iNumParams, char *pcParam[], char *pcValue[] )
|
||||
{
|
||||
int index;
|
||||
index = FindCGIParameter ( "led1_0", pcParam, iNumParams );
|
||||
if(index != -1)
|
||||
{
|
||||
// num++;
|
||||
//snprintf((char *)(data_response_buf),4,"%d",num);
|
||||
// printf("data_response_buf:%s\r\n",data_response_buf);
|
||||
//printf("green:%s\r\n",pcValue[index]);
|
||||
|
||||
clear_response_bufer(data_response_buf); //清除缓冲区的内容
|
||||
printf("LED1\r\n");
|
||||
strcat((char *)(data_response_buf),"/img/red.gif");
|
||||
}
|
||||
else
|
||||
{
|
||||
index = FindCGIParameter ( "led1_1", pcParam, iNumParams );
|
||||
if(index != -1)
|
||||
{
|
||||
clear_response_bufer(data_response_buf); //清除缓冲区的内容
|
||||
printf("LED1\r\n");
|
||||
strcat((char *)(data_response_buf),"/img/black.gif");
|
||||
}
|
||||
}
|
||||
return RESPONSE_PAGE_SET_CGI_RSP_URL;
|
||||
}
|
||||
|
||||
//led2处理函数
|
||||
static char *LED2_CGIHandler( int iIndex, int iNumParams, char *pcParam[], char *pcValue[] )
|
||||
{
|
||||
int index;
|
||||
index = FindCGIParameter ( "led2_0", pcParam, iNumParams );
|
||||
if(index != -1)
|
||||
{
|
||||
// num++;
|
||||
//snprintf((char *)(data_response_buf),4,"%d",num);
|
||||
// printf("data_response_buf:%s\r\n",data_response_buf);
|
||||
//printf("green:%s\r\n",pcValue[index]);
|
||||
|
||||
clear_response_bufer(data_response_buf); //清除缓冲区的内容
|
||||
printf("LED2\r\n");
|
||||
strcat((char *)(data_response_buf),"/img/red.gif");
|
||||
}
|
||||
else
|
||||
{
|
||||
index = FindCGIParameter ( "led2_1", pcParam, iNumParams );
|
||||
if(index != -1)
|
||||
{
|
||||
clear_response_bufer(data_response_buf); //清除缓冲区的内容
|
||||
printf("LED2\r\n");
|
||||
strcat((char *)(data_response_buf),"/img/black.gif");
|
||||
}
|
||||
}
|
||||
return RESPONSE_PAGE_SET_CGI_RSP_URL;
|
||||
}
|
||||
|
||||
//led3处理函数
|
||||
static char *LED3_CGIHandler( int iIndex, int iNumParams, char *pcParam[], char *pcValue[] )
|
||||
{
|
||||
int index;
|
||||
index = FindCGIParameter ( "led3_0", pcParam, iNumParams );
|
||||
if(index != -1)
|
||||
{
|
||||
// num++;
|
||||
//snprintf((char *)(data_response_buf),4,"%d",num);
|
||||
// printf("data_response_buf:%s\r\n",data_response_buf);
|
||||
//printf("green:%s\r\n",pcValue[index]);
|
||||
|
||||
clear_response_bufer(data_response_buf); //清除缓冲区的内容
|
||||
printf("LED3\r\n");
|
||||
strcat((char *)(data_response_buf),"/img/red.gif");
|
||||
}
|
||||
else
|
||||
{
|
||||
index = FindCGIParameter ( "led3_1", pcParam, iNumParams );
|
||||
if(index != -1)
|
||||
{
|
||||
clear_response_bufer(data_response_buf); //清除缓冲区的内容
|
||||
printf("LED3\r\n");
|
||||
strcat((char *)(data_response_buf),"/img/black.gif");
|
||||
}
|
||||
}
|
||||
return RESPONSE_PAGE_SET_CGI_RSP_URL;
|
||||
}
|
||||
|
||||
//led4处理函数
|
||||
static char *LED4_CGIHandler( int iIndex, int iNumParams, char *pcParam[], char *pcValue[] )
|
||||
{
|
||||
int index;
|
||||
index = FindCGIParameter ( "led4_0", pcParam, iNumParams );
|
||||
if(index != -1)
|
||||
{
|
||||
// num++;
|
||||
//snprintf((char *)(data_response_buf),4,"%d",num);
|
||||
// printf("data_response_buf:%s\r\n",data_response_buf);
|
||||
//printf("green:%s\r\n",pcValue[index]);
|
||||
|
||||
clear_response_bufer(data_response_buf); //清除缓冲区的内容
|
||||
printf("LED4\r\n");
|
||||
strcat((char *)(data_response_buf),"/img/red.gif");
|
||||
}
|
||||
else
|
||||
{
|
||||
index = FindCGIParameter ( "led4_1", pcParam, iNumParams );
|
||||
if(index != -1)
|
||||
{
|
||||
clear_response_bufer(data_response_buf); //清除缓冲区的内容
|
||||
printf("LED4\r\n");
|
||||
strcat((char *)(data_response_buf),"/img/black.gif");
|
||||
}
|
||||
}
|
||||
return RESPONSE_PAGE_SET_CGI_RSP_URL;
|
||||
}
|
||||
|
||||
//温度时间处理函数
|
||||
static char *Orther_CGIHandler( int iIndex, int iNumParams, char *pcParam[], char *pcValue[] )
|
||||
{
|
||||
uint8_t buf[20];
|
||||
clear_response_bufer(data_response_buf); //清除缓冲区的内容
|
||||
|
||||
get_temperature(data_response_buf);
|
||||
strcat((char *)(data_response_buf),";");
|
||||
get_time(buf);
|
||||
strcat((char *)(data_response_buf),buf);
|
||||
|
||||
// if(LED0 == 0){strcat((char *)(data_response_buf),"/img/red.gif");}
|
||||
// else {strcat((char *)(data_response_buf),"/img/black.gif");}
|
||||
|
||||
return RESPONSE_PAGE_SET_CGI_RSP_URL;
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This function is called by the HTTP server whenever it encounters an SSI
|
||||
// tag in a web page. The iIndex parameter provides the index of the tag in
|
||||
// the ppcTags array. This function writes the substitution text
|
||||
// into the pcInsert array, writing no more than iInsertLen characters.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static int SSIHandler ( int iIndex, char *pcInsert, int iInsertLen )
|
||||
{
|
||||
|
||||
|
||||
switch(iIndex)
|
||||
{
|
||||
case SSI_INDEX_ONETREE_GET:
|
||||
|
||||
break;
|
||||
|
||||
case SSI_INDEX_FILEST_GET:
|
||||
|
||||
break;
|
||||
default:
|
||||
strcpy( pcInsert , "??" );
|
||||
|
||||
}
|
||||
|
||||
return strlen ( pcInsert );
|
||||
}
|
||||
|
||||
|
||||
7
Core/LWIP/App/ssi_cgi_handle.h
Normal file
7
Core/LWIP/App/ssi_cgi_handle.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef __SSI_CGI_HANDLE_H
|
||||
#define __SSI_CGI_HANDLE_H
|
||||
|
||||
void init_ssi_cgi(void);
|
||||
|
||||
#endif
|
||||
|
||||
1077
Core/LWIP/Target/ethernetif.c
Normal file
1077
Core/LWIP/Target/ethernetif.c
Normal file
File diff suppressed because it is too large
Load Diff
45
Core/LWIP/Target/ethernetif.h
Normal file
45
Core/LWIP/Target/ethernetif.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : ethernetif.h
|
||||
* Description : This file provides initialization code for LWIP
|
||||
* middleWare.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
#ifndef __ETHERNETIF_H__
|
||||
#define __ETHERNETIF_H__
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
/* Within 'USER CODE' section, code will be kept by default at each generation */
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
err_t ethernetif_init(struct netif *netif);
|
||||
|
||||
void ethernet_link_thread(void const * argument);
|
||||
|
||||
void Error_Handler(void);
|
||||
u32_t sys_jiffies(void);
|
||||
u32_t sys_now(void);
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
#endif
|
||||
117
Core/LWIP/Target/lwipopts.h
Normal file
117
Core/LWIP/Target/lwipopts.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : Target/lwipopts.h
|
||||
* Description : This file overrides LwIP stack default configuration
|
||||
* done in opt.h file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion --------------------------------------*/
|
||||
#ifndef __LWIPOPTS__H__
|
||||
#define __LWIPOPTS__H__
|
||||
|
||||
#include "main.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Current version of LwIP supported by CubeMx: 2.1.2 -*/
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
|
||||
/* Within 'USER CODE' section, code will be kept by default at each generation */
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* STM32CubeMX Specific Parameters (not defined in opt.h) ---------------------*/
|
||||
/* Parameters set in STM32CubeMX LwIP Configuration GUI -*/
|
||||
/*----- WITH_RTOS enabled (Since FREERTOS is set) -----*/
|
||||
#define WITH_RTOS 1
|
||||
/*----- CHECKSUM_BY_HARDWARE disabled -----*/
|
||||
#define CHECKSUM_BY_HARDWARE 0
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
|
||||
/* LwIP Stack Parameters (modified compared to initialization value in opt.h) -*/
|
||||
/* Parameters set in STM32CubeMX LwIP Configuration GUI -*/
|
||||
/*----- Default value in ETH configuration GUI in CubeMx: 1524 -----*/
|
||||
#define ETH_RX_BUFFER_SIZE 1536
|
||||
/*----- Default Value for MEMP_NUM_UDP_PCB: 4 ---*/
|
||||
#define MEMP_NUM_UDP_PCB 20
|
||||
/*----- Default Value for MEMP_NUM_TCP_PCB: 5 ---*/
|
||||
#define MEMP_NUM_TCP_PCB 10
|
||||
/*----- Default Value for LWIP_MPU_COMPATIBLE: 0 ---*/
|
||||
#define LWIP_MPU_COMPATIBLE 1
|
||||
/*----- Value in opt.h for MEM_ALIGNMENT: 1 -----*/
|
||||
#define MEM_ALIGNMENT 4
|
||||
/*----- Default Value for MEM_SIZE: 1600 ---*/
|
||||
#define MEM_SIZE 1024*10
|
||||
/*----- Default Value for H7 devices: 0x30044000 -----*/
|
||||
#define LWIP_RAM_HEAP_POINTER 0x30004000
|
||||
/*----- Default Value for MEMP_NUM_PBUF: 16 ---*/
|
||||
#define MEMP_NUM_PBUF 100
|
||||
/*----- Value supported for H7 devices: 1 -----*/
|
||||
#define LWIP_SUPPORT_CUSTOM_PBUF 1
|
||||
/*----- Value in opt.h for LWIP_ETHERNET: LWIP_ARP || PPPOE_SUPPORT -*/
|
||||
#define LWIP_ETHERNET 1
|
||||
/*----- Value in opt.h for LWIP_DNS_SECURE: (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT) -*/
|
||||
#define LWIP_DNS_SECURE 7
|
||||
/*----- Value in opt.h for TCP_SND_QUEUELEN: (4*TCP_SND_BUF + (TCP_MSS - 1))/TCP_MSS -----*/
|
||||
#define TCP_SND_QUEUELEN 9
|
||||
/*----- Value in opt.h for TCP_SNDLOWAT: LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1) -*/
|
||||
#define TCP_SNDLOWAT 1071
|
||||
/*----- Value in opt.h for TCP_SNDQUEUELOWAT: LWIP_MAX(TCP_SND_QUEUELEN)/2, 5) -*/
|
||||
#define TCP_SNDQUEUELOWAT 5
|
||||
/*----- Value in opt.h for TCP_WND_UPDATE_THRESHOLD: LWIP_MIN(TCP_WND/4, TCP_MSS*4) -----*/
|
||||
#define TCP_WND_UPDATE_THRESHOLD 536
|
||||
/*----- Value in opt.h for LWIP_NETIF_LINK_CALLBACK: 0 -----*/
|
||||
#define LWIP_NETIF_LINK_CALLBACK 1
|
||||
/*----- Value in opt.h for TCPIP_THREAD_STACKSIZE: 0 -----*/
|
||||
#define TCPIP_THREAD_STACKSIZE 1024
|
||||
/*----- Value in opt.h for TCPIP_THREAD_PRIO: 1 -----*/
|
||||
#define TCPIP_THREAD_PRIO osPriorityNormal
|
||||
/*----- Value in opt.h for TCPIP_MBOX_SIZE: 0 -----*/
|
||||
#define TCPIP_MBOX_SIZE 6
|
||||
/*----- Value in opt.h for SLIPIF_THREAD_STACKSIZE: 0 -----*/
|
||||
#define SLIPIF_THREAD_STACKSIZE 1024
|
||||
/*----- Value in opt.h for SLIPIF_THREAD_PRIO: 1 -----*/
|
||||
#define SLIPIF_THREAD_PRIO 3
|
||||
/*----- Value in opt.h for DEFAULT_THREAD_STACKSIZE: 0 -----*/
|
||||
#define DEFAULT_THREAD_STACKSIZE 1024
|
||||
/*----- Value in opt.h for DEFAULT_THREAD_PRIO: 1 -----*/
|
||||
#define DEFAULT_THREAD_PRIO 3
|
||||
/*----- Value in opt.h for DEFAULT_UDP_RECVMBOX_SIZE: 0 -----*/
|
||||
#define DEFAULT_UDP_RECVMBOX_SIZE 6
|
||||
/*----- Value in opt.h for DEFAULT_TCP_RECVMBOX_SIZE: 0 -----*/
|
||||
#define DEFAULT_TCP_RECVMBOX_SIZE 6
|
||||
/*----- Value in opt.h for DEFAULT_ACCEPTMBOX_SIZE: 0 -----*/
|
||||
#define DEFAULT_ACCEPTMBOX_SIZE 6
|
||||
/*----- Value in opt.h for RECV_BUFSIZE_DEFAULT: INT_MAX -----*/
|
||||
#define RECV_BUFSIZE_DEFAULT 2000000000
|
||||
/*----- Value in opt.h for LWIP_STATS: 1 -----*/
|
||||
#define LWIP_STATS 0
|
||||
/*----- Default Value for LWIP_CHECKSUM_CTRL_PER_NETIF: 0 ---*/
|
||||
#define LWIP_CHECKSUM_CTRL_PER_NETIF 1
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 1 */
|
||||
#define MEMP_NUM_NETBUF 16
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /*__LWIPOPTS__H__ */
|
||||
Reference in New Issue
Block a user