DJI Mobile SDK Documentation

      class DJIPayload

      @interface DJIPayload : DJIBaseComponent
      Header:DJIPayload.h
      Inherits From:DJIBaseComponent
      Description:

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

      Class Members:
      Delegate
      property
      property delegate
      @property(nonatomic, weak) id<DJIPayloadDelegate> delegate
      Header:DJIPayload.h
      Description:

      Delegate to receive the update information.

      See Also:

      DJIPayloadDelegate

      Upstream Bandwidth
      method
      method getUpstreamBandwidthWithCompletion
      - (void)getUpstreamBandwidthWithCompletion:(void (^)(NSUInteger upstreamBandwidth, NSError * _Nullable error))completion
      Header:DJIPayload.h
      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:
      NSUInteger upstreamBandwidthThe upstream bandwidth determined by the firmware.
      NSError * _Nullable errorError retrieving the value.
      void (^)(NSUInteger upstreamBandwidth, NSError * _Nullable error) completionCompletion block to receive the result.
      Product Name
      method
      method getPayloadProductName
      - (NSString * _Nullable)getPayloadProductName
      Header:DJIPayload.h
      Description:

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

      Return:
      NSString * _NullableThe product name of the payload device.
      method configureWidgetValue:type:index:withCompletion
      - (void)configureWidgetValue:(NSUInteger)value type:(DJIPayloadWidgetType)type index:(NSUInteger)index withCompletion:(DJICompletionBlock)completion
      Header:DJIPayload.h
      Description:

      Set the value for a widget of the payload device. Different widget types requires different value:
      - for DJIPayloadWidgetTypeInput, the input should be an unsigned 32-bit integer
      - for DJIPayloadWidgetTypeSwitch, the input should be value of DJIPayloadSwitchState
      - for DJIPayloadWidgetTypeRange, the input should be a integer from value 0 to 100
      - for DJIPayloadWidgetTypeList, the input should be a integer not larger than list size minus one.
      Widget with type DJIPayloadWidgetTypeButton is not configurable.

      Input Parameters:
      NSUInteger valueThe value to configure.
      DJIPayloadWidgetType typeType of the widget to configure.
      NSUInteger indexIndex of the widget to configure.
      DJICompletionBlock completionCompletion block to receive the execution result.
      method setSwitchState:index:withCompletion
      - (void)setSwitchState:(DJIPayloadSwitchState)state index:(NSUInteger)index withCompletion:(DJICompletionBlock)completion
      Header:DJIPayload.h
      Description:

      Sets the switch state for the switch widget with the specific index. It has the same effect as configureWidgetValue:type:index:withCompletion with DJIPayloadWidgetTypeSwitch as the argument.

      Input Parameters:
      DJIPayloadSwitchState stateSwitch state to set.
      NSUInteger indexWidget index to set.
      DJICompletionBlock completionCompletion block to receive the execution result.
      method setRangeValue:index:withCompletion
      - (void)setRangeValue:(NSUInteger)rangeValue index:(NSUInteger)index withCompletion:(DJICompletionBlock)completion
      Header:DJIPayload.h
      Description:

      Sets the range value for the range widget with the specific index. It has the same effect as configureWidgetValue:type:index:withCompletion with DJIPayloadWidgetTypeRange as the argument.

      Input Parameters:
      NSUInteger rangeValueRange value to set. The valid range is [0, 100].
      NSUInteger indexWidget index to set.
      DJICompletionBlock completionCompletion block to receive the execution result.
      method setSelectedItem:index:withCompletion
      - (void)setSelectedItem:(NSUInteger)selectedItemIndex index:(NSUInteger)index withCompletion:(DJICompletionBlock)completion
      Header:DJIPayload.h
      Description:

      Sets the selected item index for the list widget with the specific index. It has the same effect as configureWidgetValue:type:index:withCompletion with DJIPayloadWidgetTypeList as the argument.

      Input Parameters:
      NSUInteger selectedItemIndexIndex of the selected item. The valid range is from 0 to list size - 1.
      NSUInteger indexWidget index to set.
      DJICompletionBlock completionCompletion block to receive the execution result.
      method setInputValue:index:withCompletion
      - (void)setInputValue:(NSUInteger)inputValue index:(NSUInteger)index withCompletion:(DJICompletionBlock)completion
      Header:DJIPayload.h
      Description:

      Sets the input value for the input widget with the specific index. It has the same effect as configureWidgetValue:type:index:withCompletion with DJIPayloadWidgetTypeList as the argument.

      Input Parameters:
      NSUInteger inputValueInput value to set. The valid value is an unsigned 32-bit integer.
      NSUInteger indexWidget index to set.
      DJICompletionBlock completionCompletion block to receive the execution result.
      Get Widget
      method
      method getWidget:index
      - (DJIPayloadWidget * _Nullable)getWidget:(DJIPayloadWidgetType)widgetType index:(NSInteger)widgetIndex
      Header:DJIPayload.h
      Description:

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

      Input Parameters:
      DJIPayloadWidgetType widgetTypeWidget type to get.
      NSInteger widgetIndexWidget index to get.
      Return:
      DJIPayloadWidget * _NullableThe widget corresponding to the widget type and the index. nil if the widgets are not ready or there is no widget corresponding to the widget type and the index.
      Get Widgets
      method
      method getWidgets
      - (NSArray<DJIPayloadWidget*> * _Nullable)getWidgets
      Header:DJIPayload.h
      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:
      NSArray<DJIPayloadWidget*> * _NullableThe full list of widgets. nil if the widgets are not fetched yet.
      method sendDataToPayload:withCompletion
      - (void)sendDataToPayload:(NSData *)data withCompletion:(DJICompletionBlock)completion
      Header:DJIPayload.h
      Description:

      Sends data to payload.
      - The length of the data to send cannot exceed 32 bytes for Matrice 200 series.
      - The length of the data to send cannot exceed 128 bytes for Matrice 200 V2 series. The throughput cannot exceed the bandwidth returned by getUpstreamBandwidthWithCompletion.

      Input Parameters:
      NSData * dataData that will be sent to the payload device.
      DJICompletionBlock completionCompletion block to receive the execution result.
      General
      class
      State Updates
      protocol
      protocol DJIPayloadDelegate
      @protocol DJIPayloadDelegate <NSObject>
      Header:DJIPayload.h
      Inherits From:NSObject
      Description:

      Delegate class to receive updated state related to Payload.

      Protocol Methods:

      Protocol Method

      method payload:didReceiveCommandData
      @optional
      - (void)payload:(DJIPayload *)payload didReceiveCommandData:(NSData *)data
      Header:DJIPayload.h
      Description:

      Receives the command data sent from the payload device. The command data is sent from the UART/CAN channel of the payload device and the bandwidth of this channel is 3K bytes/s on M200 series.

      Input Parameters:
      DJIPayload * payloadThe payload instance received the command data from the payload device.
      NSData * dataThe data that received by the payload instance.
      method payload:didReceiveStreamData
      @optional
      - (void)payload:(DJIPayload *)payload didReceiveStreamData:(NSData *)data
      Header:DJIPayload.h
      Description:

      Receives the stream data sent from the payload device. The stream data is sent from the UDP channel of the payload device. This channel has wider bandwidth than the channel for command data but data might get lost without re-transmission.

      Input Parameters:
      DJIPayload * payloadThe payload instance received the stream data from the payload device.
      NSData * dataThe data that received by the payload instance.
      method payload:didReceiveMessage
      @optional
      - (void)payload:(DJIPayload *)payload didReceiveMessage:(NSString *)message
      Header:DJIPayload.h
      Description:

      Receives a text message sent from the payload device.

      Input Parameters:
      DJIPayload * payloadThe payload instance received the text message from the payload device.
      NSString * messageThe message that received by the payload instance.
      method payload:didUpdateWidgets
      @optional
      - (void)payload:(DJIPayload *)payload didUpdateWidgets:(NSArray<DJIPayloadWidget*> *)widgets
      Header:DJIPayload.h
      Description:

      The payload device updates the value for the widgets.

      Input Parameters:
      DJIPayload * payloadThe payload instance received the updated widget values.
      NSArray<DJIPayloadWidget*> * widgetsThe updated value for widgets.