# Sensor Management Service

- [API reference](https://docs.qualcomm.com/doc/80-41102-2/topic/_doxygen_rst_file__doxygen_sources_taf_imuSensor_interface_h.html#file-taf-imusensor-interface-h)

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()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1ac89b0ac2d1ffb707fc4b3f0a9402484a.html#Documentationa00518_1ac89b0ac2d1ffb707fc4b3f0a9402484a), setting specific settings if required (else default settings will be applied), activating the sensor by API [taf\_imuSensor\_Activate()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1a5640c800c0125b03ee169ef74c947e43.html#Documentationa00518_1a5640c800c0125b03ee169ef74c947e43) and adding handler [taf\_imuSensor\_AddDataHandler()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1ad3646362e0cc592eab3d1c99d717f792.html#Documentationa00518_1ad3646362e0cc592eab3d1c99d717f792). The [taf\_imuSensor\_AddDataHandler()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1ad3646362e0cc592eab3d1c99d717f792.html#Documentationa00518_1ad3646362e0cc592eab3d1c99d717f792) 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()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1ad3646362e0cc592eab3d1c99d717f792.html#Documentationa00518_1ad3646362e0cc592eab3d1c99d717f792), [taf\_imuSensor\_Activate()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1a5640c800c0125b03ee169ef74c947e43.html#Documentationa00518_1a5640c800c0125b03ee169ef74c947e43) 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()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1a9f1c93d7b3744e22925c2b5ed31fdb00.html#Documentationa00518_1a9f1c93d7b3744e22925c2b5ed31fdb00) to get the reference of the available sensors. This function returns a [taf\_imuSensor\_SensorListRef\_t](https://docs.qualcomm.com/doc/80-41102-2/topic/typedef_a00515_1a09a87cf4782071184b230768ba4b9d66.html#Documentationa00515_1a09a87cf4782071184b230768ba4b9d66) that can be later used to get the information of each sensor and also to delete the list using [taf\_imuSensor\_DeleteSensorList()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1a96d57b66e982aaa7f937476e471fa0cc.html#Documentationa00518_1a96d57b66e982aaa7f937476e471fa0cc).

**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()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1a85a3469737d50b3f13007a581d5611a8.html#Documentationa00518_1a85a3469737d50b3f13007a581d5611a8) 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()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1a5640c800c0125b03ee169ef74c947e43.html#Documentationa00518_1a5640c800c0125b03ee169ef74c947e43) 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()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1a953a5145749f1f8bfe896cb793d3c171.html#Documentationa00518_1a953a5145749f1f8bfe896cb793d3c171).The third is the batch count which should be between the maximum and minimum batch count getting from [taf\_imuSensor\_GetSupportedBatchCount()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1aa99eb81599d76678c8ff21a40f3ca4bc.html#Documentationa00518_1aa99eb81599d76678c8ff21a40f3ca4bc).

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()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1ad3646362e0cc592eab3d1c99d717f792.html#Documentationa00518_1ad3646362e0cc592eab3d1c99d717f792) and [taf\_imuSensor\_RemoveDataHandler()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1afacf54789930a2930de936689ec533c1.html#Documentationa00518_1afacf54789930a2930de936689ec533c1) 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()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1ad540845828a77f403f2d732175933043.html#Documentationa00518_1ad540845828a77f403f2d732175933043) 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()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1a5aefae285587af7b951a7c9190599208.html#Documentationa00518_1a5aefae285587af7b951a7c9190599208) 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

## Subscribe configuration update notifications

TelAF Sensor Management Service provides APIs to receive notifications when the active sensor configuration changes. The client calls [taf\_imuSensor\_AddConfigUpdateHandler()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1aa1ade1c731b31362bf6556446b60a34c.html#Documentationa00518_1aa1ade1c731b31362bf6556446b60a34c) to register a callback that is triggered by the service whenever the sensor’s sampling rate, batch count, or rotation setting is updated (e.g., after a successful [taf\_imuSensor\_Activate()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1a5640c800c0125b03ee169ef74c947e43.html#Documentationa00518_1a5640c800c0125b03ee169ef74c947e43) call). The handler receives the new sampling rate (Hz), batch count, and a flag indicating whether data rotation is active. The client must call [taf\_imuSensor\_RemoveConfigUpdateHandler()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1a6a562ffbf268e158ce00dea0e81129fc.html#Documentationa00518_1a6a562ffbf268e158ce00dea0e81129fc) to unregister the handler when notifications are no longer needed.

void OnConfigUpdate(taf_imuSensor_SensorRef_t sensorRef,
          double samplingRate, uint32_t batchCount, bool isRotated, void* contextPtr)
      {
          char sensorName[50];
          taf_imuSensor_GetName(sensorRef, sensorName, sizeof(sensorName));
          LE_INFO("ConfigUpdate for %s: rate=%.2f Hz, batch=%u, rotated=%d",
                  sensorName, samplingRate, batchCount, (int)isRotated);
      }
    
      taf_imuSensor_ConfigUpdateHandlerRef_t configUpdateHandlerRef;
      configUpdateHandlerRef =
          taf_imuSensor_AddConfigUpdateHandler(sensorRef, OnConfigUpdate, NULL);
      taf_imuSensor_RemoveConfigUpdateHandler(configUpdateHandlerRef);
    Copy to clipboard

## Subscribe capability update notifications

TelAF Sensor Management Service provides APIs to receive notifications when the sensor capability status changes. The client calls [taf\_imuSensor\_AddCapabilityUpdateHandler()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1a6c99d948037bc5e1288add6339de512d.html#Documentationa00518_1a6c99d948037bc5e1288add6339de512d) to register a callback that is triggered by the service whenever the sensor’s availability, enabled state, or capability bitmask are updated. If the underlying platform adaptor does not support capability notifications, the service immediately delivers a synthetic notification with the current sensor state upon handler registration. The client must call [taf\_imuSensor\_RemoveCapabilityUpdateHandler()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00518_1a145582905d783f731fba34b19ade65f5.html#Documentationa00518_1a145582905d783f731fba34b19ade65f5) to unregister the handler when notifications are no longer needed.

void OnCapabilityChange(taf_imuSensor_SensorRef_t sensorRef,
          bool isAvailable, bool isEnabled, uint32_t capabilityMask, void* contextPtr)
      {
          char sensorName[50];
          taf_imuSensor_GetName(sensorRef, sensorName, sizeof(sensorName));
          LE_INFO("Capability for %s: available=%d, enabled=%d, mask=0x%08X",
                  sensorName, (int)isAvailable, (int)isEnabled, capabilityMask);
      }
    
      taf_imuSensor_CapabilityUpdateHandlerRef_t capabilityHandlerRef;
      capabilityHandlerRef =
          taf_imuSensor_AddCapabilityUpdateHandler(sensorRef, OnCapabilityChange, NULL);
      taf_imuSensor_RemoveCapabilityUpdateHandler(capabilityHandlerRef);
    Copy to clipboard

Last Published: Jun 09, 2026

[Previous Topic
Health Monitor Service](https://docs.qualcomm.com/bundle/publicresource/80-41102-2/topics/page_c_tafhms.md) [Next Topic
Key Store Service](https://docs.qualcomm.com/bundle/publicresource/80-41102-2/topics/page_c_tafKeyStore.md)