# Diag Service

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

Diag Service provides APIs to applications to set enable condition and get enable condition status of enable ID and it also provides notifications for tester tool OFF/ON state changes and API to cancel the file transfer operation.

## IPC interfaces binding

The functions of this API are provided by the **tafDiagSvc** platform service.

The following example illustrates how to bind to the diag service.

bindings:
     {
          clientExe.clientComponent.taf_diag -> tafDiagSvc.taf_diag
     }
    Copy to clipboard

## Enable condition API

[taf\_diag\_SetEnableCondition()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1a2e9acfc7dae56fe7fc5dddb1f6d5903b.html#Documentationa00455_1a2e9acfc7dae56fe7fc5dddb1f6d5903b) can be used to set enable condition status for given enable ID to fulfilled or not fulfilled.

The following example illustrates how to set the enable condition to fulfilled.

le_result_t result = taf_diagEvent_SetEnableCondition(ENABLE_CONDITION_ID, true);
    if (result != LE_OK)
    {
       LE_ERROR("Fail to set enable condition.");
       return result;
    }
    Copy to clipboard

[taf\_diag\_GetEnableConditionStatus()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1aa9dd12837833fc6544d78cea55a5075c.html#Documentationa00455_1aa9dd12837833fc6544d78cea55a5075c) can be used to get enable condition status for given enable ID.

The following example illustrates how to get the enable condition status.

bool enableStatus = taf_diag_GetEnableConditionStatus(ENABLE_CONDITION_ID);
    if (enableStatus)
    {
       LE_INFO(" Enable status for ENABLE_CONDITION_ID is true");
       return enableStatus;
    }
    else
    {
       LE_INFO(" Enable status for ENABLE_CONDITION_ID is false");
       return enableStatus;
    }
    Copy to clipboard

## Get diag service reference API

Get a diag service reference using [taf\_diag\_GetService()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1a5288d72492f2bb4751fa423667e1a079.html#Documentationa00455_1a5288d72492f2bb4751fa423667e1a079). Use the returned reference for subsequent operations.

The following example illustrates how to set up a diag server-service-instance.

taf_diag_ServiceRef_t svcRef;    // Service reference
    
    // Get the service reference.
    svcRef = taf_diag_GetService();
    LE_ERROR_IF((svcRef == NULL), "taf_diag_GetService returns NULL!");
    Copy to clipboard

## Set VLAN ID

After getting a service reference, an application can set the VLAN ID using [taf\_diag\_SetVlanId()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1a03f91d45b1c43cd3f45248263fa632c0.html#Documentationa00455_1a03f91d45b1c43cd3f45248263fa632c0). It shall be called before registering the handler for the Tester state notification message and API to cancel file transfer operation.

- [taf\_diag\_SetVlanId()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1a03f91d45b1c43cd3f45248263fa632c0.html#Documentationa00455_1a03f91d45b1c43cd3f45248263fa632c0) — Sets the VLAN ID.

## Select target VLAN ID

An application can select the VLAN ID by calling [taf\_diag\_SelectTargetVlanID()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1ade3a8cf66479de10b3048bc4d5f261d8.html#Documentationa00455_1ade3a8cf66479de10b3048bc4d5f261d8). If the service is bound to multiple VLANs, the application needs to select a VLAN ID for subsequent operation on target VLAN, otherwise the last VLAN ID set using [taf\_diag\_SetVlanId()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1a03f91d45b1c43cd3f45248263fa632c0.html#Documentationa00455_1a03f91d45b1c43cd3f45248263fa632c0) is considered.

// Select the VLAN ID.
    uint16_t vlanId = 10;
    le_result_t result = taf_diag_SelectTargetVlanID(SvcRef, vlanId);
    if (result != LE_OK)
    {
       LE_ERROR("Fail to select vlan Id.");
       return result;
    }
    Copy to clipboard

## Tester OFF/ON notification API

After getting the service reference, an application can call [taf\_diag\_AddTesterStateHandler()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1ad2eb1ac25925437b58185d3733f8ad67.html#Documentationa00455_1ad2eb1ac25925437b58185d3733f8ad67) to register a handler for tester state (OFF/ON) change notification. Once tester state is changed, the handler will be called with the message reference, Vlan ID and current tester State passed as input parameters. Tester state will be OFF(0), whenever there is no UDS communication with IVC for 5 second irrespective of any session. Finally call [taf\_diag\_ReleaseTesterStateMsg()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1ab1b8aa85ed6e9419e1fe03d90c1b2650.html#Documentationa00455_1ab1b8aa85ed6e9419e1fe03d90c1b2650) to release the tester state message.

// Rx tester state handler function.
    void TesterStateEventHandler
    (
         taf_diag_TesterStateRef_t rxStateRef,
         uint16_t vlanId,
         taf_diag_State_t currentTesterState,
         void* contextPtr
    )
    {
         // Process after tester state change
    }
    
    // Register the tester state handler.
    taf_diag_TesterStateHandlerRef_t handlerRef =
        taf_diag_AddTesterStateHandler(svcRef,
             (taf_diag_StateChangeHandlerFunc_t)TesterStateEventHandler, NULL);
    LE_ERROR_IF((handlerRef == NULL), "taf_diag_AddTesterStateHandler returns NULL!");
    
    // To remove the handler function, when it is not needed.
    taf_diag_RemoveTesterStateHandler(handlerRef);
    
    // To release the tester state msg after getting the state change notification.
    le_result_t result = taf_diag_ReleaseTesterStateMsg(rxStateRef);
    if (result != LE_OK)
    {
       LE_ERROR("Fail to release msg.");
       return result;
    }
    Copy to clipboard

## Cancel fileXfer API

An application can cancel the file transfer operation by calling [taf\_diag\_CancelFileXferAsync()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1afb4a55bb2e0544f27353ce1fc14bb599.html#Documentationa00455_1afb4a55bb2e0544f27353ce1fc14bb599). If the service is bound to multiple VLANs, then the application needs to select a VLAN ID first to cancel the file transfer operation of the selected VLAN. If the VLAN ID is not selected then it will cancel the file transfer operation of the last VLAN ID set by [taf\_diag\_SetVlanId()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1a03f91d45b1c43cd3f45248263fa632c0.html#Documentationa00455_1a03f91d45b1c43cd3f45248263fa632c0).

void CancelFileXferHandlerFunc
    (
        taf_diag_ServiceRef_t svcRef,
        uint16_t vlanId,
        le_result_t result,
        void* contextPtr
    )
    {
        LE_INFO(" CancelFileXferHandlerFunc with vlanId:%d, result: %d", vlanId, result);
    }
    
     // Call asynchronous API taf_diag_CancelFileXferAsync.
     taf_diag_CancelFileXferAsync(svcRef, CancelFileXferHandlerFunc, NULL);
    Copy to clipboard

## State control API

An application can pause/resume the diag service by calling [taf\_diag\_Pause()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1aa5a8bd40fa9ae043ac464bf885d20714.html#Documentationa00455_1aa5a8bd40fa9ae043ac464bf885d20714) and [taf\_diag\_Resume()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1abaf92d324c90ff2cdff4acd54743d2aa.html#Documentationa00455_1abaf92d324c90ff2cdff4acd54743d2aa). If the service is bound to multiple VLANs, then the application needs to select a VLAN ID first to pause/resume the diag service of the selected VLAN. If the VLAN ID is not selected then it will pause/resume the diag service of the last VLAN ID set by [taf\_diag\_SetVlanId()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1a03f91d45b1c43cd3f45248263fa632c0.html#Documentationa00455_1a03f91d45b1c43cd3f45248263fa632c0).

//To pause diag service
    le_result_t result = taf_diag_Pause(svcRef);
    if ((result != LE_OK) && (result != LE_IN_PROGRESS))
    {
       LE_ERROR("Fail to pause diag service.");
       return result;
    }
    
    //To resume diag service
    le_result_t result = taf_diag_Resume(svcRef);
    if (result != LE_OK)
    {
       LE_ERROR("Fail to resume diag service.");
       return result;
    }
    Copy to clipboard

An application can remove the diag service reference by calling [taf\_diag\_RemoveSvc()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00455_1a26a08039f3a0bb6d28ea348e98485ce3.html#Documentationa00455_1a26a08039f3a0bb6d28ea348e98485ce3).

le_result_t result = taf_diag_RemoveSvc(svcRef);
    if (result != LE_OK)
    {
       LE_ERROR("Fail to remove service reference.");
       return result;
    }
    Copy to clipboard

Last Published: Jun 09, 2026

[Previous Topic
Diagnostic services](https://docs.qualcomm.com/bundle/publicresource/80-41102-2/topics/diagnostic_services.md) [Next Topic
Diag Authentication Service](https://docs.qualcomm.com/bundle/publicresource/80-41102-2/topics/page_c_tafDiagAuth.md)