datanoisetv/esp_smoltcp_lwip_compat

0.1.0

Latest
uploaded 7 hours ago
BSD-sockets compatibility shim — every IDF networking component (esp_http_server, esp-tls, esp-mqtt) talks to smoltcp transparently via linker --wrap.

readme

# esp_smoltcp_lwip_compat

BSD-sockets compatibility shim for
[`datanoisetv/esp_smoltcp`](https://components.espressif.com/components/datanoisetv/esp_smoltcp).
Every IDF networking call (`esp_http_server`, `esp-tls`, `esp-mqtt`, …)
talks to smoltcp transparently — zero application source changes.

Full docs and architecture: https://github.com/DatanoiseTV/esp-smoltcp

## How it works

ESP-IDF's `<lwip/sockets.h>` defines `socket()`, `bind()`, etc. as
`static inline` wrappers calling `lwip_socket()`, `lwip_bind()`. We
add `-Wl,--wrap=lwip_socket -Wl,--wrap=lwip_bind ...` linker flags
that redirect every BSD-socket call site to a thin C shim that
proxies to smoltcp. lwIP stays compiled (its headers are needed by
IDF networking source) but its socket layer is unreachable at runtime.

In addition to the wraps:
- `127.0.0.0/8` traffic is handled by an in-RAM loopback table so
  `esp_http_server`'s control-socket pair works without going through
  smoltcp.
- A minimal `esp_netif` shim returns the iface IP, MAC, etc. for the
  IDF components that query that.

## Required sdkconfig

```
CONFIG_LWIP_COMPAT_ENABLE=y
CONFIG_VFS_SUPPORT_SELECT=n      # mandatory — see repo README
CONFIG_LWIP_NETIF_LOOPBACK=y
```

`CONFIG_VFS_SUPPORT_SELECT=n` is currently necessary because IDF's
VFS `select()` layer queries lwIP's socket table directly and our
smoltcp sockets aren't in that table. A cleaner VFS-registered
socket layer is on the v0.2 roadmap (see issue tracker).

## License

Apache-2.0 OR MIT, your choice.

Links

Supports all targets

License: Apache-2.0 OR MIT

To add this component to your project, run:

idf.py add-dependency "datanoisetv/esp_smoltcp_lwip_compat^0.1.0"

download archive

Stats

  • Archive size
    Archive size ~ 15.96 KB
  • Downloaded in total
    Downloaded in total 0 times
  • Downloaded this version
    This version: 0 times

Badge

datanoisetv/esp_smoltcp_lwip_compat version: 0.1.0
|