Skip to content

Commit

Permalink
- C++ example more organized
Browse files Browse the repository at this point in the history
- Kconfig more docs
  • Loading branch information
neel committed Oct 27, 2021
1 parent 470b75b commit b8cc3be
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 43 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build
*.kdev4
sdkconfig
docs/source/api
.cache
64 changes: 40 additions & 24 deletions Kconfig
Original file line number Diff line number Diff line change
@@ -1,99 +1,115 @@
menu "Dhyara ad hoc network"

config DHYARA_RECEIVE_QUEUE_SIZE
int "receive queue capacity"
int "Receive queue capacity"
range 20 500
default 256
default 64
help
Capacity of the queue for the received packets
All received packets are initially enqueued in a FreeRTOS queue which is dequeued by another
FreeRTOS task. This parameter specifies the capacity of that queue.

config DHYARA_SYNC_QUEUE_SIZE
int "synchronization queue capacity"
int "Synchronization queue capacity"
range 20 256
default 64
default 32
help
Capacity of the synchronization queue
The neighbourhood synchronization messages are enqueued in a FreeRTOS queue which is dequeued
by another FreeRTOS task. This parameter specifies the capacity of the synchronization queue

config DHYARA_PEER_CHANNEL
int "peer channel"
int "Peer channel"
range 1 12
default 1
help
Dhyara peer channel
The 2.4Ghz WiFi channel which will be used by the nodes participating in the ad-hoc network.

config DHYARA_BROADCAST_CHANNEL
int "broadcast channel"
int "Broadcast channel"
range 1 12
default 1
help
Dhyara broadcast channel
The 2.4Ghz WiFi channel that is used by the dhyara node to broadcast the beacon at a fixed
time interval. Note: the other nodes must be able to get the broadcasted beacon.

config DHYARA_BEACON_INTERVAL
int "beacon interval (ms)"
int "Beacon interval (ms)"
range 10 60000
default 1000
help
Dhyara beacon interval
Dhyara broadcasts a beacon at a fixed interval to its neighbourhood. This parameter specifies
the time interval (in micro seconds) of each beacons.

config DHYARA_DELAY_TOLERANCE
int "delay tolerance (us)"
int "Delay tolerance (us)"
range 0 5000
default 0
help
Dhyara delay tolerance
Once link quality of a route is changed then the old and the new delays are compared. If the
difference between the old and the new delay is higher that the value specified in this parameter
then it is considered that the link status has been changed. It is set to 0 by default. However
for a large network a too low value like 0 may result into to many unnecessary synchronizations.

config DHYARA_DEPRECIATION_COEFFICIENT
int "depreciation coefficient"
int "Depreciation coefficient"
range 2 20
default 2
help
while depretiating a route the current delay will be multiplied with this coefficient
Once the delay of a while depretiating a route the current delay will be multiplied with this coefficient

config DHYARA_ADVERTISEMENT_EXPIRY
int "advertisement expiry (ms)"
int "Advertisement expiry (ms)"
range 10 5000
default 2000
help
Dhyara advertisement expiry
Advertisement expiry

config ROUTE_EXPIRY_COEFFICIENT
int "route expiry coefficient"
range 10 5000
default 1000
help
Dhyara route expiry coefficient
Route expiry coefficient

config DISABLE_SEND_QUEUEING
bool "Disable queueing of messages that are to be sent"
default n
help
Dhyara disable queueing of messages that are to be sent
When send queuing is enabled then messages are first queued and the dequeued
by a seperate task which actually sends the message. Disabling send queuing
may improve network throughput while it may lead to frequent ESP_ERR_ESPNOW_NO_MEM
errors.

config ENABLE_MANDATORY_SLEEP_AFTER_TRANSMISSION
bool "Enable Mandatory Sleep after consecutive transmitions"
default y
help
Mandatory Sleep after N consecutive transmitions
After N consecutive transmitions there would be a mandatory sleep for specified
number of microseconds. This sleep is to prevent frequent ESP_ERR_ESPNOW_NO_MEM
errors when sending too fast. At the same time this mandatory sleep prevents too
fast communication in the network. So for high speed setup it may be disabled.

config ENABLE_MANDATORY_SLEEP_AFTER_TRANSMISSION_N
int "Mandatory Sleep after N consecutive transmitions"
range 1 100
default 1
help
After the specified transmissions there will be a mandatory sleep
Applicable only when mandatory sleep is enabled. Number of send instructions after
which the mandatoru sleep will be performed.

