# Standard

## Client API

This header file defines the types and structures that were defined in SNS\_CLIENT\_SVC. It contains the constant values defined, enums, structures, messages, and service message IDs (in that order) Structures that were defined in the IDL as messages contain mandatory elements, optional elements, a combination of mandatory and optional elements (mandatory always come before optionals in the structure), or nothing (null message)

An optional element in a message is preceded by a uint8\_t value that must be set to true if the element is going to be included. When decoding a received message, the uint8\_t values will be set to true or false by the decode routine, and should be checked before accessing the values that they correspond to.

Variable sized arrays are defined as static sized arrays with an unsigned integer (32 bit) preceding it that must be set to the number of elements in the array that are valid. For Example:

uint32\_t test\_opaque\_len; uint8\_t test\_opaque[16];

If only 4 elements are added to test\_opaque[] then test\_opaque\_len must be set to 4 before sending the message. When decoding, the \_len value is set by the decode routine and should be checked so that the correct number of elements in the array will be accessed.

- struct sns\_client\_req\_msg\_v01

    - Request Message; Send a query to the Sensors subsystem. An immediate response will always be sent, indicating the request receipt.

Public Members

- uint32\_t payload\_len

    - Must be set to # of elements in payload

- uint8\_t payload[SNS\_CLIENT\_REQ\_LEN\_MAX\_V01]

    - Protocol Buffer encoded request message buffer; see sns\_client.proto for a list of available request messages.

- uint8\_t use\_jumbo\_report\_valid

    - Must be set to true if use\_jumbo\_report is being passed

- uint8\_t use\_jumbo\_report

    - Default: False. If false, clients will receive all single and batched events only within sns\_client\_report\_ind\_msg. Individual events larger than SNS\_CLIENT\_REPORT\_LEN\_MAX will be dropped and not sent; batches of events will be split to fit. If true, enables service to use indication message sns\_client\_jumbo\_report\_ind\_msg; events may be sent within either indication message. The payload size is only guaranteed to be less than SNS\_CLIENT\_JUMBO\_REPORT\_LEN\_MAX.

- struct sns\_client\_resp\_msg\_v01

    - Response Message; Send a query to the Sensors subsystem. An immediate response will always be sent, indicating the request receipt.

Public Members

- qmi\_response\_type\_v01 resp

    - 

- uint8\_t client\_id\_valid

    - Must be set to true if client\_id is being passed

- uint64\_t client\_id

    - Client ID identifies the client connection. Generated by service, and returned in all sns\_client\_report\_ind\_msg. Will be the same value in all sns\_client\_resp\_msg/sns\_client\_report\_ind\_msg for this client connection.

- uint8\_t result\_valid

    - Must be set to true if result is being passed

- uint32\_t result

    - Result status of the request; see sns\_pb\_error\_type

- struct sns\_client\_report\_ind\_msg\_v01

    - Indication Message; Report containing one or more Sensor-generated events

Public Members

- uint64\_t client\_id

    - Client ID identifies the client connection.

- uint32\_t payload\_len

    - Must be set to # of elements in payload

- uint8\_t payload[SNS\_CLIENT\_REPORT\_LEN\_MAX\_V01]

    - Protocol Buffer encoded event message buffer; see sns\_client.proto for for a list of possible event messages/formats.

- struct sns\_client\_jumbo\_report\_ind\_msg\_v01

    - Indication Message; Report containing one or more Sensor-generated events

Public Members

- uint64\_t client\_id

    - Client ID identifies the client connection.

- uint32\_t payload\_len

    - Must be set to # of elements in payload

- uint8\_t payload[SNS\_CLIENT\_JUMBO\_REPORT\_LEN\_MAX\_V01]

    - Protocol Buffer encoded event message buffer; see sns\_client.proto for for a list of possible event messages/formats.

## Client Proto

