This project is an HTTP server library for AtomVM - a lightweight Erlang/Elixir virtual machine designed for microcontrollers and embedded systems.
AtomVM is a tiny Erlang VM that runs on resource-constrained devices like ESP32, STM32, and other microcontrollers. It allows you to write Erlang and Elixir code for embedded systems.
- GitHub: https://github.com/atomvm/AtomVM
- Documentation: https://www.atomvm.net/doc/master/
- Programming Guide: https://www.atomvm.net/doc/master/programmers-guide.html
When working on this codebase, keep in mind:
-
Limited OTP Support: AtomVM implements a subset of OTP. Not all standard library modules are available.
-
No
gen_servercallbacks withhandle_continue: Some newer OTP features may not be implemented. -
Memory Constraints: Code should be memory-efficient. Avoid large data structures and prefer streaming/chunked processing.
-
No Hot Code Loading: Unlike standard Erlang, AtomVM doesn't support hot code swapping.
-
Limited Process Dictionary: Use sparingly if at all.
-
Binary Handling: Binaries are well-supported and preferred for string/data handling.
AtomVM provides platform-specific modules:
atomvm:platform/0- Returns the current platform (e.g.,esp32,stm32,generic_unix)esp:*- ESP32-specific functions (GPIO, WiFi, etc.)network:*- Network configuration for embedded platforms
src/- Erlang source files (.erl)lib/- Elixir source files (.ex)include/- Header files (.hrl)priv/- Static assets and resourcestest/- Test files
This is a mixed Erlang/Elixir project using Mix:
mix deps.get
mix compileFor deploying to ESP32, you'll need to create an AVM file and flash it.
-
Debugging: Use
io:format/2orerlang:display/1for debugging - standard Erlang debugger is not available. -
Testing Locally: Tests run on the host machine using standard Erlang VM, not AtomVM itself.
-
Handler Pattern: This httpd uses a handler-based architecture. Each
*_handler.erlmodule handles specific route patterns. -
WebSocket Support:
httpd_ws_handler.erlprovides WebSocket functionality. -
API Handlers: Files ending in
_api_handler.erlare REST API endpoints.
Handlers implement callbacks for HTTP request processing. Check httpd_handler.erl for the behavior definition.
gen_tcp_server.erl provides the underlying TCP socket management.