开发环境:野火的stm32f407,rt-thread studio版本是版本: 2.2.6,stm32f4的资源包为0.2.2,rt-thread版本为4.0.3。
以RT-Thread中Lan8720和lwip协议栈的使用文章创建的工程为基础。
httpd(The Apache HTTP Server)的官方网址。
在rtthread工程中新建文件夹webserver,存放webserver相关文件。
在正点原子例程网络实验10 NETCONN_WEBserver实验中的LWIPlwip_appweb_server_demo 文件夹 下的文件拷贝到文件夹webserver。如下图:
对工程进行编译,工程报错。根据报错提示进行修改。修改过程如下:
STEP1:错误提示 httpd.c8623: fatal error: lwip_comm.h: No such file or directory。屏蔽掉头文件 //#include "lwip_comm.h"
保存,编译
STEP2 :错误提示:httpd_cgi_ssi.c523: fatal error: lwip_comm.h: No such file or directory。屏蔽掉头文件 //#include "lwip_comm.h"。同时屏蔽掉//#include "led.h" //#include "tsensor.h" //#include "rtc.h" //#include "lcd.h"
修改httpd_cgi_ssi.c文件中的内容,将xxx_Handler函数中内容屏蔽掉,只保留定义。比如RTCdate_Handler函数。LEDS_CGI_Handler函数只保留return "/STM32_LED_OFF_BEEP_OFF.shtml";
编译报错,提示fsdata.o:(.rodata.file__image_head_jpg+0x0): multiple definition offileimage_head_jpg’ ;fs.o:(.rodata.fileimage_head_jpg+0x0): first defined here`
将fsdata.c 排除构建
新建web_server.c文件,添加代码如下:
void webserver_start(void)
{
rt_kprintf("nntNow, Initializing The WEB File System...n");
/* Httpd Init /
httpd_init();
/ 配置 SSI 处理程序 /
httpd_ssi_init();
/ 配置 CGI 处理器 */
httpd_cgi_init();
rt_kprintf("tNow, Starting The WEB Server Thread...n");
}
MSH_CMD_EXPORT(webserver_start, start web server);
编译,下载到开发板。启动后输入webserver_start指令,打开浏览器输入ip地址,效果 如下:
相关文章









