MSDK 智能返航提示框不触发
Completed您好,在使用智能返航提示框,不触发,获取的状态值一直是IDLE,正确来说应该是COUNTING_DOWN。以下是我的代码
SettingSwitchHelper.setSmartReturnToHomeEnabled(isChecked, djiError -> {
if (djiError == null) {
ToastUtil.show(getContext(), "智能低电量返航已" + (isChecked ? "开启" : "关闭"));
SettingSwitchHelper.getSmartReturnToHomeEnabled(djiError1 -> {
if (djiError1 != null){
ToastUtil.show("返航提示框设置失败:"+djiError1.toString());
}
});
} else {
ToastUtil.show(getContext(), (isChecked ? "开启" : "关闭") + "智能低电量返航失败!");
}
});
下面代码是上面SettingSwitchHelper所调用的
/**
* 设置智能低电量返航
*/
public static void setSmartReturnToHomeEnabled(boolean b, CommonCallbacks.CompletionCallback callback) {
if (PhoApplication.getProductInstance() != null) {
Aircraft aircraft = (Aircraft) PhoApplication.getProductInstance();
if (aircraft.getFlightController() != null) {
FlightController fc = aircraft.getFlightController();
if (fc != null) {
fc.setSmartReturnToHomeEnabled(b, callback);
}
}
}
}
/**
* 智能返航提示框
* @param callback
*/
public static void getSmartReturnToHomeEnabled(CommonCallbacks.CompletionCallback callback){
if (PhoApplication.getProductInstance() != null) {
Aircraft aircraft = (Aircraft) PhoApplication.getProductInstance();
if (aircraft.getFlightController() != null) {
FlightController fc = aircraft.getFlightController();
if (fc != null) {
fc.getSmartReturnToHomeEnabled(new CommonCallbacks.CompletionCallbackWith<Boolean>() {
@Override
public void onSuccess(Boolean aBoolean) {
FlightControllerState state = fc.getState();
if (state != null){
GoHomeAssessment goHomeAssessment = state.getGoHomeAssessment();
if (goHomeAssessment != null){
SmartRTHState smartRTHState = goHomeAssessment.getSmartRTHState();
if (smartRTHState != null){
if (smartRTHState == SmartRTHState.COUNTING_DOWN) {
fc.confirmSmartReturnToHomeRequest(aBoolean, callback);
}else {
ToastUtil.show(smartRTHState.toString());
}
}
}
}
}
@Override
public void onFailure(DJIError djiError) {
if (djiError != null)
ToastUtil.show("低电量返航提示框状态错误:"+djiError.toString());
}
});
}
}
}
}
Please sign in to leave a comment.
Comments
1 comment