# topic
thing/product/{你的機場}/property/set# 監聽topic,獲取設置結果
thing/product/+/property/set_reply#mqtt
https://developer.dji.com/doc/cloud-api-tutorial/cn/api-reference/dock-to-cloud/mqtt/aircraft/m3d-properties.htmlthermal_current_palette_style: {"0":"白熱","1":"黑熱","2":"描紅","3":"醫療","5":"彩虹 1","6":"鐵紅","8":"北極","11":"熔巖","12":"熱鐵","13":"彩虹 2"} 81-0-0: 為無人機payload第一個攝像頭的payload_index值消息體:
{"tid": "0cfb666f-9cc7-4ca4-8962-3074cc342a66","bid": "98509752-e2d3-45e3-b113-53d9087fe58b","timestamp": 1750295776621,"data": {"81-0-0": {"thermal_current_palette_style": 1}}
}對應Java代碼 Common.publish 參考:https://blog.csdn.net/now19930616/article/details/148625191?spm=1011.2415.3001.5331public void setThermalPaletteStyle(String sn, Integer state) {// 校驗state M3TDList<Integer> stateList = Arrays.asList(0, 1, 2, 3, 5, 6, 8, 11, 12, 13);if (!stateList.contains(state)) {throw new BusinessException("參數錯誤: state: " + state);}// 調用上云api獲取設備信息LinkedHashMap dockInfoMap = cloudApiInvoke.cloudApiDeviceInfo(sn);// 獲取機場綁定的無人機信息String droneSn = TypeUtils.castToString(dockInfoMap.get("child_device_sn"));if (StrUtil.isBlank(droneSn)) {throw new RuntimeException("當前機場尚未綁定無人機");}// 獲取無人機osd信息,無人機開機狀態是可以獲取到的,關機獲取不到LinkedHashMap droneOsdInfo = cloudApiInvoke.cloudApiOsdDockDroneDeviceInfo(droneSn);String payloadIndex = TypeUtils.castToString(((ArrayList<LinkedHashMap>) droneOsdInfo.get("payload")).get(0).get("payload_index"));Map<String, Object> map = new HashMap<>();String uuid = IdUtil.simpleUUID();map.put("bid", uuid);map.put("tid", uuid);map.put("timestamp", System.currentTimeMillis());HashMap<String, Object> data = new HashMap<>();data.put(payloadIndex, new HashMap<String, Object>() {{put("thermal_current_palette_style", state);}});map.put("data", data);JSONObject publish = Common.publish(mqttMessageGateway, "thing/product/" + sn + "/property/set", map);if (publish == null || !publish.containsKey("data")) {throw new BusinessException("設置失敗,請稍后重試");}JSONObject d = publish.getJSONObject("data");if (TypeUtils.castToInt(d.getJSONObject(payloadIndex).getJSONObject("thermal_current_palette_style").get("result")) != 0) {throw new BusinessException("設置失敗, result:" + TypeUtils.castToInt(d.get("result")));}}
