> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs-staging.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# QSH PB Sensor Utils

**Header:** `utils/inc/qshPbSensorUtils.h`

## Structures

### `qshPb::suid_list`

Output context passed to the decode\_suids() nanopb callback.

**Members**

<ParamField path="suids" type="std::vector< suid > *">
  Destination vector for decoded SUIDs.
</ParamField>

<ParamField path="datatype" type="std::string *">
  Destination for the sensor datatype string.
</ParamField>

### `qshPb::attribute`

Holds a single decoded sns\_std\_attr\_value\_data value.

**Members**

<ParamField path="has_subtype" type="bool">
  True if the value is a nested subtype.
</ParamField>

<ParamField path="subtype" type="std::vector< float >">
  Decoded float subtype values.
</ParamField>

<ParamField path="has_str" type="bool">
  True if the value is a string.
</ParamField>

<ParamField path="str" type="std::string">
  Decoded string value.
</ParamField>

<ParamField path="has_flt" type="bool">
  True if the value is a float.
</ParamField>

<ParamField path="flt" type="float">
  Decoded float value.
</ParamField>

<ParamField path="has_sint" type="bool">
  True if the value is a signed integer.
</ParamField>

<ParamField path="sint" type="int64_t">
  Decoded signed integer value.
</ParamField>

<ParamField path="has_boolean" type="bool">
  True if the value is a boolean.
</ParamField>

<ParamField path="boolean" type="bool">
  Decoded boolean value.
</ParamField>

## Functions

### `get_msg_id`

Extract the message ID from a client event stream.

Decodes only the msg\_id field of the first sns\_client\_event\_msg\_sns\_client\_event in stream.

```cpp theme={null}
uint32_t get_msg_id(pb_istream_t stream)
```

**Parameters**

<ParamField path="stream" type="pb_istream_t">
  A copy of the nanopb input stream positioned at the event.
</ParamField>

**Returns**

The decoded message ID, or 0 on failure.

### `decode_suids`

Nanopb repeated-field callback that decodes SUID lookup events.

Expects the stream to contain sns\_client\_event\_msg\_sns\_client\_event records carrying SNS\_SUID\_MSGID\_SNS\_SUID\_EVENT payloads. Appends each discovered SUID to suid\_list::suids and stores the datatype string in suid\_list::datatype.

```cpp theme={null}
bool decode_suids(pb_istream_t *stream, const pb_field_t *field, void **arg)
```

**Parameters**

<ParamField path="stream" type="pb_istream_t *">
  Nanopb input stream.
</ParamField>

<ParamField path="field" type="const pb_field_t *">
  Field descriptor (unused).
</ParamField>

<ParamField path="arg" type="void **">
  Pointer to a suid\_list output context.
</ParamField>

**Returns**

true on success, false on decode error.

### `decode_attribute`

Nanopb repeated-field callback that decodes a single sns\_std\_attr.

Appends the decoded attribute and its values to the sensor\_attributes map passed via arg.

```cpp theme={null}
bool decode_attribute(pb_istream_t *stream, const pb_field_t *field, void **arg)
```

**Parameters**

<ParamField path="stream" type="pb_istream_t *">
  Nanopb input stream.
</ParamField>

<ParamField path="field" type="const pb_field_t *">
  Field descriptor (unused).
</ParamField>

<ParamField path="arg" type="void **">
  Pointer to a sensor\_attributes output map.
</ParamField>

**Returns**

true on success, false on decode error.

### `decode_attributes`

Nanopb repeated-field callback that decodes attribute events.

Expects the stream to contain sns\_client\_event\_msg\_sns\_client\_event records carrying SNS\_STD\_MSGID\_SNS\_STD\_ATTR\_EVENT payloads. Populates the sensor\_attributes map passed via arg.

```cpp theme={null}
bool decode_attributes(pb_istream_t *stream, const pb_field_t *field, void **arg)
```

**Parameters**

<ParamField path="stream" type="pb_istream_t *">
  Nanopb input stream.
</ParamField>

<ParamField path="field" type="const pb_field_t *">
  Field descriptor (unused).
</ParamField>

<ParamField path="arg" type="void **">
  Pointer to a sensor\_attributes output map.
</ParamField>

**Returns**

true on success, false on decode error.

## Type Definitions

### `suid`

Convenience alias for the public session SUID type.

```cpp theme={null}
typedef com::quic::sensinghub::suid suid
```

### `attributes`

A list of attribute values for a single attribute ID.

```cpp theme={null}
typedef std::vector< attribute > attributes
```

### `sensor_attributes`

Map from attribute ID (sns\_std\_attr\_id) to its decoded values.

```cpp theme={null}
typedef std::map< int32_t, attributes > sensor_attributes
```
