Skip to main content

Drone Warning Information Usage Tutorial

1. Overview

When the aircraft detects abnormal situations, whether it is a hardware anomaly or a software anomaly, it will report to the MSDK in the form of an alarm. Through the alarm, we can know the current status of the unmanned aerial vehicle in a timely manner to take corresponding treatment measures.

The alarm notifications of the unmanned aerial vehicle are divided into alarm notifications and real-time alarm notifications.

2. Instructions for the Use of Aircraft Alarms

2.1 Aircraft Alarms and Real-time Alarm Reporting

The aircraft alarm is a fixed-frequency reporting event, which means that the alarm list will be received all the time. If the reporting list is empty, the alarm is lifted.

val keyDroneWarning: AutelKey<List<WarningAtom>> = KeyTools.createKey(CommonKey.KeyDroneWarning)

Real-time alarm from drones are reported when there are changes, and only one report will be made when an alert occurs.

val keyDroneRuntimeWarning: AutelKey<List<WarningAtom>> =  KeyTools.createKey(CommonKey.KeyDroneRuntimeWarning)

2.2 Monitoring of aircraft alarms

Example Code One

//Monitor alarm reporting
val key: AutelKey<List<WarningAtom>> = KeyTools.createKey(CommonKey.KeyDroneWarning)
val CallBack = object : CommonCallbacks.KeyListener<List<WarningAtom>> {
override fun onValueChange(oldValue: List<WarningAtom>?, newValue: List<WarningAtom>) {
//Process
}
}
DeviceManager.getDeviceManager().getFirstDroneDevice()?.getKeyManager()?.listen(key, CallBack)
//Cancel monitor alarm reporting
DeviceManager.getDeviceManager().getFirstDroneDevice()?.getKeyManager()?.cancelListen(key, CallBack)

Example Code Two

//Monitor real-time alarm reporting
val key: AutelKey<List<WarningAtom>> = KeyTools.createKey(CommonKey.KeyDroneRuntimeWarning)
val CallBack = object : CommonCallbacks.KeyListener<List<WarningAtom>> {
override fun onValueChange(oldValue: List<WarningAtom>?, newValue: List<WarningAtom>) {
//Process
}
}
DeviceManager.getDeviceManager().getFirstDroneDevice()?.getKeyManager()?.listen(key, CallBack)
//Cancel monitor real-time alarm reporting
DeviceManager.getDeviceManager().getFirstDroneDevice()?.getKeyManager()?.cancelListen(key, CallBack)

2.3 Alarm parameter description

At present, we only focus on WaringIdEnum. For a more detailed explanation of the alarm enumeration, please refer to the API Reference.

 data class WarningAtom(

/**
* 组件类型
*/
var componentType: DroneComponentEnum = DroneComponentEnum.UNKNOWN,

/**
* 组件ID
*/
var componentId: DroneComponentIdEnum = DroneComponentIdEnum.NONE,

/**
* 告警ID
*/
var warningId: WaringIdEnum = WaringIdEnum.UNKNOWN,
)