2026-02-01 14:34:23 +08:00
|
|
|
|
package com.aros.apron.manager;
|
2026-04-08 13:39:51 +08:00
|
|
|
|
|
2026-02-01 14:34:23 +08:00
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
|
2026-05-20 10:15:41 +08:00
|
|
|
|
import android.os.Handler;
|
|
|
|
|
|
import android.os.Looper;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
|
2026-02-01 14:34:23 +08:00
|
|
|
|
import com.aros.apron.base.BaseManager;
|
2026-05-20 10:15:41 +08:00
|
|
|
|
import com.aros.apron.constant.AMSConfig;
|
|
|
|
|
|
import com.aros.apron.entity.Movement;
|
2026-02-01 14:34:23 +08:00
|
|
|
|
import com.aros.apron.entity.PayloadInfo;
|
2026-05-20 10:15:41 +08:00
|
|
|
|
import com.aros.apron.entity.PsdkWidgetValuesReport;
|
2026-02-01 14:34:23 +08:00
|
|
|
|
import com.aros.apron.tools.LogUtil;
|
2026-05-20 10:15:41 +08:00
|
|
|
|
import com.aros.apron.tools.MqttManager;
|
2026-04-08 13:39:51 +08:00
|
|
|
|
import com.aros.apron.xclog.XcFileLog;
|
2026-02-01 14:34:23 +08:00
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
|
import com.google.gson.GsonBuilder;
|
2026-04-08 13:39:51 +08:00
|
|
|
|
|
2026-02-01 14:34:23 +08:00
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Map;
|
2026-05-20 10:15:41 +08:00
|
|
|
|
import java.util.UUID;
|
2026-04-08 13:39:51 +08:00
|
|
|
|
|
2026-02-01 14:34:23 +08:00
|
|
|
|
import dji.sdk.keyvalue.key.FlightControllerKey;
|
|
|
|
|
|
import dji.sdk.keyvalue.key.KeyTools;
|
|
|
|
|
|
import dji.v5.common.callback.CommonCallbacks;
|
|
|
|
|
|
import dji.v5.common.error.IDJIError;
|
|
|
|
|
|
import dji.v5.manager.KeyManager;
|
|
|
|
|
|
import dji.v5.manager.aircraft.payload.PayloadCenter;
|
|
|
|
|
|
import dji.v5.manager.aircraft.payload.PayloadIndexType;
|
|
|
|
|
|
import dji.v5.manager.aircraft.payload.data.PayloadBasicInfo;
|
|
|
|
|
|
import dji.v5.manager.aircraft.payload.data.PayloadWidgetInfo;
|
|
|
|
|
|
import dji.v5.manager.aircraft.payload.listener.PayloadBasicInfoListener;
|
|
|
|
|
|
import dji.v5.manager.aircraft.payload.listener.PayloadDataListener;
|
|
|
|
|
|
import dji.v5.manager.aircraft.payload.listener.PayloadWidgetInfoListener;
|
|
|
|
|
|
import dji.v5.manager.interfaces.IPayloadManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-03-04 11:20:07 +08:00
|
|
|
|
public class PayloadWidgetManager extends BaseManager {
|
2026-02-01 14:34:23 +08:00
|
|
|
|
private String TAG = this.getClass().getSimpleName();
|
|
|
|
|
|
|
|
|
|
|
|
private List<PayloadInfo> payloadInfos = new ArrayList<>();
|
|
|
|
|
|
|
2026-05-20 10:15:41 +08:00
|
|
|
|
private PayloadBasicInfo cachedBasicInfo;
|
|
|
|
|
|
private PayloadWidgetInfo cachedWidgetInfo;
|
|
|
|
|
|
private Handler psdkReportHandler;
|
|
|
|
|
|
private Runnable psdkReportRunnable;
|
|
|
|
|
|
private static final long PSDK_REPORT_INTERVAL = 5000; // 5秒
|
|
|
|
|
|
|
|
|
|
|
|
private StringBuffer payloadBuffer = new StringBuffer();
|
|
|
|
|
|
private volatile boolean hasSpeaker = false;
|
|
|
|
|
|
private volatile boolean speakerPortSet = false;
|
|
|
|
|
|
|
2026-02-01 14:34:23 +08:00
|
|
|
|
private PayloadWidgetManager() {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static class PayloadWidgetHolder {
|
|
|
|
|
|
private static final PayloadWidgetManager INSTANCE = new PayloadWidgetManager();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static PayloadWidgetManager getInstance() {
|
|
|
|
|
|
return PayloadWidgetHolder.INSTANCE;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 使用GsonBuilder配置Gson实例以允许序列化特殊浮点数值
|
|
|
|
|
|
Gson gson = new GsonBuilder()
|
|
|
|
|
|
.serializeSpecialFloatingPointValues() // 这是关键
|
|
|
|
|
|
.create();
|
|
|
|
|
|
|
2026-04-08 13:39:51 +08:00
|
|
|
|
|
2026-02-01 14:34:23 +08:00
|
|
|
|
public void initPayloadInfo() {
|
|
|
|
|
|
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.KeyConnection));
|
|
|
|
|
|
if (isConnect != null && isConnect) {
|
2026-04-08 13:39:51 +08:00
|
|
|
|
//负载信息
|
2026-02-01 14:34:23 +08:00
|
|
|
|
Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
|
|
|
|
if (payloadManager != null) {
|
2026-04-25 15:36:59 +08:00
|
|
|
|
IPayloadManager iPayloadManager = payloadManager.get(PayloadIndexType.PORT_2);
|
2026-02-01 14:34:23 +08:00
|
|
|
|
if (iPayloadManager != null) {
|
2026-04-25 15:36:59 +08:00
|
|
|
|
PayloadCenter.getInstance().getPayloadManager().get(PayloadIndexType.PORT_2).pullWidgetInfoFromPayload(new CommonCallbacks.CompletionCallback() {
|
2026-02-01 14:34:23 +08:00
|
|
|
|
@Override
|
2026-03-04 11:20:07 +08:00
|
|
|
|
public void onSuccess() {
|
2026-04-08 13:39:51 +08:00
|
|
|
|
//基础信息
|
2026-04-25 15:36:59 +08:00
|
|
|
|
PayloadCenter.getInstance().getPayloadManager().get(PayloadIndexType.PORT_2).addPayloadBasicInfoListener(new PayloadBasicInfoListener() {
|
2026-04-08 13:39:51 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void onPayloadBasicInfoUpdate(PayloadBasicInfo info) {
|
2026-05-20 10:15:41 +08:00
|
|
|
|
//LogUtil.log(TAG, "左侧负载基础信息:" + info.toString());
|
|
|
|
|
|
// XcFileLog.getInstace().w(TAG, "左侧负载基础信息:" + info.toString());
|
|
|
|
|
|
//cachedBasicInfo = info;
|
|
|
|
|
|
//startPsdkWidgetReport();
|
2026-04-08 13:39:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-04-25 15:36:59 +08:00
|
|
|
|
PayloadCenter.getInstance().getPayloadManager().get(PayloadIndexType.PORT_2).addPayloadDataListener(new PayloadDataListener() {
|
2026-04-08 13:39:51 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void onDataFromPayloadUpdate(byte[] data) {
|
2026-05-20 10:15:41 +08:00
|
|
|
|
String cleanData = new String(data, java.nio.charset.StandardCharsets.UTF_8)
|
|
|
|
|
|
.replaceAll("[^\\x20-\\x7E\\u4e00-\\u9fa5]", "");
|
|
|
|
|
|
// LogUtil.log(TAG, "左侧负载数据信息:" + cleanData);
|
|
|
|
|
|
// XcFileLog.getInstace().w(TAG, "左侧负载数据信息:" + cleanData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cleanData.contains("jwD")) {
|
|
|
|
|
|
payloadBuffer.setLength(0);
|
|
|
|
|
|
payloadBuffer.append(cleanData);
|
|
|
|
|
|
// LogUtil.log(TAG, "负载数据开始,清空缓存");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cleanData.contains("}")) {
|
|
|
|
|
|
if (payloadBuffer.length() > 0) {
|
|
|
|
|
|
payloadBuffer.append(cleanData);
|
|
|
|
|
|
String fullJson = payloadBuffer.toString();
|
|
|
|
|
|
payloadBuffer.setLength(0); // 清空,准备下次
|
|
|
|
|
|
// LogUtil.log(TAG, "负载完整数据: " + fullJson);
|
|
|
|
|
|
sendFloatingWindowText(fullJson);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//LogUtil.log(TAG, "负载数据: 缓存为空,忽略孤立}");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-08 13:39:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-03-04 11:20:07 +08:00
|
|
|
|
//可以把负载设备控件打印
|
2026-04-25 15:36:59 +08:00
|
|
|
|
PayloadCenter.getInstance().getPayloadManager().get(PayloadIndexType.PORT_2).addPayloadWidgetInfoListener(new PayloadWidgetInfoListener() {
|
2026-03-04 11:20:07 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void onPayloadWidgetInfoUpdate(PayloadWidgetInfo info) {
|
2026-05-20 10:15:41 +08:00
|
|
|
|
//LogUtil.log(TAG, "左侧负载控件信息:" + info.toString());
|
|
|
|
|
|
//XcFileLog.getInstace().w(TAG, "左侧负载控件信息:" + info.toString());
|
|
|
|
|
|
//cachedWidgetInfo = info;
|
2026-03-04 11:20:07 +08:00
|
|
|
|
//如果负载为空
|
2026-05-20 10:15:41 +08:00
|
|
|
|
detectSpeaker(info, 2);
|
|
|
|
|
|
|
2026-04-08 13:39:51 +08:00
|
|
|
|
if (info.getConfigInterfaceWidgetList() == null || info.getMainInterfaceWidgetList() == null) {
|
2026-04-25 15:36:59 +08:00
|
|
|
|
PayloadCenter.getInstance().getPayloadManager().get(PayloadIndexType.PORT_2).pullWidgetInfoFromPayload(new CommonCallbacks.CompletionCallback() {
|
2026-03-04 11:20:07 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void onSuccess() {
|
2026-04-08 13:39:51 +08:00
|
|
|
|
LogUtil.log(TAG, "负载重复拉取成功");
|
|
|
|
|
|
|
2026-03-04 11:20:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onFailure(@NonNull IDJIError idjiError) {
|
2026-04-08 13:39:51 +08:00
|
|
|
|
LogUtil.log(TAG, "负载重复拉取失败");
|
2026-03-04 11:20:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2026-02-01 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2026-03-04 11:20:07 +08:00
|
|
|
|
public void onFailure(@NonNull IDJIError idjiError) {
|
2026-04-08 13:39:51 +08:00
|
|
|
|
LogUtil.log(TAG, "负载第一次拉取失败");
|
2026-02-01 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
LogUtil.log(TAG, "监听LEFT_OR_MAIN PSDK数据失败:设备未连接");
|
|
|
|
|
|
}
|
2026-04-08 13:39:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
2026-05-20 10:15:41 +08:00
|
|
|
|
IPayloadManager iPayloadManager3 = payloadManager.get(PayloadIndexType.PORT_3);
|
|
|
|
|
|
if (iPayloadManager3 != null) {
|
|
|
|
|
|
//基础信息
|
|
|
|
|
|
PayloadCenter.getInstance().getPayloadManager().get(PayloadIndexType.PORT_3).addPayloadBasicInfoListener(new PayloadBasicInfoListener() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onPayloadBasicInfoUpdate(PayloadBasicInfo info) {
|
|
|
|
|
|
// LogUtil.log(TAG, "3号负载基础信息:" + info.toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
PayloadCenter.getInstance().getPayloadManager().get(PayloadIndexType.PORT_3).addPayloadDataListener(new PayloadDataListener() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onDataFromPayloadUpdate(byte[] data) {
|
|
|
|
|
|
// LogUtil.log(TAG, "3号Data负载基础信息:" + data);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
//可以把负载设备控件打印
|
|
|
|
|
|
PayloadCenter.getInstance().getPayloadManager().get(PayloadIndexType.PORT_3).addPayloadWidgetInfoListener(new PayloadWidgetInfoListener() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onPayloadWidgetInfoUpdate(PayloadWidgetInfo info) {
|
|
|
|
|
|
// LogUtil.log(TAG, "3号负载控件信息:" + info.toString());
|
|
|
|
|
|
detectSpeaker(info, 3);
|
|
|
|
|
|
if (info.getConfigInterfaceWidgetList() == null || info.getMainInterfaceWidgetList() == null) {
|
|
|
|
|
|
PayloadCenter.getInstance().getPayloadManager().get(PayloadIndexType.PORT_3).pullWidgetInfoFromPayload(new CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onSuccess() {
|
|
|
|
|
|
// LogUtil.log(TAG, "负载重复拉取成功");
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onFailure(@NonNull IDJIError idjiError) {
|
|
|
|
|
|
//LogUtil.log(TAG, "负载重复拉取失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
LogUtil.log(TAG, "监听right_OR_MAIN PSDK数据失败:设备未连接");
|
|
|
|
|
|
}
|
2026-04-08 13:39:51 +08:00
|
|
|
|
|
2026-05-20 10:15:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
LogUtil.log(TAG, "监听psdk数据失败:未检测到设备");
|
|
|
|
|
|
}
|
2026-02-01 14:34:23 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
LogUtil.log(TAG, "设备未连接");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-04 11:20:07 +08:00
|
|
|
|
|
2026-02-01 14:34:23 +08:00
|
|
|
|
// //设置三方负载控件
|
|
|
|
|
|
// public void setWidget(MQMessage message) {
|
|
|
|
|
|
// Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.KeyConnection));
|
|
|
|
|
|
// if (isConnect != null && isConnect) {
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManagerMap = payloadManager;
|
|
|
|
|
|
// WidgetValue widgetValue = new WidgetValue();
|
|
|
|
|
|
// widgetValue.setValue(message.getWidgetValue());
|
|
|
|
|
|
// widgetValue.setIndex(message.getWidgetIndex());
|
|
|
|
|
|
// widgetValue.setType(WidgetType.find(message.getWidgetType()));
|
|
|
|
|
|
// payloadManagerMap.get(PayloadIndexType.PORT_2).setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onSuccess() {
|
|
|
|
|
|
// LogUtil.log(TAG,"设置widget成功");
|
|
|
|
|
|
// sendMsg2Server(message);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onFailure(@NonNull IDJIError error) {
|
|
|
|
|
|
// LogUtil.log(TAG,"设置widget失败:"+getIDJIErrorMsg(error));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// //锁定
|
|
|
|
|
|
// public void lock(MQMessage message) {
|
|
|
|
|
|
// Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.KeyConnection));
|
|
|
|
|
|
// if (isConnect != null && isConnect) {
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManagerMap = payloadManager;
|
|
|
|
|
|
// WidgetValue widgetValue = new WidgetValue();
|
|
|
|
|
|
// widgetValue.setValue(0);
|
|
|
|
|
|
// widgetValue.setIndex(0);
|
|
|
|
|
|
// widgetValue.setType(WidgetType.SWITCH);
|
|
|
|
|
|
// payloadManagerMap.get(PayloadIndexType.PORT_2).setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onSuccess() {
|
|
|
|
|
|
// sendMsg2Server(message);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onFailure(@NonNull IDJIError error) {
|
|
|
|
|
|
// LogUtil.log(TAG,"解锁失败:" +new Gson().toJson(error));
|
|
|
|
|
|
// sendMsg2Server(message, "解锁失败:" + getIDJIErrorMsg(error));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// //解锁
|
|
|
|
|
|
// public void unlock(MQMessage message) {
|
|
|
|
|
|
// Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.KeyConnection));
|
|
|
|
|
|
// if (isConnect != null && isConnect) {
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManagerMap = payloadManager;
|
|
|
|
|
|
// WidgetValue widgetValue = new WidgetValue();
|
|
|
|
|
|
// widgetValue.setValue(1);
|
|
|
|
|
|
// widgetValue.setIndex(0);
|
|
|
|
|
|
// widgetValue.setType(WidgetType.SWITCH);
|
|
|
|
|
|
// payloadManagerMap.get(PayloadIndexType.PORT_2).setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onSuccess() {
|
|
|
|
|
|
// sendMsg2Server(message);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onFailure(@NonNull IDJIError idjiError) {
|
|
|
|
|
|
// LogUtil.log(TAG,"解锁失败:" +new Gson().toJson(idjiError));
|
|
|
|
|
|
// sendMsg2Server(message, "解锁失败:" + getIDJIErrorMsg(idjiError));
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// //抛投
|
|
|
|
|
|
// public void throwOne(MQMessage message) {
|
|
|
|
|
|
// Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.KeyConnection));
|
|
|
|
|
|
// if (isConnect != null && isConnect) {
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManagerMap = payloadManager;
|
|
|
|
|
|
// WidgetValue widgetValue = new WidgetValue();
|
|
|
|
|
|
// widgetValue.setValue(0);
|
|
|
|
|
|
// widgetValue.setIndex(0);
|
|
|
|
|
|
// widgetValue.setType(WidgetType.SWITCH);
|
|
|
|
|
|
// payloadManagerMap.get(PayloadIndexType.PORT_2).setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onSuccess() {
|
|
|
|
|
|
// new Handler().postDelayed(new Runnable() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void run() {
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManagerMap = payloadManager;
|
|
|
|
|
|
// WidgetValue widgetValue = new WidgetValue();
|
|
|
|
|
|
// widgetValue.setValue(1);
|
|
|
|
|
|
// widgetValue.setIndex(0);
|
|
|
|
|
|
// widgetValue.setType(WidgetType.SWITCH);
|
|
|
|
|
|
// payloadManagerMap.get(PayloadIndexType.PORT_2).setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onSuccess() {
|
|
|
|
|
|
// new Handler().postDelayed(new Runnable() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void run() {
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManagerMap = payloadManager;
|
|
|
|
|
|
// WidgetValue widgetValue = new WidgetValue();
|
|
|
|
|
|
// widgetValue.setValue(1);
|
|
|
|
|
|
// widgetValue.setIndex(1);
|
|
|
|
|
|
// widgetValue.setType(WidgetType.BUTTON);
|
|
|
|
|
|
// payloadManagerMap.get(PayloadIndexType.PORT_2).setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onSuccess() {
|
|
|
|
|
|
// sendMsg2Server(message);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onFailure(@NonNull IDJIError idjiError) {
|
|
|
|
|
|
// LogUtil.log(TAG,"抛投失败:" +new Gson().toJson(idjiError));
|
|
|
|
|
|
// sendMsg2Server(message, "抛投失败:" + getIDJIErrorMsg(idjiError));
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }, 500);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onFailure(@NonNull IDJIError idjiError) {
|
|
|
|
|
|
// LogUtil.log(TAG,"解锁失败:" +new Gson().toJson(idjiError));
|
|
|
|
|
|
// sendMsg2Server(message, "解锁失败:" + getIDJIErrorMsg(idjiError));
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }, 500);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onFailure(@NonNull IDJIError idjiError) {
|
|
|
|
|
|
// LogUtil.log(TAG,"锁定失败:" +new Gson().toJson(idjiError));
|
|
|
|
|
|
// sendMsg2Server(message, "锁定失败:" + getIDJIErrorMsg(idjiError));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// //一件抛投
|
|
|
|
|
|
// public void throwAll(MQMessage message) {
|
|
|
|
|
|
// Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.KeyConnection));
|
|
|
|
|
|
// if (isConnect != null && isConnect) {
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManagerMap = payloadManager;
|
|
|
|
|
|
// WidgetValue widgetValue = new WidgetValue();
|
|
|
|
|
|
// widgetValue.setValue(0);
|
|
|
|
|
|
// widgetValue.setIndex(0);
|
|
|
|
|
|
// widgetValue.setType(WidgetType.SWITCH);
|
|
|
|
|
|
// payloadManagerMap.get(PayloadIndexType.PORT_2).setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onSuccess() {
|
|
|
|
|
|
// new Handler().postDelayed(new Runnable() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void run() {
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManagerMap = payloadManager;
|
|
|
|
|
|
// WidgetValue widgetValue = new WidgetValue();
|
|
|
|
|
|
// widgetValue.setValue(1);
|
|
|
|
|
|
// widgetValue.setIndex(0);
|
|
|
|
|
|
// widgetValue.setType(WidgetType.SWITCH);
|
|
|
|
|
|
// payloadManagerMap.get(PayloadIndexType.PORT_2).setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onSuccess() {
|
|
|
|
|
|
// new Handler().postDelayed(new Runnable() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void run() {
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManagerMap = payloadManager;
|
|
|
|
|
|
// WidgetValue widgetValue = new WidgetValue();
|
|
|
|
|
|
// widgetValue.setValue(1);
|
|
|
|
|
|
// widgetValue.setIndex(2);
|
|
|
|
|
|
// widgetValue.setType(WidgetType.BUTTON);
|
|
|
|
|
|
// payloadManagerMap.get(PayloadIndexType.PORT_2).setWidgetValue(widgetValue, new CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onSuccess() {
|
|
|
|
|
|
// sendMsg2Server(message);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onFailure(@NonNull IDJIError idjiError) {
|
|
|
|
|
|
// LogUtil.log(TAG,"全抛失败:" +new Gson().toJson(idjiError));
|
|
|
|
|
|
// sendMsg2Server(message, "全抛失败:" + getIDJIErrorMsg(idjiError));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }, 500);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onFailure(@NonNull IDJIError idjiError) {
|
|
|
|
|
|
// LogUtil.log(TAG,"解锁失败:" +new Gson().toJson(idjiError));
|
|
|
|
|
|
// sendMsg2Server(message, "解锁失败:" + getIDJIErrorMsg(idjiError));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }, 500);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onFailure(@NonNull IDJIError idjiError) {
|
|
|
|
|
|
// LogUtil.log(TAG,"锁定失败:" +new Gson().toJson(idjiError));
|
|
|
|
|
|
// sendMsg2Server(message, "锁定失败:" + getIDJIErrorMsg(idjiError));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// public void sendMsgToPayload(MQMessage message) {
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
|
|
|
|
// if (payloadManager != null) {
|
|
|
|
|
|
// IPayloadManager iPayloadManager = payloadManager.get(PayloadIndexType.EXTERNAL);
|
|
|
|
|
|
// if (iPayloadManager != null) {
|
|
|
|
|
|
// if (TextUtils.isEmpty(message.getPayloadData())) {
|
|
|
|
|
|
// sendMsg2Server( message, "发送数据到psdk失败:参数有误");
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// iPayloadManager.sendDataToPayload(Utils.getByte(message.getPayloadData()), new CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onSuccess() {
|
|
|
|
|
|
// LogUtil.log(TAG, "发送数据到psdk:" + Utils.getByte(message.getPayloadData()));
|
|
|
|
|
|
// sendMsg2Server( message);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onFailure(@NonNull IDJIError idjiError) {
|
|
|
|
|
|
// LogUtil.log(TAG,"发送数据到psdk失败:" +new Gson().toJson(idjiError));
|
|
|
|
|
|
// sendMsg2Server( message, "发送数据到psdk失败:" + getIDJIErrorMsg(idjiError));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// sendMsg2Server( message, "发送数据到psdk失败:设备未连接");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// sendMsg2Server( message, "发送数据到psdk失败:未检测到设备");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// public void sendMsgToLeftPayload(String txt) {
|
|
|
|
|
|
// Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
|
|
|
|
|
|
// if (payloadManager != null) {
|
|
|
|
|
|
// IPayloadManager iPayloadManager = payloadManager.get(PayloadIndexType.LEFT_OR_MAIN);
|
|
|
|
|
|
// if (iPayloadManager != null) {
|
|
|
|
|
|
//
|
|
|
|
|
|
// iPayloadManager.sendDataToPayload(txt.getBytes(), new CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onSuccess() {
|
|
|
|
|
|
// LogUtil.log(TAG,"send"+txt+"to psdk success");
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onFailure(@NonNull IDJIError idjiError) {
|
|
|
|
|
|
// LogUtil.log(TAG,"send"+txt+"to psdk fail:"+new Gson().toJson(idjiError));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// LogUtil.log(TAG,"发送数据到psdk失败:设备未连接");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// LogUtil.log(TAG,"发送数据到psdk失败:未检测到设备");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// //推送MSDK收到的PSDK数据
|
|
|
|
|
|
// public void sendMsgFromPSDK2Server(MqttAndroidClient client,byte[] data) {
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// if (client.isConnected()) {
|
|
|
|
|
|
// MqttMessage mqttMessage = null;
|
|
|
|
|
|
// MessageReply message = new MessageReply();
|
|
|
|
|
|
// message.setMsg_type(60119);
|
|
|
|
|
|
// message.setResult(1);
|
|
|
|
|
|
// message.setPayloadData(data);
|
|
|
|
|
|
// mqttMessage = new MqttMessage(new Gson().toJson(message).getBytes("UTF-8"));
|
|
|
|
|
|
// mqttMessage.setQos(2);
|
|
|
|
|
|
// client.publish(AMSConfig.getInstance().getMqttMsdkPushEvent2ServerTopic(), mqttMessage);
|
|
|
|
|
|
//
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// LogUtil.log(TAG, "psdkData发送失败:mqtt 未连接");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
|
// LogUtil.log(TAG, "psdkData发送异常:mqtt 未连接");
|
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-05-20 10:15:41 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 检测负载控件信息中是否有喊话器,检测到后自动设置喊话器位置
|
|
|
|
|
|
* @param info 负载控件信息
|
|
|
|
|
|
* @param portIndex 端口编号 2或3
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void detectSpeaker(PayloadWidgetInfo info, int portIndex) {
|
|
|
|
|
|
if (info == null || speakerPortSet) return;
|
|
|
|
|
|
try {
|
|
|
|
|
|
Object speakerWidget = info.getSpeakerWidget();
|
|
|
|
|
|
if (speakerWidget != null) {
|
|
|
|
|
|
String infoStr = info.toString();
|
|
|
|
|
|
// speakerWidget=SpeakerWidget{isTTSEnabled=true, isVoiceEnabled=true} 代表有喊话器
|
|
|
|
|
|
if (infoStr.contains("SpeakerWidget") && infoStr.contains("isTTSEnabled=true")) {
|
|
|
|
|
|
hasSpeaker = true;
|
|
|
|
|
|
LogUtil.log(TAG, "检测到喊话器负载(SpeakerWidget)在 PORT_" + portIndex);
|
|
|
|
|
|
// 自动设置喊话器位置,设置成功后不再重复设置
|
|
|
|
|
|
dji.v5.manager.aircraft.megaphone.MegaphoneIndex targetIndex =
|
|
|
|
|
|
portIndex == 2 ? dji.v5.manager.aircraft.megaphone.MegaphoneIndex.PORT_2
|
|
|
|
|
|
: dji.v5.manager.aircraft.megaphone.MegaphoneIndex.PORT_3;
|
|
|
|
|
|
LogUtil.log(TAG, "自动设置喊话器位置到: " + targetIndex);
|
|
|
|
|
|
dji.v5.manager.aircraft.megaphone.MegaphoneManager.getInstance().setMegaphoneIndex(targetIndex,
|
|
|
|
|
|
new dji.v5.common.callback.CommonCallbacks.CompletionCallback() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onSuccess() {
|
|
|
|
|
|
speakerPortSet = true;
|
|
|
|
|
|
LogUtil.log(TAG, "喊话器位置设置成功(从负载控件自动设置): " + targetIndex + ",不再重复设置");
|
|
|
|
|
|
// 同步到 SpeakerManager
|
|
|
|
|
|
com.aros.apron.manager.SpeakerManager.psdkindex = portIndex;
|
|
|
|
|
|
com.aros.apron.manager.SpeakerManager.getInstance().getMegaphoneIndex();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onFailure(@NonNull dji.v5.common.error.IDJIError error) {
|
|
|
|
|
|
LogUtil.log(TAG, "喊话器位置设置失败(从负载控件自动设置): " + error);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
LogUtil.log(TAG, "检测喊话器异常: " + e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean hasSpeaker() {
|
|
|
|
|
|
return hasSpeaker;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-01 14:34:23 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 检查列表中是否已经存在指定payloadIndexType的PayloadInfo对象。
|
|
|
|
|
|
*/
|
|
|
|
|
|
private boolean isPayloadIndexTypeExists(List<PayloadInfo> list, String payloadIndexType) {
|
|
|
|
|
|
for (PayloadInfo payloadInfo : list) {
|
|
|
|
|
|
if (payloadInfo.getPayloadIndexType().equals(payloadIndexType)) {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2026-05-20 10:15:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 启动5秒定时上报
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void startPsdkWidgetReport() {
|
|
|
|
|
|
if (psdkReportHandler == null) {
|
|
|
|
|
|
psdkReportHandler = new Handler(Looper.getMainLooper());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (psdkReportRunnable != null) {
|
|
|
|
|
|
return; // 已经在运行
|
|
|
|
|
|
}
|
|
|
|
|
|
psdkReportRunnable = new Runnable() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
|
|
|
|
psdkReportHandler.postDelayed(this, PSDK_REPORT_INTERVAL);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
psdkReportHandler.post(psdkReportRunnable);
|
|
|
|
|
|
LogUtil.log(TAG, "启动PSDK负载控件5秒定时上报");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 停止定时上报
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void stopPsdkWidgetReport() {
|
|
|
|
|
|
if (psdkReportHandler != null && psdkReportRunnable != null) {
|
|
|
|
|
|
psdkReportHandler.removeCallbacks(psdkReportRunnable);
|
|
|
|
|
|
psdkReportRunnable = null;
|
|
|
|
|
|
LogUtil.log(TAG, "停止PSDK负载控件定时上报");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 发送PSDK负载控件值到MQTT
|
|
|
|
|
|
*/
|
|
|
|
|
|
// private void sendPsdkWidgetValues() {
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// if (MqttManager.getInstance().mqttAndroidClient == null || !MqttManager.getInstance().mqttAndroidClient.isConnected()) {
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (cachedBasicInfo == null && cachedWidgetInfo == null) {
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// PsdkWidgetValuesReport report = new PsdkWidgetValuesReport();
|
|
|
|
|
|
// report.setTid(UUID.randomUUID().toString());
|
|
|
|
|
|
// report.setBid(UUID.randomUUID().toString());
|
|
|
|
|
|
// report.setTimestamp(System.currentTimeMillis());
|
|
|
|
|
|
// report.setMethod("psdk_widget_values");
|
|
|
|
|
|
// report.setGateway(Movement.getInstance().getSerialNumber());
|
|
|
|
|
|
//
|
|
|
|
|
|
// PsdkWidgetValuesReport.Data data = new PsdkWidgetValuesReport.Data();
|
|
|
|
|
|
// List<PsdkWidgetValuesReport.PsdkWidgetValue> widgetList = new ArrayList<>();
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 从cachedBasicInfo和cachedWidgetInfo组装数据
|
|
|
|
|
|
// if (cachedBasicInfo != null) {
|
|
|
|
|
|
// PsdkWidgetValuesReport.PsdkWidgetValue w = new PsdkWidgetValuesReport.PsdkWidgetValue();
|
|
|
|
|
|
// w.setPsdk_index(2);
|
|
|
|
|
|
// w.setPsdk_lib_version(cachedBasicInfo.getVersion() != null ? cachedBasicInfo.getVersion() : "");
|
|
|
|
|
|
// w.setPsdk_name(cachedBasicInfo.getProductName() != null ? cachedBasicInfo.getProductName() : "");
|
|
|
|
|
|
// w.setPsdk_sn(cachedBasicInfo.getDeviceSN() != null ? cachedBasicInfo.getDeviceSN() : "");
|
|
|
|
|
|
// w.setPsdk_type(5); // Speaker type
|
|
|
|
|
|
// w.setPsdk_version(cachedBasicInfo.getVersion() != null ? cachedBasicInfo.getVersion() : "");
|
|
|
|
|
|
//
|
|
|
|
|
|
// // Speaker数据
|
|
|
|
|
|
// PsdkWidgetValuesReport.SpeakerData speaker = new PsdkWidgetValuesReport.SpeakerData();
|
|
|
|
|
|
// speaker.setPlay_file_md5("");
|
|
|
|
|
|
// speaker.setPlay_file_name("");
|
|
|
|
|
|
// speaker.setPlay_mode(1);
|
|
|
|
|
|
// speaker.setPlay_volume(30);
|
|
|
|
|
|
// speaker.setSystem_state(0);
|
|
|
|
|
|
// speaker.setWork_mode(1);
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 从widgetInfo中尝试获取实际的widget值
|
|
|
|
|
|
// if (cachedWidgetInfo != null) {
|
|
|
|
|
|
// if (cachedWidgetInfo.getMainInterfaceWidgetList() != null) {
|
|
|
|
|
|
// for (Object widget : cachedWidgetInfo.getMainInterfaceWidgetList()) {
|
|
|
|
|
|
// // 根据widget类型设置speaker字段
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// w.setSpeaker(speaker);
|
|
|
|
|
|
// w.setValues(new ArrayList<>());
|
|
|
|
|
|
// widgetList.add(w);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// data.setPsdk_widget_values(widgetList);
|
|
|
|
|
|
// report.setData(data);
|
|
|
|
|
|
//
|
|
|
|
|
|
// String json = gson.toJson(report);
|
|
|
|
|
|
// LogUtil.log(TAG, "上报psdk_widget_values: " + json);
|
|
|
|
|
|
//
|
|
|
|
|
|
// MqttMessage msg = new MqttMessage(json.getBytes("UTF-8"));
|
|
|
|
|
|
// msg.setQos(0);
|
|
|
|
|
|
// MqttManager.getInstance().mqttAndroidClient.publish(AMSConfig.UP_UAV_EVENT, msg);
|
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
|
// LogUtil.log(TAG, "发送psdk_widget_values异常: " + e.getMessage());
|
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 发送负载浮窗文本到MQTT
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void sendFloatingWindowText(String value) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (MqttManager.getInstance().mqttAndroidClient == null || !MqttManager.getInstance().mqttAndroidClient.isConnected()) {
|
|
|
|
|
|
LogUtil.log(TAG, "MQTT未连接,跳过浮窗文本上报");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
java.util.Map<String, Object> report = new java.util.LinkedHashMap<>();
|
|
|
|
|
|
report.put("bid", UUID.randomUUID().toString());
|
|
|
|
|
|
report.put("tid", UUID.randomUUID().toString());
|
|
|
|
|
|
report.put("timestamp", System.currentTimeMillis());
|
|
|
|
|
|
report.put("method", "psdk_floating_window_text_jdw");
|
|
|
|
|
|
report.put("gateway", Movement.getInstance().getSerialNumber());
|
|
|
|
|
|
|
|
|
|
|
|
java.util.Map<String, Object> data = new java.util.LinkedHashMap<>();
|
|
|
|
|
|
data.put("psdk_index", 2);
|
|
|
|
|
|
data.put("value", value);
|
|
|
|
|
|
report.put("data", data);
|
|
|
|
|
|
|
|
|
|
|
|
String json = new Gson().toJson(report);
|
|
|
|
|
|
LogUtil.log(TAG, "发送浮窗文本: " + json);
|
|
|
|
|
|
|
|
|
|
|
|
org.eclipse.paho.client.mqttv3.MqttMessage msg = new org.eclipse.paho.client.mqttv3.MqttMessage(json.getBytes("UTF-8"));
|
|
|
|
|
|
msg.setQos(1);
|
|
|
|
|
|
MqttManager.getInstance().mqttAndroidClient.publish(AMSConfig.UP_UAV_EVENT, msg);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
LogUtil.log(TAG, "发送浮窗文本异常: " + e.getMessage());
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-02-01 14:34:23 +08:00
|
|
|
|
}
|