livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
Loading...
Searching...
No Matches
session.hpp File Reference

Session layer: discovery and synchronous command round-trips with one Mid-360. More...

#include <atomic>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <expected>
#include <optional>
#include <span>
#include <stop_token>
#include <string>
#include <string_view>
#include <vector>
#include "livox/mid360/export.hpp"
#include "livox/mid360/keys.hpp"
#include "livox/mid360/protocol.hpp"
#include "livox/mid360/transport.hpp"

Go to the source code of this file.

Classes

struct  livox::mid360::SessionError
 Error of a Session call or of discover(). Only the fields named by kind are meaningful. More...
struct  livox::mid360::DiscoveredDevice
 One LiDAR that answered the 0x0000 discovery broadcast. More...
struct  livox::mid360::DiscoveryOptions
 Parameters of discover(). More...
struct  livox::mid360::RequestOptions
 Timeout and retry policy of one request. More...
struct  livox::mid360::SessionOptions
 Parameters of Session::connect(). More...
struct  livox::mid360::SessionStats
 Counters of one Session, see Session::stats(). More...
struct  livox::mid360::RawAck
 Result of a raw request: the ACK payload, owned. More...
struct  livox::mid360::InquireResult
 Result of 0x0101: owns the ACK bytes so that values stays valid after moves. More...
class  livox::mid360::Session
 Synchronous command channel to one LiDAR. Move-only. More...

Namespaces

namespace  livox
 Livox LiDAR drivers.
namespace  livox::mid360
 The livox_mid360_core library: everything declared by the public headers.

Enumerations

enum class  livox::mid360::SessionErrorKind : std::uint8_t {
  livox::mid360::kTransport , livox::mid360::kTimeout , livox::mid360::kBadResponse , livox::mid360::kLidarRejected ,
  livox::mid360::kUnexpectedState , livox::mid360::kCancelled , livox::mid360::kInvalidArgument
}
 Category of a SessionError. More...
enum class  livox::mid360::DeviceType : std::uint8_t { livox::mid360::kUnknown , kMid360 }
 Device type named by the dev_type byte of the 0x0000 ACK (#58). More...

Functions

std::string_view livox::mid360::to_string (SessionErrorKind kind) noexcept
 Short snake_case name, e.g. "timeout".
std::string livox::mid360::to_string (const SessionError &err)
 Human readable one-line description.
constexpr DeviceType livox::mid360::to_device_type (std::uint8_t dev_type) noexcept
 Map a raw dev_type byte; every value other than kMid360DevType is kUnknown.
std::string_view livox::mid360::to_string (DeviceType type) noexcept
 "mid360" or "unknown".
std::expected< std::vector< DiscoveredDevice >, SessionError > livox::mid360::discover (const DiscoveryOptions &options={})
 Send 0x0000 and collect ACKs.

Variables

constexpr std::uint8_t livox::mid360::kMid360DevType = 9
 dev_type a Mid-360 reports in the 0x0000 ACK.

Detailed Description

Session layer: discovery and synchronous command round-trips with one Mid-360.

Design (see issue #4):

  • No threads. Every call blocks on the calling thread and drives Poller::wait. A receive thread / Device abstraction is layered on top in phase 2 (#9).
  • Requests are matched by seq_num + cmd_id + source endpoint; retries reuse the same seq_num so that a delayed ACK to an earlier attempt still matches.
  • Errors are std::expected<T, SessionError>; a LiDAR ret_code != 0 is final (never retried), malformed datagrams count as "no response".
  • cancel() may be called from any thread to abort a blocking call.

API stability: this header is expected to change when #9 settles the public API.