27 lines
679 B
C++
27 lines
679 B
C++
#pragma once
|
|
|
|
#include <span>
|
|
|
|
#include "protocol_codec.h"
|
|
#include "tbox_data_manager.h"
|
|
#include "tcp_client_instance.h"
|
|
|
|
struct ReceivedPacket
|
|
{
|
|
uint8_t command_id;
|
|
uint8_t response_flag;
|
|
std::vector<uint8_t> data_unit;
|
|
};
|
|
|
|
inline std::string byte_to_hex(uint8_t v)
|
|
{
|
|
std::ostringstream oss;
|
|
oss << "0x" << std::hex << std::uppercase << std::setw(2) << std::setfill('0') << static_cast<int>(v);
|
|
return oss.str();
|
|
}
|
|
|
|
// 信息上报使用
|
|
std::string build_command_packet(uint8_t command_id, std::span<const uint8_t> payload = {}); // 构建命令包
|
|
|
|
ReceivedPacket process_received_packet(const std::vector<uint8_t>& data); // 解析收到的报文
|