## Message IDs: Message IDs uniquely identify a particular message among all messages supported by a Sensor, both requests and events. IDs are subdivided into reserved pools as shown below.

*Reserved for Framework use only:*

Note: Message IDs in these ranges are common to all Sensors. 0-127 - Request Messages 128-255 - Non-recurrent events (e.g configuration updates, infrequent sensor samples) 256-511 - Recurrent and/or periodic events (e.g. sensor samples)

*Sensor use:*

Note: Message IDs in these ranges may not be common among different Sensor data types. Both the data type and message ID is necessary to uniquely identify a message. 512-767 - Request messages 768-1023 - Non-recurrent events (e.g configuration updates, infrequent sensor samples) 1024-1536 - Recurrent and/or periodic events (e.g. sensor samples)

Enums

- enum sns\_client\_msgid

    - Framework defined message IDs:

*Values:*

- enumerator SNS\_CLIENT\_MSGID\_SNS\_CLIENT\_DISABLE\_REQ

    - Request to disable client Message : Empty.

- enum sns\_client\_delivery

    - Delivery configuration.

*Values:*

- enumerator SNS\_CLIENT\_DELIVERY\_WAKEUP

    - 

- enumerator SNS\_CLIENT\_DELIVERY\_NO\_WAKEUP

    -

- struct sns\_resampler\_client\_config

    - Public Members

- required sns\_resampler\_rate rate\_type

    - Resampler rate type.

- required bool filter

    - Set to true to enable alias filtering.

- struct sns\_threshold\_client\_config

    - Public Members

- required sns\_threshold\_type threshold\_type

    - Threshold type.

- repeated float threshold\_val

    - The threshold value per data field.

The number of threshold values must be less than or equal to the number of sensor data fields. Thresholding can be disabled for specific fields by setting corresponding values to FLT\_MAX.

- SNS\_THRESHOLD\_TYPE\_RELATIVE\_VALUE and SNS\_THRESHOLD\_TYPE\_ABSOLUTE, units for threshold\_val are the same as the sensor data.
- SNS\_THRESHOLD\_TYPE\_RELATIVE\_PERCENT, threshold\_val is in percentage.
- SNS\_THRESHOLD\_TYPE\_ANGLE, an angle in radians between current and last reported quaternions must be provided.

- struct sns\_client\_request\_msg

    - - struct suspend\_config

    - Public Members

- required sns\_std\_client\_processor client\_proc\_type [default=SNS\_STD\_CLIENT\_PROCESSOR\_APSS]

    - Processor on which the client resides; When sending data to any client on a particular processor, all clients on that processor will receive batched data.

- required sns\_client\_delivery delivery\_type [default=SNS\_CLIENT\_DELIVERY\_WAKEUP]

    - Delivery configuration.

- repeated fixed32 nowakeup\_msg\_ids

    - List of message Ids which should not wakeup client processor from suspend even if the delivery type is set to SNS\_CLIENT\_DELIVERY\_WAKEUP.

Public Members

- required sns\_std\_suid suid

    - SUID of the requested Sensor.

- required fixed32 msg\_id

    - Msg Id of the request message as defined in the Sensor’s API.

- required suspend\_config susp\_config

    - The suspend config.

- required sns\_std\_request request

    - Base message payload; contents are specified in sns\_std.proto and by the requested Sensor API.

- optional sns\_resampler\_client\_config resampler\_config

    - Resampler configuration for the requested sensor.

- optional sns\_threshold\_client\_config threshold\_config

    - Threshold configuration for the requested sensor.

- optional sns\_tech client\_tech

    - Client technology.

- struct sns\_client\_event\_msg

    - - struct sns\_client\_event

    - Public Members

- required fixed32 msg\_id

    - Msg Id of the event as defined in the Sensor API.

- required fixed64 timestamp

    - Timestamp, typically in clock ticks, associated with this event.

