SessionClient sample application shows the usage of QSH client API to develop applications. By default, this sample application is built in the /usr/bin directory on the device. For a complete code sample, see the <workspace>/build-qcom-wayland/workspace/sources/sensinghub/sensing-hub/examples/SessionClient/SessionClient.cpp file.
The following figure shows the call flow for streaming the accelerometer
sensor and the usage of the QSH client APIs.
Figure: Call flow to stream a specified sensor
-
The SUID query, retrieves SUIDs for the specified sensor:
a. Create an interface for SUID by calling the
getSession()API with the newsessionFactory()class. Requesting the SUID is the first and important request to get SUID of the requested data type for any use case.b. Open a created session interface by calling theopen()API.c. Set callbacks by calling thesetCallBacks()API and handling the response, event, or error for the SUID activity.d. Create and send a Pb-encoded request message for SUID of a specified data type by calling thesendRequest()API.e. Close the session by calling theclose()API and delete it after receiving the SUID events for the requested data type. -
The attribute request, retrieves attributes for the specified sensor:
a. Create an interface session for an attribute by calling
getSession()with the newsessionFactory()class. Requesting the attributes is important to get the capabilities of the requested data type for any use case.b. Open a created session interface by calling theopen()API.c. Set callbacks by callingsetCallBacks()and handling the response, event, or error for the attribute activity.d. Create and send a Pb-encoded configuration request for an attribute of a specified data type by calling thesendRequest()API.e. Close the session by calling theclose()API after receiving the attribute events for the requested data type. -
The sensor streaming, streams the sensor and receives the data events:
a. Create an interface session for streaming the sensor by calling
getSession()with the newsessionFactory()class. Here, requesting sensor data is the final stage of a requested data type for any use case.b. Open a created session interface by calling theopen()API.c. Set callbacks by callingsetCallBacks()and handling the response, event, or error for streaming the activity.d. Create and send a Pb-encoded configuration request for streaming the sensor of a specified data type by calling thesendRequest()API, which eventually allows the requested sensor.e. Handle samples in the event callbacks and wait for the specified duration of the test. -
The stop sensor streaming client, stops streaming by sending a request to disable:
a. Call the
sendRequest()API.b. Close the session by calling theclose()API after receiving the streaming events for the requested data type.
SessionClient sample application
output. It allows an accelerometer sensor with 10 Hz sample rate and a
2-second batch period for 10 sec and prints the received sensor events.

