项目:检测PM2.5并在网页上显示。(局域网内)
下面是网页代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>index</title>
</head>
<body>
<table width="700" border="0" cellspacing="0" cellpadding="1">
<td align="center" >
<strong>空气检测议PM2.5的浓度:<span style="color:red;">xx </span>
<input type=button value="刷新数据" onclick="window.location.href('/?led=1')"> <br />
</strong>
<tr>
<td align="center">
</table>
</body>
</html>
下面是程序修改部分
char *strx;
u8 dbuf[17];
PSOCK_BEGIN(&s->sin);
PSOCK_READTO(&s->sin, ISO_space);
if(strncmp(s->inputbuf, http_get, 4)!=0)PSOCK_CLOSE_EXIT(&s->sin); //比较客户端浏览器输入的指令是否是申请WEB指令 “GET ”
PSOCK_READTO(&s->sin, ISO_space); //" "
if(s->inputbuf[0] != ISO_slash)PSOCK_CLOSE_EXIT(&s->sin); //判断第一个(去掉IP地址之后)数据,是否是"/"
if(s->inputbuf[1] == ISO_space||s->inputbuf[1] == '?') //第二个数据是空格/问号
{
strx=strstr((const char*)(data_index_html+13),"空气检测议PM2.5的浓度:"); //如果找到PM2.5浓度
if(strx)//如果找到浓度:
{
get_PM(dbuf); //得到浓度
strncpy(strx+4,(const char*)dbuf,5); //更新浓度
}
}
|