For events generated by the Framework (such as configuration updates or error events), this timestamp refers to the time at which the event was created. For most events this timestamp is specified by the Sensor. For example, many Sensors define the timestamp as the time at which the data was sampled.

- required bytes payload

    - Payload containing the data/event from the requested Sensor. This payload will need to be decoded using definition in the requested Sensor API.

Public Members

- required sns\_std\_suid suid

    - SUID of the requested sensor.

- repeated sns\_client\_event events

    -

## Direct Channel

## To activate a Sensor Stream on a new Direct Channel:

1. Client must first create a channel using [sns\_direct\_channel\_create\_msg](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__direct__channel__create__msg).
2. Client may then optionally send a [sns\_direct\_channel\_set\_ts\_offset](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__direct__channel__set__ts__offset) as part of [sns\_direct\_channel\_config\_msg](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__direct__channel__config__msg) to set timestamp offset for this channel. The offset will be added to timestamps of all Sensor samples delivered on this channel.
3. Client must then send [sns\_direct\_channel\_set\_client\_req](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__direct__channel__set__client__req) as part of [sns\_direct\_channel\_config\_msg](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__direct__channel__config__msg) to start streaming the required Sensor on this channel.
4. An ongoing Sensor stream can be reconfigured by resending the [sns\_direct\_channel\_set\_client\_req](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__direct__channel__set__client__req) with updated settings for the Sensor.
5. If Channel type is DIRECT\_CHANNEL\_TYPE\_STRUCTURED\_MUX\_CHANNEL, Client may stream additional Sensors on the same channel by sending additional [sns\_direct\_channel\_set\_client\_req](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__direct__channel__set__client__req) messages.
6. Client may remove an existing Sensor stream on a channel by sending [sns\_direct\_channel\_remove\_client\_req](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__direct__channel__remove__client__req) as part of [sns\_direct\_channel\_config\_msg](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__direct__channel__config__msg) for the Sensor.

    ## To read the sensor data from shared buffer and to deliver the data to the Algorithm/Sensor:

1. The client must first create a channel by sending a [sns\_direct\_channel\_create\_msg](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__direct__channel__create__msg), followed by a [sns\_direct\_channel\_set\_read\_config](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__direct__channel__set__read__config) message to configure channel for read operation.
2. Algorithm or sensor that requires data from the shared buffer must send request to direct channel sensor as defined in sns\_direct\_channel\_sensor.proto.

Enums

- enum sns\_direct\_channel\_msgid

    - Direct channel defined Message IDs.

*Values:*

- enumerator SNS\_DIRECT\_CHANNEL\_MSGID\_SNS\_GENERIC\_CHANNEL\_LATENCY\_MSG

    - Generic Channel Latency Event. Message: [sns\_generic\_channel\_latency\_msg](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__generic__channel__latency__msg).

- enum direct\_channel\_type

    - Direct Channel Type.

*Values:*

- enumerator DIRECT\_CHANNEL\_TYPE\_STRUCTURED\_MUX\_CHANNEL

    - Sensor data on this channel is of type sensors\_event\_t as defined by the Android Open Source Project. Sensor data from multiple streams can be multiplexed in one channel.

- enumerator DIRECT\_CHANNEL\_TYPE\_GENERIC\_CHANNEL

    - Sensor data on this channel is in the format defined in the Sensor’s proto API. Channel only supports a single stream of Sensor data.

- enum sns\_direct\_channel\_mode

    - Direct channel mode of operation.

*Values:*

- enumerator DIRCT\_CHANNEL\_MODE\_INVALID

    - Invalid channel mode, channel creation fails if the client chooses the mode.

- enumerator DIRCT\_CHANNEL\_MODE\_WRITE

    - Channel to set it up in write mode.

- enumerator DIRCT\_CHANNEL\_MODE\_READ

    - Channel to set it up in read mode.

- struct sns\_direct\_channel\_stream\_id

    - Public Members

- required sns\_std\_suid suid

    - SUID of the requested Sensor.

