
2.3 LwIP的说明文档
下面简单浏览一下LwIP的官方说明文档(http://www.nongnu.org/lwip/2_1_x/index.html)。打开连接,可以看到LwIP的Overview(概述),简单阅读一下即可,单击左侧的Common pitfalls链接,查看一下LwIP的常见陷阱,在使用过程中遇到这些陷阱时注意一下即可。LwIP可以工作在无操作系统环境,也可以工作在有操作系统的环境中,关于Common pitfalls中提到的Mainloop Mode(主函数轮询模式)和OS Mode(操作系统模式),有一些事项需要注意,具体如图2-8所示。

图2-8 Common pitfalls
此外,我们还可以单击左侧的Modules链接查看一些模块相关的说明以及示例,比如有/无操作系统模拟层、LwIP基础配置、内存管理模块、数据包缓冲区等,这些相关的说明可在Modules ->Infrastructure页面中找到,具体如图2-9所示。

图2-9 Modules
当然,一些很重要的用户常用的API函数在Modules中也可以找到,例如"raw" API、Sequential-style API和Socket API等,如图2-10所示。

图2-10 Modules->APIs
此外,Applications中还有一些应用层的相关说明,如HTTP server、MQTT client、TFTP server等,如图2-11所示。

图2-11 Modules->Applications
Modules ->Data Structures中有一些与数据结构相关的说明,当在程序中看到不懂的数据结构时,可以在这里找到对应的说明。数据是比较重要的,LwIP的本质就是对数据进行处理,其中也使用了大量的数据结构,有时间可以深入研究,具体如图2-12所示。

图2-12 Data Structures
当然,我们也能通过函数名的首字母来查找函数的作用,如图2-13所示。

图2-13 Function