Snapdragon® Telematics Application Framework (TelAF) Interface Specification
Thermal Management Service

API Reference


Components need access to the TelAF Thermal Manager to get information about present thermal zones and cooling devices.

IPC interfaces binding

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

The following example illustrates how to bind to Therm services.

  bindings:
  {
      clientExe.clientComponent.taf_therm -> tafThermSvc.taf_therm
  }

Get the available thermal zone information

TelAF Thermal Manager Service provides APIs to know the available thermal zones on the device. TelAF Thermal Manager's client calls taf_therm_GetThermalZonesList() to get the reference of the available thermal zones. This function returns a taf_therm_ThermalZoneListRef_t that can be later used to get the information of each thermal zone, and also to delete the list reference using taf_therm_DeleteThermalZoneList().

Note
The following APIs are supported only on SA525M devices: a. taf_therm_GetTripPointTripID() b. taf_therm_GetTripPointThermalZoneID() c. taf_therm_GetBoundTripPointTripID() d. taf_therm_GetBoundTripPointThermalZoneID()
    le_result_t result;
    taf_therm_ThermalZoneListRef_t tZoneListRef = taf_therm_GetThermalZonesList();
    if (tZoneListRef == NULL)
        return;
    taf_therm_ThermalZoneListRef_t headTZoneListRef = tZoneListRef;

    taf_therm_ThermalZoneRef_t tZone = taf_therm_GetFirstThermalZone(tZoneListRef);
    uint32_t thermalZoneListSize;
    result = taf_therm_GetThermalZonesListSize(tZoneListRef, &thermalZoneListSize);

    while (tZone != NULL and thermalZoneListSize--)
    {
        uint32_t tripPointListSize;
        result = taf_therm_GetTripPointListSize(tZone, &tripPointListSize);
        uint32_t boundCDevListSize;
        result = taf_therm_GetBoundCoolingDeviceListSize(tZone, &boundCDevListSize);
        uint32_t tZoneid;
        result = taf_therm_GetThermalZoneID(tZone, &tZoneid);
        char thermalZoneType[TYPE_SIZE];
        memset(thermalZoneType, 0, TYPE_SIZE);
        result = taf_therm_GetThermalZoneType(tZone, thermalZoneType, sizeof(thermalZoneType));
        uint32_t currTemp;
        result = taf_therm_GetThermalZoneCurrentTemp(tZone, &currTemp);
        uint32_t passiveTemp;
        result = taf_therm_GetThermalZonePassiveTemp(tZone, &passiveTemp);
        if (tripPointListSize > 0)
        {
            taf_therm_TripPointRef_t tripPoint = taf_therm_GetFirstTripPoint(tZone);
            uint32_t listSize;
            result = taf_therm_GetTripPointListSize(tZone, &listSize);
            while (tripPoint != NULL and listSize--)
            {
                uint32_t tripID;
                result = taf_therm_GetTripPointTripID(tripPoint, &tripID);
                uint32_t tZoneID;
                result = taf_therm_GetTripPointThermalZoneID(tripPoint, &tZoneID);
                char tripType[TYPE_SIZE];
                memset(tripType, 0, TYPE_SIZE);
                taf_therm_GetTripPointType(tripPoint, tripType, sizeof(tripType));
                uint32_t threshold;
                result = taf_therm_GetTripPointThreshold(tripPoint, &threshold);
                uint32_t hysterisis;
                result = taf_therm_GetTripPointHysterisis(tripPoint, &hysterisis);
                if (listSize > 0)
                {
                    tripPoint = taf_therm_GetNextTripPoint(tZone);
                }
            }
        }
        if (boundCDevListSize > 0)
        {
            taf_therm_BoundCoolingDeviceRef_t boundCDev = taf_therm_GetFirstBoundCDev(tZone);
            uint32_t listSize;
            result = taf_therm_GetBoundCoolingDeviceListSize(tZone, &listSize);

            while (boundCDev != NULL and listSize--)
            {
                uint32_t coolingID;
                result = taf_therm_GetBoundCoolingId(boundCDev, &coolingID);
                uint32_t tripPointListSize;
                if (taf_therm_GetBoundTripPointListSize(boundCDev, &tripPointListSize) <= 0)
                    return;
                taf_therm_TripPointRef_t boundTripPoint = taf_therm_GetFirstBoundTripPoint(boundCDev);
                result = taf_therm_GetBoundTripPointListSize(boundCDev, &tripPointListSize);
                while (boundTripPoint != NULL and tripPointListSize--)
                {
                    uint32_t boundTripID;
                    result = taf_therm_GetBoundTripPointTripID(boundTripPoint, &boundTripID);
                    uint32_t boundTZoneID;
                    result = taf_therm_GetBoundTripPointThermalZoneID(boundTripPoint, &boundTZoneID);
                    char boundTripType[TYPE_SIZE];
                    memset(boundTripType, 0, TYPE_SIZE);
                    taf_therm_GetBoundTripPointType(boundTripPoint, boundTripType,
                    sizeof(boundTripType));
                    uint32_t boundThreshold;
                    result = taf_therm_GetBoundTripPointThreshold(boundTripPoint, &boundThreshold);
                    uint32_t boundHysterisis;
                    result = taf_therm_GetBoundTripPointHysterisis(boundTripPoint, &boundHysterisis);
                    if (tripPointListSize > 0)
                    {
                        boundTripPoint = taf_therm_GetNextBoundTripPoint(boundCDev);
                    }
                }
                if (listSize > 0)
                {
                    boundCDev = taf_therm_GetNextBoundCDev(tZone);
                }
            }
        }
        if (thermalZoneListSize > 0)
        {
            tZone = taf_therm_GetNextThermalZone(tZoneListRef);
        }
    }
    result = taf_therm_DeleteThermalZoneList(headTZoneListRef);

