Obtain Log via JSBridge

2024-10-17
No Rating

Overview

In the process of using DJI Pilot 2, it is inevitable to encounter problems such as abnormal interface communication and function failure, and it is necessary to pull the DJI Pilot 2 log for diagnosis(Refer to Log Exportopen in new window). In order to solve this problem, DJI Pilot 2 also provides JSBridge interface for developers to pull the log. And upload the Webview to the developer's own server for analysis.

Note:

DJI Pilot 2 logs are encrypted, so the developer needs to provide the public key information for log encryption through the JSBridge interface, and the pulled logs also need to be decrypted to view them. DJI provides a JAR library for decrypting logs that can be decrypted by developers running scripts.

Decryption method: Use plogdecoder. jar library to run scripts to decrypt the pulled logs. Downloadopen in new window

Example:

java -jar PlogDecoder.jar -key "Desktop/rsa_keys/pri.key" -log "/open_platform/log-2022-01-18.log".
//If the public key is not set, you can omit the -key parameter.

Detailed API Realization

Please refer to JSBridgeopen in new window.

  • Get Logs Path window.djiBridge.platformGetLogPath()

    The developer can get the path to the logs saved by the DJI Pilot 2 via the js method and then can upload the logs via file upload.

  • Set Logs Encrypt Key window.djiBridge.platformSetLogEncryptKey(String key)

  • Clear Logs Encrypt Key window.djiBridge.platformClearLogEncryptKey()

Note: When clearing the encryption key, if there is already part of the log using the original key, it will not be re-encrypted. In this case, the developer needs to save the historical key himself to prevent the log file from not being opened.

If you have any comments or confusion about our documentation, you can click here to give feedback and we will get back to you as soon as possible.