dji_flight_actions_module.hpp
Go to the documentation of this file.
1 
29 #ifndef DJI_FLIGHT_ACTIONS_MODULE_HPP
30 #define DJI_FLIGHT_ACTIONS_MODULE_HPP
31 
32 #include "dji_vehicle_callback.hpp"
33 
34 namespace DJI {
35 namespace OSDK {
36 
37 class FlightLink;
38 class FlightActions {
39  public:
40  FlightActions(Vehicle *vehicle);
41  ~FlightActions();
42 
43  public:
46  enum FlightCommand : uint8_t {
47  TAKE_OFF = 1,
48  LANDING = 2,
49  COURSE_LOCK = 5,
50  GO_HOME = 6,
51  START_MOTOR = 7,
52  STOP_MOTOR = 8,
53  CALIBRATE_COMPASS = 9,
54  EXIT_GOHOME = 12,
55  EXIT_TAKEOFF = 13,
56  EXIT_LANDING = 14,
57  EXIT_CALIBRATE_COMPASS = 21,
58  LANDING_GEAR_DOWN = 28,
59  LANDING_GEAR_UP = 29,
60  FORCE_LANDING_AVOID_GROUND = 30,
61  FORCE_LANDING = 31,
62  };
63  enum KillSwitch
64  {
65  ENABLE = 0x01,
66  DISABLE = 0x02
67  };
68 #pragma pack(1)
69  typedef struct CommonAck {
70  uint8_t retCode;
71  } CommonAck; // pack(1)
72 
73  typedef struct KillSwitchData
74  {
75  uint8_t high_version;
76  uint8_t low_version;
77  uint8_t debug_description[10];
78  uint8_t cmd : 2;
79  uint8_t reserved : 6;
80  } KillSwitchData; // pack(1)
81 #pragma pack()
82 
85  typedef struct UCBRetCodeHandler {
86  void (*UserCallBack)(ErrorCode::ErrorCodeType errCode, UserData userData);
87  UserData userData;
89 
90  static const int maxSize = 32;
91  UCBRetCodeHandler ucbHandler[maxSize];
92 
93  UCBRetCodeHandler *allocUCBHandler(void *callback, UserData userData);
94 
95  static void commonAckDecoder(Vehicle *vehicle, RecvContainer recvFrame,
96  UCBRetCodeHandler *ucb);
97 
98  ErrorCode::ErrorCodeType actionSync(uint8_t req, int timeout);
99 
100  void actionAsync(FlightCommand req,
101  void (*ackDecoderCB)(Vehicle *vehicle,
102  RecvContainer recvFrame,
103  UCBRetCodeHandler *ucb),
104  void (*userCB)(ErrorCode::ErrorCodeType, UserData userData),
105  UserData userData, int timeout = 2000, int retryTime = 1);
106 
107  ErrorCode::ErrorCodeType EmergencyBrakeActionSync(uint8_t req, int timeout);
108 
109  ErrorCode::ErrorCodeType killSwitch(KillSwitch cmd, int wait_timeout, char debugMsg[10]);
110  private:
111  FlightLink *flightLink;
112 
113 };
114 }
115 }
116 
117 #endif // DJI_FLIGHT_ACTIONS_MODULE_HPP
void * UserData
This is used as the datatype for all data arguments in callbacks.
Definition: dji_type.hpp:75
int64_t ErrorCodeType
Unified error type.
Definition: dji_error.hpp:144
Type definition for new Vehicle-style callbacks.
Received info.
Definition: dji_vehicle_callback.hpp:59
type of callback only deal the retCode for user
Definition: dji_flight_actions_module.hpp:85
Definition: dji_ack.cpp:38