Get the available cooling devices information

TelAF Thermal Manager Service provides APIs to know the available cooling devices on the target. TelAF Thermal Manager's client calls taf_therm_GetCoolingDeviceList() to get the cooling devices available reference. This function returns a taf_therm_CoolingDeviceListRef_t that can be later used to get the information of each cooling device, and also to delete the list reference using taf_therm_DeleteCoolingDeviceList().

   le_result_t result;
   taf_therm_CoolingDeviceListRef_t cDevListRef = taf_therm_GetCoolingDeviceList();

    taf_therm_CoolingDeviceListRef_t headCDevListRef = cDevListRef;

    taf_therm_CoolingDeviceRef_t cDev = taf_therm_GetFirstCoolingDevice(cDevListRef);
    uint32_t coolingDeviceListSize;
    result = taf_therm_GetCoolingDeviceListSize(cDevListRef, &coolingDeviceListSize);
    while (cDev != NULL and coolingDeviceListSize--)
    {
        char description[TYPE_SIZE];
        memset(description, 0, TYPE_SIZE);
        result = taf_therm_GetCDevDescription(cDev, description, sizeof(description));
        uint32_t coolingID;
        result = taf_therm_GetCDevID(cDev, &coolingID);
        uint32_t maxCooling;
        result = taf_therm_GetCDevMaxCoolingLevel(cDev, &maxCooling);
        uint32_t currCooling;
        result = taf_therm_GetCDevCurrentCoolingLevel(cDev, &currCooling);
        if (coolingDeviceListSize > 0) {
            cDev = taf_therm_GetNextCoolingDevice(cDevListRef);
        }
    }
    result = taf_therm_DeleteCoolingDeviceList(headCDevListRef);

Get specified thermal zone information

