dji_psdk_module.hpp
Go to the documentation of this file.
1 
29 #ifndef ONBOARDSDK_DJI_PSDK_MODULE_HPP
30 #define ONBOARDSDK_DJI_PSDK_MODULE_HPP
31 
32 #include <vector>
33 #include "dji_payload_base.hpp"
34 #include "dji_payload_link.hpp"
35 #if defined(__linux__)
36 #include "dji_mop_client.hpp"
37 #endif
38 
39 namespace DJI {
40 namespace OSDK {
43 class PSDKModule : public PayloadBase {
44  public:
45  enum FunctionID {
46  FUNCTION_SET_PSDK_1_0_WIDGET_VALUE = 70,
47  };
48  const static uint8_t psdkWidgetMaxCount = 30;
49  const static uint16_t MAX_SIZE_OF_PACKAGE = 255;
50 
52  BUTTON = 1,
55  SWITCH = 2,
59  RANGE = 3,
61  LIST = 4,
64  INPUT = 5,
66  UNKNOWN = 0xFF,
67  };
68 #pragma pack(1)
69  typedef struct PSDKWidgetInfo {
70  uint8_t type;
71  uint8_t index;
72  int32_t value;
73  } PSDKWidgetInfo; // pack(1)
74 
75  typedef struct PSDKWidgetReq {
76  uint8_t funcIndex;
77  uint8_t payloadNodeIndex;
79  PSDKWidgetInfo widgetInfo;
80  } PSDKWidgetReq; // pack(1)
81 
82  typedef struct PSDKWidgetRsp {
83  uint8_t funcIndex;
84  uint8_t payloadNodeIndex;
86  uint8_t ret_code;
87  } PSDKWidgetRsp; // pack(1)
88 
91  typedef struct PSDKWidgetValuesData {
92  uint8_t widgetTotalCount;
93  uint8_t widgetLocalCount;
94  PSDKWidgetInfo widgets[psdkWidgetMaxCount];
95  } PSDKWidgetValuesData; // pack(1)
96 #pragma pack()
97 
98  typedef void (*PSDKWidgetValuesUserCallback)(
99  std::vector<PSDKWidgetInfo> widgets, UserData userData);
100 
101  typedef struct PSDKWidgetValuesUserHandler {
102  PSDKWidgetValuesUserCallback callback;
103  UserData userData;
104  } PSDKWidgetValuesUserHandler;
105 
106  typedef void (*PSDKCommunicationUserCallback)(uint8_t *dataBuf,
107  uint16_t dataLen,
108  UserData userData);
109 
110  typedef struct PSDKCommonicationUserHandler {
111  PSDKCommunicationUserCallback callback;
112  UserData userData;
113  } PSDKCommonicationUserHandler;
114 
115  public:
116  PSDKModule(PayloadLink *payloadLink, PayloadIndexType payloadIndex,
117  std::string name, bool enable);
118 
119  ~PSDKModule();
120 
121  public:
122 #if defined(__linux__)
123 
125 #endif
126 
136  uint8_t widgetIndex, PayloadWidgetType widgetType, int widgetValue,
137  int timeout);
138 
149  uint8_t widgetIndex, PayloadWidgetType widgetType, int widgetValue,
150  void (*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData),
151  UserData userData);
152 
162  PSDKWidgetValuesUserCallback cb, UserData userData);
163 
169 
176 
185  PSDKCommunicationUserCallback cb, UserData userData);
186 
193 
200 
207  ErrorCode::ErrorCodeType sendDataToPSDK(uint8_t *data, uint16_t len);
208 
209  private:
210  static const int maxSize = 32;
211 #if defined(__linux__)
212  MopClient *mopClient;
213 #endif
214  PayloadLink *payloadLink;
215 
218  VehicleCallBackHandler psdkWidgetValuesDecodeHandler;
219 
221  VehicleCallBackHandler psdkCommonicationDecodeHandler;
222 
224  PSDKWidgetValuesUserHandler psdkWidgetValuesUserHandler;
225 
227  PSDKCommonicationUserHandler psdkCommonicationUserHandler;
228 
231  typedef struct UCBRetCodeHandler {
232  void (*UserCallBack)(ErrorCode::ErrorCodeType errCode, UserData userData);
233  UserData userData;
234  } UCBRetCodeHandler;
235 
238  UCBRetCodeHandler ucbHandler[maxSize];
239 
242  UCBRetCodeHandler *allocUCBHandler(void *callback, UserData userData);
243 
244  static void widgetValueDecoder(Vehicle *vehicle, RecvContainer recvFrame,
245  UserData userData);
246 
247  static void PSDKSetWidgetDecoder(Vehicle *vehicle, RecvContainer recvFrame,
248  UCBRetCodeHandler *ucb);
249 
250  static void commonicationDataDecoder(Vehicle *vehicle,
251  RecvContainer recvFrame,
252  UserData userData);
253 }; /* PSDKModule camera */
254 } // namespace OSDK
255 } // namespace DJI
256 
257 #endif // ONBOARDSDK_DJI_PSDK_MODULE_HPP
void * UserData
This is used as the datatype for all data arguments in callbacks.
Definition: dji_type.hpp:75
ErrorCode::ErrorCodeType sendDataToPSDK(uint8_t *data, uint16_t len)
sending data from OSDK to PSDK
ErrorCode::ErrorCodeType subscribePSDKCommonication(PSDKCommunicationUserCallback cb, UserData userData)
Sample to set the callback for PSDK commonication data, non-blocking.
Implementation of the mop client.
Definition: dji_psdk_module.hpp:55
Definition: dji_psdk_module.hpp:59
VehicleCallBackHandler * getCommunicationHandler()
used in internal to do suhscribing task for PSDK commonication data
int64_t ErrorCodeType
Unified error type.
Definition: dji_error.hpp:144
PSDK module.
Definition: dji_psdk_module.hpp:43
MopClient * getMopClient()
PayloadBase.
Definition: dji_payload_base.hpp:54
PayloadIndexType
The payload Index of camera.
Definition: dji_payload_base.hpp:42
uint8_t widgetTotalCount
Definition: dji_psdk_module.hpp:92
Abstract protocol implementation for payload module.
Definition: dji_psdk_module.hpp:66
ErrorCode::ErrorCodeType unsubscribeWidgetValues()
Sample to disable the callback for widget values, non-blocking.
Received info.
Definition: dji_vehicle_callback.hpp:59
Capturing PushData of PSDK widget values, CMD: 0x00, 0x07.
Definition: dji_psdk_module.hpp:91
The CallBackHandler struct allows users to encapsulate callbacks and data in one struct.
Definition: dji_vehicle_callback.hpp:83
ErrorCode::ErrorCodeType unsubscribePSDKCommonication()
Sample to disable the callback for PSDK commonication data, non-blocking.
Definition: dji_psdk_module.hpp:64
uint8_t widgetLocalCount
Definition: dji_psdk_module.hpp:93
Definition: dji_psdk_module.hpp:52
struct DJI::OSDK::PSDKModule::PSDKWidgetValuesData PSDKWidgetValuesData
Capturing PushData of PSDK widget values, CMD: 0x00, 0x07.
PayloadWidgetType
Definition: dji_psdk_module.hpp:51
ErrorCode::ErrorCodeType configureWidgetValueSync(uint8_t widgetIndex, PayloadWidgetType widgetType, int widgetValue, int timeout)
Sample to configure the value, blocking.
void configureWidgetValueAsync(uint8_t widgetIndex, PayloadWidgetType widgetType, int widgetValue, void(*UserCallBack)(ErrorCode::ErrorCodeType retCode, UserData userData), UserData userData)
Sample to configure the value, non-blocking.
Definition: dji_ack.cpp:38
VehicleCallBackHandler * getSubscribeWidgetValuesHandler()
used in internal to do suhscribing task for PSDK widget
ErrorCode::ErrorCodeType subscribePSDKWidgetValues(PSDKWidgetValuesUserCallback cb, UserData userData)
Sample to set the callback for widget values, non-blocking.
Class providing APIs & data structures for acting as a MOP client.
Definition: dji_mop_client.hpp:43
Definition: dji_psdk_module.hpp:61