Device Log Upload

Last Updated on : 2025-01-16 09:57:49download

Device logs can improve your efficiency in troubleshooting device issues. To swiftly pinpoint user issues, it is advisable for the devices to support this feature.

IPC Embedded SDK version 3.10.6 and above support sending Upload log commands via the App SDK, while earlier versions only support sending Upload log commands via the platform.

IThingIPCTool provides a collection of APIs related to IPC utilities.

Register a listener

Register a listener to monitor the results of log uploads.

API description

void registerUploadLogListener(CameraUploadLogListener listener);

Parameter description

Parameter Description
listener Monitor the results of log uploads.

CameraUploadLogListener

Monitor the results of log uploads.

public void onCameraUploadLogResult(String deviceId, boolean result, Map<String, Object> extInfo)
Parameter Description
deviceId The device ID.
result The results of log uploads.
extInfo The extension information.

Remove a listener

Remove a listener and recycle resources.

API description

void unregisterUploadLogListener(CameraUploadLogListener listener);

Parameter description

Parameter Description
listener Monitor the results of log uploads.

Check support for log upload

Check whether a device supports log upload.

API description

boolean hasRespondToUploadLogCmdAbility(String deviceId);

Parameter description

Parameter Description
deviceId The device ID.

Upload device logs

This asynchronous interface is used to upload device logs. Refer to the monitoring results of CameraUploadLogListener.

API description

void deliverUploadLogCmd(String deviceId, long timeoutSec, OperationDelegateCallBack callBack);

Parameter description

Parameter Description
deviceId The device ID.
timeoutSec The timeout, in seconds.
callBack The callback.

Example


IThingIPCTool thingIPCTool = ThingIPCSdk.getTool();
// Check support for log upload.
boolean ret = thingIPCTool.hasRespondToUploadLogCmdAbility(devId);


if(ret) {
    CameraUploadLogListener cameraUploadLogListener = new CameraUploadLogListener() {
                            @Override
                            public void onCameraUploadLogResult(String deviceId, boolean result, Map<String, Object> extInfo) {
                                // The results of log uploads.
                                // true: success. false: failure.
                            }
                        };
    // Register a listener. Note that you need to remove the listener after use.
    thingIPCTool.registerUploadLogListener(cameraUploadLogListener);
    // Send commands to the device and instruct the device to upload logs.
    thingIPCTool.deliverUploadLogCmd(devId, timeout, new OperationDelegateCallBack(){

                @Override
                public void onSuccess(int sessionId, int requestId, String data) {
                }

                @Override
                public void onFailure(int sessionId, int requestId, int errCode) {

                }
            });
}