I'm trying to transition beyond Arduino and I'm trying to learn how to use an RTOS (like FreeRTOS) to connect to the web via Wifi. It seems that FreeRTOS and ZentriOS and other RTOS supply TCP/IP stacks. Correct me if I'm wrong but It seems to me that this TCP/IP stack provides the API for interacting with the outside world through either Ethernet or Wifi. Is the Wifi Driver what interfaces the TCP/IP stack with the Wifi Module itself? Does the Wifi Driver implement standard TCP/IP interfaces? Or is it the firmware developers job to figure out how to interact a TCP/IP stack with the wifi driver?


1 Answer 1


TCP/IP stack is designed to be generic as possible, so applications can interact with various data link protocols such as 802.3 (Ethernet), 802.11 (Wi-Fi), PPP (point-to-point protocol) and so on without needing to know what sort of link they are using..

TCP/IP actually comprises several layers of protocols, e.g.

 5. Application DNS, FTP, HTTP, IMAP, POP3, SMTP, SSH, Telnet, SSL, ...
 4. Transport   TCP, UDP, ...
 3. Network     IP (IPv4, IPv6), ICMP, ARP, ...
 2. Data Link   802.3 (Ethernet), 802.11 (Wi-Fi), PPP, ...
 1. Physical    Ethernet (NIC), Wireless (NIC), Cat 5/RJ-45, ... 

(The top layer is often broken out into three separate ones, I am simplfying things a little.)

So it will be the bottom level where the stack needs to interface with the driver for your specific Wi-Fi module.

Since this is at the byte level, there will be a limited number of functions that needed to be implemented. They follow a pretty much standard I/O device driver model, i.e.

Open function
Close function
Send function
Receive function
IO Control function
Get PhysicalAddress function
Interrupt service routine (ISR) callback

so it should be pretty simply to marry up the stack interface with a particular module.

See here for an example with some more detail for one particular OS.

Some Wi-Fi modules, like the ESP8266, come with a TCP/IP stack built-in, since TCP/IP can be taxing on a small microcontroller. It is accessed via AT commands, much like a cell module or Bluetooth module.

  • \$\begingroup\$ Does the layer 1 Physical layer and Wifi Drivers have an agreed upon set of API's such that any Wifi Driver an interact with a TCP/IP stack? Or is it up to Firmware Engineers to interface the physical layer with Wifi Drivers if the are using a new Wifi component. \$\endgroup\$
    – Inc1982
    Jul 15, 2016 at 17:25
  • \$\begingroup\$ @Inc1982 I've added a little bit more to my answer. The interface should be pretty much the same as any I/O device driver, e.g. open, close, send, receive etc. Pretty simple to write any "glue" routines between the stack and the driver as needed. \$\endgroup\$
    – tcrosley
    Jul 15, 2016 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.