A top-level encapsulation of a DJI drone/FC connected to your OES. More...
#include <dji_vehicle.hpp>
Public Types | |
typedef struct DJI::OSDK::Vehicle::ActivateData | ActivateData |
Public Member Functions | |
Vehicle (const char *device, uint32_t baudRate, bool threadSupport, bool enableAdvancedSensing=false) | |
Vehicle (bool threadSupport) | |
void | obtainCtrlAuthority (VehicleCallBack callback=0, UserData userData=0) |
Obtain the control authority of the api (non-blocking call) More... | |
ACK::ErrorCode | obtainCtrlAuthority (int timeout) |
Obtain the control authority of the api (blocking call) More... | |
void | releaseCtrlAuthority (VehicleCallBack callback=0, UserData userData=0) |
Release the control authority of the api (non-blocking call) More... | |
ACK::ErrorCode | releaseCtrlAuthority (int timeout) |
Release the control authority of the api (blocking call) More... | |
ACK::ErrorCode | activate (ActivateData *data, int timeout) |
Send activation control to your flight controller to check if: a) your application registered in your developer account b) API Control enabled in the Assistant software Proceed to programming if activation successful. More... | |
ACK::DroneVersion | getDroneVersion (int timeout) |
Send get version control to the vehicle. More... | |
void | activate (ActivateData *data, VehicleCallBack callback=0, UserData userData=0) |
Send activation request to your flight controller to check if: a) your application registered in your developer account b) API Control enabled in the Assistant software Proceed to programming if activation successful. More... | |
Public Attributes | |
OpenProtocol * | protocolLayer |
DataSubscription * | subscribe |
DataBroadcast * | broadcast |
Control * | control |
Camera * | camera |
Gimbal * | gimbal |
MFIO * | mfio |
MobileCommunication * | moc |
MobileDevice * | mobileDevice |
MissionManager * | missionManager |
HardwareSync * | hardSync |
VirtualRC * | virtualRC |
PayloadDevice * | payloadDevice |
CameraManager * | cameraManager |
FlightController * | flightController |
PSDKManager * | psdkManager |
CircularBuffer * | circularBuffer |
void * | nbCallbackFunctions [200] |
UserData | nbUserData [200] |
bool | hotPointData |
bool | wayPointData |
void | getDroneVersion (VehicleCallBack callback=0, UserData userData=0) |
ActivateData | getAccountData () const |
void | setAccountData (const ActivateData &value) |
void | setVersion (const Version::FirmWare &value) |
Version::FirmWare | getFwVersion () const |
char * | getHwVersion () const |
char * | getHwSerialNum () const |
bool | isLegacyM600 () |
bool | isM100 () |
bool | isM210V2 () |
void | setKey (const char *key) |
void | setLastReceivedFrame (RecvContainer recvFrame) |
RecvContainer | getLastReceivedFrame () |
void * | waitForACK (const uint8_t(&cmd)[OpenProtocolCMD::MAX_CMD_ARRAY_SIZE], int timeout) |
Wait for ACK frame to arrive. | |
void | processReceivedData (RecvContainer *receivedFrame) |
This function takes a frame and calls the right handlers/functions based on the nature of the frame (ack, blocking, etc.) More... | |
void | callbackPoll () |
int | callbackIdIndex () |
Thread * | getSerialReadThread () const |
Thread management. | |
Thread * | getCallbackThread () const |
Thread * | getUSBReadThread () const |
bool | isUSBThreadReady () |
uint8_t * | getRawVersionAck () |
int | functionalSetUp () |
Initialize all functional Vehicle components like, Subscription, Broadcast, Control, ect. | |
bool | GimbalSetUp () |
Initialize gimbal component. | |
PlatformManager * | getPlatformManager () const |
void | setEncryption (bool encryptSetting) |
bool | getEncryption () |
bool | getActivationStatus () |
MobileDevice * | getMobileDevice () |
static bool | parseDroneVersionInfo (Version::VersionData &versionData, uint8_t *ackPtr) |
Detailed Description
A top-level encapsulation of a DJI drone/FC connected to your OES.
This class instantiates objects for all features your drone/FC supports. Create a Vechile object in your code and you will have access to the entire DJI OSDK API.
Member Function Documentation
◆ activate() [1/2]
ACK::ErrorCode Vehicle::activate | ( | ActivateData * | data, |
int | timeout | ||
) |
Send activation control to your flight controller to check if:
a) your application registered in your developer account
b) API Control enabled in the Assistant software
Proceed to programming if activation successful.
- Remarks
- Blocks until ACK frame arrives or timeout occurs
- Returns
- ACK from flight controller
- Note
- for ios verification
Using function prototype II of send
Let user know about other errors if any
◆ activate() [2/2]
void Vehicle::activate | ( | ActivateData * | data, |
VehicleCallBack | callback = 0 , |
||
UserData | userData = 0 |
||
) |
Send activation request to your flight controller to check if:
a) your application registered in your developer account
b) API Control enabled in the Assistant software
Proceed to programming if activation successful.
- Note
- for ios verification
Using function prototype II of send
◆ callbackPoll()
void Vehicle::callbackPoll | ( | ) |
User sets this to true in order to enable Callback thread with Non blocking calls.
If Head = Tail, there is no data in the buffer, do not call cbPop.
◆ getAccountData()
Vehicle::ActivateData Vehicle::getAccountData | ( | ) | const |
Get Activation information
◆ getDroneVersion() [1/2]
ACK::DroneVersion Vehicle::getDroneVersion | ( | int | timeout | ) |
Send get version control to the vehicle.
- Returns
- type ACK::DroneVersion containing: ACKErrorCode: data (ack value) VersionData: hardware version VersionData: firmware version VersionData: hardware serial number VersionData: CRC VersionData: version name
Set fwVersion to 0 so we can catch the error.
Construct final ACK to return to user
◆ getDroneVersion() [2/2]
void Vehicle::getDroneVersion | ( | VehicleCallBack | callback = 0 , |
UserData | userData = 0 |
||
) |
Get aircraft version.
- Note
- You can query your flight controller prior to activation.
◆ isLegacyM600()
bool Vehicle::isLegacyM600 | ( | ) |
Check for the special M600 backwards compatibility
◆ isM100()
bool Vehicle::isM100 | ( | ) |
Check for the M100 backwards compatibility
◆ obtainCtrlAuthority() [1/2]
void Vehicle::obtainCtrlAuthority | ( | VehicleCallBack | callback = 0 , |
UserData | userData = 0 |
||
) |
Obtain the control authority of the api (non-blocking call)
- Parameters
-
callback callback function userData user data (void ptr)
◆ obtainCtrlAuthority() [2/2]
ACK::ErrorCode Vehicle::obtainCtrlAuthority | ( | int | timeout | ) |
Obtain the control authority of the api (blocking call)
- Parameters
-
timeout time to wait for ACK
◆ parseDroneVersionInfo()
|
static |
Note down our starting point as a sanity check
2b ACK.
Next, we might have CRC or ID; Put them into a variable that we will parse later. Find next \0
Fill in the termination character
Now we're at the name. First, let's fill up the name field.
Now, we start parsing the name. Let's find the second space character.
Found first space ("SDK-v1.x")
Found second space ("BETA")
Next is the HW version
Fill in the termination character
Finally, we come to the FW version. We don't know if each clause is 2 or 3 digits long.
Special cases M100:
Bug in M100 does not report the right FW.
M600/A3 FW 3.2.10
Bug in M600 does not report the right FW.
Now, we can parse the CRC and ID based on FW version. If it's older than 3.2 then it'll have a CRC, else not.
Not catastrophic error
Fill in the termination character
Not catastrophic error
Fill in the termination character
Finally, we print stuff out.
◆ processReceivedData()
void Vehicle::processReceivedData | ( | RecvContainer * | receivedFrame | ) |
This function takes a frame and calls the right handlers/functions based on the nature of the frame (ack, blocking, etc.)
- Parameters
-
receivedFrame RecvContainer populated by the protocolLayer
- Returns
- NULL
◆ releaseCtrlAuthority() [1/2]
void Vehicle::releaseCtrlAuthority | ( | VehicleCallBack | callback = 0 , |
UserData | userData = 0 |
||
) |
Release the control authority of the api (non-blocking call)
- Parameters
-
callback callback function userData user data (void ptr)
◆ releaseCtrlAuthority() [2/2]
ACK::ErrorCode Vehicle::releaseCtrlAuthority | ( | int | timeout | ) |
Release the control authority of the api (blocking call)
- Parameters
-
timeout time to wait for ACK
◆ setLastReceivedFrame()
void Vehicle::setLastReceivedFrame | ( | RecvContainer | recvFrame | ) |
- Note
- not used yet Storage for last received packet: accessors
◆ setVersion()
void Vehicle::setVersion | ( | const Version::FirmWare & | value | ) |
Set SDK version.
Member Data Documentation
◆ nbUserData
UserData DJI::OSDK::Vehicle::nbUserData[200] |
The documentation for this class was generated from the following files:
- osdk-core/api/inc/dji_vehicle.hpp
- osdk-core/api/src/dji_vehicle.cpp