# Sensor Management Service

- API reference

Components need access to the TelAF Sensor Management Service to get information about available sensors and acquire data from these sensors.

## IPC interfaces binding

The functions of this API are provided by the **tafImuSensorSvc** application service.

The following example illustrates how to bind to Sensor services.

bindings:
     {
         clientExe.clientComponent.taf_imuSensor -> tafImuSensorSvc.taf_imuSensor
     }
    Copy to clipboard

The Sensor Management Service provides multi-client safe APIs. An API call from a client thread (main or sub thread) will be treated as a new session in sensor service. The client needs to connect the sensor service by API taf\_imuSensor\_ConnectService(), setting specific settings if required (else default settings will be applied), activating the sensor by API taf\_imuSensor\_Activate() and adding handler taf\_imuSensor\_AddDataHandler(). The taf\_imuSensor\_AddDataHandler() is used by the client to register a handler to be triggered from the service when there’s the sensor data calculated. The client can get sensor data/information in the same thread until the client disconnects from sensor service. The previous data and setting shall not presist for next run/iteration if client thread exits.

**NOTE:** Each time client creates a new thread, it needs to connect, call, taf\_imuSensor\_AddDataHandler(), taf\_imuSensor\_Activate() for the new session to setup.

## Get available sensors

TelAF Sensor Management Service provides APIs to get the available sensors on the device. The client calls taf\_imuSensor\_GetSensorList() to get the reference of the available sensors. This function returns a taf\_imuSensor\_SensorListRef\_t that can be later used to get the information of each sensor and also to delete the list using taf\_imuSensor\_DeleteSensorList().

**NOTE:** If the sensor type is ACCELEROMETER, the resolution value should be in meter per second per second and if sensor type is GYROSCOPE then values should be in radians per second.

le_result_t result;
      taf_sensor_SensorListRef_t listRef = taf_imuSensor_GetSensorList();
      taf_sensor_SensorListRef_t headTSensorListRef = listRef;
      taf_sensor_SensorRef_t sensorRef = taf_imuSensor_GetFirstSensor(listRef);
      while(sensorRef != NULL)
      {
          uint32_t id;
          char sensorName[50];
          char sensorVendorName[50];
          taf_sensor_SensorType_t sensorType;
          char version[10];
          result = taf_imuSensor_GetId(sensorRef,&id);
          result = taf_imuSensor_GetName(sensorRef,sensorName,sizeof(sensorName));
          result = taf_imuSensor_GetVendorName(sensorRef,sensorVendorName,sizeof(sensorVendorName));
          result = taf_imuSensor_GetType(sensorRef,&sensorType);
          result = taf_imuSensor_GetVersion(sensorRef,version,sizeof(version));
    
          double sampleRateList[TAF_SENSOR_MAX_NUM_SUPPORTED_SAMPLE_RATE];
          size_t size = sizeof(sampleRateList)/sizeof(double);
          result = taf_imuSensor_GetSupportedSamplingRate(sensorRef,sampleRateList,&size);
    
          uint32_t maxBatchCount;
          uint32_t minBatchCount;
          result = taf_imuSensor_GetSupportedBatchCount(sensorRef,&maxBatchCount,&minBatchCount);
    
          double range;
          result = taf_imuSensor_GetRange(sensorRef,&range);
    
          double resolution;
          result = taf_imuSensor_GetResolution(sensorRef,&resolution);
    
          sensorRef = taf_imuSensor_GetNextSensor(listRef);
    
      }
      result = taf_imuSensor_DeleteSensorList(headTSensorListRef)
    Copy to clipboard

## Set reference coordinate system by euler angle

TelAF Sensor Management Service provides APIs to set the reference coordinate system by euler angle to get rotated sensor data. The client calls taf\_imuSensor\_SetRefCoordinateByEulerAngle() to set the euler angle for new reference coordinate system of the whole IMU. This function takes four input parameters. The First is the sensor reference, due to the underlying layer constrains, the setting for individual sensor is not supported, this parameter is ignored currently. The second is pitch, which is rotation around the x axis.The third is roll, which is rotation around the y axis. The fourth is yaw, which is rotation around the z axis. The values of pitch, roll, and yaw should be in the range of [0,360] degrees.