config ENABLE_MANDATORY_SLEEP_AFTER_TRANSMISSION_TIME
int "Amount of sleep (in ms) after consecutive transmitions"
range 1 100
default 1
help
Amount of sleep (ms) after consecutive transmitions
Applicable only when mandatory sleep is enabled. Amount of time in number of micro
seconds, during which there will be no transmission (e.g. sleep).

config ENABLE_HTTP_MANAGEMENT_SERVER
bool "If enabled then provides an web based management console over HTTP"
default y
help
Dhyara enable web based management console over HTTP
Enable web based management console over HTTP that can be accessed by http://192.168.4.1
after connecting to ESP32 node via wifi.

config DHYARA_UTIL_UDP_RELAY_BUFFER_SIZE
int "UDP Relay Buffer Size"
Expand Down
12 changes: 6 additions & 6 deletions examples/hello-cxx/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ void app_main(){

ESP_ERROR_CHECK(dhyara_init(WIFI_MODE_AP));

// // For high speed communication uncommon the following (Additionally disable AMPDU)
// ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));
// ESP_ERROR_CHECK(esp_wifi_set_max_tx_power(78));
// ESP_ERROR_CHECK(esp_wifi_set_protocol(WIFI_IF_AP, WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_LR));
// ESP_ERROR_CHECK(esp_wifi_set_bandwidth(WIFI_IF_AP, WIFI_BW_HT40));
// ESP_ERROR_CHECK(esp_wifi_internal_set_fix_rate(WIFI_IF_AP, 1, WIFI_PHY_RATE_MCS7_SGI));
// // For high speed communication uncomment the following (Additionally disable AMPDU)
// ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));
// ESP_ERROR_CHECK(esp_wifi_set_max_tx_power(78));
// ESP_ERROR_CHECK(esp_wifi_set_protocol(WIFI_IF_AP, WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N));
// ESP_ERROR_CHECK(esp_wifi_set_bandwidth(WIFI_IF_AP, WIFI_BW_HT40));
// ESP_ERROR_CHECK(esp_wifi_internal_set_fix_rate(WIFI_IF_AP, 1, WIFI_PHY_RATE_MCS7_SGI));

mainx(); // Enter C++
}
35 changes: 22 additions & 13 deletions examples/hello-cxx/main/mainx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,43 @@
#include <dhyara/utils/http.h>

void mainx(){
dhyara::utils::http server(dhyara_link());

dhyara::network network(dhyara_link());
dhyara_set_default_network(&network);

dhyara::address sink("4c:11:ae:9c:a6:85"), source("4c:11:ae:71:0f:4d");
dhyara::address sink("ac:67:b2:25:8e:a5"), source("4c:11:ae:9c:1a:c9");

dhyara_start_default_network();
network.start();

// For experimental purpose
// Optionally ban direct communication between the source and the target
// Force the source and target to communicate via one or more intermediate nodes
network.isolate(source, sink);
/**
* For experimental purpose
* Optionally ban direct communication between the source and the target
* Force the source and target to communicate via one or more intermediate nodes
*/
// network.isolate(source, sink);

dhyara::address local = dhyara_local();
dhyara::address other = (local == source) ? sink : ((local == sink) ? source : dhyara::address::null());

// The anonymous function will be called once all chunks of a data packet is received
dhyara_receive_data([](const dhyara::address& source, const dhyara::packets::data& data){
/**
* The anonymous function will be called once all chunks of a data packet is received
*/
network.on_data([](const dhyara::address& source, const dhyara::packets::data& data){
std::cout << "received data " << " originating from " << data.source() << " via " << source << " of size " << data.length() << std::endl;
});

while(1){
if(!other.is_null()){
dhyara_ping(other, 1, 10);
dhyara_traceroute(other);
dhyara::tools::ping ping(network);
ping.count(1).batch(50).sleep(0);
ping(other);
vTaskDelay(pdMS_TO_TICKS(2000));

dhyara::tools::traceroute traceroute(network, other);
traceroute();
vTaskDelay(pdMS_TO_TICKS(2000));

std::string buffer = "Hello World";
dhyara_send(other, buffer.begin(), buffer.end());
network.send(other, buffer.begin(), buffer.end());
}
vTaskDelay(pdMS_TO_TICKS(5000));
}
Expand Down

0 comments on commit b8cc3be

Please sign in to comment.