大疆demo提交2

This commit is contained in:
chenlu 2025-09-23 11:15:44 +08:00
parent 9ea77aa679
commit b3412109ca
18 changed files with 2182 additions and 299 deletions

View File

@ -4,7 +4,26 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="7517474b-10e4-4adc-97fc-a0206ac0798a" name="Changes" comment="大疆demo提交" />
<list default="true" id="7517474b-10e4-4adc-97fc-a0206ac0798a" name="Changes" comment="大疆demo提交">
<change afterPath="$PROJECT_DIR$/src/main/java/com/example/math/constants/DJICommonConstants.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/example/math/enums/TakeOffToPointEnum.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/example/math/utils/DJIUtils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/math/constants/CommonConstants.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/math/constants/CommonConstants.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/math/constants/DJIMethonConstants.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/math/constants/DJIMethonConstants.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/math/controller/OperateController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/math/controller/OperateController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/math/mqtt/MqttConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/math/mqtt/MqttConfig.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/math/mqtt/consumer/MqttConsumerCallBack.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/math/mqtt/consumer/MqttConsumerCallBack.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/math/task/FirstTask.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/math/task/FirstTask.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/application.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/example/math/constants/CommonConstants.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/example/math/constants/CommonConstants.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/example/math/constants/DJIMethonConstants.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/example/math/constants/DJIMethonConstants.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/example/math/controller/OperateController.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/example/math/controller/OperateController.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/example/math/mqtt/MqttConfig.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/example/math/mqtt/MqttConfig.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/example/math/mqtt/consumer/MqttConsumerCallBack.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/example/math/mqtt/consumer/MqttConsumerCallBack.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/example/math/task/FirstTask.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/example/math/task/FirstTask.class" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -23,28 +42,30 @@
</option>
</component>
<component name="ProjectId" id="2w9dTkbds1SLHxtWq1eBVM0rJkj" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RequestMappingsPanelOrder0": "0",
"RequestMappingsPanelOrder1": "1",
"RequestMappingsPanelWidth0": "75",
"RequestMappingsPanelWidth1": "75",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"last_opened_file_path": "D:/newCode/dji_demo",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"settings.editor.selected.configurable": "vcs.Git",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RequestMappingsPanelOrder0&quot;: &quot;0&quot;,
&quot;RequestMappingsPanelOrder1&quot;: &quot;1&quot;,
&quot;RequestMappingsPanelWidth0&quot;: &quot;75&quot;,
&quot;RequestMappingsPanelWidth1&quot;: &quot;75&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;last_opened_file_path&quot;: &quot;D:/code/dji_demo&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;MavenSettings&quot;,
&quot;spring.configuration.checksum&quot;: &quot;4f45992762eb36378bf6bd0fb0b9c291&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="ReactorSettings">
<option name="notificationShown" value="true" />
</component>
@ -52,8 +73,26 @@
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\newCode\dji_demo" />
</key>
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="com.example.math.enums" />
<recent name="com.example.math.constants" />
<recent name="com.example.math.utils" />
</key>
</component>
<component name="RunManager">
<component name="RunManager" selected="Spring Boot.DemoAirportApplication">
<configuration name="OperateController" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.example.math.controller.OperateController" />
<module name="demo-airport" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.example.math.controller.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="JetRunConfigurationType">
<module name="dji_demo" />
<method v="2">
@ -74,6 +113,11 @@
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.OperateController" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
@ -84,6 +128,82 @@
<option name="presentableId" value="Default" />
<updated>1745457734060</updated>
<workItem from="1745457735996" duration="626000" />
<workItem from="1745573734834" duration="12172000" />
<workItem from="1745804092531" duration="622000" />
<workItem from="1745811131652" duration="1880000" />
<workItem from="1745849444771" duration="17349000" />
<workItem from="1746702218482" duration="9245000" />
<workItem from="1746775603996" duration="4278000" />
<workItem from="1747185494742" duration="642000" />
<workItem from="1747304258767" duration="597000" />
<workItem from="1747356268648" duration="1227000" />
<workItem from="1747442534757" duration="481000" />
<workItem from="1748308277291" duration="5354000" />
<workItem from="1748406065842" duration="595000" />
<workItem from="1748413842743" duration="608000" />
<workItem from="1748425001532" duration="7947000" />
<workItem from="1749171541978" duration="11161000" />
<workItem from="1749285546877" duration="2171000" />
<workItem from="1749429812890" duration="599000" />
<workItem from="1749774951055" duration="654000" />
<workItem from="1749777013838" duration="599000" />
<workItem from="1749861102586" duration="3140000" />
<workItem from="1750034102545" duration="3116000" />
<workItem from="1750123282056" duration="597000" />
<workItem from="1750125483669" duration="68000" />
<workItem from="1750130631809" duration="4873000" />
<workItem from="1750152073570" duration="2660000" />
<workItem from="1750209909517" duration="1234000" />
<workItem from="1750226161543" duration="204000" />
<workItem from="1750226379447" duration="3079000" />
<workItem from="1750293539048" duration="5617000" />
<workItem from="1750379878072" duration="2554000" />
<workItem from="1750466103423" duration="1208000" />
<workItem from="1750491928454" duration="599000" />
<workItem from="1750647615339" duration="1198000" />
<workItem from="1750725600556" duration="2446000" />
<workItem from="1750848630017" duration="596000" />
<workItem from="1751101718275" duration="1488000" />
<workItem from="1751269862330" duration="3147000" />
<workItem from="1751333593584" duration="280000" />
<workItem from="1751340546230" duration="516000" />
<workItem from="1751361561706" duration="11425000" />
<workItem from="1751531672871" duration="675000" />
<workItem from="1751539018383" duration="6833000" />
<workItem from="1752111996657" duration="958000" />
<workItem from="1752297676928" duration="610000" />
<workItem from="1752651343517" duration="1669000" />
<workItem from="1752712856808" duration="597000" />
<workItem from="1752721948690" duration="5477000" />
<workItem from="1752897079985" duration="1312000" />
<workItem from="1752913418893" duration="3495000" />
<workItem from="1753145776971" duration="1532000" />
<workItem from="1753160939496" duration="598000" />
<workItem from="1753166679112" duration="652000" />
<workItem from="1753230955634" duration="215000" />
<workItem from="1753408556319" duration="1162000" />
<workItem from="1753424974257" duration="1344000" />
<workItem from="1753521115040" duration="790000" />
<workItem from="1753532572293" duration="24000" />
<workItem from="1753770664163" duration="9144000" />
<workItem from="1753880392335" duration="155000" />
<workItem from="1753923445734" duration="9798000" />
<workItem from="1754028330798" duration="597000" />
<workItem from="1754278770125" duration="7458000" />
<workItem from="1754294920049" duration="3215000" />
<workItem from="1754354429646" duration="1809000" />
<workItem from="1754710156315" duration="2094000" />
<workItem from="1754872583621" duration="112000" />
<workItem from="1754959006084" duration="1855000" />
<workItem from="1755045504312" duration="395000" />
<workItem from="1755255229544" duration="3080000" />
<workItem from="1755563698990" duration="4383000" />
<workItem from="1755650311144" duration="594000" />
<workItem from="1755737721064" duration="1192000" />
<workItem from="1756452369056" duration="3989000" />
<workItem from="1756545800079" duration="592000" />
<workItem from="1758182413279" duration="2381000" />
<workItem from="1758594169567" duration="2118000" />
</task>
<task id="LOCAL-00001" summary="大疆demo提交">
<option name="closed" value="true" />
@ -99,8 +219,115 @@
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="大疆demo提交" />
<option name="LAST_COMMIT_MESSAGE" value="大疆demo提交" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/controller/OperateController.java</url>
<line>1199</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/controller/OperateController.java</url>
<line>1213</line>
<option name="timeStamp" value="2" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/mqtt/consumer/MqttConsumerCallBack.java</url>
<line>344</line>
<option name="timeStamp" value="20" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/mqtt/consumer/MqttConsumerCallBack.java</url>
<line>352</line>
<option name="timeStamp" value="21" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/mqtt/consumer/MqttConsumerCallBack.java</url>
<line>220</line>
<option name="timeStamp" value="26" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/mqtt/consumer/MqttConsumerCallBack.java</url>
<line>225</line>
<option name="timeStamp" value="27" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/mqtt/consumer/MqttConsumerCallBack.java</url>
<line>222</line>
<option name="timeStamp" value="28" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/controller/OperateController.java</url>
<line>1625</line>
<option name="timeStamp" value="30" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/controller/OperateController.java</url>
<line>1553</line>
<option name="timeStamp" value="31" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/controller/OperateController.java</url>
<line>1627</line>
<option name="timeStamp" value="32" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/controller/OperateController.java</url>
<line>1515</line>
<option name="timeStamp" value="35" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/controller/OperateController.java</url>
<line>1539</line>
<option name="timeStamp" value="36" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/controller/OperateController.java</url>
<line>1730</line>
<option name="timeStamp" value="37" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/controller/OperateController.java</url>
<line>1733</line>
<option name="timeStamp" value="38" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/mqtt/consumer/MqttConsumerCallBack.java</url>
<line>244</line>
<option name="timeStamp" value="46" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/mqtt/consumer/MqttConsumerCallBack.java</url>
<line>1284</line>
<option name="timeStamp" value="59" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/mqtt/consumer/MqttConsumerCallBack.java</url>
<line>241</line>
<option name="timeStamp" value="60" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/example/math/mqtt/consumer/MqttConsumerCallBack.java</url>
<line>273</line>
<option name="timeStamp" value="62" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>

