Access to the Cloud Server

2022-07-19
No Rating

Create Cloud API License

Before you can use the Cloud API interface, you need to register as a developer on the DJI developer website. After registration, you will be able to create the "Cloud API" application and get the APP ID, APP key, and APP License required for the API interaction. If the DJI Pilot 2 does not check the license correctly, then it will not be able to complete the subsequent actions of the DJI Pilot 2 on the cloud. Before the pilot access to the Third-Party platform, the App License should be verified. API: JSBridge:platformVerifyLicense.



Pilot access to Third-party Platform

Notification:

  • When DJI Pilot 2 and the airport access third-party clouds, in scenarios with high-security requirements, the communication link needs to be encrypted to achieve secure data communication. By default, the device on the SSL link authenticates the server, and the server does not authenticate the device. If the server enables device authentication, the client Auth configuration needs to be performed on the server.
  • DJI Pilot 2 supports certificates issued by Godaddy. If developers need data security encryption, they can use the same certification authority certificate as DJI to achieve MQTT SSL authentication.

Interactive timing diagram

device online.png

To verify the Token, there are three situations:

  • No Token, return H5 login page.

  • Have Token and Token is valid, return the main page after login.

  • Have Token but Token is invalid, the following process should be executed.

Token  expired.png

verify success.png

Configure Thrid Cloud

As shown in the image below, there is an "Open Platforms" portal in the Cloud Service section of the DJI Pilot 2's main page, and then you can initiate a connection by entering the URL link you are accessing on the Open Platforms page.

Since the first time the H5 page is requested, there is no token. so the server needs to develop an H5 login page, which the DJI Pilot 2 will first pull after each configured access link, and then all subsequent actions to obtain the token will be completed by this H5 page.

Note:

The access link is an http/https link. If https is required, SSL certification is required, as detailed in the section Data Security.



Pilot disconnect to the Third-party platform

  • Active offline Active offline always is that the drone disconnect from the remote controller. Device self-offline.png

  • Passive offline device  force offline.png

Detailed Realization

License Certificate Verification.

After registering the Cloud API application, developers will need to perform a license authentication verification. Refer to App API > JSBridge API References window.djiBridge.platformVerifyLicense(String appId,String appKey,String license)

Requests the Token that is Stored in DJI Pilot 2

The DJI Pilot 2 stores the token locally and developers can get the token stored by the DJI Pilot 2 through the Webview JSBridge interface, which allows developers to check whether the token has expired. Refer to App API > JSBridge API References window.djiBridge.apiGetToken()

Note:

Before you can use this interface, you need to load the "API Module".

Refer to App API > JSBridge API References window.djiBridge.platformVerifyLicense(String appId,String appKey,String license)

Load Cloud Module

The process of loading the cloud module will initiate an MQTT login request, so the server needs to pre-configure the login password for the MQTT gateway and remove the MQTT anonymous login method. Of course, if there is no requirement for security, you can also directly use the default anonymous login, thus reducing the configuration of the MQTT account password.

DJI Pilot 2 does not load the cloud module by default, so the Webview needs to apply to the server to get the MQTT related login information required for the cloud module and assign the value to DJI Pilot 2's cloud module throughJSBridge. After DJI Pilot 2's cloud module component is loaded, it will initiate an MQTT connection request to the server using MQTT parameters. After successful login, DJI Pilot 2 will also inform the Webview of the status throughJSBridge. Refer to App API > JSBridge API References window.djiBridge.platformVerifyLicense(String appId,String appKey,String license)

Set Workspace ID/Platform Information

The Webview can request the platform and workspace name and description that need to be set in DJI Pilot 2 to the backend after getting the online success information pushed from the cloud module, and the content of these three fields will be defined by the developer according to the actual business requirements. After the H5 page gets the platform name, workspace name and workspace description, it can set the information to DJI Pilot 2 throughJSBridge interface, and DJI Pilot 2 will display the workspace name and workspace description fields in the cloud portal on DJI Pilot 2, and the platform name is displayed in the top tab bar of webview.

API interface:

  1. Set workspace id: Refer to App API > JSBridge API References- window.djiBridge.platformSetWorkspaceId(String uuid)
  2. Set platform information: Refer to App API > JSBridge API References- window.djiBridge.platformSetInformation(String platformName, String workspaceName, String desc)