- optional bool calibrated [default=true]

    - if set to true, auto calibrated data is generated if set to false, factory calibrated data is generated

- optional bool resampled [default=true]

    - if set to true, resampled data is generated at a rate which is at most twice the requested rate if set to false, data is generated at the rate defined by SNS\_STD\_SENSOR\_ATTRID\_RATES, SNS\_STD\_SENSOR\_ATTRID\_ADDITIONAL\_LOW\_LATENCY\_RATES attributes for the Sensor.

- struct sns\_direct\_channel\_create\_msg

    - - struct shared\_buffer\_config

    - Public Members

- required fixed32 fd

    - File descriptor to the shared memory buffer.

- required fixed32 size

    - Size of the buffer.

Public Members

- required shared\_buffer\_config buffer\_config

    - shared buffer config

- required direct\_channel\_type channel\_type

    - Type of channel.

- optional sns\_std\_client\_processor client\_proc [default=SNS\_STD\_CLIENT\_PROCESSOR\_APSS]

    - Processor on which the client resides.

- optional sns\_direct\_channel\_mode mode [default=DIRCT\_CHANNEL\_MODE\_WRITE]

    - Channel mode of operation. Read operation supported only in Generic channel.

- optional uint32 interrupt\_id

    - Client to supply the IPCC interrupt id, if the channel is configured for interrupt mode.

- struct sns\_direct\_channel\_set\_client\_req

    - - struct structured\_mux\_channel\_stream\_attributes

    - Public Members

- required fixed32 sensor\_handle

    - Sensor ID for requested Sensor as defined by the Android Open Source Project. This value will be populated in the “sensor\_event\_t::sensor” field for the events delivered from this Sensor.

- required fixed32 sensor\_type

    - Sensor Type for requested Sensor as defined by the Android Open Source Project. This value will be populated in the “sensor\_event\_t::type” field for the events delivered from this Sensor.

Public Members

- required fixed32 msg\_id

    - Msg Id of the Request message as defined in the Sensor’s API.

- required sns\_direct\_channel\_stream\_id stream\_id

    - Sensor Stream Configuration.

- required sns\_std\_request request

    - Request message as specified in sns\_std.proto and the Sensor’s API.

- optional structured\_mux\_channel\_stream\_attributes attributes

    - MUX Stream Attributes.

- struct sns\_direct\_channel\_remove\_client\_req

    - Public Members

- required sns\_direct\_channel\_stream\_id stream\_id

    -

- struct sns\_direct\_channel\_set\_ts\_offset

    - Clients requiring timestamps in the Client Processor Time Domain may use this message to convey the offset with Sensing Hub Time Domain. This offset will be added to the Sensing Hub timestamps of all Sensor samples delivered on the channel.

Public Members

- required fixed64 ts\_offset

    - Timestamp offset in clock ticks.

- struct sns\_direct\_channel\_set\_read\_config

    - Public Members

- optional sns\_direct\_channel\_stream\_id stream\_id

    - Only SUID from the stream\_id structure is required for read configuration.

- struct sns\_direct\_channel\_config\_msg

    - - union channel\_config\_msg\_payload

    - Public Members

