DJISDKManager

@interface DJISDKManager : NSObject

This class contains methods to register the app, start or stop connections with the product, and use the DJI Bridge app and Remote Logger tools, etc. After registration, the user can access the connected product through DJISDKManager. Then the user can start to control the components of the product.

  • Product connected to the mobile device. The product is accessible only after successful registration of the app.

    Declaration

    Objective-C

    + (__kindof DJIBaseProduct *_Nullable)product;

    Return Value

    The available DJIBaseProduct object, or nil if no product is available.

  • Connector used to establish a Bluetooth connection between the Mobile SDK on the mobile device and a DJI product.

    Declaration

    Objective-C

    + (nullable DJIBluetoothProductConnector *)bluetoothConnector;
  • The first time the app is initialized after installation, the app connects to a DJI Server through the internet to verify the Application Key. Subsequent app starts will use locally cached verification information to register the app.

    Declaration

    Objective-C

    + (void)registerApp:(nonnull NSString *)appKey
           withDelegate:(nonnull id<DJISDKManagerDelegate>)delegate;

    Parameters

    appKey

    Application key that was provided by DJI after the application was registered.

    delegate

    Registration result callback delegate

  • Queue in which completion blocks are called. If left unset, completion blocks are called in main queue.

    Declaration

    Objective-C

    + (void)setCompletionBlockQueue:(nonnull dispatch_queue_t)completionBlockQueue;

    Parameters

    completionBlockQueue

    Dispatch queue.

  • Some products (Mavic Pro, Inspire 2, Phantom 4 Pro) can use 5 GHz wireless spectrum that is not permissable in some countries. By default, the 5 GHz usage is not enabled, but on registration the SDK will do a country code check to determine whether 5 GHz can be used. The check can involve sending location data to a server. This method can be used to disable this check, leaving the default configuration of only using the 2.4 GHz spectrum.

    Note: this method must be called before calling +registerApp:withDelegate: in order to take effect.

    Declaration

    Objective-C

    + (void)setDisableCountryCodeCheck:(BOOL)disableCountryCodeCheck;
  • Start a connection to the DJI product. Call this method after successful registration of the app. sdkManagerProductDidChangeFrom:to: delegate method will be called if the connection succeeded.

    Declaration

    Objective-C

    + (BOOL)startConnectionToProduct;

    Return Value

    YES if the connection has started successfully.

  • Disconnect the existing connection to the DJI product.

    Declaration

    Objective-C

    + (void)stopConnectionToProduct;
  • Set the SDK to close the connection automatically when the app enters the background, and resume connection automatically when the app enters the foreground. Default is YES.

    Declaration

    Objective-C

    + (void)closeConnectionWhenEnterBackground:(BOOL)isClose;

    Parameters

    isClose

    Determines whether to close the connection when the app enters the background.

  • Gets the DJI Mobile SDK Version.

    Declaration

    Objective-C

    + (nonnull NSString *)getSDKVersion;

    Return Value

    SDK version as a string.

  • Enter debug mode with debug ID.

    Declaration

    Objective-C

    + (void)enterDebugModeWithDebugId:(nonnull NSString *)debugId;

    Parameters

    debugId

    Debug ID from the DJI Bridge App.

  • Enter enable remote logging with log server URL.

    Declaration

    Objective-C

    + (void)enableRemoteLoggingWithDeviceID:(NSString *_Nullable)deviceID
                         logServerURLString:(nonnull NSString *)url;

    Parameters

    deviceID

    Optional device ID to uniquely identify logs from an installation.

    url

    URL of the remote log server.

  • The DJI Mobile SDK collects logs that are related to flight. These logs can be used to help diagnose the cause of a product’s flight failure at the SDK and mobile application layer. They are predominantly used by a DJI service facility, who will combine them with the product’s flight logs (stored on the product) to better understand the root cause of a crash and determine whether the incident is covered under warranty. They can also be used by developers to debug their application.

    SDK Logs record commands from the application to the SDK, and information from the SDK to the application that are related to flight. Logs are cached to the mobile device, and will overwrite themselves to limit storage footprint. archiveLogs will move the logs to an archive folder. Logs in the archive, will only be overwritten by newer archives that go beyond the storage limit and not normal log generation. The storage limit for normal log generation is 400 MB (about 500 minutes of flight). The storage limit for the archive is an additional 400 MB.

    The logs have an encrypted and unencrypted portion. The unencrypted portion can be used by developers to see all commands and information sent to and received from the SDK by the mobile application that is related to flight. The encrypted portion can only be used by a DJI service facility as it includes proprietary hardware protocols and is used to tie the SDK logs and product flight logs together.

    Logs can be transferred to the DJI service facility either by manually downloading from the mobile device using iTunes, or the application can send archived logs to a DJI endpoint using uploadArchive. Developers should be careful to upload logs directly when the user is on a cellular connection as the archive can be up to 400 MB.

    Declaration

    Objective-C

    + (nullable NSString *)archiveLogs;

    Return Value

    path of archived logs, nil if a problem occurred.

  • Upload the archive to DJI. The archive will not be deleted when calling this method.

    Declaration

    Objective-C

    + (void)uploadArchivedLogs;