Dhyara
Dhyara adhoc Network
|
GitHub Repository | Doxygen Documentation
Dhyara is a ESP-IDF component for Mobile Ad-Hoc Networks on the top of ESP NOW (Layer 2). Dhyara is Open Source under BSD 2 Clause License. See LICENSE
The dhyara nodes identify each other via MAC address. Once deployed the nodes communicate with each other and each node builds a routing table based on its local view. On the top of that, dhyara provides C and C++ APIs for send/receice/ping/traceroute functionalities.
In the following example, the string "Hello World" is a variable length data which is sent to the destination identified with the mac address 4c:11:ae:9c:a6:85
over the multihop network. If the destination is a direct neighbour of the source then the message will be delivered in one hop. Otherwise the message sent will find its path to the destination 4c:11:ae:9c:a6:85
on its own by following the routing decisions of each intermediate nodes.
C++ version of the above mentined C example.
To receive the mesage sent over the network the sink node needs to register a callback where the data is received.
ESP Now limits maximum size of a frame to 250 bytes. The variable length data is represented as a data packet (dhyara::packets::data), which is broken into multiple smaller sized chunks. On the receiving end these chunks are joined to comstruct a data packet, which is used while calling the receive callback set using dhyara_receivef, dhyara_receive, and dhyara_receive_data.
In the above mentioned C++ example, source represents the immediate neighbour of the desination, and data.source()
is the originator of the message.
Dhyara is a C++11 library that has to be used as an ESP-IDF component. It can be cloned to the components
directory or can be used as a git submodule
inside your projects components
directory. If the application project is using an extra components directory then path to that directory has to be added in the root directory's CMakeLists.txt file as shown in the following example.
To configure the network parameters use idf.py menuconfig
in the aplications directory and Go to Component config > Dhyara ad hoc network
To build and flash the application use idf.py build
and idf.py flash
as usual.
See Building the examples.
The examples are provided in the examples directory. See Building the examples for instructions on building the examples.
Following is a C example demonstrating basic usage of dhyara
Dhyara is primarily intended to be used for C++ application. To build a C++ application with ESP-IDF we first start from a main.c
which calls a C++ function mainx()
. Following is the main.c
from the example hello-cxx
The mainx()
is declared and gaurded by extern C{}
block in the mainx.h
, so that it can be included from c as well as C++. Following is the definition of mainx() which can be found in the mainx.cpp
in the hello-cxx
example project.