View File

@ -11,4 +11,45 @@ public class CommonConstants {
* 无人机异步飞行
*/
public static final String ASYNFLY = "asynFly";
/**
* 喊话次数对应租户 唯一
*/
public static final String SHOUT_NUM = "shoutNum";
/**
* 喊话标识1代表喊话中null代表无喊话实时
*/
public static final String SHOUT_FLAG = "shoutFlag";
/**
* 最近一次某个喊话器的喊话类型 1:停止 2:暂停 3恢复
*/
public static final String SHOUT_TYPE = "shoutType";
/**
* 喊话点击暂停时间戳
*/
public static final String SHOUT_PAUSE_TIME = "shoutPauseTime";
/**
* 喊话点击恢复时间戳
*/
public static final String SHOUT_RESUME_TIME = "shoutResumeTime";
/**
* 喊话某一次喊话开始时间戳
*/
public static final String SHOUT_START_TIME = "shoutStartTime";
/**
* 一键起飞事件通知 redis的key值
*/
public static final String TAKE_OFF_TO_POINT_PROGRESS = "takeoffToPointProgress";
/**
* flyto 执行结果事件通知 redis的key值
*/
public static final String FLY_TOPOINT_PROGRESS = "flyToPointProgress";
}

View File

@ -0,0 +1,83 @@
package com.example.math.constants;
/**
* @Author: 吴彬
* @CreateTime: 2023-08-07 16:11
* @Description: 公共常量
* @Version: 1.0
*/
public class DJICommonConstants {
/**
* 直播方法
*/
public static final String NTP_SERVER_HOST = "Google.mzr.me";
/**
* events 飞行任务时间
*/
public static final String APP_ID = "148774";
/**
* 大疆机场关于 组织 设备绑定码校验回复
*/
public static final String APP_KEY = "a3ba3e9934f43b82bd52428b26e695b";
/**
* 大疆机场关于 组织 设备绑定码校验回复 二次握手
*/
public static final String APP_LICENSE = "Cm+BDccW/auc1L5Fixy59JrudnnXxguksAfGNPRjaDDqf3ESlHJt4JYaYBlXJ/rkkSPREF/MIg5FZV3MSwPVcXQ2ioOahFH0OEHx0fhxLnrS2uUVXaXcDkDxLRfDuOTvkmojS3KFZIgPOjt6hdF9Madi/WC+EsnZzpA5RvTD/u4=";
/**
* 下发任务后的二次航线获取
*/
public static final Integer EXPIRE = 3600;
/**
* 下发任务后的二次航线获取
*/
public static final String BUCKET = "dji-dev";
/**
* 下发任务后的二次航线获取
*/
public static final String ENDPOINT = "https://oss-cn-shanghai.aliyuncs.com";
/**
* 下发任务后的二次航线获取
*/
public static final String OBJECT_KEY_PREFIX = "hyslj";
/**
* 下发任务后的二次航线获取
*/
public static final String PROVIDER = "ali";
/**
* 下发任务后的二次航线获取
*/
public static final String REGION = "sh";
/**
* 是设备绑定组织
*/
public static final Boolean IS_DEVICE_BIND_ORGANIZATION = true;
/**
* 大疆组织id 和机器输入的一致
*/
public static final String ORGANIZATION_ID = "w";
/**
* 默认即可
*/
public static final String ORGANIZATION_NAME = "Test Group One";
/**
* DJI 大疆前缀
*/
public static final String DJI = "DJI";
}

View File

