-
Notifications
You must be signed in to change notification settings - Fork 0
Scratchpad
Nishant Aswani edited this page Jan 31, 2021
·
16 revisions
-
git submodule --init
(only required first time cloning the repo) git pull --recurse-submodules
git submodule update --remote --recursive
git checkout b36cc818db89430b7564d1c56a668937f6dae6ec
- A random broadcast consensus synchronization algorithm for large scale wireless mesh networks
- Enhanced IEEE 802.11 Power Saving for Multi-Hop Toy-to-Toy Communication
- https://techjury.net/blog/how-many-iot-devices-are-there/
- Getting Started with ESP-NOW (ESP32 with Arduino IDE)
- ESP8266 pinout:
void _server::setElectionAlarm() {
// Create a new election alarm task for the scheduler
_task_election_ptr =
new Task(TASK_ELECTION_INTERVAL * TASK_MILLISECOND, TASK_FOREVER, [&] {
// Check if there are nodes in the network
bool isAloneNode = (_mesh.getNodeList(false).size() == 0);
// Timeout if in follower mode or alone in the network
if(this->_state == 0 || isAloneNode) {
// Start a new election if the coin is flipped true or the maximum
// number of skips reached
if((this->_mesh.getNodeTime() % 2) ||
(_task_election_skipped_coin_flips >
TASK_ELECTION_MAXIMUM_SKIPPED_COIN_FLIPS)) {
// Reset the flips
this->_task_election_skipped_coin_flips = 0;
// If coin toss results in 1, start a new election
// In this way, we randomize the election duration without worrying
// about timer overflow
startNewElection();
} else {
this->_task_election_skipped_coin_flips += 1;
}
}
});
// Add the alarm to scheduler and enable it
this->_scheduler.addTask(*_task_election_ptr);
_task_election_ptr->enable();
this->_logger(DEBUG, "Set the election timer\n");
};