Skip to content

Commit

Permalink
Send reboot cmd to connections when listener is stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
markjfisher committed Jan 21, 2024
1 parent 61fd306 commit b89f4fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source/SPoverSLIP/Connection.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
Expand All @@ -25,6 +26,8 @@ class Connection

void join();

static constexpr std::array<uint8_t, 4> reboot_sequence = {0xFF, 0x00, 0x00, 0xFF};

private:
std::atomic<bool> is_connected_{false};

Expand Down
2 changes: 2 additions & 0 deletions source/SPoverSLIP/Listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ void Listener::stop()
for (auto &pair : connection_map_)
{
const auto &connection = pair.second;
// Send connection a reset sequence.
connection->send_data(std::vector<uint8_t>(Connection::reboot_sequence.begin(), Connection::reboot_sequence.end()));
connection->set_is_connected(false);
connection->join();
}
Expand Down

0 comments on commit b89f4fa

Please sign in to comment.