le_result_t result;
      double pitch = 90, roll = 90, yaw = 90;
      result = taf_imuSensor_SetRefCoordinateByEulerAngle(NULL,pitch, roll, yaw);
    Copy to clipboard

## Set configuration and activate the sensor

TelAF Sensor Management Service provides APIs to set configuration of sensor and activate the sensor to get sensor data. The client calls taf\_imuSensor\_Activate() to configure and activate the sensor. This function takes four input parameters. The first is sensor reference. The second is the sampling rate which should be one of the supported sampling rates coming from taf\_imuSensor\_GetSupportedSamplingRate().The third is the batch count which should be between the maximum and minimum batch count getting from taf\_imuSensor\_GetSupportedBatchCount().

le_result_t result;
      double samplingRate = 104.00;
      uint32 batchCount = 50;
      le_result_t result  =  taf_imuSensor_Activate(sensorRef,samplingRate,batchCount);
    Copy to clipboard

taf\_imuSensor\_AddDataHandler() and taf\_imuSensor\_RemoveDataHandler() are used for the client application to register or unregister the handler to subscribe or unsubscribe the notification when there is a sensor data calculated.

void TestSensorOnEventFunc(taf_imuSensor_SampleRef_t sampleRef,
          const taf_imuSensor_DataValue_t* rawData,  size_t rawDataCount,
          const taf_imuSensor_DataValue_t* biasData, size_t biasDataCount,
          void* contextPtr)
      {
          // Use the data and then free server-side sample ref
          result = taf_imuSensor_DeleteData(sampleRef);
      }
      taf_imuSensor_SensorListRef_t listRef = taf_imuSensor_GetSensorList();
      taf_imuSensor_SensorRef_t sensorRef = taf_imuSensor_GetFirstSensor(listRef);
      taf_sensor_DataHandlerRef_t eventHandlerRef;
      eventHandlerRef = taf_imuSensor_AddDataHandler(config->sensorRef,
                                                           TestSensorOnEventFunc, sensorRef);
      taf_imuSensor_RemoveDataHandler(eventHandlerRef);
    Copy to clipboard

The application has to release each sensor sample list received by the handler, using the taf\_imuSensor\_DeleteData() triggered inside the TestSensorOnEventFunc() function.

## Initiate self test

TelAF Sensor Management Service provides APIs to test whether the sensor is working properly or not. The client calls taf\_imuSensor\_SelfTest() to initiate test. This function takes three input parameters. The first is sensor reference. The second is mode of test. The third is timestamp at which test is performed.

uint64_t timestamp =0;
      le_result_t result = taf_imuSensor_SelfTest(sensorRef,TAF_IMUSENSOR_POSITIVE,&timestamp);
    Copy to clipboard

The taf\_imuSensor\_AddSelfTestFailedHandler is used by client to register handler to be triggered by service when a sensor fails in voluntary self test.

void TestSensorFailedEvent(taf_imuSensor_SelfTestEventRef_t eventRef,
          taf_imuSensor_SensorRef_t sensorRef,uint64_t timestamp,
          void* contextPtr){
          char sensorName[50];
          le_result_t result = taf_imuSensor_GetName(sensorRef,sensorName,sizeof(sensorName));
      }
    
      taf_imuSensor_SelfTestFailedHandlerRef_t selfTestHandlerRef;
      selfTestHandlerRef =
          taf_imuSensor_AddSelfTestFailedHandler(sensorRef,TestSensorFailedEvent,NULL);
      taf_imuSensor_RemoveSelfTestFailedHandler(selfTestHandlerRef);
    Copy to clipboard

Last Published: May 11, 2026

Previous Topic
 
Health Monitor Service Next Topic

Key Store Service