23 #include <boost/asio.hpp> 35 public std::enable_shared_from_this<MAVConnTCPClient> {
46 std::string server_host = DEFAULT_SERVER_HOST,
unsigned short server_port = DEFAULT_SERVER_PORT);
51 boost::asio::io_service &server_io);
54 void close()
override;
56 void send_message(
const mavlink::mavlink_message_t *message)
override;
58 void send_bytes(
const uint8_t *bytes,
size_t length)
override;
67 std::unique_ptr<boost::asio::io_service::work>
io_work;
76 std::deque<MsgBuffer>
tx_q;
77 std::array<uint8_t, MsgBuffer::MAX_SIZE>
rx_buf;
86 void do_send(
bool check_tx_state);
95 public std::enable_shared_from_this<MAVConnTCPServer> {
97 static constexpr
auto DEFAULT_BIND_HOST =
"localhost";
98 static constexpr
auto DEFAULT_BIND_PORT = 5760;
105 std::string bind_host = DEFAULT_BIND_HOST,
unsigned short bind_port = DEFAULT_BIND_PORT);
108 void close()
override;
110 void send_message(
const mavlink::mavlink_message_t *message)
override;
112 void send_bytes(
const uint8_t *bytes,
size_t length)
override;
114 mavlink::mavlink_status_t
get_status()
override;
117 return acceptor.is_open();
122 std::unique_ptr<boost::asio::io_service::work>
io_work;
136 void client_closed(std::weak_ptr<MAVConnTCPClient> weak_instp);
137 void recv_message(
const mavlink::mavlink_message_t *message,
const Framing framing);
virtual mavlink::mavlink_status_t get_status()
MAVConnTCPClient(uint8_t system_id=1, uint8_t component_id=MAV_COMP_ID_UDP_BRIDGE, std::string server_host=DEFAULT_SERVER_HOST, unsigned short server_port=DEFAULT_SERVER_PORT)
static constexpr auto DEFAULT_SERVER_HOST
boost::asio::ip::tcp::acceptor acceptor
static constexpr auto DEFAULT_SERVER_PORT
boost::asio::io_service io_service
void close() override
Close connection.
std::atomic< bool > tx_in_progress
std::unique_ptr< boost::asio::io_service::work > io_work
static constexpr auto MAV_COMP_ID_UDP_BRIDGE
Same as mavlink::common::MAV_COMPONENT::COMP_ID_UDP_BRIDGE.
std::recursive_mutex mutex
boost::asio::ip::tcp::endpoint bind_ep
std::recursive_mutex mutex
Generic mavlink interface.
void send_message(const mavlink::mavlink_message_t *message) override
Send message (mavlink_message_t)
void client_connected(size_t server_channel)
friend class MAVConnTCPServer
MAVConn message buffer class (internal)
virtual IOStat get_iostat()
std::array< uint8_t, MsgBuffer::MAX_SIZE > rx_buf
std::atomic< bool > is_destroying
void send_bytes(const uint8_t *bytes, size_t length) override
Send raw bytes (for some quirks)
std::atomic< bool > is_destroying
boost::asio::ip::tcp::socket socket
std::list< std::shared_ptr< MAVConnTCPClient > > client_list
std::unique_ptr< boost::asio::io_service::work > io_work
boost::asio::ip::tcp::endpoint server_ep
std::deque< MsgBuffer > tx_q
boost::asio::io_service io_service
Framing
Rx packer framing status. (same as mavlink::mavlink_framing_t)
void do_send(bool check_tx_state)