@ -8,16 +8,81 @@ package com.example.math.constants;
*/
public class DJIMethonConstants {
/**
* 开启调试模式
*/
public static final String DEBUG_MODE_OPEN = "debug_mode_open";
/**
* 关闭调试模式
*/
public static final String DEBUG_MODE_CLOSE = "debug_mode_close";
/**
* 开机
*/
public static final String DRONE_OPEN = "drone_open";
/**
* 关机
*/
public static final String DRONE_CLOSE = "drone_close";
/**
* 机场重启
*/
public static final String DEVICE_REBOOT = "device_reboot";
/**
* 空调模式切换
*/
public static final String AIR_CONDITIONER_MODE_SWITCH = "air_conditioner_mode_switch";
/**
* 镜头点击转动
*/
public static final String CAMERA_AIM = "camera_aim";
/**
* 开舱
*/
public static final String COVER_OPEN = "cover_open";
/**
* 强制关舱盖
*/
public static final String COVER_FORCE_CLOSE = "cover_force_close";
/**
* 回舱
*/
public static final String COVER_CLOSE = "cover_close";
/**
* 直播方法
*/
public static final String LIVE_START_PUSH = "live_start_push";
/**
* events 飞行任务时间
* 关闭直播
*/
public static final String LIVE_STOP_PUSH = "live_stop_push";
/**
* events 飞行任务
*/
public static final String FLIGHTTASK_PROGRESS = "flighttask_progress";
/**
* events 告警事件
*/
public static final String HMS = "hms";
/**
* events 飞行任务时间
*/
public static final String drc_status_notify = "drc_status_notify";
/**
* 大疆机场关于 组织 设备绑定码校验回复
*/
@ -29,13 +94,19 @@ public class DJIMethonConstants {
public static final String AIRPORT_ORGANIZATION_GET = "airport_organization_get";
/**
* 机场建立连接
* 设备绑定到组织
*/
public static final String AIRPORT_ORGANIZATION_BIND = "airport_organization_bind";
/**
* 与阿里云建立连接
*/
public static final String CONFIG = "config";
/**
* 与阿里云建立连接
*/
public static final String STORAGE_CONFIG_GET = "storage_config_get";
/**
@ -44,29 +115,9 @@ public class DJIMethonConstants {
public static final String FLIGHTTASK_RESOURCE_GET = "flighttask_resource_get";
/**
* 一键起飞
* 设备拓扑更新 请求设备上线
*/
public static final String TAKEOFF_TO_POINT = "takeoff_to_point";
/**
* 飞行控制权抢夺
*/
public static final String FLIGHT_AUTHORITY_GRAB = "flight_authority_grab";
/**
* 负载控制权抢夺
*/
public static final String PAYLOAD_AUTHORITY_GRAB = "payload_authority_grab";
/**
* 进入指令飞行控制模式
*/
public static final String DRC_MODE_ENTER = "drc_mode_enter";
/**
* 退出指令飞行控制模式
*/
public static final String DRC_MODE_EXIT = "drc_mode_exit";
public static final String UPDATE_TODO = "update_topo";
/**
* 负载控制切换相机模式
@ -108,11 +159,25 @@ public class DJIMethonConstants {
*/
public static final String DRONE_EMERGENCY_STOP = "drone_emergency_stop";
/**
* DRC-杆量控制
*/
public static final String STICK_CONTROL = "stick_control";
/**
* DRC-飞行控制
*/
public static final String DRONE_CONTROL = "drone_control";
/**
* 下发任务
*/
public static final String FLIGHTTASK_PREPARE = "flighttask_prepare";
/**
* 执行任务
*/
public static final String FLIGHTTASK_EXECUTE = "flighttask_execute";
/**
* 航线暂停
@ -134,21 +199,36 @@ public class DJIMethonConstants {
*/
public static final String LIVE_LENS_CHANGE = "live_lens_change";
/**
* 仓内外镜头切换
*/
public static final String LIVE_CAMERA_CHANGE = "live_camera_change";
/**
* 一键返航
*/
public static final String RETURN_HOME = "return_home";
/**
* 取消任务
* 一键起飞
*/
public static final String FLIGHTTASK_UNDO = "flighttask_undo";
public static final String TAKEOFF_TO_POINT = "takeoff_to_point";
/**
* 指点飞行
*/
public static final String FLY_TO_POINT = "fly_to_point";
/**
* 指点飞行结果
*/
public static final String FLY_TO_POINT_PROGRESS = "fly_to_point_progress";
/**
* 一键起飞结果事件通知
*/
public static final String TAKEOFF_TO_POINT_PROGRESS = "takeoff_to_point_progress";
/**
* 结束 flyto 飞向目标点任务
*/
@ -159,4 +239,102 @@ public class DJIMethonConstants {
*/
public static final String FLY_TO_POINT_UPDATE = "fly_to_point_update";
/**
* 取消任务
*/
public static final String FLIGHTTASK_UNDO = "flighttask_undo";
/**
* 开启补光灯
*/
public static final String SUPPLEMENT_LIGHT_OPEN = "supplement_light_open";
/**
* 关闭补光灯
*/
public static final String SUPPLEMENT_LIGHT_CLOSE = "supplement_light_close";
/**
* 浮窗文本推送
*/
public static final String PSDK_FLOATING_WINDOW_TEXT = "psdk_floating_window_text";
/**
* 发送文本框内容
*/
public static final String PSDK_INPUT_BOX_TEXT_SET = "psdk_input_box_text_set";
/**
* 设置单元控件
*/
public static final String PSDK_WIDGET_VALUE_SET = "psdk_widget_value_set";
/**
* 设置单元控件
*/
public static final String SPEAKER_PLAY_STOP = "speaker_play_stop";
/**
* 设置播放模式
*/
public static final String SPEAKER_PLAY_MODE_SET = "speaker_play_mode_set";
/**
* 设置播放音量
*/
public static final String SPEAKER_PLAY_VOLUME_SET = "speaker_play_volume_set";
/**
* tts文本播放
*/
public static final String SPEAKER_TTS_PLAY_START = "speaker_tts_play_start";
/**
* 音频播放
*/
public static final String SPEAKER_AUDIO_PLAY_START = "speaker_audio_play_start";
/**
* 飞行控制权抢夺
*/
public static final String FLIGHT_AUTHORITY_GRAB = "flight_authority_grab";
/**
* 负载控制权抢夺
*/
public static final String PAYLOAD_AUTHORITY_GRAB = "payload_authority_grab";
/**
* 进入指令飞行控制模式
*/
public static final String DRC_MODE_ENTER = "drc_mode_enter";
/**
* 指令飞行控制模式 状态
*/
public static final String DRC_STATUS = "drc_status";
/**
* DRC心跳包
*/
public static final String HEART_BEAT = "heart_beat";
/**
* 退出指令飞行控制模式
*/
public static final String DRC_MODE_EXIT = "drc_mode_exit";
/**
* events 返航信息
*/
public static final String RETURN_HOME_INFO = "return_home_info";
/**
* 切换直播清晰度
*/
public static final String LIVE_SET_QUALITY = "live_set_quality";
}

View File

@ -3,6 +3,12 @@ package com.example.math.controller;
import com.alibaba.fastjson2.JSONObject;
import com.aliyun.sts20150401.Client;
import com.aliyun.sts20150401.models.AssumeRoleRequest;
import com.aliyun.sts20150401.models.AssumeRoleResponse;
import com.aliyun.tea.TeaException;
import com.aliyun.teautil.models.RuntimeOptions;
import com.example.math.constants.DJICommonConstants;
import com.example.math.constants.DJIMethonConstants;
import com.example.math.entity.dto.BreakPoint;
import com.example.math.entity.dto.ExecutableConditions;
@ -13,20 +19,22 @@ import com.example.math.entity.dto.SimulateMission;
import com.example.math.mqtt.MqttConfig;
import com.example.math.mqtt.SpringUtil;
//import com.example.math.task.FirstTask;
import com.example.math.mqtt.consumer.MqttConsumerCallBack;
import com.example.math.task.FirstTask;
import com.example.math.utils.RedisUtils;
import com.example.math.utils.SslUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.lang3.ThreadUtils;
import org.eclipse.paho.client.mqttv3.MqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedReader;
@ -41,12 +49,11 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.sql.Date;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
@ -75,10 +82,25 @@ import java.util.UUID;
*
* live_stop_push
* http://localhost:9999/operate/live_stop_push?one=7CTDM7H00B5EM1&two=165-0-7&three=normal-0
*
* http://localhost:9999/operate/live_stop_push?one=1581F6Q8D248900G5PYE&two=81-0-0&three=normal-0
*
* http://localhost:9999/operate/live_lens_change?video_type=normal
*
* 控制模式
* http://localhost:9999/operate/flightAuthorityGrab
*
* http://localhost:9999/operate/payloadAuthorityGrab
*
* http://localhost:9999/operate/drcModeEnter
*
* http://localhost:9999/operate/droneEmergencyStop
*
* http://localhost:9999/operate/stickControl?roll=1024&pitch=1024&throttle=1024&yaw=1024&gimbal_pitch=1024
*Integer roll, Integer pitch, Integer throttle, Integer yaw, Integer gimbal_pitch
*
*
*
*
* * @param airPortSn 机场sn号
* * @param airPortSn 速度 String maxsSpeed
@ -98,6 +120,7 @@ import java.util.UUID;
*/
@RequestMapping(path="/operate")
@Controller
@Slf4j
public class OperateController {
@ -112,7 +135,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "firsttest";
@ -145,7 +168,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -187,7 +210,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -230,7 +253,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -272,7 +295,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -315,7 +338,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -359,7 +382,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -395,7 +418,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00BXZD1/services";
@ -437,7 +460,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -531,7 +554,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -582,7 +605,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -621,7 +644,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTXM9Q00B02H2/services";
@ -660,7 +683,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -704,7 +727,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -748,7 +771,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -788,7 +811,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -831,7 +854,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -875,7 +898,7 @@ public class OperateController {
qos = 2;
}
if(retained == null){
retained = true;
retained = false;
}
if(topic == null){
topic = "thing/product/7CTDM7H00B5EM1/services";
@ -923,7 +946,7 @@ public class OperateController {
}
try {
Integer qos = 2;
Boolean retained = true;
Boolean retained = false;
//topic主题 sn是机场sn号 thing/product/%s/services
String topic = String.format(someTopic, airPortSn);
//封装数据
@ -971,7 +994,7 @@ public class OperateController {
}
@Autowired
private static String airPortSn = "7CTXMC900B054P";
private static String airPortSn = "7CTDM7H00BXZD1";
/**
* 飞行控制权抢夺 /flightAuthorityGrab
@ -983,7 +1006,7 @@ public class OperateController {
public String flightAuthorityGrab(){
try {
Integer qos = 2;
Boolean retained = true;
Boolean retained = false;
//topic主题 sn是机场sn号 thing/product/%s/services
//TODO 此处用的是无人的SN号 待测试
String topic = String.format(someTopic, airPortSn);
@ -1014,7 +1037,7 @@ public class OperateController {
public String payloadAuthorityGrab(String cameraIndex){
try {
Integer qos = 2;
Boolean retained = true;
Boolean retained = false;
//topic主题 sn是机场sn号 thing/product/%s/services
//TODO 此处用的是无人的SN号 待测试
String topic = String.format(someTopic, airPortSn);
@ -1054,9 +1077,37 @@ public class OperateController {
@Value("${spring.mqtt.client.id}")
private String clientId;
/**
* DRC心跳
* @return JsonResult
*/
private static Integer seq = 0;
@ResponseBody
@RequestMapping("/drcOsd")
public String drcOsd() throws InterruptedException{
if (true){
Map<String,Object> content = new HashMap<>();
HashMap<String, Long> data = new HashMap<>();
data.put("timestamp", System.currentTimeMillis());
seq++;
content.put("method", "heart_beat");
content.put("data", data);
content.put("seq", 0);
String message = com.alibaba.fastjson.JSONObject.toJSONString(content);
Thread.sleep(2000L);
MqttDeliveryToken publish = providerClient.publish(1, false, "thing/product/8UUXN3500A02BE/drc/down", message);
}
return "发送成功";
}
/**
* 进入指令飞行控制模式
* @param airPortSn 机场sn号
* @return JsonResult
*/
@ResponseBody
@ -1065,7 +1116,7 @@ public class OperateController {
try {
Integer qos = 1;
Boolean retained = true;
Boolean retained = false;
//topic主题 sn是机场sn号 thing/product/%s/services
//TODO 此处用的是无人的SN号 待测试
String topic = String.format(someTopic, airPortSn);
@ -1073,7 +1124,7 @@ public class OperateController {
Map<String,Object> content = new HashMap<>();
Map<String,Object> data = new HashMap<>();
//负载枚举值 镜头负载
data.put("hsi_frequency", 20);
data.put("hsi_frequency", 1);
//Broker 连接信息
Map<String,Object> mqttBroker = new HashMap<>();
@ -1091,7 +1142,7 @@ public class OperateController {
mqttBroker.put("username", username);
data.put("mqtt_broker", mqttBroker);
//设置 OSD 上报频率 {"max":30,"min":1,"unit_name":"赫兹 / Hz"}
data.put("osd_frequency", 20);
data.put("osd_frequency", 1);
content.put("tid", UUID.randomUUID().toString());
content.put("bid", UUID.randomUUID().toString());
@ -1099,6 +1150,40 @@ public class OperateController {
content.put("method", DJIMethonConstants.DRC_MODE_ENTER);
content.put("data", data);
String message = com.alibaba.fastjson.JSONObject.toJSONString(content);
System.out.println(topic);
System.out.println(message);
MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
return "发送成功";
} catch (Exception e) {
e.printStackTrace();
return "发送失败";
}
}
/**
* 退出指令飞行控制模式
* @return JsonResult
*/
@ResponseBody
@RequestMapping("/drcModeExit")
public String drcModeExit(){
try {
Integer qos = 1;
Boolean retained = false;
//topic主题 sn是机场sn号 thing/product/%s/services
//TODO 此处用的是无人的SN号 待测试
String topic = String.format(someTopic, airPortSn);
//封装数据
Map<String,Object> content = new HashMap<>();
Map<String,Object> data = new HashMap<>();
content.put("tid", UUID.randomUUID().toString());
content.put("bid", UUID.randomUUID().toString());
content.put("timestamp",System.currentTimeMillis());
content.put("method", DJIMethonConstants.DRC_MODE_EXIT);
content.put("data", data);
String message = com.alibaba.fastjson.JSONObject.toJSONString(content);
System.out.println(topic);
System.out.println(message);
MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
return "发送成功";
@ -1110,10 +1195,10 @@ public class OperateController {
@RequestMapping("/droneEmergencyStop")
public String droneEmergencyStop(String airPortSn){
public String droneEmergencyStop(){
try {
Integer qos = 2;
Boolean retained = true;
Boolean retained = false;
//topic主题 sn是机场sn号 thing/product/%s/services
//TODO 此处用的是无人的SN号 待测试
String topic = String.format("thing/product/%s/drc/down", airPortSn);
@ -1123,6 +1208,7 @@ public class OperateController {
content.put("method", DJIMethonConstants.DRONE_EMERGENCY_STOP);
content.put("data", data);
String message = com.alibaba.fastjson.JSONObject.toJSONString(content);
System.out.println(topic);
System.out.println(message);
MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
return "发送成功";
@ -1133,6 +1219,53 @@ public class OperateController {
}
@RequestMapping("/stickControl")
public String stickControl(Integer roll, Integer pitch, Integer throttle, Integer yaw, Integer gimbal_pitch){
Integer seq = 1;
// for (int i = 0; i < 10; i++) {
if (!roll.equals(0)){
roll += 20;
}
if (!pitch.equals(0)){
pitch += 20;
}
if (!throttle.equals(0)){
throttle += 20;
}
if (!yaw.equals(0)){
yaw += 20;
}
if (!gimbal_pitch.equals(0)){
gimbal_pitch += 20;
}
seq = seq + 1;
Integer qos = 2;
Boolean retained = false;
//topic主题 sn是机场sn号
//TODO 此处用的是无人的SN号 待测试
String topic = String.format("thing/product/%s/drc/down", airPortSn);
//封装数据
Map<String,Object> content = new HashMap<>();
Map<String,Object> data = new HashMap<>();
data.put("roll", roll);
data.put("pitch", pitch);
data.put("throttle", throttle);
data.put("yaw", yaw);
data.put("gimbal_pitch", gimbal_pitch);
content.put("method", "stick_control");
content.put("seq", seq);
content.put("data", data);
String message = com.alibaba.fastjson.JSONObject.toJSONString(content);
System.out.println(message);
MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
// }
return "";
}
/**
* @param sn 机场sn号
* @param flightId 任务id
@ -1144,7 +1277,7 @@ public class OperateController {
try {
//sn = "7CTDM7H00B5EM1";
Integer qos = 2;
Boolean retained = true;
Boolean retained = false;
//topic主题 sn是机场sn号 thing/product/%s/services
String topic = String.format("thing/product/%s/services", sn);
//参数封装
@ -1183,7 +1316,7 @@ public class OperateController {
public String flyToPoint(String airPortSn, Integer maxsSpeed, Integer height, Double latitude, Double longitude){
try {
Integer qos = 2;
Boolean retained = true;
Boolean retained = false;
//topic主题 sn是机场sn号 thing/product/%s/services
String topic = String.format(someTopic, airPortSn);
Map<String,Object> content = new HashMap<>();
@ -1230,7 +1363,7 @@ public class OperateController {
public String flyToPointStop(String airPortSn){
try {
Integer qos = 2;
Boolean retained = true;
Boolean retained = false;
//topic主题 sn是机场sn号 thing/product/%s/services
String topic = String.format(someTopic, airPortSn);
Map<String,Object> content = new HashMap<>();
@ -1265,7 +1398,7 @@ public class OperateController {
public String flyToPointUpdate(String airPortSn, String maxsSpeed, String height, String latitude, String longitude){
try {
Integer qos = 2;
Boolean retained = true;
Boolean retained = false;
//topic主题 sn是机场sn号 thing/product/%s/services
String topic = String.format(someTopic, airPortSn);
Map<String,Object> content = new HashMap<>();
@ -1370,26 +1503,317 @@ public class OperateController {
}
public static void main(String[] args) {
String capacityPercent = "32767.00";
if(Objects.nonNull(capacityPercent)){
double v = Double.parseDouble(capacityPercent.toString());
if (v > 100){
System.out.printf("++++++"+ capacityPercent);
}
/**
* 查询日志列表
* @return
*/
@RequestMapping("/fileuploadList")
public String fileuploadList(String airPortSn, String module) {
try {
// 从请求中获取参数如果没有提供则使用默认值或生成
// 构建消息内容
Map<String, Object> content = new HashMap<>();
Map<String, Object> data = new HashMap<>();
// 构建module_list
List<String> moduleList = new ArrayList<>();
// moduleList.add("0");
// moduleList.add("3");
moduleList.add(module);
data.put("module_list", moduleList);
content.put("bid", UUID.randomUUID().toString());
content.put("tid", UUID.randomUUID().toString());
content.put("timestamp", System.currentTimeMillis());
content.put("method", "fileupload_list");
content.put("data", data);
// 转换为JSON字符串
String message = JSONObject.toJSONString(content);
System.out.println("发送的消息: " + message);
// 发布消息
String topic = String.format(someTopic, airPortSn);
int qos = 1;
boolean retained = false;
MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
return "发送成功: " + publish.isComplete();
} catch (Exception e) {
e.printStackTrace();
return "发送失败: " + e.getMessage();
}
}
@ResponseBody
@RequestMapping("/fileuploadStart")
public String fileuploadStart(String airPortSn, String type, Integer[] bootIndices, String module) {
try {
Integer qos = 1;
Boolean retained = false;
String topic = String.format(someTopic, airPortSn);
Map<String, Object> content = new HashMap<>();
Map<String, Object> data = new HashMap<>();
Map<String, Object> credentials = new HashMap<>();
Map<String, Object> params = new HashMap<>();
List<Map<String, Object>> files = new ArrayList<>();
Map<String, Object> fileEntry = new HashMap<>();
List<Map<String, Object>> list = new ArrayList<>();
//获取阿里云 OSS对应文件夹的token
Map<String, String> ossMap = ossToken();
if (!CollectionUtils.isEmpty(ossMap)) {
credentials.put("access_key_id", ossMap.get("access_key_id"));
credentials.put("access_key_secret", ossMap.get("access_key_secret"));
credentials.put("expire", DJICommonConstants.EXPIRE);
credentials.put("security_token", ossMap.get("security_token"));
log.info("获取阿里云上传凭证成功");
} else {
log.info("获取阿里云上传凭证失败");
}
// Map<String, Object> outputItem = new HashMap<>();
// outputItem.put("bucket", DJICommonConstants.BUCKET);
// outputItem.put("endpoint", DJICommonConstants.ENDPOINT);
// //outputItem.put("object_key_prefix" , DJICommonConstants.OBJECT_KEY_PREFIX);
// outputItem.put("object_key_prefix", DJICommonConstants.DJI + airPortSn);
// outputItem.put("provider", DJICommonConstants.PROVIDER);
// outputItem.put("region", DJICommonConstants.REGION);
// outputItem.put("credentials", credentials);
// 构建 list 数组
for (Integer bootIndex : bootIndices) {
Map<String, Object> item = new HashMap<>();
item.put("boot_index", bootIndex);
list.add(item);
}
// 构建 fileEntry 对象
fileEntry.put("list", list);
fileEntry.put("module", module);
fileEntry.put("object_key", "7CTDM7H00BXZD1-A");
// 构建 files 数组
files.add(fileEntry);
// 构建 params 对象
params.put("files", files);
// 构建 data 对象
data.put("bucket", DJICommonConstants.BUCKET);
data.put("credentials", credentials);
data.put("endpoint", DJICommonConstants.ENDPOINT);
data.put("params", params);
data.put("provider", DJICommonConstants.PROVIDER);
data.put("region", DJICommonConstants.REGION);
// 构建 content 对象
content.put("bid", UUID.randomUUID().toString());
content.put("data", data);
content.put("tid", UUID.randomUUID().toString());
content.put("timestamp", System.currentTimeMillis());
content.put("method", "fileupload_start");
String message = JSONObject.toJSONString(content);
System.out.println("Sending message: " + message);
MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
return "发送成功";
} catch (Exception e) {
e.printStackTrace();
return "发送失败: " + e.getMessage();
}
}
//http://localhost:9999/operate/otaCreate?airPortSn=7CTXN1E00B06ZR&fileName=DOCK2_10.01.16.12_pro.zip&fileSize=485800158&fileUrl=https://dji-dev.oss-cn-shanghai.aliyuncs.com/firmware/DOCK2_10.01.16.12_pro.zip&firmwareUpgradeType=1&md5=&productVersion=1612&sn=drone_sn&dockFirmwareUpgradeType=3&dockProductVersion=1612&dockSn=dock_sn
@ResponseBody
@RequestMapping("/otaCreate")
public String otaCreate(String airPortSn,
String fileName,
Long fileSize,
String fileUrl,
Integer firmwareUpgradeType,
String md5,
String productVersion,
String sn,
Integer dockFirmwareUpgradeType,
String dockProductVersion,
String dockSn) {
try {
Integer qos = 1;
Boolean retained = false;
String topic = String.format(someTopic, airPortSn);
Map<String, Object> content = new HashMap<>();
Map<String, Object> data = new HashMap<>();
List<Map<String, Object>> devices = new ArrayList<>();
// 构建无人机设备信息
Map<String, Object> droneDevice = new HashMap<>();
droneDevice.put("file_name", fileName);
droneDevice.put("file_size", fileSize);
droneDevice.put("file_url", fileUrl);
droneDevice.put("firmware_upgrade_type", firmwareUpgradeType);
droneDevice.put("md5", md5);
droneDevice.put("product_version", productVersion);
droneDevice.put("sn", sn);
devices.add(droneDevice);
// 构建机场设备信息
Map<String, Object> dockDevice = new HashMap<>();
dockDevice.put("firmware_upgrade_type", dockFirmwareUpgradeType);
dockDevice.put("product_version", dockProductVersion);
dockDevice.put("sn", dockSn);
devices.add(dockDevice);
// 构建 data 对象
data.put("devices", devices);
// 构建 content 对象
content.put("bid", UUID.randomUUID().toString());
content.put("data", data);
content.put("tid", UUID.randomUUID().toString());
content.put("timestamp", System.currentTimeMillis());
content.put("method", "ota_create");
String message = JSONObject.toJSONString(content);
System.out.println("Sending ota_create message: " + message);
MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
return "发送成功";
} catch (Exception e) {
e.printStackTrace();
return "发送失败: " + e.getMessage();
}
}
/**
* 获取
*/
private Map<String, String> ossToken() {
Map<String, String> ossMap = new HashMap<>();
String policy = "{\n" +
" \"Version\": \"1\", \n" +
" \"Statement\": [\n" +
" {\n" +
" \"Action\": [\n" +
" \"oss:PutObject\"\n" +
" ], \n" +
" \"Resource\": [\n" +
" \"acs:oss:*:*:dji-dev/*\" \n" +
" ], \n" +
" \"Effect\": \"Allow\"\n" +
" }\n" +
" ]\n" +
"}";
// String roleARN = "acs:ram::1399733914954856:role/ramosstest";
String roleARN = "acs:ram::1399733914954856:role/oss-role";
String sessionName = "SessionTest";
java.util.List<String> args = Arrays.asList();
Client client = null;
try {
client = MqttConsumerCallBack.createClient();
} catch (Exception e) {
log.info("获取阿里云token失败");
}
AssumeRoleRequest assumeRoleRequest = new com.aliyun.sts20150401.models.AssumeRoleRequest()
.setDurationSeconds(3600L)
.setPolicy(policy)
.setRoleArn(roleARN)
.setRoleSessionName(sessionName);
try {
// 复制代码运行请自行打印 API 的返回值
AssumeRoleResponse assumeRoleResponse = client.assumeRoleWithOptions(assumeRoleRequest, new RuntimeOptions());
String arn = assumeRoleResponse.getBody().getAssumedRoleUser().getArn();
String assumedRoleId = assumeRoleResponse.getBody().getAssumedRoleUser().getAssumedRoleId();
String accessKeyId = assumeRoleResponse.getBody().getCredentials().getAccessKeyId();
String accessKeySecret = assumeRoleResponse.getBody().getCredentials().getAccessKeySecret();
String securityToken = assumeRoleResponse.getBody().getCredentials().getSecurityToken();
String expiration = assumeRoleResponse.getBody().getCredentials().getExpiration();
log.info(arn);
log.info(assumedRoleId);
log.info(accessKeyId);
log.info(accessKeySecret);
log.info(securityToken);
log.info(expiration);
log.info("a");
ossMap.put("access_key_id", accessKeyId);
ossMap.put("access_key_secret", accessKeySecret);
ossMap.put("security_token", securityToken);
return ossMap;
} catch (TeaException error) {
// 此处仅做打印展示请谨慎对待异常处理在工程项目中切勿直接忽略异常
// 错误 message
log.info(error.getMessage());
// 诊断地址
log.info(error.getData().get("Recommend") + "");
com.aliyun.teautil.Common.assertAsString(error.message);
} catch (Exception _error) {
TeaException error = new TeaException(_error.getMessage(), _error);
// 此处仅做打印展示请谨慎对待异常处理在工程项目中切勿直接忽略异常
// 错误 message
log.info(error.getMessage());
// 诊断地址
log.info(error.getData().get("Recommend") + "");
com.aliyun.teautil.Common.assertAsString(error.message);
}
return ossMap;
}
// public static void main(String[] args) {
// String capacityPercent = "32767.00";
// if(Objects.nonNull(capacityPercent)){
// double v = Double.parseDouble(capacityPercent.toString());
// if (v > 100){
// System.out.printf("++++++"+ capacityPercent);
// }
// }
// }
public static void main(String[] args) {
// 示例当前时间戳
long timestampInSeconds = System.currentTimeMillis() / 1000;
timestampInSeconds = 1749403384;
// 转换为北京时间
String beijingTime = convertTimestampToBeijingTime(timestampInSeconds);
// 输出结果
System.out.println("北京时间: " + beijingTime);
}
public static String convertTimestampToBeijingTime(long timestamp) {
ZoneId beijingZone = ZoneId.of("Asia/Shanghai");
Instant instant = Instant.ofEpochSecond(timestamp); // 使用 ofEpochSecond
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(beijingZone);
return formatter.format(instant);
}
}

View File

@ -0,0 +1,38 @@
package com.example.math.enums;
import lombok.Getter;
/**
* @Author: 陈璐
* @CreateTime: 2024-08-12 15:24
* @Description: 一键起飞结果实践通知 通用雨flyto事件
* @Version: 1.0
*/
public enum TakeOffToPointEnum {
TASK_FINISH("task_finish","一键起飞任务完成"),
TASK_READY("task_ready","准备起飞" ),
WAYLINE_CANCEL("wayline_cancel","取消飞向目标点" ),
WAYLINE_FAILED("wayline_failed","执行失败" ),
WAYLINE_OK("wayline_ok","执行成功,已飞向目标点" ),
WAYLINE_PROGRESS("wayline_progress","执行中" ),
;
TakeOffToPointEnum(String code, String value){
this.code = code;
this.value = value;
}
@Getter
private String code;
@Getter
private String value;
}

View File

@ -73,13 +73,14 @@ public class MqttConfig {
//订阅主题
//消息等级和主题数组一一对应服务端将按照指定等级给订阅了主题的客户端推送消息
//订阅主题
// client.subscribe("thing/product/+/requests",1);
// client.subscribe("thing/product/+/requests_reply",1);
// client.subscribe("thing/product/+/services",1);
// client.subscribe("thing/product/+/services_reply",1);
// client.subscribe("sys/product/+/status",1);
// client.subscribe("thing/product/+/osd",1);
// client.subscribe("thing/product/8UUXN2T00A01RU/events",1);
// client.subscribe("thing/product/8UUXN3500A02BE/requests",1);
// client.subscribe("thing/product/8UUXN3500A02BE/requests_reply",1);
// client.subscribe("thing/product/8UUXN3500A02BE/services",1);
// client.subscribe("thing/product/8UUXN3500A02BE/services_reply",1);
// client.subscribe("sys/product/8UUXN3500A02BE/status",1);
// client.subscribe("thing/product/7CTXMC900B054P/osd",1);
// client.subscribe("thing/product/8UUXN3500A02BE/events",1);
// client.subscribe("thing/product/1581F6Q83254100BD0UV/osd",1);
} catch(MqttException e){
e.printStackTrace();

View File

@ -1,5 +1,6 @@
package com.example.math.task;
import com.alibaba.fastjson.JSONObject;
import com.example.math.constants.DJIMethonConstants;
import com.example.math.mqtt.MqttConfig;
import com.example.math.mqtt.SendMsg;
@ -14,6 +15,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@Slf4j
@Configuration //1.主要用于标记配置类兼备Component的效果
@ -22,6 +24,8 @@ public class FirstTask {
private static Integer seq = 0;
private static Boolean aBoolean = false;
@Autowired
private MqttConfig providerClient;
@ -37,28 +41,111 @@ public class FirstTask {
// while(sendList.size()>0) {
// SendMsg sendMsg = sendList.remove(0);
// log.info("sendmsg qos is {},retained is {}, topic is {}, msg is {}",
// sendMsg.getQos(),sendMsg.isRetained(),sendMsg.getTopic(),sendMsg.getMessage());
// sendMsg.retained = false;Qos(),sendMsg.isRetained(),sendMsg.getTopic(),sendMsg.getMessage());
// providerClient.publish(sendMsg.getQos(),sendMsg.isRetained(),sendMsg.getTopic(),sendMsg.getMessage());
//
// }
// }
@Scheduled(cron = "0/5 * * * * ?")
//或直接指定时间间隔例如5秒
//@Scheduled(fixedRate=5000)
@Scheduled(cron = "0/2 * * * * ?")
private void aaaa() {
Map<String,Object> content = new HashMap<>();
HashMap<String, Long> data
= new HashMap<>();
data.put("timestamp", System.currentTimeMillis());
seq++;
content.put("method", "heart_beat");
content.put("data", data);
content.put("seq", seq);
String message = com.alibaba.fastjson.JSONObject.toJSONString(content);
System.out.println(message);
MqttDeliveryToken publish = providerClient.publish(1, false, "thing/product/7CTDM7H00BXZD1/drc/down", message);
if (true){
Map<String,Object> content = new HashMap<>();
HashMap<String, Long> data
= new HashMap<>();
data.put("timestamp", System.currentTimeMillis());
seq++;
content.put("method", "heart_beat");
content.put("data", data);
content.put("seq", 0);
String message = com.alibaba.fastjson.JSONObject.toJSONString(content);
// System.out.println(message);
MqttDeliveryToken publish = providerClient.publish(1, false, "thing/product/8UUXN3500A02BE/drc/down", message);
}
}
// @Scheduled(cron = "0/1 * * * * ?")
// //或直接指定时间间隔例如5秒
// //@Scheduled(fixedRate=5000)
// private void configureTasks() {
//
// flightAuthorityGrab("7CTXMC500B052Q");
//
// payloadAuthorityGrab("81-0-0", "7CTXMC500B052Q");
// }
private static String someTopic = "thing/product/%s/services";
/**
* 飞行控制权抢夺 /flightAuthorityGrab
* @param airPortSn 机场sn号
* @return JsonResult
*/
public String flightAuthorityGrab(String airPortSn){
try {
log.info("飞行控制权抢夺 flight_authority_grab is start");
Integer qos = 1;
Boolean retained = false;
//topic主题 sn是机场sn号 thing/product/%s/services
//TODO 此处用的是无人的SN号 待测试
String topic = String.format(someTopic, airPortSn);
//封装数据
Map<String,Object> content = new HashMap<>();
Map<String,Object> data = new HashMap<>();
String tid = UUID.randomUUID().toString();
content.put("tid", tid);
content.put("bid", UUID.randomUUID().toString());
content.put("timestamp",System.currentTimeMillis());
content.put("method", DJIMethonConstants.FLIGHT_AUTHORITY_GRAB);
content.put("data", data);
String message = JSONObject.toJSONString(content);
System.out.println(message);
MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
log.info("飞行控制权抢夺 flight_authority_grab is end topic is {}, message is {}, token is {} ", topic, message, publish);
return "发送成功";
} catch (Exception e) {
e.printStackTrace();
return "发送失败";
}
}
/**
* 负载控制权抢夺 /payloadAuthorityGrab
* @param airPortSn 机场sn号
* @param cameraIndex 镜头参数
* @return JsonResult
*/
public String payloadAuthorityGrab(String cameraIndex, String airPortSn){
try {
Integer qos = 2;
Boolean retained = false;
//topic主题 sn是机场sn号 thing/product/%s/services
//TODO 此处用的是无人的SN号 待测试
String topic = String.format(someTopic, airPortSn);
//封装数据
Map<String,Object> content = new HashMap<>();
Map<String,Object> data = new HashMap<>();
//负载枚举值 镜头负载
data.put("payload_index", cameraIndex);
content.put("tid", UUID.randomUUID().toString());
content.put("bid", UUID.randomUUID().toString());
content.put("timestamp",System.currentTimeMillis());
content.put("method", DJIMethonConstants.PAYLOAD_AUTHORITY_GRAB);
content.put("data", data);
String message = com.alibaba.fastjson.JSONObject.toJSONString(content);
System.out.println(message);
MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
return "发送成功";
} catch (Exception e) {
e.printStackTrace();
return "发送失败";
}
}
}

View File

@ -0,0 +1,222 @@
//package com.example.math.utils;
//
//import com.alibaba.fastjson.JSONObject;
//import com.example.math.constants.DJIMethonConstants;
//import com.example.math.mqtt.MqttConfig;
//import lombok.extern.slf4j.Slf4j;
//import org.eclipse.paho.client.mqttv3.MqttDeliveryToken;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import javax.annotation.Resource;
//import java.util.HashMap;
//import java.util.Map;
//import java.util.UUID;
//
///**
// * 远程大疆的工具类
// */
//@Component
//@Slf4j
//public class DJIUtils {
//
// @Resource
// private MqttConfig providerClient;
//
// @Value("${spring.newMqtt.username}")
// private String username;
//
// @Value("${spring.newMqtt.password}")
// private String password;
//
// @Value("${spring.newMqtt.url}")
// private String address;
//
// @Value("${spring.newMqtt.newUrl}")
// private String newAddress;
//
// @Value("${spring.newMqtt.client.id}")
// private String clientId;
//
// @Autowired
// private RedisUtils redisUtils;
//
// public static String filePath = "";
// public static String fileMd5 = "";
//
// //topic固定参数
// private static String someTopic = "thing/product/%s/services";
//
//
// //topic固定参数
// private static String propertySet = "thing/product/%s/property/set";
//
//
// //机场 无人机 镜头清晰度
// private static String camera = "normal-0";
//
//
//
//
// public static int seq = 0;
//
// /**
// * 飞行控制权抢夺 /flightAuthorityGrab
// * @param airPortSn 机场sn号
// * @return JsonResult
// */
// public String flightAuthorityGrab(String airPortSn){
// try {
// log.info("飞行控制权抢夺 flight_authority_grab is start");
// Integer qos = 1;
// Boolean retained = false;
// //topic主题 sn是机场sn号 thing/product/%s/services
// //TODO 此处用的是无人的SN号 待测试
// String topic = String.format(someTopic, airPortSn);
// //封装数据
// Map<String,Object> content = new HashMap<>();
// Map<String,Object> data = new HashMap<>();
// String tid = UUID.randomUUID().toString();
// content.put("tid", tid);
// content.put("bid", UUID.randomUUID().toString());
// content.put("timestamp",System.currentTimeMillis());
// content.put("method", "flight_authority_grab");
// content.put("data", data);
// String message = JSONObject.toJSONString(content);
// System.out.println(message);
// MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
// log.info("飞行控制权抢夺 flight_authority_grab is end topic is {}, message is {}, token is {} ", topic, message, publish);
// return "发送成功";
// } catch (Exception e) {
// e.printStackTrace();
// return "发送成功";
// }
// }
//
// /**
// * 负载控制权抢夺 /payloadAuthorityGrab
// * @param airPortSn 机场sn号
// * @param cameraIndex 镜头参数
// * @return JsonResult
// */
// public String payloadAuthorityGrab(String cameraIndex, String airPortSn){
// try {
// Integer qos = 2;
// Boolean retained = false;
// //topic主题 sn是机场sn号 thing/product/%s/services
// //TODO 此处用的是无人的SN号 待测试
// String topic = String.format(someTopic, airPortSn);
// //封装数据
// Map<String,Object> content = new HashMap<>();
// Map<String,Object> data = new HashMap<>();
// //负载枚举值 镜头负载
// data.put("payload_index", cameraIndex);
// content.put("tid", UUID.randomUUID().toString());
// content.put("bid", UUID.randomUUID().toString());
// content.put("timestamp",System.currentTimeMillis());
// content.put("method", "payload_authority_grab");
// content.put("data", data);
// String message = JSONObject.toJSONString(content);
// System.out.println(message);
// MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
// return "发送成功";
// } catch (Exception e) {
// e.printStackTrace();
// return "发送失败";
// }
// }
//
//
// /**
// * 进入指令飞行控制模式
// * @return JsonResult
// */
// public String drcModeEnter(String airPortSn){
// try {
// seq = 0;
// Integer qos = 1;
// Boolean retained = false;
// //topic主题 sn是机场sn号 thing/product/%s/services
// //TODO 此处用的是无人的SN号 待测试
// String topic = String.format(someTopic, airPortSn);
// //封装数据
// Map<String,Object> content = new HashMap<>();
// Map<String,Object> data = new HashMap<>();
// //负载枚举值 镜头负载
// data.put("hsi_frequency", 1);
//
// //Broker 连接信息
// Map<String,Object> mqttBroker = new HashMap<>();
// //服务器连接地址
// mqttBroker.put("address", newAddress);
// //客户端ID
// mqttBroker.put("client_id", "DRC" + "-" + airPortSn);
// //enable_tls
// mqttBroker.put("enable_tls", false);
// //expire_time 当前时间+3000秒
// mqttBroker.put("expire_time", System.currentTimeMillis()/1000 + 36000);
// //密码
// mqttBroker.put("password", password);
// //用户名
// mqttBroker.put("username", username);
// data.put("mqtt_broker", mqttBroker);
// //设置 OSD 上报频率 {"max":30,"min":1,"unit_name":"赫兹 / Hz"}
// data.put("osd_frequency", 1);
//
// content.put("tid", UUID.randomUUID().toString());
// content.put("bid", UUID.randomUUID().toString());
// content.put("timestamp",System.currentTimeMillis());
// content.put("method", DJIMethonConstants.DRC_MODE_ENTER);
// content.put("data", data);
// String message = com.alibaba.fastjson.JSONObject.toJSONString(content);
// System.out.println(message);
// MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
// return "发送成功";
// } catch (Exception e) {
// e.printStackTrace();
// return "发送失败";
// }
// }
//
//
//
// /**
// * 退出指令飞行控制模式
// * @param airPortSn 机场sn号
// * @return JsonResult
// */
// @ResponseBody
// public String drcModeExit(String airPortSn){
// try {
// log.info("退出指令飞行控制模式 drc_mode_exit is start");
// Integer qos = 1;
// Boolean retained = false;
// //topic主题 sn是机场sn号 thing/product/%s/services
// //TODO 此处用的是无人的SN号 待测试
// String topic = String.format(someTopic, airPortSn);
// //封装数据
// Map<String,Object> content = new HashMap<>();
// Map<String,Object> data = new HashMap<>();
// content.put("tid", UUID.randomUUID().toString());
// content.put("bid", UUID.randomUUID().toString());
// content.put("timestamp",System.currentTimeMillis());
// content.put("method", DJIMethonConstants.DRC_MODE_EXIT);
// content.put("data", data);
// String message = JSONObject.toJSONString(content);
// System.out.println(message);
// MqttDeliveryToken publish = providerClient.publish(qos, retained, topic, message);
//// log.info("退出指令飞行控制模式 drc_mode_exit is end topic is {}, message is {}, token is {} ", topic, message, publish);
// return "发送成功";
// } catch (Exception e) {
// e.printStackTrace();
// return "发送失败";
// }
// }
//
//
//
//
//}
//

View File

@ -21,7 +21,25 @@ spring:
default:
topic: topic
newUrl: 58.213.148.44:1883
# djiClientId: airport_dji_mqtt
# mqtt:
# #MQTT服务地址端口号默认11883如果有多个用逗号隔开
# onlineUrl: https://mqtt.t-aaron.com
# #MQTT服务地址端口号默认11883如果有多个用逗号隔开
# url: tcp://mqtt.t-aaron.com:10883
# #用户名
# username: admin
# #密码
# password: admin##123
# #客户端id(不能重复)
# client:
# id: provider-id
# #MQTT默认的消息推送主题实际可在调用接口是指定
# default:
# topic: topic
# newUrl: mqtt.t-aaron.com:10883
# djiClientId: airport_dji_mqtt
# mqtt:
# onlineUrl: http://101.133.163.127:18083
# #MQTT服务地址端口号默认11883如果有多个用逗号隔开

View File

@ -21,7 +21,25 @@ spring:
default:
topic: topic
newUrl: 58.213.148.44:1883
# djiClientId: airport_dji_mqtt
# mqtt:
# #MQTT服务地址端口号默认11883如果有多个用逗号隔开
# onlineUrl: https://mqtt.t-aaron.com
# #MQTT服务地址端口号默认11883如果有多个用逗号隔开
# url: tcp://mqtt.t-aaron.com:10883
# #用户名
# username: admin
# #密码
# password: admin##123
# #客户端id(不能重复)
# client:
# id: provider-id
# #MQTT默认的消息推送主题实际可在调用接口是指定
# default:
# topic: topic
# newUrl: mqtt.t-aaron.com:10883
# djiClientId: airport_dji_mqtt
# mqtt:
# onlineUrl: http://101.133.163.127:18083
# #MQTT服务地址端口号默认11883如果有多个用逗号隔开