The KeyManager class provides a set of methods to access the parameters of the hardware module and control the behavior of the hardware module, including DJIKey Value setting, Value acquisition, Value monitoring, and Action execution. The DJIKey instance can be created more conveniently through the createKey method provided by the KeyTools class.
- DJIKey's setValue method.
- DJIKey's getValue method.
- DJIKey's value listener.
- DJIKey's action execution.
You can easily create a DJIKey instance bu calling the createKey() or createCameraKey() method from KeyTools class.
In MSDK V4, the usage of DJIKey has been encapsulated as setter and getter method such as setHomeLocation() and getHomeLocation(). In fact the setHomeLocation() is calling the setValue method for DJIKey HOME_LOCATION. In MSDK V5, all DJIKey will not be encapsulated and it requires you to use the very basic method to execute those keys.
There are 7 types of DJIKey is opened to public:
- ProductKey
- AirlinkKey
- CameraKey
- GimbalKey
- FlightControllerKey
- RemoteControllerKey
- BatteryKey
The following figure shows the calling process of using the KeyManager interface to determine that the flight controller is connected normally and the GPS signal level is greater than or equal to level 2, then setting the home point for the aircraft, and finally executing the return operation. For detailed usage, please check the API documentation of Mobile SDK.
The flowchart provides a clear understanding that the invocation of DJIKey is actually divided into two parts: creating the DJIKey and executing it.
- The interface provided by KeyManager is responsible for execution, which includes methods like setValue, getValue, and listen;
- KeyTools is responsible for creating the DJIKey. The DJIKey includes the type of Key and its corresponding parameters, for example, CameraKey.KeyCameraZoomRatios is a type of DJIKey, and you can also pass in componentIndexType (gimbal load position) and cameraLensType (lens type) to specify the target camera's lens. To obtain the zoom ratio, you need to specify the zoom lens.
- For information on how to check which execution methods are supported by a Key, you can refer to this article: How to check which KeyManager interfaces are supported by a Key?
Comments
1 comment
In sdk 4 the keylistener callbacks by default occurred on a dji_callback_thread. It appears that some, maybe all callbacks in sdk 5 occur on the main thread. Is that expected behaviour?
Please sign in to leave a comment.