start_activity_host_response.h 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. #pragma once
  2. #include <array>
  3. #include <cstddef>
  4. #include <cstdint>
  5. #include <span>
  6. namespace sunrise::middleware::bap::activity_message::start_activity_host_response {
  7. /** Message type the client accepts, and the fixed field sizes of its body. */
  8. inline constexpr std::uint32_t kMessageType = 10;
  9. inline constexpr std::size_t kSessionIdBytes = 8;
  10. inline constexpr std::size_t kHostInstanceNameBytes = 128;
  11. inline constexpr std::size_t kByteCount = kSessionIdBytes + kHostInstanceNameBytes;
  12. /** Exact fixed message-10 body. The 128-byte tail is preserved without interpretation. */
  13. struct Body final {
  14. std::uint64_t sessionId{};
  15. std::array<std::byte, kHostInstanceNameBytes> hostInstanceName{};
  16. };
  17. /** Encodes one nonzero session id and the complete 128-byte instance-name field. */
  18. [[nodiscard]] bool
  19. encode(const Body& body, std::span<std::byte> output, std::size_t& written) noexcept;
  20. /** Decodes one exact 136-byte body and rejects a zero session id. */
  21. [[nodiscard]] bool decode(std::span<const std::byte> input, Body& body) noexcept;
  22. /** Checks one exact message-10 body without retaining decoded state. */
  23. [[nodiscard]] bool validate(std::span<const std::byte> input) noexcept;
  24. } // namespace sunrise::middleware::bap::activity_message::start_activity_host_response