#pragma once

#ifdef __cplusplus

#include <cstdint>
#include <functional>
#include <string>
#include <vector>

namespace softbus::hardware::interfaces
{

struct Frame
{
    std::vector<std::uint8_t> payload;
    std::uint32_t             id{0};       // 如 CAN ID
    std::uint64_t             timestamp{0};
};

// 面向帧设备（如 CAN 总线）的统一驱动接口
class IFrameDriver
{
public:
    using FrameCallback = std::function<void(const Frame&)>;
    using ErrorCallback = std::function<void(const std::string& message)>;

    virtual ~IFrameDriver() = default;

    virtual bool Open(const std::string& endpoint) = 0;
    virtual void Close() = 0;

    virtual bool WriteFrame(const Frame& frame) = 0;

    virtual void SetFrameCallback(FrameCallback cb) = 0;
    virtual void SetErrorCallback(ErrorCallback cb) = 0;
};

} // namespace softbus::hardware::interfaces

#endif // __cplusplus

