# Example code

Source: [https://docs.qualcomm.com/doc/80-PK177-134/topic/example_code_QC_2.html](https://docs.qualcomm.com/doc/80-PK177-134/topic/example_code_QC_2.html)

## Java

**Required imports**

    import com.qualcomm.qti.qesdk.Modem.LinkInterruptManager;
    import com.qualcomm.qti.qesdk.QesdkStatusException;
    import com.qualcomm.qti.qesdkIntf.IQesdk; 
    import com.qualcomm.qti.qesdk.QesdkStatusException;Copy to clipboard

**Declare required objects**

    private final IQesdk qesdkManager = IQesdk.createInstance(this);
    private final LinkLatencyEstimateManager lleManager = new LinkLatencyEstimateManager(qesdkManager);Copy to clipboard

**Initialize**

    int status = lleManager.init([String license], (opcodes, subsystem) -> {
        // Handle QESDK event
    });Copy to clipboard

**Set Reporting Criteria**

    int result = lleManager.setReportingCriteria(reportInterval);Copy to clipboard

**Register for Estimation Reports**

    int result = lleManager.registerForEstimationReports(
    (linkLatencyInfoStatusCode, uplink, downlink, interval, ratType) -> {
    //Handle LCE estimation report
    });Copy to clipboard

**Get Last estimation Report**

    int result = lleManager.getLastEstimationReport(
    (linkLatencyInfoStatusCode, uplink, downlink, interval, ratType) -> {
    // Handle last LCE estimation report
    });Copy to clipboard

**Deinitialize**

    lleManager.deinit()Copy to clipboard

## Native

**Required includes**

    #include "qesdk_ndk.h"
    #include "qesdk_Modem_LinkLatencyEstimate.h"Copy to clipboard

**Declare required objects**

    lleManager = new LinkLatencyEstimateManager();Copy to clipboard

**Initialize**

    int ret = lleManager->init(licenseStr, license_length, (uint32_t opcodes, uint32_t *subsystems) {
    // Handle QESDK event
    });Copy to clipboard

**Set Reporting Criteria**

    int8_t ret = -1;
    qesdk_transaction_status qesdk_ndk_response = lleManager->setReportingCriteria(report_interval, ret); 
    if(qesdk_ndk_response.is_ok()){
      // Use the ret value
    } else {
      // Can get error code by get_error_code() 
    }Copy to clipboard

**Register for Estimation Reports**

    qesdk_ndk_response = lleManager->registerForEstimationReports(lle_registerForEstimationReportsCallback, ret); 
    if(qesdk_ndk_response.is_ok()){
      // Use the ret value
    } else {
      // Can get error code by get_error_code() 
    }Copy to clipboard

**Get Last estimation Report**

    qesdk_ndk_response = lleManager->getLastEstimationReport(lle_getLastEstimationReportCallback, ret); 
    if(qesdk_ndk_response.is_ok()){
      // Use the ret value
    } else {
      // Can get error code by get_error_code() 
    }Copy to clipboard

**Callbacks handle**

    void lle_registerForEstimationReportCallback(lle_LinkLatencyInfoStatusCode status_code, 
        lle_LinkLatencyInfoDirection ul, 
        lle_LinkLatencyInfoDirection dl,
        u_int32_t report_interval, 
        lle_RatType rat_type) {
    // Callback to handle for estimation report 
    });
    
    void lle_getLastEstimationReportCallback(lle_LinkLatencyInfoStatusCode status_code, 
        lle_LinkLatencyInfoDirection ul, 
        lle_LinkLatencyInfoDirection dl, 
        u_int32_t report_interval, 
        lle_RatType rat_type) {
    // Callback to handle for Last estimation report 
    });Copy to clipboard

**Deinitialize**

    int ret = lliManager->deinit();Copy to clipboard

**Parent Topic:** [Link latency estimation (smart data link)](https://docs.qualcomm.com/doc/80-PK177-134/topic/link_latency_estimation.html)

Last Published: Nov 14, 2024

[Previous Topic
Direction information](https://docs.qualcomm.com/bundle/publicresource/80-PK177-134/topics/direction_information.md) [Next Topic
Link layer interruption (smart data link)](https://docs.qualcomm.com/bundle/publicresource/80-PK177-134/topics/link_layer_interruption.md)