Newer
Older
casic_unitree_dog / src / tcp_service.hpp
//
// Created by casic on 25-2-25.
//

#ifndef TCP_SERVICE_HPP
#define TCP_SERVICE_HPP

#include <vector>
#include <boost/asio.hpp>

using boost::asio::serial_port_base;

class TcpService {
public:
    explicit TcpService(boost::asio::io_context &io_context, const std::string &port_name, int baud_rate);

    void start(int port);

    void init_serial_port(const std::string &port_name, int baud_rate);

private:
    int _socket_fd;
    boost::asio::io_context &_context;
    boost::asio::serial_port _port;

    void handle_data_packet(std::vector<uint8_t> &data);

    void handle_client(int client_socket);
};


#endif //TCP_SERVICE_HPP