activity_state_refresh_parser.h 1.0 KB

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include <cstddef>
  3. #include <cstdint>
  4. #include <span>
  5. namespace sunrise::middleware::bap::activity_message::state_refresh {
  6. /** State-refresh requests use activity message type 18. */
  7. inline constexpr std::uint32_t kMessageType = 18;
  8. /** Two big-endian 32-bit fields form the complete request body. */
  9. inline constexpr std::size_t kEncodedSize = 8;
  10. /** Membership revision and logical bubble index requested by the client. */
  11. struct StateRefresh final {
  12. std::uint32_t membershipRevision{};
  13. std::int32_t bubbleIndex{};
  14. };
  15. /**
  16. * Parses the complete fixed state-refresh request body.
  17. * @param input Activity message body holding exactly 8 bytes.
  18. * @param refresh Cleared first. Filled in only on success.
  19. * @return True only when both big-endian fields are present with no tail.
  20. */
  21. [[nodiscard]] bool parse_state_refresh(std::span<const std::byte> input,
  22. StateRefresh& refresh) noexcept;
  23. } // namespace sunrise::middleware::bap::activity_message::state_refresh