31[[nodiscard]]
inline Error Parse(
const std::uint8_t* inf, std::size_t inf_len,
Profile* out)
noexcept {
32 if (inf ==
nullptr || out ==
nullptr) {
39 for (std::size_t i = 0; i < 5U; ++i) {
40 out->vendor_id[i] = inf[1U + i];
42 const std::size_t dllp_len = inf[6];
43 if (7U + dllp_len > inf_len || dllp_len < 4U) {
46 const std::uint8_t* dllp = inf + 7U;
47 out->bwt =
static_cast<std::uint16_t
>((
static_cast<std::uint16_t
>(dllp[0]) << 8U) | dllp[1]);
48 out->ifsc =
static_cast<std::uint16_t
>((
static_cast<std::uint16_t
>(dllp[2]) << 8U) | dllp[3]);
50 std::size_t off = 7U + dllp_len;
51 if (off + 2U > inf_len) {
54 out->plid = inf[off++];
55 const std::size_t plp_len = inf[off++];
56 if (off + plp_len > inf_len || plp_len < 11U) {
59 const std::uint8_t* plp = inf + off;
60 out->max_i2c_khz =
static_cast<std::uint16_t
>((
static_cast<std::uint16_t
>(plp[0]) << 8U) | plp[1]);
62 out->min_poll_ms = plp[3];
63 out->segt_us =
static_cast<std::uint16_t
>((
static_cast<std::uint16_t
>(plp[7]) << 8U) | plp[8]);
64 out->wakeup_us =
static_cast<std::uint16_t
>((
static_cast<std::uint16_t
>(plp[9]) << 8U) | plp[10]);
70 const std::size_t hb_len = inf[off++];
71 if (off + hb_len > inf_len) {
74 out->historical = inf + off;
75 out->historical_len = hb_len;