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);
57 void close()
override;
59 void send_message(
const mavlink::mavlink_message_t *message)
override;
61 void send_bytes(
const uint8_t *bytes,
size_t length)
override;
70 std::unique_ptr<boost::asio::io_service::work>
io_work;
79 std::deque<MsgBuffer>
tx_q;
80 std::array<uint8_t, MsgBuffer::MAX_SIZE>
rx_buf;
89 void do_send(
bool check_tx_state);
98 public std::enable_shared_from_this<MAVConnTCPServer> {
100 static constexpr
auto DEFAULT_BIND_HOST =
"localhost";
101 static constexpr
auto DEFAULT_BIND_PORT = 5760;
108 std::string bind_host = DEFAULT_BIND_HOST,
unsigned short bind_port = DEFAULT_BIND_PORT);
114 void close()
override;
116 void send_message(
const mavlink::mavlink_message_t *message)
override;
118 void send_bytes(
const uint8_t *bytes,
size_t length)
override;
120 mavlink::mavlink_status_t
get_status()
override;
123 return acceptor.is_open();
128 std::unique_ptr<boost::asio::io_service::work>
io_work;
142 void client_closed(std::weak_ptr<MAVConnTCPClient> weak_instp);
virtual mavlink::mavlink_status_t get_status()
virtual ~MAVConnTCPClient()
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
std::function< void(const mavlink::mavlink_message_t *message, const Framing framing)> ReceivedCb
void connect(const ReceivedCb &cb_handle_message, const ClosedCb &cb_handle_closed_port=ClosedCb()) override
Establish connection, automatically called by open_url()
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
std::function< void(void)> ClosedCb
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
void do_send(bool check_tx_state)