Opening and closing a connection to an interim data unit

Updated: April 19, 2023

Applications use a handle provided through the Sensor API to access each of the interim data units that are configured in the interim data configuration file.

Opening an interim data unit connection

Similar to how you use logical sensor units, you need to first request a handle to an interim data unit from the Sensor library. Your application uses this handle to make use of a given interim data unit through the Sensor API. To request a handle for an interim data unit, call sensor_interim_data_open(). For example:

int err;
sensor_interim_data_unit_t unit = INTERIM_DATA_UNIT_1;
sensor_handle_t handle = SENSOR_HANDLE_INVALID;
...
err = sensor_interim_data_open(unit, &handle);
...

When you call sensor_interim_data_open(), you must specify the interim data unit. This is the interim data unit that you are requesting the handle for. This unit corresponds to one of the interim data units that are listed in your interim data configuration file. See the Interim Data configuration file section in the System Services guide.

When sensor_interim_data_open() returns successfully, the Sensor library provides you with a handle to the interim data unit in the handle of the function. You can use this handle throughout your application to access the interim data unit.

A publisher uses this handle to publish interim data; a subscriber uses this handle to access the interim data provided by the publisher.

Closing an interim data unit connection

After you are finished using a interim data unit, you must remove the connection so that the Sensor library releases all the resources that it allocated for this interim data unit. To remove a connection to an interim data unit, call sensor_interim_data_close(). For example:

int err;
...
err = sensor_interim_data_close(handle);
...

The handle that you pass in to the sensor_interim_data_close() function must have been a handle that was requested with sensor_interim_data_open().