Crate dji_log_parser

source ·
Expand description

§DJILog Parser Module

This module provides functionality for parsing DJI log files.

§Encryption in Version 13 and Later

Starting with version 13, log records are AES encrypted and require a specific keychain for decryption. This keychain must be obtained from DJI using their API. An apiKey is necessary to access the DJI API.

Once keychains are retrieved, they can be stored along with the original log for further offline use.

§Obtaining an ApiKey

To acquire an apiKey, follow these steps:

  1. Visit DJI Developer Technologies and log in.
  2. Click CREATE APP, choose Open API as the App Type, and provide the necessary details like App Name, Category, and Description.
  3. After creating the app, activate it through the link sent to your email.
  4. On your developer user page, find your app’s details to retrieve the ApiKey (labeled as the SDK key).

§Usage

§Initialization

Initialize a DJILog instance from a byte slice to access version information and metadata:

let parser = DJILog::from_bytes(bytes).unwrap();

§Access general data

General data are not encrypted and can be accessed from the parser for all log versions:

// Print the log version
println!("Version: {:?}", parser.version);

// Print the log details section
println!("Details: {}", parser.details);

§Retrieve keychains

For logs version 13 and later, keychains must be retrieved from the DJI API to decode the records:

// Replace `__DJI_API_KEY__` with your actual apiKey
let keychains = parser.fetch_keychains("__DJI_API_KEY__").unwrap();

Keychains can be retrieved once, serialized, and stored along with the log file for future offline use.

§Accessing Frames

Decrypt frames based on the log file version.

A Frame is a standardized representation of log data, normalized across different log versions. It provides a consistent and easy-to-use format for analyzing and processing DJI log information.

For versions prior to 13:

let frames = parser.frames(None);

For version 13 and later:

let frames = parser.frames(Some(keychains));

§Accessing raw Records

Decrypt raw records based on the log file version. For versions prior to 13:

let records = parser.records(None);

For version 13 and later:

let records = parser.records(Some(keychains));

§Binary structure of log files:

v1 -> v6

┌─────────────────┐
│     Prefix      │ detail_offset ─┐
├─────────────────┤                │
│     Records     │                │
├─────────────────┤<───────────────┘
│     Details     │ detail_length
└─────────────────┘

v7 -> v11

┌─────────────────┐
│     Prefix      │ detail_offset ─┐
├─────────────────┤                │
│     Records     │                │
│   (Encrypted)   │                |
├─────────────────┤<───────────────┘
│     Details     │ detail_length
└─────────────────┘

v12

┌─────────────────┐
│     Prefix      │ detail_offset ─┐
├─────────────────┤                │
│      Details    │ detail_length  │
├─────────────────┤                │
│     Records     │                │
│   (Encrypted)   │                │
└─────────────────┘<───────────────┘

v13 -> v14

┌─────────────────┐
│     Prefix      │ detail_offset ─┐
├─────────────────┤                │
│ Auxiliary Info  |                |
│ (Encrypted      │ detail_length  │
│      Details)   |                |
├─────────────────┤                │
│    Auxiliary    |                |
│     Version     |                │
├─────────────────┤<───────────────┘
│     Records     │
│(Encrypted + AES)|
└─────────────────┘

Modules§

Structs§

Enums§

Type Aliases§