DJI Mobile SDK Documentation

      class Payload

      class Payload extends BaseComponent
      Package:dji.sdk.payload
      Inherits From:BaseComponent
      Description:

      Class used to interact with the payload device mounted on DJI aircraft.

      Class Members:
      Upstream Bandwidth
      method
      method getUpstreamBandwidth
      void getUpstreamBandwidth(final CommonCallbacks.CompletionCallbackWith<Float> callback)
      Package:dji.sdk.payload
      Description:

      Gets the bandwidth of the upstream (from Mobile SDK to Payload). The unit is bytes/s. The bandwidth is determined by the firmware and currently it is not larger than 500 bytes/s.

      Input Parameters:
      final CommonCallbacks.CompletionCallbackWith<Float> callbackThe execution callback with the returned value(s).
      Product Name
      method
      method getPayloadProductName
      String getPayloadProductName()
      Package:dji.sdk.payload
      Description:

      Gets the product name defined by the manufacturer of the payload device.

      Return:
      StringThe product name of the payload device.
      Widget Value
      method
      method configureWidgetValue
      void configureWidgetValue(int index, PayloadWidget.PayloadWidgetType type, int value, CommonCallbacks.CompletionCallback callback)
      Package:dji.sdk.payload
      Description:

      Set the value for a widget of the payload device.

      Input Parameters:
      int indexIndex of the widget.
      PayloadWidget.PayloadWidgetType typeType of the widget.
      int valueValue of the widget.
      CommonCallbacks.CompletionCallback callbackThe execution callback with the returned value(s).
      Get Widget
      method
      method getWidget
      PayloadWidget getWidget(int widgetIndex, PayloadWidget.PayloadWidgetType widgetType)
      Package:dji.sdk.payload
      Description:

      Gets a widget by specifying the widget type and the index.

      Input Parameters:
      int widgetIndexThe index of the widget.
      PayloadWidget.PayloadWidgetType widgetTypeThe type of the widget.
      Return:
      PayloadWidgetThe widget corresponding to the widget type and the index. null if the widgets are not ready or there is no widget corresponding to the widget type and the index.
      Get Widgets
      method
      method getWidgets
      PayloadWidget[] getWidgets()
      Package:dji.sdk.payload
      Description:

      Gets the full list of widgets on the payload device. A new instance of "NSArray" is returned when one of the widget is updated.

      Return:
      PayloadWidget[]The full list of widgets. null if the widgets are not fetched yet.
      Send Data
      method
      method sendDataToPayload
      void sendDataToPayload(byte[] data, CommonCallbacks.CompletionCallback callback)
      Package:dji.sdk.payload
      Description:

      Sends data to payload. The length of the data to send cannot exceed 32 bytes. The throughput cannot exceed the bandwidth returned by getUpstreamBandwidth.

      Input Parameters:
      byte[] dataData that will be sent to the payload device.
      CommonCallbacks.CompletionCallback callbackThe execution callback with the returned value(s).
      method addWidgetValueChangedCallback
      void addWidgetValueChangedCallback(int index, PayloadWidget.PayloadWidgetType type,WidgetValueChangedCallback callback )
      Package:dji.sdk.payload
      Description:

      Set a callback for the specific widget, if the value of the widget is changed, the callback will be called.

      Input Parameters:
      int indexThe index of the widget.
      PayloadWidget.PayloadWidgetType typeAn enum value of PayloadWidgetType.
      WidgetValueChangedCallback callbackThe interface of WidgetValueChangedCallback.
      method removeWidgetValueChangedCallback
      void removeWidgetValueChangedCallback(int index, PayloadWidget.PayloadWidgetType type, WidgetValueChangedCallback callback)
      Package:dji.sdk.payload
      Description:

      Remove a callback for the widget.

      Input Parameters:
      int indexThe index of the widget.
      PayloadWidget.PayloadWidgetType typeAn enum value of PayloadWidgetType.
      WidgetValueChangedCallback callbackThe interface of WidgetValueChangedCallback.
      method removeWidgetValueChangedCallback
      void removeWidgetValueChangedCallback(WidgetValueChangedCallback callback)
      Package:dji.sdk.payload
      Description:

      Remove a callback for the widget.

      Input Parameters:
      WidgetValueChangedCallback callbackThe interface of WidgetValueChangedCallback.

      State Updates

      General
      method
      method setMessageCallback
      void setMessageCallback(HintMessageCallback callback)
      Package:dji.sdk.payload
      Description:

      Set the message callback, message is a string, the content of string is determined by firmware, it could be changed dynamically.

      Input Parameters:
      HintMessageCallback callbackThe interface of HintMessageCallback.
      method setCommandDataCallback
      void setCommandDataCallback(CommandDataCallback callback)
      Package:dji.sdk.payload
      Description:

      Set the command data callback, the command date typically send by payload in UART/CAN channel, the max bandwidth of this channel is 3KBytes/s on M200

      Input Parameters:
      CommandDataCallback callbackThe interface of CommandDataCallback.
      method setStreamDataCallback
      void setStreamDataCallback(StreamDataCallback callback)
      Package:dji.sdk.payload
      Description:

      Set the UDP data callback, this callback is for receiving the Non-Video data in UDP channel, the max bandwidth of this channel is 8Mbps in M200, 4Mbps in M210.

      Input Parameters:
      StreamDataCallback callbackThe interface of StreamDataCallback.


      General
      class
      Callbacks
      interface
      interface HintMessageCallback
      interface HintMessageCallback
      Package:dji.sdk.payload
      Description:

      This interface provides a callback to get messages sent from payload to the Mobile SDK.

      Interface Methods:

      Callback Method

      State
      method
      method onGetMessage
      void onGetMessage(String str)
      Package:dji.sdk.payload
      Description:

      when the payload send some message string to the Mobile SDK, this method will be called.

      Input Parameters:
      String strHint message string.
      interface CommandDataCallback
      interface CommandDataCallback
      Package:dji.sdk.payload
      Description:

      This interface provides a callback to get command data sent from payload to the Mobile SDK.

      Interface Methods:

      Callback Method

      State
      method
      method onGetCommandData
      void onGetCommandData(byte[] data)
      Package:dji.sdk.payload
      Description:

      When the payload send some command bytes to the Mobile SDK, this method will be called.

      Input Parameters:
      byte[] dataThe received command data.
      interface StreamDataCallback
      interface StreamDataCallback
      Package:dji.sdk.payload
      Description:

      This interface provides a callback to get stream data sent from payload to the Mobile SDK.

      Interface Methods:

      Callback Method

      State
      method
      method onGetStreamData
      void onGetStreamData(byte[] data, int len)
      Package:dji.sdk.payload
      Description:

      When the payload send the bytes to the Mobile SDK by UDP channel, this method will be called, note that if dealing of the data block the data feeder, the byte might lost.

      Input Parameters:
      byte[] dataThe received stream data.
      int lenValid length of the data.
      interface WidgetValueChangedCallback
      interface WidgetValueChangedCallback
      Package:dji.sdk.payload
      Description:

      This interface provides a callback to get value of the widget when changed.

      Interface Methods:

      Callback Method

      method onWidgetValueChanged
      void onWidgetValueChanged(PayloadWidget.PayloadWidgetType type, int index, int newValue)
      Package:dji.sdk.payload
      Description:

      Called when the value of the widget is changed.

      Input Parameters:
      PayloadWidget.PayloadWidgetType typeThe enum value of PayloadWidgetType.
      int indexThe index of the widget.
      int newValueAn int value.
      Inherited Methods:
      dji.sdk.base.BaseComponent
      method
      method setComponentListener
      void setComponentListener(ComponentListener listener)
      Package:dji.sdk.base
      Description:

      Sets the listener for the DJI component.

      Input Parameters:
      ComponentListener listenerThe callback of ComponentListener.
      method
      method getIndex
      int getIndex()
      Package:dji.sdk.base
      Description:

      Returns the component index. Index is zero based. A component will have an index greater than zero when there are multiple components of the same type on the DJI product, and one of the components already has the index 0. For instance, M210 can have two gimbal mounted cameras, and will therefore have two gimbal components with indices 0 and 1, and two camera components with indices 0 and 1. For Matrice 600, there are printed numbers on the battery boxes. The Battery component instance with index 0 corresponds to battery compartment number 1. For Inspire 2 and M200 series, Battery with index 0 corresponds to the battery on the port (left hand) side of the aircraft. For M210 and M210 RTK, Camera and Gimbal with index 0 corresponds to the camera and gimbal on the port (left hand) side of the aircraft.

      Return:
      intAn int value of index.
      method isConnected
      boolean isConnected()
      Package:dji.sdk.base
      Description:

      true if the component is connected.

      Return:
      booleantrue if the component is connected.
      method getSerialNumber
      void getSerialNumber(@NonNull CompletionCallbackWith<String> callback)
      Package:dji.sdk.base
      Description:

      Gets the serial number of the component. Depending on the component, this serial number might not match the serial number found on the physical component.

      Input Parameters:
      @NonNull CompletionCallbackWith<String> callbackThe execution callback with the value returned.
      method getFirmwareVersion
      void getFirmwareVersion(@NonNull CompletionCallbackWith<String> callback)
      Package:dji.sdk.base
      Description:

      Returns the firmware version of the component. Each component will have a different firmware version, the combination of which will form the package firmware version getFirmwarePackageVersion found in BaseProduct.

      Input Parameters:
      @NonNull CompletionCallbackWith<String> callbackThe execution callback with the value(s) returned.