This library implements a simple MDNS client for the esp8266.
See the header file include/mdns/mdns.h
for documentation.
TODO
Some pointers:
- Get the ESP8266 compiler: https://github.com/pfalcon/esp-open-sdk
- Get the SDK
- Unpack SDK somewhere
- Set up the environment
export PATH="/path/to/compiler/xtensa-lx106-elf/bin:$PATH" export SDK_PATH="$HOME/esp-sdk/ESP8266_RTOS_SDK" export BIN_PATH="$HOME/esp-sdk/build" export CFLAGS="-I${SDK_PATH}/include -I${SDK_PATH}/extra_include $CFLAGS" export LDFLAGS="-L${SDK_PATH}/lib $LDFLAGS"
- Switch to the base directory and run
make
- Grab the library from
.output/lib/libmdns.a
- Grab the headers from
include/*.h
The code in library
is abstracted from the actual hardware by a very thin abstraction layer which is defined in platform
. To adapt the mdns service to another platform you will have to exchange the Makefiles and supply implementations for the following functions in libplatform
:
mdnsUDPHandle
: handle for the UDP connection (socket, LWIPudp_pcb
, etc.)mdnsNetworkBuffer
: platform specific buffer type (probably a linked list, etc.)struct _mdnsStreamBuf
: stream buffer internal state (probably a byte offset and a linked list of buffers)struct ip_addr
: a IPv4 address (the one from LWIP is fine, just import it)
bool mdns_join_multicast_group(void)
: join the MDNS multicast groupbool mdns_leave_multicast_group(void)
: leave the MDNS multicast groupmdnsUDPHandle *mdns_listen(mdnsHandle *handle)
: listen to packets from the multicast group and connectuint16_t mdns_send_udp_packet(mdnsHandle *handle, char *data, uint16_t len)
: send UDP payloadvoid mdns_shutdown_socket(mdnsUDPHandle *pcb)
: shutdown a socket
mdnsStreamBuf *mdns_stream_new(mdnsNetworkBuffer *buffer)
: create a stream buffer for the platform specific response buffersuint8_t mdns_stream_read8(mdnsStreamBuf *buffer)
: read a byte from the buffervoid mdns_stream_destroy(mdnsStreamBuf *buffer)
: free stream buffer
License: 3 Clause BSD (see LICENSE-BSD.txt)