TelAF Thermal Manager Service provides APIs to get information of thermal zone by name present on the device. TelAF Thermal Manager's client calls taf_therm_GetThermalZoneByName() and provides the name of the specific thermal zone that the client wants the information about. The client gets the reference of the thermal zone, if available. This function returns a taf_therm_ThermalZoneRef_t that can be later used to get the information of the thermal zone.

    le_result_t result;
    taf_therm_ThermalZoneRef_t tZone = taf_therm_GetThermalZoneByName("ThermalZoneName");
    if (tZone != NULL)
    {
            uint32_t tripPointListSize;
        result = taf_therm_GetTripPointListSize(tZone, &tripPointListSize);
        uint32_t boundCDevListSize;
        result = taf_therm_GetBoundCoolingDeviceListSize(tZone, &boundCDevListSize);
        uint32_t tZoneid;
        result = taf_therm_GetThermalZoneID(tZone, &tZoneid);
        char thermalZoneType[TYPE_SIZE];
        memset(thermalZoneType, 0, TYPE_SIZE);
        result = taf_therm_GetThermalZoneType(tZone, thermalZoneType, sizeof(thermalZoneType));
        uint32_t currTemp;
        result = taf_therm_GetThermalZoneCurrentTemp(tZone, &currTemp);
        uint32_t passiveTemp;
        result = taf_therm_GetThermalZonePassiveTemp(tZone, &passiveTemp);
        if (tripPointListSize > 0)
        {
            taf_therm_TripPointRef_t tripPoint = taf_therm_GetFirstTripPoint(tZone);
            uint32_t listSize;
            result = taf_therm_GetTripPointListSize(tZone, &listSize);
            while (tripPoint != NULL and listSize--)
            {
                uint32_t tripID;
                result = taf_therm_GetTripPointTripID(tripPoint, &tripID);
                uint32_t tZoneID;
                result = taf_therm_GetTripPointThermalZoneID(tripPoint, &tZoneID);
                char tripType[TYPE_SIZE];
                memset(tripType, 0, TYPE_SIZE);
                taf_therm_GetTripPointType(tripPoint, tripType, sizeof(tripType));
                uint32_t threshold;
                result = taf_therm_GetTripPointThreshold(tripPoint, &threshold);
                uint32_t hysterisis;
                result = taf_therm_GetTripPointHysterisis(tripPoint, &hysterisis);
                if (listSize > 0)
                {
                    tripPoint = taf_therm_GetNextTripPoint(tZone);
                }
            }
        }
        if (boundCDevListSize > 0)
        {
            taf_therm_BoundCoolingDeviceRef_t boundCDev = taf_therm_GetFirstBoundCDev(tZone);
            uint32_t listSize;
            result = taf_therm_GetBoundCoolingDeviceListSize(tZone, &listSize);

            while (boundCDev != NULL and listSize--)
            {
                uint32_t coolingID;
                result = taf_therm_GetBoundCoolingId(boundCDev, &coolingID);
                uint32_t tripPointListSize;
                if (taf_therm_GetBoundTripPointListSize(boundCDev, &tripPointListSize) <= 0)
                    return;
                taf_therm_TripPointRef_t boundTripPoint = taf_therm_GetFirstBoundTripPoint(boundCDev);
                result = taf_therm_GetBoundTripPointListSize(boundCDev, &tripPointListSize);
                while (boundTripPoint != NULL and tripPointListSize--)
                {
                    uint32_t boundTripID;
                    result = taf_therm_GetBoundTripPointTripID(boundTripPoint, &boundTripID);
                    uint32_t boundTZoneID;
                    result = taf_therm_GetBoundTripPointThermalZoneID(boundTripPoint, &boundTZoneID);
                    char boundTripType[TYPE_SIZE];
                    memset(boundTripType, 0, TYPE_SIZE);
                    taf_therm_GetBoundTripPointType(boundTripPoint, boundTripType, sizeof(boundTripType));
                    uint32_t boundThreshold;
                    result = taf_therm_GetBoundTripPointThreshold(boundTripPoint, &boundThreshold);
                    uint32_t boundHysterisis;
                    result = taf_therm_GetBoundTripPointHysterisis(boundTripPoint, &boundHysterisis);
                    if (tripPointListSize > 0)
                    {
                        boundTripPoint = taf_therm_GetNextBoundTripPoint(boundCDev);
                    }
                }
                if (listSize > 0)
                {
                    boundCDev = taf_therm_GetNextBoundCDev(tZone);
                }
            }
    }

The application needs to release the thermal zone object after processing it by calling taf_therm_ReleaseThermalZoneRef().

*   taf_therm_ReleaseThermalZoneRef(tZone);
*  

Get specified cooling device information

TelAF Thermal Manager Service provides APIs to get information of cooling device by name present on the device. TelAF Thermal Manager's client calls taf_therm_GetCoolingDeviceByName() and provides the name of the specific cooling device that the client wants the information about. The client gets the reference of the cooling device, if available. This function returns a taf_therm_CoolingDeviceRef_t that can be later used to get the information of each cooling device.

  le_result_t result;
  taf_therm_CoolingDeviceRef_t cDev = taf_therm_GetCoolingDeviceByName("CoolingDeviceName");
  if (cDev != NULL)
  {
          char description[TYPE_SIZE];
          memset(description, 0, TYPE_SIZE);
          result = taf_therm_GetCDevDescription(cDev, description, sizeof(description));
          uint32_t coolingID;
          result = taf_therm_GetCDevID(cDev, &coolingID);
          uint32_t maxCooling;
          result = taf_therm_GetCDevMaxCoolingLevel(cDev, &maxCooling);
          uint32_t currCooling;
          result = taf_therm_GetCDevCurrentCoolingLevel(cDev, &currCooling);
  }

The application needs to release the cooling device object after processing it by calling taf_therm_ReleaseCoolingDeviceRef().

*   taf_therm_ReleaseCoolingDeviceRef(tripEventSampleRef);
*  

An application may register and deregister a trip event handler to be notified when the trip points trip with taf_therm_AddTripEventHandler() and taf_therm_RemoveTripEventHandler(). When a trip event is triggered, the handler is called.

static void TestTripEventHandler
(
    taf_therm_TripPointRef_t tripPoint,
    taf_therm_TripEventType_t type,
    void* contextPtr
)
{
    le_result_t result;
    uint32_t tripID, tZoneID, threshold, hysterisis;
    result = taf_therm_GetTripPointTripID(tripPoint, &tripID);
    result = taf_therm_GetTripPointThermalZoneID(tripPoint, &tZoneID);
    result = taf_therm_GetTripPointThreshold(tripPoint, &threshold);
    result = taf_therm_GetTripPointHysterisis(tripPoint, &hysterisis);
    char tripType[TYPE_SIZE];
    memset(tripType, 0, TYPE_SIZE);
    taf_therm_GetTripPointType(tripPoint, tripType, sizeof(tripType));
    taf_therm_ReleaseTripEventRef(tripPoint);
}

handlerRef = taf_therm_AddTripEventHandler
((taf_therm_TripEventHandlerFunc_t) TripEventHandler, NULL);
LE_ASSERT(handlerRef != NULL);
taf_therm_RemoveTripEventHandler(handlerRef);

The application needs to release the trip point object after processing it by calling taf_therm_ReleaseTripEventRef().

  taf_therm_ReleaseTripEventRef(tripEventSampleRef);

An application may register and deregister a cooling level change handler to be notified when the cooling level changes for a cooling device with: taf_therm_AddCoolingLevelChangeEventHandler() and taf_therm_RemoveCoolingLevelChangeEventHandler(). When a cooling level is changed, the handler is called.

void TestCoolingLevelChangeHandler
(
    taf_therm_CoolingDeviceRef_t cDev,
    void* contextPtr
)
{
    le_result_t result;
    uint32_t coolingID, maxCooling, currCooling;
    result = taf_therm_GetCDevID(cDev, &coolingID);
    result = taf_therm_GetCDevMaxCoolingLevel(cDev, &maxCooling);
    result = taf_therm_GetCDevCurrentCoolingLevel(cDev, &currCooling);
    char description[TYPE_SIZE];
    memset(description, 0, TYPE_SIZE);
    result = taf_therm_GetCDevDescription(cDev, description, sizeof(description));
    taf_therm_ReleaseCoolingDeviceRef(cDev);
}

handlerRef = taf_therm_AddCoolingLevelChangeEventHandler
((taf_therm_CoolingLevelChangeEventHandlerFunc_t) TestCoolingLevelChangeHandler, NULL);
LE_ASSERT(handlerRef != NULL);
taf_therm_RemoveTripEventHandler(handlerRef);

The application needs to release the cooling device object after processing it by calling taf_therm_ReleaseCoolingDeviceRef().

  taf_therm_ReleaseCoolingDeviceRef(coolingDeviceSampleRef);