# Example code Source: [https://docs.qualcomm.com/doc/80-PK177-134/topic/lce_example_code.html](https://docs.qualcomm.com/doc/80-PK177-134/topic/lce_example_code.html) ## Java **Required imports** import com.qualcomm.qti.qesdk.Modem.ILinkCapacityEstimateCBs; import com.qualcomm.qti.qesdk.Modem.LinkCapacityEstimateEnums; import com.qualcomm.qti.qesdk.Modem.LinkCapacityEstimateManager; import com.qualcomm.qti.qesdkIntf.IQesdk;Copy to clipboard **Initialize** IQesdk qesdkManager = Iqesdk.createInstance(getApplicationContext()); LinkCapacityEstimateManager lceManager = new LinkCapacityEstimateManager(qesdkManager); int status = LinkCapacityEstimateManager.init([String license], (opcodes, subsystem) -> { // Callback handle });Copy to clipboard **Reporting action** LinkCapacityEstimateEnums.reportingAction action = LinkCapacityEstimateEnums.reportingAction.START; //action = LinkCapacityEstimateEnums.reportingAction.STOP; //action = LinkCapacityEstimateEnums.reportingAction.RESET;Copy to clipboard **Declare callbacks** IqesdkEventCallBack eventCallbackHandler = new IqesdkEventCallBack() { @Override public void onEvent(int opcode, int[] subsys) { // Handle QESDK event } }; IlinkCapacityEstimateCBs.IestimationReport estimationReportCallback = new IlinkCapacityEstimateCBs.IestimationReport() { @Override public void onValues(long rate,LinkCapacityEstimateEnums.confidenceLevel confidenceLevel, LinkCapacityEstimateEnums.linkDirection linkDirection, long queueSizeUL, String error) { // Handle LCE estimation report callback } } IlinkCapacityEstimateCBs.IasyncResult() resultCallback = new IlinkCapacityEstimateCBs.IasyncResult() { @Override public void onValues(boolean success, String error) { // Handle API result callback } } IlinkCapacityEstimateCBs.IestimationReport lastEstimationReportCallback = new IlinkCapacityEstimateCBs.IestimationReport() { @Override public void onValues(long rate,LinkCapacityEstimateEnums.confidenceLevel confidenceLevel, LinkCapacityEstimateEnums.linkDirection linkDirection, long queueSizeUL, String error) { // Handle last LCE estimation report callback } }Copy to clipboard **Register for estimation reports** int ret = lceManager.registerForEstimationReports(estimationReportCallback);Copy to clipboard **Set reporting criteria** ret = lceManager.setReportingCriteria(hyst, thresholdDown, thresholdUp, techType, period, resultCallback);Copy to clipboard **Get last estimation report** int m = lceManager.getLastEstimationReport(lastEstimationReportCallback);Copy to clipboard **Perform start/stop/rest action for the set criteria** int m = lceManager.performReportingAction(action);Copy to clipboard ## Native **Required includes** #include “qesdk_ndk.h” #include “qesdk_Modem_LinkCapacityEstimate.h”Copy to clipboard **Initialize** LinkCapacityEstimateManager *lceManager = new LinkCapacityEstimateManager(); int ret = lceManager->init(nativeLicense, len, event_callback_handler); lce_reportingAction action = lce_reportingAction.START; //action = lce_reportingAction.STOP; //action = lce_reportingAction.RESET;Copy to clipboard **Declare callbacks** void event_callback_handler(uint32_t opcode, uint32_t subsys[]) { // Callback to handle QESDK events } void estimationReportCallback(uint32_t rate, lce_confidenceLevel confidenceLevel, lce_linkDirection linkDirection, uint32_t queueSizeUL, std::string error){ // Handle LCE estimation report } void lastEstimationReportCallback(uint32_t rate, lce_confidenceLevel confidenceLevel, lce_linkDirection linkDirection, uint32_t queueSizeUL, std::string error){ // Handle last LCE estimation report } void setCriteriaStatusCallback(bool success, std::string error){ // Handle set criteria status }Copy to clipboard **Register for estimation reports** int8_t ret = -1; qesdk_transaction_status qesdk_ndk_response = lceManager->registerForEstimationReports(estimationReportCallback, ret); if(qesdk_ndk_response.is_ok()){ // Use the ret value } else { // Can get error code by get_error_code() }Copy to clipboard **Set reporting criteria** qesdk_ndk_response = lceManager->setReportingCriteria(hyst, thresholds_down_vector, thresholds_up_vector, tech_type, period, setCriteriaStatusCallback, ret); if(qesdk_ndk_response.is_ok()){ // Use the ret value } else { // Can get error code by get_error_code() } // The API’s return value is in ‘ret’ which should be interpreted as the output parameterCopy to clipboard **Get last estimation report** qesdk_ndk_response = lceManager-> getLastEstimationReport(lastEstimationReportCallback, ret); if(qesdk_ndk_response.is_ok()){ // Use the ret value } else { // Can get error code by get_error_code() }Copy to clipboard **Perform start/stop/rest action for the set criteria** qesdk_ndk_response = lceManager->performReportingAction(action, ret); if(qesdk_ndk_response.is_ok()){ // Use the ret value } else { // Can get error code by get_error_code() }Copy to clipboard **Parent Topic:** [Link capacity estimation (smart data link)](https://docs.qualcomm.com/doc/80-PK177-134/topic/latency_capacity_estimation.html) Last Published: Nov 14, 2024 [Previous Topic reportingAction](https://docs.qualcomm.com/bundle/publicresource/80-PK177-134/topics/lce_enum_reporting_action.md) [Next Topic Link latency manager (smart data flow)](https://docs.qualcomm.com/bundle/publicresource/80-PK177-134/topics/llm.md)