已经将LwIP有关移植的文件做了相应的修改,那么要在main函数中建立什么样的LwIP任务才能用电脑ping通呢?
void LwIPEntry(void * pvArg)
{
struct netconn *Conn, *NewConn;
struct netbuf *Netbuf;
//* 初始化LwIP
lwip_init();
tcpip_init(NULL , NULL);
//* 设置LwIP,包括添加配置网络接口、建立接收任务等工作
SetLwIP();
Conn = netconn_new(NETCONN_TCP);
netconn_bind( Conn, NULL, 80);
netconn_listen( Conn);
while(TRUE)
{
netconn_accept( Conn,&NewConn);
if( NewConn != NULL)
{
netconn_recv( NewConn,&Netbuf);
if( Netbuf != NULL)
{
netconn_write( NewConn, "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n", 44, NETCONN_COPY);
netconn_write( NewConn, "<body><h1>这是LWIP TCP测试!</h1></body>", 40, NETCONN_COPY);
netbuf_delete( Netbuf);
}
netconn_close( NewConn);
while(netconn_delete( NewConn) != ERR_OK)
OSTimeDlyHMSM(0, 0, 1, 0);
}
}
}
#endif
上面那个LwIPEntry函数的作用是什么呢?为其建立一个任务之后ping不通..... |