28 lines
832 B
C++
28 lines
832 B
C++
|
|
#pragma once
|
|||
|
|
|
|||
|
|
#include <vector>
|
|||
|
|
#include <string>
|
|||
|
|
#include <cstdint>
|
|||
|
|
#include "protocol_struct.hpp"
|
|||
|
|
#include "mqtt_config.hpp"
|
|||
|
|
|
|||
|
|
namespace ProtocolCodec
|
|||
|
|
{
|
|||
|
|
// BCC 校验
|
|||
|
|
uint8_t calculate_bcc(const std::vector<uint8_t> &data);
|
|||
|
|
|
|||
|
|
// 编码 FullPacket 为字节流(使用大端)
|
|||
|
|
std::vector<uint8_t> encode_full_packet(const FullPacket &packet);
|
|||
|
|
|
|||
|
|
// 解码字节流为 FullPacket(成功返回 packet,否则 std::nullopt)
|
|||
|
|
std::optional<FullPacket> decode_full_packet(const std::vector<uint8_t> &buffer);
|
|||
|
|
|
|||
|
|
// 构造心跳包
|
|||
|
|
FullPacket create_heartbeat_packet(const std::string &vin);
|
|||
|
|
|
|||
|
|
std::optional<MqttParamSetting> parse_mqtt_param_setting(const std::vector<uint8_t> &data);
|
|||
|
|
|
|||
|
|
std::vector<uint8_t> make_ack_response(const FullPacket &request, bool result);
|
|||
|
|
|
|||
|
|
} // namespace ProtocolCodec
|