- [sns\_direct\_channel\_set\_client\_req](https://docs.qualcomm.com/doc/80-P9361-100/topic/client.html#_CPPv433sns_direct_channel_set_client_req) set\_client\_req

    - 

- [sns\_direct\_channel\_remove\_client\_req](https://docs.qualcomm.com/doc/80-P9361-100/topic/client.html#_CPPv436sns_direct_channel_remove_client_req) remove\_client\_req

    - 

- [sns\_direct\_channel\_set\_ts\_offset](https://docs.qualcomm.com/doc/80-P9361-100/topic/client.html#_CPPv432sns_direct_channel_set_ts_offset) set\_ts\_offset

    - 

- [sns\_direct\_channel\_set\_read\_config](https://docs.qualcomm.com/doc/80-P9361-100/topic/client.html#_CPPv434sns_direct_channel_set_read_config) set\_read\_config

    -

- struct sns\_generic\_channel\_latency\_msg

    - Latency is measured as the difference between the time when the sample is written to channel buffer and the sample measurement time.

Public Members

- required fixed64 sample\_count

    - Number of samples associated with this measurement.

- required fixed64 max\_latency\_ts

    - Measurement timestamp of sample with maximum latency Units: nano-seconds.

- required fixed32 max\_latency

    - Maximum latency measured across all samples in sample\_count Units: micro-seconds.

- required fixed32 avg\_latency

    - Average latency calculated across all samples in sample\_count Units: micro-seconds.

## Qsocket

Module for managing all qsocket based connections for the framework.

- struct sns\_client\_qsocket\_config\_req

    - 

- struct sns\_client\_qsocket\_config\_resp

    - Public Members

- optional fixed32 max\_req\_size

    - Max supported size of the encoded request message in bytes.

- optional fixed32 max\_ind\_size

    - Max supported size of the encoded indication message in bytes.

- struct sns\_client\_qsocket\_req

    - Public Members

- required sns\_client\_request\_msg request

    - Base message payload.

- required fixed32 request\_id

    - Request ID will be returned in [sns\_client\_qsocket\_resp::request\_id](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__client__qsocket__resp_1afd0fa9b83c4d136997a0b72013dd92c1).

- struct sns\_client\_qsocket\_resp

    - Public Members

- required fixed64 client\_id

    - Client ID identifies the client connection.

- required fixed32 request\_id

    - Request ID as provided in [sns\_client\_qsocket\_req::request\_id](https://docs.qualcomm.com/doc/80-P9361-100/topic/standard.html#structsns__client__qsocket__req_1a2830a605f68378f9e3d48cb4d983bf7d).

- required sns\_std\_error error

    - Error Response:

1. SNS\_STD\_ERROR\_NO\_ERROR
2. SNS\_STD\_ERROR\_INVALID\_TYPE - Received an unknown request message
3. SNS\_STD\_ERROR\_INVALID\_VALUE - Request message exceeded size requirements
4. SNS\_STD\_ERROR\_NOT\_SUPPORTED - Sensor received an unsupported request; or a supported request at an unexpected time.

- struct sns\_client\_qsocket\_ind

    - Public Members

- required fixed64 client\_id

    - Client ID identifies the client connection.

- required sns\_client\_event\_msg event

    - Event message contents.

- struct sns\_client\_qsocket\_msg

    - - union msg

    - Public Members

- [sns\_client\_qsocket\_req](https://docs.qualcomm.com/doc/80-P9361-100/topic/client.html#_CPPv422sns_client_qsocket_req) req

    - 

- [sns\_client\_qsocket\_resp](https://docs.qualcomm.com/doc/80-P9361-100/topic/client.html#_CPPv423sns_client_qsocket_resp) resp

    - 

- [sns\_client\_qsocket\_ind](https://docs.qualcomm.com/doc/80-P9361-100/topic/client.html#_CPPv422sns_client_qsocket_ind) ind

    - 

- [sns\_client\_qsocket\_config\_req](https://docs.qualcomm.com/doc/80-P9361-100/topic/client.html#_CPPv429sns_client_qsocket_config_req) config\_req

    - 

- [sns\_client\_qsocket\_config\_resp](https://docs.qualcomm.com/doc/80-P9361-100/topic/client.html#_CPPv430sns_client_qsocket_config_resp) config\_resp

    -

Last Published: Jul 14, 2025

[Previous Topic
sns\_remote\_proc\_state\_set\_time\_offset()](https://docs.qualcomm.com/bundle/publicresource/80-P9361-100/topics/skel.md) [Next Topic
Session Management](https://docs.qualcomm.com/bundle/publicresource/80-P9361-100/topics/isession.md)