Browse Source

What's new?

1. Added support for new Dock model: DJI Dock2
        2. Fixed some issues.
v1.8.0
sean.zhou 1 year ago
parent
commit
e37df40061
  1. 2
      README.md
  2. 7
      pom.xml
  3. 58
      sql/cloud_sample.sql
  4. 2
      src/main/java/com/dji/sample/manage/service/IDeviceService.java
  5. 1
      src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java
  6. 28
      src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java
  7. 20
      src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java
  8. 4
      src/main/java/com/dji/sdk/annotations/CloudSDKVersion.java
  9. 2
      src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointRequest.java
  10. 26
      src/main/java/com/dji/sdk/cloudapi/control/api/AbstractControlService.java
  11. 39
      src/main/java/com/dji/sdk/cloudapi/debug/api/AbstractDebugService.java
  12. 4
      src/main/java/com/dji/sdk/cloudapi/device/DeviceDomainEnum.java
  13. 20
      src/main/java/com/dji/sdk/cloudapi/device/DeviceEnum.java
  14. 14
      src/main/java/com/dji/sdk/cloudapi/device/DeviceTypeEnum.java
  15. 5
      src/main/java/com/dji/sdk/cloudapi/device/DockLiveErrorStatus.java
  16. 2
      src/main/java/com/dji/sdk/cloudapi/device/DockPositionState.java
  17. 12
      src/main/java/com/dji/sdk/cloudapi/device/NetworkStateQualityEnum.java
  18. 2
      src/main/java/com/dji/sdk/cloudapi/device/OsdDockDrone.java
  19. 2
      src/main/java/com/dji/sdk/cloudapi/device/OsdRcDrone.java
  20. 38
      src/main/java/com/dji/sdk/cloudapi/device/PayloadModelConst.java
  21. 77
      src/main/java/com/dji/sdk/cloudapi/device/PayloadModelEnum.java
  22. 2
      src/main/java/com/dji/sdk/cloudapi/device/api/AbstractDeviceService.java
  23. 2
      src/main/java/com/dji/sdk/cloudapi/firmware/api/AbstractFirmwareService.java
  24. 2
      src/main/java/com/dji/sdk/cloudapi/livestream/LiveErrorCodeEnum.java
  25. 16
      src/main/java/com/dji/sdk/cloudapi/livestream/api/AbstractLivestreamService.java
  26. 2
      src/main/java/com/dji/sdk/cloudapi/log/api/AbstractLogService.java
  27. 4
      src/main/java/com/dji/sdk/cloudapi/media/api/AbstractMediaService.java
  28. 4
      src/main/java/com/dji/sdk/cloudapi/property/api/AbstractPropertyService.java
  29. 89
      src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakPoint.java
  30. 192
      src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakReasonEnum.java
  31. 5
      src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskPrepareRequest.java
  32. 6
      src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressExt.java
  33. 153
      src/main/java/com/dji/sdk/cloudapi/wayline/ProgressExtBreakPoint.java
  34. 6
      src/main/java/com/dji/sdk/cloudapi/wayline/api/AbstractWaylineService.java
  35. 1
      src/main/java/com/dji/sdk/common/BaseModel.java
  36. 19
      src/main/java/com/dji/sdk/common/Common.java
  37. 2
      src/main/java/com/dji/sdk/common/CommonErrorEnum.java
  38. 48
      src/main/java/com/dji/sdk/common/GatewayThingVersion.java
  39. 2
      src/main/java/com/dji/sdk/common/SDKManager.java
  40. 5
      src/main/java/com/dji/sdk/config/CloudSDKHandler.java
  41. 6
      src/main/java/com/dji/sdk/config/version/CloudSDKVersionEnum.java
  42. 41
      src/main/java/com/dji/sdk/config/version/Dock2ThingVersionEnum.java
  43. 17
      src/main/java/com/dji/sdk/config/version/DockThingVersionEnum.java
  44. 6
      src/main/java/com/dji/sdk/config/version/DroneThingVersionEnum.java
  45. 6
      src/main/java/com/dji/sdk/config/version/GatewayManager.java
  46. 37
      src/main/java/com/dji/sdk/config/version/GatewayThingVersion.java
  47. 7
      src/main/java/com/dji/sdk/config/version/GatewayTypeEnum.java
  48. 13
      src/main/java/com/dji/sdk/config/version/IThingVersion.java
  49. 4
      src/main/java/com/dji/sdk/config/version/RcThingVersionEnum.java
  50. 2
      src/main/java/com/dji/sdk/exception/CloudSDKVersionException.java
  51. 2
      src/main/java/com/dji/sdk/mqtt/drc/DrcUpSubscribe.java
  52. 1
      src/main/java/com/dji/sdk/mqtt/events/EventsErrorCode.java
  53. 2
      src/main/java/com/dji/sdk/mqtt/events/EventsSubscribe.java
  54. 23
      src/main/java/com/dji/sdk/mqtt/osd/OsdDeviceTypeEnum.java
  55. 10
      src/main/java/com/dji/sdk/mqtt/osd/OsdRouter.java
  56. 2
      src/main/java/com/dji/sdk/mqtt/osd/OsdSubscribe.java
  57. 2
      src/main/java/com/dji/sdk/mqtt/property/PropertySetSubscribe.java
  58. 2
      src/main/java/com/dji/sdk/mqtt/requests/RequestsSubscribe.java
  59. 1
      src/main/java/com/dji/sdk/mqtt/services/ServicesErrorCode.java
  60. 20
      src/main/java/com/dji/sdk/mqtt/services/ServicesPublish.java
  61. 2
      src/main/java/com/dji/sdk/mqtt/services/ServicesSubscribe.java
  62. 2
      src/main/java/com/dji/sdk/mqtt/state/DockStateDataKeyEnum.java
  63. 2
      src/main/java/com/dji/sdk/mqtt/state/RcStateDataKeyEnum.java
  64. 1
      src/main/java/com/dji/sdk/mqtt/state/StateRouter.java
  65. 2
      src/main/java/com/dji/sdk/mqtt/state/StateSubscribe.java
  66. 2
      src/main/java/com/dji/sdk/mqtt/status/StatusSubscribe.java
  67. 16226
      src/main/resources/hms.json

2
README.md

@ -14,7 +14,7 @@ For more documentation, please visit the [DJI Developer Documentation](https://d @@ -14,7 +14,7 @@ For more documentation, please visit the [DJI Developer Documentation](https://d
## Latest Release
Cloud API 1.1.0 was released on 22 July 2022. For more information, please visit the [Release Note](https://developer.dji.com/doc/cloud-api-tutorial/cn/).
Cloud API 1.8.0 was released on 11 Dec 2023. For more information, please visit the [Release Note](https://developer.dji.com/doc/cloud-api-tutorial/cn/).
## License

7
pom.xml

@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
<groupId>com.dji</groupId>
<artifactId>cloud-api-sample</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
<name>cloud-api-sample</name>
<properties>
@ -180,6 +180,11 @@ @@ -180,6 +180,11 @@
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-boot-starter</artifactId>-->
<!-- <version>3.0.0</version>-->
<!-- </dependency>-->
<!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-ui -->
<dependency>
<groupId>org.springdoc</groupId>

58
sql/cloud_sample.sql

@ -110,32 +110,38 @@ LOCK TABLES `manage_device_dictionary` WRITE; @@ -110,32 +110,38 @@ LOCK TABLES `manage_device_dictionary` WRITE;
INSERT INTO `manage_device_dictionary` (`id`, `domain`, `device_type`, `sub_type`, `device_name`, `device_desc`)
VALUES
(1,0,60,0,'Matrice 300 RTK',NULL),
(2,0,67,0,'Matrice 30',NULL),
(3,0,67,1,'Matrice 30T',NULL),
(4,1,20,0,'Z30',NULL),
(5,1,26,0,'XT2',NULL),
(6,1,39,0,'FPV',NULL),
(7,1,41,0,'XTS',NULL),
(8,1,42,0,'H20',NULL),
(9,1,43,0,'H20T',NULL),
(10,1,50,65535,'P1','include 24 and 35 and 50mm'),
(11,1,52,0,'M30 Camera',NULL),
(12,1,53,0,'M30T Camera',NULL),
(13,1,61,0,'H20N',NULL),
(14,1,165,0,'DJI Dock Camera',NULL),
(15,1,90742,0,'L1',NULL),
(16,2,56,0,'DJI Smart Controller','Remote control for M300'),
(17,2,119,0,'DJI RC Plus','Remote control for M30'),
(18,3,1,0,'DJI Dock',''),
(19,0,77,0,'Mavic 3E',NULL),
(20,0,77,1,'Mavic 3T',NULL),
(21,1,66,0,'Mavic 3E Camera',NULL),
(22,1,67,0,'Mavic 3T Camera',NULL),
(23,2,144,0,'DJI RC Pro','Remote control for Mavic 3E/T and Mavic 3M'),
(24,0,77,2,'Mavic 3M',NULL),
(25,1,68,0,'Mavic 3M Camera',NULL),
(26,0,89,0,'Matrice 350 RTK',NULL);
(1, 0, 60, 0, 'Matrice 300 RTK', NULL),
(2, 0, 67, 0, 'Matrice 30', NULL),
(3, 0, 67, 1, 'Matrice 30T', NULL),
(4, 1, 20, 0, 'Z30', NULL),
(5, 1, 26, 0, 'XT2', NULL),
(6, 1, 39, 0, 'FPV', NULL),
(7, 1, 41, 0, 'XTS', NULL),
(8, 1, 42, 0, 'H20', NULL),
(9, 1, 43, 0, 'H20T', NULL),
(10, 1, 50, 65535, 'P1', 'include 24 and 35 and 50mm'),
(11, 1, 52, 0, 'M30 Camera', NULL),
(12, 1, 53, 0, 'M30T Camera', NULL),
(13, 1, 61, 0, 'H20N', NULL),
(14, 1, 165, 0, 'DJI Dock Camera', NULL),
(15, 1, 90742, 0, 'L1', NULL),
(16, 2, 56, 0, 'DJI Smart Controller', 'Remote control for M300'),
(17, 2, 119, 0, 'DJI RC Plus', 'Remote control for M30'),
(18, 3, 1, 0, 'DJI Dock', ''),
(19, 0, 77, 0, 'Mavic 3E', NULL),
(20, 0, 77, 1, 'Mavic 3T', NULL),
(21, 1, 66, 0, 'Mavic 3E Camera', NULL),
(22, 1, 67, 0, 'Mavic 3T Camera', NULL),
(23, 2, 144, 0, 'DJI RC Pro', 'Remote control for Mavic 3E/T and Mavic 3M'),
(24, 0, 77, 2, 'Mavic 3M', NULL),
(25, 1, 68, 0, 'Mavic 3M Camera', NULL),
(26, 0, 89, 0, 'Matrice 350 RTK', NULL),
(27, 3, 2, 0, 'DJI Dock2', NULL),
(28, 0, 91, 0, 'M3D', NULL),
(29, 0, 91, 1, 'M3TD', NULL),
(30, 1, 80, 0, 'M3D Camera', NULL),
(31, 1, 81, 0, 'M3TD Camera', NULL);
/*!40000 ALTER TABLE `manage_device_dictionary` ENABLE KEYS */;
UNLOCK TABLES;

2
src/main/java/com/dji/sample/manage/service/IDeviceService.java

@ -9,7 +9,7 @@ import com.dji.sdk.cloudapi.device.ControlSourceEnum; @@ -9,7 +9,7 @@ import com.dji.sdk.cloudapi.device.ControlSourceEnum;
import com.dji.sdk.cloudapi.device.DeviceOsdHost;
import com.dji.sdk.cloudapi.device.DockModeCodeEnum;
import com.dji.sdk.cloudapi.device.DroneModeCodeEnum;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.common.HttpResultResponse;
import com.dji.sdk.common.PaginationData;
import com.fasterxml.jackson.databind.JsonNode;

1
src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java

@ -24,6 +24,7 @@ import com.dji.sdk.cloudapi.property.api.AbstractPropertyService; @@ -24,6 +24,7 @@ import com.dji.sdk.cloudapi.property.api.AbstractPropertyService;
import com.dji.sdk.cloudapi.tsa.DeviceIconUrl;
import com.dji.sdk.cloudapi.tsa.TopologyDeviceModel;
import com.dji.sdk.common.*;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.exception.CloudSDKException;
import com.dji.sdk.mqtt.IMqttTopicService;
import com.dji.sdk.mqtt.MqttGatewayPublish;

28
src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java

@ -14,7 +14,7 @@ import com.dji.sdk.cloudapi.device.*; @@ -14,7 +14,7 @@ import com.dji.sdk.cloudapi.device.*;
import com.dji.sdk.cloudapi.device.api.AbstractDeviceService;
import com.dji.sdk.cloudapi.tsa.DeviceIconUrl;
import com.dji.sdk.cloudapi.tsa.IconUrlEnum;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.common.SDKManager;
import com.dji.sdk.mqtt.MqttReply;
import com.dji.sdk.mqtt.osd.TopicOsdRequest;
@ -99,7 +99,6 @@ public class SDKDeviceService extends AbstractDeviceService { @@ -99,7 +99,6 @@ public class SDKDeviceService extends AbstractDeviceService {
// Subscribe to topic related to drone devices.
deviceService.subDeviceOnlineSubscribeTopic(gatewayManager);
deviceService.pushDeviceOnlineTopo(gateway.getWorkspaceId(), gateway.getDeviceSn(), subDevice.getDeviceSn());
deviceRedisService.setDeviceOnline(subDevice);
log.debug("{} online.", subDevice.getDeviceSn());
return new TopicStatusResponse<MqttReply>().setData(MqttReply.success());
@ -143,14 +142,16 @@ public class SDKDeviceService extends AbstractDeviceService { @@ -143,14 +142,16 @@ public class SDKDeviceService extends AbstractDeviceService {
log.error("Please restart the drone.");
return;
}
if (!StringUtils.hasText(deviceOpt.get().getWorkspaceId())) {
log.error("Please bind the dock first.");
return;
}
}
DeviceDTO device = deviceOpt.get();
if (!StringUtils.hasText(device.getWorkspaceId())) {
log.error("Please bind the dock first.");
}
if (StringUtils.hasText(device.getChildDeviceSn())) {
deviceRedisService.getDeviceOnline(device.getChildDeviceSn()).ifPresent(device::setChildren);
}
deviceRedisService.setDeviceOnline(device);
fillDockOsd(from, request.getData());
@ -193,6 +194,9 @@ public class SDKDeviceService extends AbstractDeviceService { @@ -193,6 +194,9 @@ public class SDKDeviceService extends AbstractDeviceService {
}
}
DeviceDTO device = deviceOpt.get();
if (StringUtils.hasText(device.getChildDeviceSn())) {
deviceRedisService.getDeviceOnline(device.getChildDeviceSn()).ifPresent(device::setChildren);
}
deviceRedisService.setDeviceOnline(device);
OsdRemoteControl data = request.getData();
@ -216,14 +220,13 @@ public class SDKDeviceService extends AbstractDeviceService { @@ -216,14 +220,13 @@ public class SDKDeviceService extends AbstractDeviceService {
return;
}
}
if (!StringUtils.hasText(deviceOpt.get().getWorkspaceId())) {
DeviceDTO device = deviceOpt.get();
deviceRedisService.setDeviceOnline(device);
if (!StringUtils.hasText(device.getWorkspaceId())) {
log.error("Please bind the drone first.");
return;
}
DeviceDTO device = deviceOpt.get();
deviceRedisService.setDeviceOnline(device);
OsdRcDrone data = request.getData();
deviceService.pushOsdDataToPilot(device.getWorkspaceId(), from,
new DeviceOsdHost()
@ -349,9 +352,10 @@ public class SDKDeviceService extends AbstractDeviceService { @@ -349,9 +352,10 @@ public class SDKDeviceService extends AbstractDeviceService {
}
if (!Objects.requireNonNullElse(subDevice.getBoundStatus(), false)) {
// Directly bind the drone of the dock to the same workspace as the dock.
deviceService.bindDevice(DeviceDTO.builder().deviceSn(subDevice.getChildDeviceSn()).workspaceId(gateway.getWorkspaceId()).build());
deviceService.bindDevice(DeviceDTO.builder().deviceSn(subDevice.getDeviceSn()).workspaceId(gateway.getWorkspaceId()).build());
subDevice.setWorkspaceId(gateway.getWorkspaceId());
}
deviceRedisService.setDeviceOnline(subDevice);
}
private void changeSubDeviceParent(String deviceSn, String gatewaySn) {

20
src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java

@ -12,6 +12,8 @@ import com.dji.sample.wayline.model.entity.WaylineFileEntity; @@ -12,6 +12,8 @@ import com.dji.sample.wayline.model.entity.WaylineFileEntity;
import com.dji.sample.wayline.service.IWaylineFileService;
import com.dji.sdk.cloudapi.device.DeviceDomainEnum;
import com.dji.sdk.cloudapi.device.DeviceEnum;
import com.dji.sdk.cloudapi.device.DeviceSubTypeEnum;
import com.dji.sdk.cloudapi.device.DeviceTypeEnum;
import com.dji.sdk.cloudapi.wayline.GetWaylineListRequest;
import com.dji.sdk.cloudapi.wayline.GetWaylineListResponse;
import com.dji.sdk.cloudapi.wayline.WaylineTypeEnum;
@ -206,21 +208,15 @@ public class WaylineFileServiceImpl implements IWaylineFileService { @@ -206,21 +208,15 @@ public class WaylineFileServiceImpl implements IWaylineFileService {
throw new RuntimeException("The file format is incorrect.");
}
String type = droneNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_DRONE_ENUM_VALUE);
String subType = droneNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_DRONE_SUB_ENUM_VALUE);
String payloadType = payloadNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_PAYLOAD_ENUM_VALUE);
String payloadSubType = payloadNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_PAYLOAD_SUB_ENUM_VALUE);
DeviceTypeEnum type = DeviceTypeEnum.find(Integer.parseInt(droneNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_DRONE_ENUM_VALUE)));
DeviceSubTypeEnum subType = DeviceSubTypeEnum.find(Integer.parseInt(droneNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_DRONE_SUB_ENUM_VALUE)));
DeviceTypeEnum payloadType = DeviceTypeEnum.find(Integer.parseInt(payloadNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_PAYLOAD_ENUM_VALUE)));
DeviceSubTypeEnum payloadSubType = DeviceSubTypeEnum.find(Integer.parseInt(payloadNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_PAYLOAD_SUB_ENUM_VALUE)));
String templateType = document.valueOf("//" + KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_TEMPLATE_TYPE);
if (!StringUtils.hasText(type) || !StringUtils.hasText(subType) ||
!StringUtils.hasText(payloadSubType) || !StringUtils.hasText(payloadType) ||
!StringUtils.hasText(templateType)) {
throw new RuntimeException("The file format is incorrect.");
}
return Optional.of(WaylineFileDTO.builder()
.droneModelKey(String.format("%s-%s-%s", DeviceDomainEnum.DRONE.getDomain(), type, subType))
.payloadModelKeys(List.of(String.format("%s-%s-%s",DeviceDomainEnum.PAYLOAD.getDomain(), payloadType, payloadSubType)))
.droneModelKey(DeviceEnum.find(DeviceDomainEnum.DRONE, type, subType).getDevice())
.payloadModelKeys(List.of(DeviceEnum.find(DeviceDomainEnum.PAYLOAD, payloadType, payloadSubType).getDevice()))
.objectKey(OssConfiguration.objectDirPrefix + File.separator + filename)
.name(filename.substring(0, filename.lastIndexOf(WAYLINE_FILE_SUFFIX)))
.sign(DigestUtils.md5DigestAsHex(file.getInputStream()))

4
src/main/java/com/dji/sdk/annotations/CloudSDKVersion.java

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
package com.dji.sdk.annotations;
import com.dji.sdk.common.CloudSDKVersionEnum;
import com.dji.sdk.common.GatewayTypeEnum;
import com.dji.sdk.config.version.CloudSDKVersionEnum;
import com.dji.sdk.config.version.GatewayTypeEnum;
import java.lang.annotation.*;

2
src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointRequest.java

@ -5,7 +5,7 @@ import com.dji.sdk.cloudapi.device.ExitWaylineWhenRcLostEnum; @@ -5,7 +5,7 @@ import com.dji.sdk.cloudapi.device.ExitWaylineWhenRcLostEnum;
import com.dji.sdk.cloudapi.device.RcLostActionEnum;
import com.dji.sdk.cloudapi.wayline.RthModeEnum;
import com.dji.sdk.common.BaseModel;
import com.dji.sdk.common.CloudSDKVersionEnum;
import com.dji.sdk.config.version.CloudSDKVersionEnum;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

26
src/main/java/com/dji/sdk/cloudapi/control/api/AbstractControlService.java

@ -4,9 +4,9 @@ import com.dji.sdk.annotations.CloudSDKVersion; @@ -4,9 +4,9 @@ import com.dji.sdk.annotations.CloudSDKVersion;
import com.dji.sdk.cloudapi.control.*;
import com.dji.sdk.common.BaseModel;
import com.dji.sdk.common.Common;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.common.GatewayTypeEnum;
import com.dji.sdk.exception.CloudSDKErrorEnum;
import com.dji.sdk.common.SpringBeanUtils;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.config.version.GatewayTypeEnum;
import com.dji.sdk.exception.CloudSDKException;
import com.dji.sdk.mqtt.ChannelName;
import com.dji.sdk.mqtt.MqttReply;
@ -23,7 +23,8 @@ import org.springframework.messaging.Message; @@ -23,7 +23,8 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import javax.annotation.Resource;
import java.util.Objects;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* @author sean
@ -278,16 +279,17 @@ public abstract class AbstractControlService { @@ -278,16 +279,17 @@ public abstract class AbstractControlService {
* @param request data
* @return services_reply
*/
@CloudSDKVersion(exclude = GatewayTypeEnum.RC)
public TopicServicesResponse<ServicesReplyData> payloadControl(GatewayManager gateway, PayloadControlMethodEnum methodEnum, BaseModel request) {
if (Objects.isNull(request) || request.getClass() != methodEnum.getClazz()) {
throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER);
try {
AbstractControlService abstractControlService = SpringBeanUtils.getBean(this.getClass());
Method method = abstractControlService.getClass().getDeclaredMethod(
Common.convertSnake(methodEnum.getPayloadMethod().getMethod()),GatewayManager.class, methodEnum.getClazz());
return (TopicServicesResponse<ServicesReplyData>) method.invoke(abstractControlService, gateway, request);
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new CloudSDKException(e);
} catch (InvocationTargetException e) {
throw new CloudSDKException(e.getTargetException());
}
Common.validateModel(request);
return servicesPublish.publish(
gateway.getGatewaySn(),
methodEnum.getPayloadMethod().getMethod(),
request);
}

39
src/main/java/com/dji/sdk/cloudapi/debug/api/AbstractDebugService.java

@ -4,9 +4,9 @@ import com.dji.sdk.annotations.CloudSDKVersion; @@ -4,9 +4,9 @@ import com.dji.sdk.annotations.CloudSDKVersion;
import com.dji.sdk.cloudapi.debug.*;
import com.dji.sdk.common.BaseModel;
import com.dji.sdk.common.Common;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.common.GatewayTypeEnum;
import com.dji.sdk.exception.CloudSDKErrorEnum;
import com.dji.sdk.common.SpringBeanUtils;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.config.version.GatewayTypeEnum;
import com.dji.sdk.exception.CloudSDKException;
import com.dji.sdk.mqtt.ChannelName;
import com.dji.sdk.mqtt.MqttReply;
@ -22,6 +22,10 @@ import org.springframework.messaging.Message; @@ -22,6 +22,10 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
@ -242,7 +246,7 @@ public abstract class AbstractDebugService { @@ -242,7 +246,7 @@ public abstract class AbstractDebugService {
* @param gateway
* @return services_reply
*/
@CloudSDKVersion(exclude = GatewayTypeEnum.RC)
@CloudSDKVersion(exclude = {GatewayTypeEnum.RC, GatewayTypeEnum.DOCK2})
public TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> putterOpen(GatewayManager gateway) {
return servicesPublish.publish(
new TypeReference<RemoteDebugResponse>() {},
@ -255,7 +259,7 @@ public abstract class AbstractDebugService { @@ -255,7 +259,7 @@ public abstract class AbstractDebugService {
* @param gateway
* @return services_reply
*/
@CloudSDKVersion(exclude = GatewayTypeEnum.RC)
@CloudSDKVersion(exclude = {GatewayTypeEnum.RC, GatewayTypeEnum.DOCK2})
public TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> putterClose(GatewayManager gateway) {
return servicesPublish.publish(
new TypeReference<RemoteDebugResponse>() {},
@ -311,19 +315,24 @@ public abstract class AbstractDebugService { @@ -311,19 +315,24 @@ public abstract class AbstractDebugService {
* @param request data
* @return services_reply
*/
@CloudSDKVersion(exclude = GatewayTypeEnum.RC)
public TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> remoteDebug(GatewayManager gateway, DebugMethodEnum methodEnum, BaseModel request) {
if (Objects.nonNull(methodEnum.getClazz())) {
if (methodEnum.getClazz() != request.getClass()) {
throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER);
try {
List<Class> clazz = new ArrayList<>();
List<Object> args = new ArrayList<>();
clazz.add(GatewayManager.class);
args.add(gateway);
if (Objects.nonNull(request)) {
clazz.add(request.getClass());
args.add(request);
}
Common.validateModel(request);
AbstractDebugService abstractDebugService = SpringBeanUtils.getBean(this.getClass());
Method method = abstractDebugService.getClass().getDeclaredMethod(Common.convertSnake(methodEnum.getMethod()), clazz.toArray(Class[]::new));
return (TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>>) method.invoke(abstractDebugService, args.toArray());
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new CloudSDKException(e);
} catch (InvocationTargetException e) {
throw new CloudSDKException(e.getTargetException());
}
return servicesPublish.publish(
new TypeReference<RemoteDebugResponse>() {},
gateway.getGatewaySn(),
methodEnum.getMethod(),
request);
}
/**

4
src/main/java/com/dji/sdk/cloudapi/device/DeviceDomainEnum.java

@ -22,7 +22,9 @@ public enum DeviceDomainEnum { @@ -22,7 +22,9 @@ public enum DeviceDomainEnum {
REMOTER_CONTROL(2),
DOCK (3);
DOCK (3),
;
private final int domain;

20
src/main/java/com/dji/sdk/cloudapi/device/DeviceEnum.java

@ -19,9 +19,9 @@ public enum DeviceEnum { @@ -19,9 +19,9 @@ public enum DeviceEnum {
M300(DeviceDomainEnum.DRONE, DeviceTypeEnum.M300, DeviceSubTypeEnum.ZERO),
M30(DeviceDomainEnum.DRONE, DeviceTypeEnum.M30, DeviceSubTypeEnum.ZERO),
M30(DeviceDomainEnum.DRONE, DeviceTypeEnum.M30_OR_M3T_CAMERA, DeviceSubTypeEnum.ZERO),
M30T(DeviceDomainEnum.DRONE, DeviceTypeEnum.M30, DeviceSubTypeEnum.ONE),
M30T(DeviceDomainEnum.DRONE, DeviceTypeEnum.M30_OR_M3T_CAMERA, DeviceSubTypeEnum.ONE),
M3E(DeviceDomainEnum.DRONE, DeviceTypeEnum.M3E, DeviceSubTypeEnum.ZERO),
@ -55,7 +55,7 @@ public enum DeviceEnum { @@ -55,7 +55,7 @@ public enum DeviceEnum {
M3E_CAMERA(DeviceDomainEnum.PAYLOAD, DeviceTypeEnum.M3E_CAMERA, DeviceSubTypeEnum.ZERO),
M3T_CAMERA(DeviceDomainEnum.PAYLOAD, DeviceTypeEnum.M3T_CAMERA, DeviceSubTypeEnum.ZERO),
M3T_CAMERA(DeviceDomainEnum.PAYLOAD, DeviceTypeEnum.M30_OR_M3T_CAMERA, DeviceSubTypeEnum.ZERO),
M3M_CAMERA(DeviceDomainEnum.PAYLOAD, DeviceTypeEnum.M3M_CAMERA, DeviceSubTypeEnum.ZERO),
@ -66,6 +66,16 @@ public enum DeviceEnum { @@ -66,6 +66,16 @@ public enum DeviceEnum {
RC_PRO(DeviceDomainEnum.REMOTER_CONTROL, DeviceTypeEnum.RC_PRO, DeviceSubTypeEnum.ZERO),
DOCK(DeviceDomainEnum.DOCK, DeviceTypeEnum.DOCK, DeviceSubTypeEnum.ZERO),
DOCK2(DeviceDomainEnum.DOCK, DeviceTypeEnum.DOCK2, DeviceSubTypeEnum.ZERO),
M3D(DeviceDomainEnum.DRONE, DeviceTypeEnum.M3D, DeviceSubTypeEnum.ZERO),
M3TD(DeviceDomainEnum.DRONE, DeviceTypeEnum.M3D, DeviceSubTypeEnum.ONE),
M3D_CAMERA(DeviceDomainEnum.PAYLOAD, DeviceTypeEnum.M3D_CAMERA, DeviceSubTypeEnum.ZERO),
M3TD_CAMERA(DeviceDomainEnum.PAYLOAD, DeviceTypeEnum.M3TD_CAMERA, DeviceSubTypeEnum.ZERO),
;
@Schema(enumAsRef = true)
@ -101,9 +111,7 @@ public enum DeviceEnum { @@ -101,9 +111,7 @@ public enum DeviceEnum {
}
public static DeviceEnum find(DeviceDomainEnum domain, DeviceTypeEnum type, DeviceSubTypeEnum subType) {
return Arrays.stream(values()).filter(device -> device.domain == domain && device.type == type && device.subType == subType)
.findAny().orElseThrow(() -> new CloudSDKException(DeviceEnum.class,
String.format("%s-%s-%s", domain.getDomain(), type.getType(), subType.getSubType())));
return DeviceEnum.find(domain.getDomain(), type.getType(), subType.getSubType());
}
public static DeviceEnum find(int domain, int type, int subType) {

14
src/main/java/com/dji/sdk/cloudapi/device/DeviceTypeEnum.java

@ -19,7 +19,7 @@ public enum DeviceTypeEnum { @@ -19,7 +19,7 @@ public enum DeviceTypeEnum {
M300(60),
M30(67),
M30_OR_M3T_CAMERA(67),
M3E(77),
@ -49,8 +49,6 @@ public enum DeviceTypeEnum { @@ -49,8 +49,6 @@ public enum DeviceTypeEnum {
M3E_CAMERA(66),
M3T_CAMERA(67),
M3M_CAMERA(68),
RC(56),
@ -59,7 +57,15 @@ public enum DeviceTypeEnum { @@ -59,7 +57,15 @@ public enum DeviceTypeEnum {
RC_PRO(144),
DOCK(1)
DOCK(1),
DOCK2(2),
M3D(91),
M3D_CAMERA(80),
M3TD_CAMERA(81),
;
private final int type;

5
src/main/java/com/dji/sdk/cloudapi/device/DockLiveErrorStatus.java

@ -31,10 +31,7 @@ public class DockLiveErrorStatus { @@ -31,10 +31,7 @@ public class DockLiveErrorStatus {
@JsonCreator
public DockLiveErrorStatus(int code) {
if (MqttReply.CODE_SUCCESS == code) {
this.success = true;
return;
}
this.success = MqttReply.CODE_SUCCESS == code;
this.source = ErrorCodeSourceEnum.find(code / MOD);
this.errorCode = LiveErrorCodeEnum.find(code % MOD);
}

2
src/main/java/com/dji/sdk/cloudapi/device/DockPositionState.java

@ -39,7 +39,7 @@ public class DockPositionState { @@ -39,7 +39,7 @@ public class DockPositionState {
}
public DockPositionState setCalibration(Boolean calibration) {
calibration = calibration;
this.calibration = calibration;
return this;
}

12
src/main/java/com/dji/sdk/cloudapi/device/NetworkStateQualityEnum.java

@ -13,11 +13,17 @@ import java.util.Arrays; @@ -13,11 +13,17 @@ import java.util.Arrays;
*/
public enum NetworkStateQualityEnum {
BAD(0),
NO_SIGNAL(0),
MODERATE(1),
BAD(1),
GOOD(2),
POOR(2),
FAIR(3),
GOOD(4),
EXCELLENT(5),
;
private final int quality;

2
src/main/java/com/dji/sdk/cloudapi/device/OsdDockDrone.java

@ -49,7 +49,7 @@ public class OsdDockDrone { @@ -49,7 +49,7 @@ public class OsdDockDrone {
private DronePositionState positionState;
@JsonProperty(PayloadModelEnum.PAYLOAD_KEY)
@JsonProperty(PayloadModelConst.PAYLOAD_KEY)
private List<DockDronePayload> payloads;
private Storage storage;

2
src/main/java/com/dji/sdk/cloudapi/device/OsdRcDrone.java

@ -49,7 +49,7 @@ public class OsdRcDrone { @@ -49,7 +49,7 @@ public class OsdRcDrone {
private DronePositionState positionState;
@JsonProperty(PayloadModelEnum.PAYLOAD_KEY)
@JsonProperty(PayloadModelConst.PAYLOAD_KEY)
private List<RcDronePayload> payloads;
private Storage storage;

38
src/main/java/com/dji/sdk/cloudapi/device/PayloadModelConst.java

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
package com.dji.sdk.cloudapi.device;
import java.util.Arrays;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author sean
* @version 1.0
* @date 2022/4/29
*/
public class PayloadModelConst {
private PayloadModelConst() {
}
public static final String PAYLOAD_KEY = "payload";
public static Set<String> getAllModelWithPosition() {
Set<String> position = Arrays.stream(PayloadPositionEnum.values()).map(PayloadPositionEnum::getPosition)
.map(String::valueOf).collect(Collectors.toSet());
return Arrays.stream(DeviceEnum.values()).filter(device -> DeviceDomainEnum.PAYLOAD == device.getDomain())
.map(Enum::name).map(name -> name.replace("_CAMERA", ""))
.map(m -> position.stream().map(p -> m.concat("-").concat(p)))
.flatMap(Function.identity()).collect(Collectors.toSet());
}
public static Set<String> getAllIndexWithPosition() {
Set<String> position = Arrays.stream(PayloadPositionEnum.values()).map(PayloadPositionEnum::getPosition)
.map(String::valueOf).collect(Collectors.toSet());
return Arrays.stream(DeviceEnum.values()).filter(device -> DeviceDomainEnum.PAYLOAD == device.getDomain())
.map(device -> String.format("%d-%d", device.getType().getType(), device.getSubType().getSubType()))
.map(m -> position.stream().map(p -> m.concat("-").concat(p)))
.flatMap(Function.identity()).collect(Collectors.toSet());
}
}

77
src/main/java/com/dji/sdk/cloudapi/device/PayloadModelEnum.java

@ -1,77 +0,0 @@ @@ -1,77 +0,0 @@
package com.dji.sdk.cloudapi.device;
import com.dji.sdk.exception.CloudSDKException;
import java.util.Arrays;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author sean
* @version 1.0
* @date 2022/4/29
*/
public enum PayloadModelEnum {
Z30("Z30", "20-0"),
XT2("XT2", "26-0"),
XTS("XTS", "41-0"),
H20("H20", "42-0"),
H20T("H20T", "43-0"),
P1("P1", "50-65535"),
M30("M30", "52-0"),
M30T("M30T", "53-0"),
H20N("H20N", "61-0"),
DOCK("DOCK", "165-0"),
L1("L1", "90742-0");
public static final String PAYLOAD_KEY = "payload";
private final String model;
private final String index;
PayloadModelEnum(String model, String index) {
this.model = model;
this.index = index;
}
public String getModel() {
return model;
}
public String getIndex() {
return index;
}
public static Set<String> getAllModelWithPosition() {
Set<String> position = Arrays.stream(PayloadPositionEnum.values()).map(PayloadPositionEnum::getPosition)
.map(String::valueOf).collect(Collectors.toSet());
return Arrays.stream(values()).map(PayloadModelEnum::getModel).map(m -> position.stream().map(p -> m.concat("-").concat(p)))
.flatMap(Function.identity()).collect(Collectors.toSet());
}
public static Set<String> getAllIndexWithPosition() {
Set<String> position = Arrays.stream(PayloadPositionEnum.values()).map(PayloadPositionEnum::getPosition)
.map(String::valueOf).collect(Collectors.toSet());
return Arrays.stream(values()).map(PayloadModelEnum::getIndex).map(m -> position.stream().map(p -> m.concat("-").concat(p)))
.flatMap(Function.identity()).collect(Collectors.toSet());
}
public static PayloadModelEnum find(String model) {
return Arrays.stream(values()).filter(modelEnum -> modelEnum.model.equals(model)).findAny()
.orElseThrow(() -> new CloudSDKException(PayloadModelEnum.class, model));
}
}

2
src/main/java/com/dji/sdk/cloudapi/device/api/AbstractDeviceService.java

@ -169,7 +169,7 @@ public class AbstractDeviceService { @@ -169,7 +169,7 @@ public class AbstractDeviceService {
* @param request data
* @param headers The headers for a {@link Message}.
*/
@ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_WPMZ_VERSION)
@ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_PAYLOAD)
public void dockPayload(TopicStateRequest<DockPayload> request, MessageHeaders headers) {
throw new UnsupportedOperationException("dockPayload not implemented");
}

2
src/main/java/com/dji/sdk/cloudapi/firmware/api/AbstractFirmwareService.java

@ -4,7 +4,7 @@ import com.dji.sdk.cloudapi.firmware.FirmwareMethodEnum; @@ -4,7 +4,7 @@ import com.dji.sdk.cloudapi.firmware.FirmwareMethodEnum;
import com.dji.sdk.cloudapi.firmware.OtaCreateRequest;
import com.dji.sdk.cloudapi.firmware.OtaCreateResponse;
import com.dji.sdk.cloudapi.firmware.OtaProgress;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.mqtt.ChannelName;
import com.dji.sdk.mqtt.MqttReply;
import com.dji.sdk.mqtt.events.EventsDataRequest;

2
src/main/java/com/dji/sdk/cloudapi/livestream/LiveErrorCodeEnum.java

@ -12,6 +12,8 @@ import java.util.Arrays; @@ -12,6 +12,8 @@ import java.util.Arrays;
*/
public enum LiveErrorCodeEnum implements IServicesErrorCode, IErrorInfo {
SUCCESS(0, "Success"),
NO_AIRCRAFT(13001, "No aircraft."),
NO_CAMERA(13002, "No camera."),

16
src/main/java/com/dji/sdk/cloudapi/livestream/api/AbstractLivestreamService.java

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
package com.dji.sdk.cloudapi.livestream.api;
import com.dji.sdk.cloudapi.livestream.*;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.mqtt.ChannelName;
import com.dji.sdk.mqtt.services.ServicesPublish;
import com.dji.sdk.mqtt.services.ServicesReplyData;
@ -24,6 +24,8 @@ public abstract class AbstractLivestreamService { @@ -24,6 +24,8 @@ public abstract class AbstractLivestreamService {
@Resource
private ServicesPublish servicesPublish;
private static final long DEFAULT_TIMEOUT = 20_000;
/**
* Livestream ability update for remote control
* @param request data
@ -55,7 +57,8 @@ public abstract class AbstractLivestreamService { @@ -55,7 +57,8 @@ public abstract class AbstractLivestreamService {
new TypeReference<String>() {},
gateway.getGatewaySn(),
LiveStreamMethodEnum.LIVE_START_PUSH.getMethod(),
request);
request,
DEFAULT_TIMEOUT);
}
/**
@ -68,7 +71,8 @@ public abstract class AbstractLivestreamService { @@ -68,7 +71,8 @@ public abstract class AbstractLivestreamService {
return servicesPublish.publish(
gateway.getGatewaySn(),
LiveStreamMethodEnum.LIVE_STOP_PUSH.getMethod(),
request);
request,
DEFAULT_TIMEOUT);
}
/**
@ -81,7 +85,8 @@ public abstract class AbstractLivestreamService { @@ -81,7 +85,8 @@ public abstract class AbstractLivestreamService {
return servicesPublish.publish(
gateway.getGatewaySn(),
LiveStreamMethodEnum.LIVE_SET_QUALITY.getMethod(),
request);
request,
DEFAULT_TIMEOUT);
}
/**
@ -94,7 +99,8 @@ public abstract class AbstractLivestreamService { @@ -94,7 +99,8 @@ public abstract class AbstractLivestreamService {
return servicesPublish.publish(
gateway.getGatewaySn(),
LiveStreamMethodEnum.LIVE_LENS_CHANGE.getMethod(),
request);
request,
DEFAULT_TIMEOUT);
}

2
src/main/java/com/dji/sdk/cloudapi/log/api/AbstractLogService.java

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
package com.dji.sdk.cloudapi.log.api;
import com.dji.sdk.cloudapi.log.*;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.mqtt.ChannelName;
import com.dji.sdk.mqtt.MqttReply;
import com.dji.sdk.mqtt.events.EventsDataRequest;

4
src/main/java/com/dji/sdk/cloudapi/media/api/AbstractMediaService.java

@ -3,8 +3,8 @@ package com.dji.sdk.cloudapi.media.api; @@ -3,8 +3,8 @@ package com.dji.sdk.cloudapi.media.api;
import com.dji.sdk.annotations.CloudSDKVersion;
import com.dji.sdk.cloudapi.media.*;
import com.dji.sdk.cloudapi.storage.StsCredentialsResponse;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.common.GatewayTypeEnum;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.config.version.GatewayTypeEnum;
import com.dji.sdk.mqtt.ChannelName;
import com.dji.sdk.mqtt.MqttReply;
import com.dji.sdk.mqtt.events.TopicEventsRequest;

4
src/main/java/com/dji/sdk/cloudapi/property/api/AbstractPropertyService.java

@ -4,8 +4,8 @@ import com.dji.sdk.annotations.CloudSDKVersion; @@ -4,8 +4,8 @@ import com.dji.sdk.annotations.CloudSDKVersion;
import com.dji.sdk.cloudapi.property.PropertySetEnum;
import com.dji.sdk.common.BaseModel;
import com.dji.sdk.common.Common;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.common.GatewayTypeEnum;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.config.version.GatewayTypeEnum;
import com.dji.sdk.exception.CloudSDKErrorEnum;
import com.dji.sdk.exception.CloudSDKException;
import com.dji.sdk.mqtt.property.PropertySetPublish;

89
src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakPoint.java

@ -35,33 +35,8 @@ public class FlighttaskBreakPoint { @@ -35,33 +35,8 @@ public class FlighttaskBreakPoint {
/**
* Wayline ID
*/
private Integer waylineID;
/**
* Break reason
*/
private FlighttaskBreakReasonEnum breakReason;
/**
* Breakpoint latitude
*/
private Float latitude;
/**
* Breakpoint longitude
*/
private Float longitude;
/**
* Breakpoint altitude relative to the Earth's ellipsoid surface
*
*/
private Float height;
/**
* Yaw angle relative to true north (meridian), with positive values from 0 to 6 o'clock direction and negative values from 6 to 12 o'clock direction
*/
private Integer attitudeHead;
@NotNull
private Integer waylineId;
public FlighttaskBreakPoint() {}
@ -71,12 +46,7 @@ public class FlighttaskBreakPoint { @@ -71,12 +46,7 @@ public class FlighttaskBreakPoint {
"index=" + index +
", state=" + state +
", progress=" + progress +
", waylineID=" + waylineID +
", breakReason=" + breakReason +
", latitude=" + latitude +
", longitude=" + longitude +
", height=" + height +
", attitudeHead=" + attitudeHead +
", waylineId=" + waylineId +
'}';
}
@ -107,57 +77,12 @@ public class FlighttaskBreakPoint { @@ -107,57 +77,12 @@ public class FlighttaskBreakPoint {
return this;
}
public Integer getWaylineID() {
return waylineID;
}
public FlighttaskBreakPoint setWaylineID(Integer waylineID) {
this.waylineID = waylineID;
return this;
}
public FlighttaskBreakReasonEnum getBreakReason() {
return breakReason;
}
public FlighttaskBreakPoint setBreakReason(FlighttaskBreakReasonEnum breakReason) {
this.breakReason = breakReason;
return this;
}
public Float getLatitude() {
return latitude;
}
public FlighttaskBreakPoint setLatitude(Float latitude) {
this.latitude = latitude;
return this;
}
public Float getLongitude() {
return longitude;
}
public FlighttaskBreakPoint setLongitude(Float longitude) {
this.longitude = longitude;
return this;
}
public Float getHeight() {
return height;
}
public FlighttaskBreakPoint setHeight(Float height) {
this.height = height;
return this;
}
public Integer getAttitudeHead() {
return attitudeHead;
public Integer getWaylineId() {
return waylineId;
}
public FlighttaskBreakPoint setAttitudeHead(Integer attitudeHead) {
this.attitudeHead = attitudeHead;
public FlighttaskBreakPoint setWaylineId(Integer waylineId) {
this.waylineId = waylineId;
return this;
}
}

192
src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakReasonEnum.java

@ -1,5 +1,11 @@ @@ -1,5 +1,11 @@
package com.dji.sdk.cloudapi.wayline;
import com.dji.sdk.exception.CloudSDKException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
/**
* @author sean
* @version 1.7
@ -7,5 +13,189 @@ package com.dji.sdk.cloudapi.wayline; @@ -7,5 +13,189 @@ package com.dji.sdk.cloudapi.wayline;
*/
public enum FlighttaskBreakReasonEnum {
// TODO 增加枚举值
NORMAL(0, "No abnormalities"),
NOT_ID(1, "Mission ID does not exist. The wayline mission has not been executed."),
UNCOMMON_ERROR(2, "Uncommon error, please contact technical support."),
ERROR_LOADING_FILE(4, "Error loading wayline file when requesting to start/resume the wayline mission, please try uploading the file again or contact technical support."),
ERROR_BREAKPOINT_FILE(5, "Failed to query breakpoint file when requesting breakpoint information. Failed to parse breakpoint type when requesting to resume the wayline mission."),
INCORRECT_PARAMETER(6, "Incorrect cmd parameter when requesting to start/end the wayline mission, incorrect protocol command in the request. Failed to parse breakpoint type when requesting to resume the wayline mission."),
PARSING_FILE_TIMEOUT(7, "Timeout parsing the WPMZ file when requesting to start/resume the wayline mission, please retry."),
ALREADY_STARTED(257, "Wayline has already started, cannot start again."),
UNABLE_TO_INTERRUPT_WAYLINE(258, "Unable to interrupt the wayline in this state, only allowed to pause the wayline in the executing state."),
NOT_STARTED(259, "Wayline has not started, cannot end the wayline."),
FLIGHT_MISSION_CONFLICT(261, "Flight mission conflict, unable to obtain control of the aircraft, not allowed to start the wayline during landing and return."),
UNABLE_TO_RESUME_WAYLINE(262, "Unable to resume wayline in this state, only allowed when the wayline is paused."),
MAXIMUM_ALTITUDE_LIMIT(513, "Aircraft exceeded the maximum altitude limit."),
MAXIMUM_DISTANCE_LIMIT(514, "Aircraft exceeded the maximum distance limit."),
TOO_LOW_HEIGHT(516, "The height of the drone is too low."),
OBSTACLE_AVOIDANCE(517, "Aircraft triggered obstacle sensing."),
POOR_RTK(518, "Poor RTK signal"),
BOUNDARY_OF_RESTRICTED_ZONE(519, "Approaching the boundary of Restricted Zone."),
GEO_ALTITUDE_LIMIT(521, "Exceeded the dock's GEO zone altitude limit."),
TAKEOFF_REQUEST_FAILED(522, "Failed to request takeoff for the wayline."),
TAKEOFF_EXECUTION_FAILED(523, "Takeoff mission execution failed."),
WAYLINE_MISSION_REQUEST_FAILED(524, "Failed to request wayline mission."),
RTK_FIXING_REQUEST_FAILED(526, "Failed to request wayline RTK fixing mission."),
RTK_FIXING_EXECUTION_FAILED(527, "Wayline RTK fixing mission failed to run."),
WEAK_GPS(769, "Weak GPS signal."),
ERROR_RC_MODE(770, "Remote controller not in N mode, unable to start the task."),
HOME_POINT_NOT_REFRESHED(771, "Home point not refreshed."),
LOW_BATTERY(772, "Unable to start the mission due to low current battery level."),
LOW_BATTERY_RTH(773, "Wayline interrupted due to low battery causing return to home."),
RC_DISCONNECTION(775, "Disconnection between the remote controller and the aircraft."),
ON_THE_GROUND(778, "Aircraft is on the ground with propellers spinning, not allowed to start the wayline."),
ABNORMAL_VISUAL_STATUS(779, "Abnormal visual status (for example, too bright, too dark, inconsistent brightness on both sides) during real-time terrain follow."),
INVALID_ALTITUDE(780, "Real-time terrain-following altitude set by the user is invalid (greater than 200m or less than 30m)."),
CALCULATION_ERROR(781, "Global map calculation error during real-time terrain follow."),
STRONG_WINDS_RTH(784, "Wayline interrupted due to strong winds causing return to home."),
USER_EXIT(1281, "User exit."),
USER_INTERRUPTION(1282, "User interruption."),
USER_TRIGGERED_RTH(1283, "User triggered return to home."),
INCORRECT_START_INFORMATION(1539, "Incorrect start information (waypoint index or progress)."),
UNSUPPORTED_COORDINATE_SYSTEM(1540, "Using an unsupported coordinate system."),
UNSUPPORTED_ALTITUDE_MODE(1541, "Using an unsupported altitude mode."),
UNSUPPORTED_TRANSITIONAL_WAYLINE_MODE(1542, "Using an unsupported transitional wayline mode."),
UNSUPPORTED_YAW_MODE(1543, "Using an unsupported yaw mode."),
UNSUPPORTED_YAW_DIRECTION_REVERSAL_MODE(1544, "Using an unsupported yaw direction reversal mode."),
UNSUPPORTED_WAYPOINT_TYPE(1545, "Using an unsupported waypoint type."),
INVALID_COORDINATED_TURNING_TYPE(1546, "Coordinated turning type cannot be used for the start and end points."),
INVALID_GLOBAL_SPEED(1547, "Wayline global speed exceeds a reasonable range."),
WAYPOINT_NUMBER_ABNORMAL(1548, "Waypoint number abnormal."),
INVALID_LATITUDE_AND_LONGITUDE(1549, "Abnormal latitude and longitude data."),
ABNORMAL_TURNING_INTERCEPT(1550, "Abnormal turning intercept."),
INVALID_SEGMENT_MAXIMUM_SPEED(1551, "Maximum speed of wayline segment exceeds a reasonable range."),
INVALID_TARGET_SPEED(1552, "Wayline segment target speed exceeds a reasonable range."),
INVALID_YAW_ANGLE(1553, "Waypoint yaw angle exceeds a reasonable range."),
BREAKPOINT_INVALID_MISSION_ID(1555, "Input mission_id of resuming from breakpoint is wrong."),
BREAKPOINT_INVALID_PROGRESS_INFORMATION(1556, "Progress information of resuming from breakpoint input error."),
BREAKPOINT_ERROR_MISSION_STATE(1557, "Mission state of resuming from breakpoint is abnormal."),
BREAKPOINT_INVALID_INDEX_INFORMATION(1558, "Wapoint index information of resuming from breakpoint input error."),
BREAKPOINT_INCORRECT_LATITUDE_AND_LONGITUDE(1559, "Incorrect latitude and longitude information for resuming from breakpoint."),
BREAKPOINT_INVALID_YAW(1560, "Yaw input error for waypoints during resuming from breakpoint."),
BREAKPOINT_INCORRECT_FLAG_SETTING(1561, "Incorrect flag setting for resuming from breakpoint."),
WAYLINE_GENERATION_FAILED(1563, "Wayline generation failed."),
WAYLINE_EXECUTION_FAILED(1564, "Wayline execution failed."),
WAYLINE_OBSTACLE_SENSING(1565, "Emergency stop due to wayline obstacle sensing."),
UNRECOGNIZED_ACTION_TYPE(1588, "Unrecognized action type."),
DUPLICATE_ACTION_ID(1595, "Action ID of same action group can not be the same."),
ACTION_ID_NOT_65535(1598, "Action ID value cannot be 65535."),
INVALID_NUMBER_OF_ACTION_GROUPS(1602, "Number of action groups exceeds a reasonable range."),
ERROR_EFFECTIVE_RANGE(1603, "Error in action group effective range."),
BREAKPOINT_INVALID_ACTION_INDEX(1606, "Action index exceeds a reasonable range during resuming from breakpoint."),
BREAKPOINT_TRIGGER_RUNNING_ABNORMAL(1608, "Trigger running result of breakpoint information is abnormal."),
BREAKPOINT_DUPLICATE_ACTION_GROUP_ID(1609, "Action group ID information can not be duplicated during resume from breakpoint."),
BREAKPOINT_DUPLICATE_ACTION_GROUP_POSITION(1610, "Action group positions cannot be repeated during resuming from breakpoint."),
BREAKPOINT_INVALID_ACTION_GROUP_POSITION(1611, "Action group positions exceed a reasonable range during resuming from breakpoint."),
BREAKPOINT_INVALID_ACTION_ID(1612, "Action ID is not in the breakpoint information during resuming."),
BREAKPOINT_UNABLE_TO_INTERRUPT(1613, "Cannot modify the action state to interrupt during resuming."),
INCORRECT_BREAKPOINT_INFORMATION(1614, "Resume failure due to incorrect breakpoint information."),
BREAKPOINT_UNRECOGNIZED_ACTION_TYPE(1634, "Unrecognized action type."),
BREAKPOINT_UNRECOGNIZED_TRIGGER_TYPE(1649, "Unrecognized trigger type."),
UNKNOWN_ERROR_1(65534, "Unknown error."),
UNKNOWN_ERROR_2(65535, "Unknown error."),
;
private final int reason;
private final String msg;
FlighttaskBreakReasonEnum(int reason, String msg) {
this.reason = reason;
this.msg = msg;
}
public int getReason() {
return reason;
}
@JsonValue
public String getMsg() {
return msg;
}
@JsonCreator
public static FlighttaskBreakReasonEnum find(int reason) {
return Arrays.stream(values()).filter(reasonEnum -> reasonEnum.reason == reason).findAny()
.orElseThrow(() -> new CloudSDKException(FlighttaskBreakReasonEnum.class, reason));
}
}

5
src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskPrepareRequest.java

@ -3,7 +3,7 @@ package com.dji.sdk.cloudapi.wayline; @@ -3,7 +3,7 @@ package com.dji.sdk.cloudapi.wayline;
import com.dji.sdk.annotations.CloudSDKVersion;
import com.dji.sdk.cloudapi.device.ExitWaylineWhenRcLostEnum;
import com.dji.sdk.common.BaseModel;
import com.dji.sdk.common.CloudSDKVersionEnum;
import com.dji.sdk.config.version.CloudSDKVersionEnum;
import javax.validation.Valid;
import javax.validation.constraints.Max;
@ -59,16 +59,19 @@ public class FlighttaskPrepareRequest extends BaseModel { @@ -59,16 +59,19 @@ public class FlighttaskPrepareRequest extends BaseModel {
/**
* Task readiness condition
*/
@Valid
private ReadyConditions readyConditions;
/**
* Task executable condition
*/
@Valid
private ExecutableConditions executableConditions;
/**
* Wayline breakpoint information
*/
@Valid
private FlighttaskBreakPoint breakPoint;
/**

6
src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressExt.java

@ -15,7 +15,7 @@ public class FlighttaskProgressExt { @@ -15,7 +15,7 @@ public class FlighttaskProgressExt {
private String trackId;
private FlighttaskBreakPoint breakPoint;
private ProgressExtBreakPoint breakPoint;
public FlighttaskProgressExt() {
}
@ -67,11 +67,11 @@ public class FlighttaskProgressExt { @@ -67,11 +67,11 @@ public class FlighttaskProgressExt {
return this;
}
public FlighttaskBreakPoint getBreakPoint() {
public ProgressExtBreakPoint getBreakPoint() {
return breakPoint;
}
public FlighttaskProgressExt setBreakPoint(FlighttaskBreakPoint breakPoint) {
public FlighttaskProgressExt setBreakPoint(ProgressExtBreakPoint breakPoint) {
this.breakPoint = breakPoint;
return this;
}

153
src/main/java/com/dji/sdk/cloudapi/wayline/ProgressExtBreakPoint.java

@ -0,0 +1,153 @@ @@ -0,0 +1,153 @@
package com.dji.sdk.cloudapi.wayline;
/**
* @author sean
* @version 1.7
* @date 2023/6/6
*/
public class ProgressExtBreakPoint {
/**
* Breakpoint index
*/
private Integer index;
/**
* Breakpoint state
*/
private BreakpointStateEnum state;
/**
* Current wayline segment process
*/
private Float progress;
/**
* Wayline ID
*/
private Integer waylineId;
/**
* Break reason
*/
private FlighttaskBreakReasonEnum breakReason;
/**
* Breakpoint latitude
*/
private Float latitude;
/**
* Breakpoint longitude
*/
private Float longitude;
/**
* Breakpoint altitude relative to the Earth's ellipsoid surface
*
*/
private Float height;
/**
* Yaw angle relative to true north (meridian), with positive values from 0 to 6 o'clock direction and negative values from 6 to 12 o'clock direction
*/
private Integer attitudeHead;
public ProgressExtBreakPoint() {}
@Override
public String toString() {
return "FlighttaskBreakPoint{" +
"index=" + index +
", state=" + state +
", progress=" + progress +
", waylineId=" + waylineId +
", breakReason=" + breakReason +
", latitude=" + latitude +
", longitude=" + longitude +
", height=" + height +
", attitudeHead=" + attitudeHead +
'}';
}
public Integer getIndex() {
return index;
}
public ProgressExtBreakPoint setIndex(Integer index) {
this.index = index;
return this;
}
public BreakpointStateEnum getState() {
return state;
}
public ProgressExtBreakPoint setState(BreakpointStateEnum state) {
this.state = state;
return this;
}
public Float getProgress() {
return progress;
}
public ProgressExtBreakPoint setProgress(Float progress) {
this.progress = progress;
return this;
}
public Integer getWaylineId() {
return waylineId;
}
public ProgressExtBreakPoint setWaylineId(Integer waylineId) {
this.waylineId = waylineId;
return this;
}
public FlighttaskBreakReasonEnum getBreakReason() {
return breakReason;
}
public ProgressExtBreakPoint setBreakReason(FlighttaskBreakReasonEnum breakReason) {
this.breakReason = breakReason;
return this;
}
public Float getLatitude() {
return latitude;
}
public ProgressExtBreakPoint setLatitude(Float latitude) {
this.latitude = latitude;
return this;
}
public Float getLongitude() {
return longitude;
}
public ProgressExtBreakPoint setLongitude(Float longitude) {
this.longitude = longitude;
return this;
}
public Float getHeight() {
return height;
}
public ProgressExtBreakPoint setHeight(Float height) {
this.height = height;
return this;
}
public Integer getAttitudeHead() {
return attitudeHead;
}
public ProgressExtBreakPoint setAttitudeHead(Integer attitudeHead) {
this.attitudeHead = attitudeHead;
return this;
}
}

6
src/main/java/com/dji/sdk/cloudapi/wayline/api/AbstractWaylineService.java

@ -2,10 +2,10 @@ package com.dji.sdk.cloudapi.wayline.api; @@ -2,10 +2,10 @@ package com.dji.sdk.cloudapi.wayline.api;
import com.dji.sdk.annotations.CloudSDKVersion;
import com.dji.sdk.cloudapi.wayline.*;
import com.dji.sdk.common.CloudSDKVersionEnum;
import com.dji.sdk.config.version.CloudSDKVersionEnum;
import com.dji.sdk.common.Common;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.common.GatewayTypeEnum;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.config.version.GatewayTypeEnum;
import com.dji.sdk.exception.CloudSDKErrorEnum;
import com.dji.sdk.exception.CloudSDKException;
import com.dji.sdk.mqtt.ChannelName;

1
src/main/java/com/dji/sdk/common/BaseModel.java

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
package com.dji.sdk.common;
import com.dji.sdk.annotations.CloudSDKVersion;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.exception.CloudSDKErrorEnum;
import com.dji.sdk.exception.CloudSDKException;
import org.springframework.util.CollectionUtils;

19
src/main/java/com/dji/sdk/common/Common.java

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
package com.dji.sdk.common;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.exception.CloudSDKErrorEnum;
import com.dji.sdk.exception.CloudSDKException;
import com.fasterxml.jackson.annotation.JsonInclude;
@ -57,4 +58,22 @@ public class Common { @@ -57,4 +58,22 @@ public class Common {
public static ObjectMapper getObjectMapper() {
return MAPPER_BUILDER.build();
}
public static String convertSnake(String key) {
StringBuilder sb = new StringBuilder();
boolean isChange = false;
for (char c : key.toCharArray()) {
if (c == '_') {
isChange = true;
continue;
}
if (isChange) {
sb.append((char)(c - 32));
isChange = false;
continue;
}
sb.append(c);
}
return sb.toString();
}
}

2
src/main/java/com/dji/sdk/common/CommonErrorEnum.java

@ -13,6 +13,8 @@ import java.util.Arrays; @@ -13,6 +13,8 @@ import java.util.Arrays;
*/
public enum CommonErrorEnum implements IServicesErrorCode, IEventsErrorCode, IErrorInfo {
SUCCESS(0, "Success"),
STATUS_NOT_SUPPORTED(314000, "The device is either uploading logs or executing a flight mission. Please try again later."),
WRONG_PARAMETER(325001, "Cloud command parameter error. Dock unable to execute command."),

48
src/main/java/com/dji/sdk/common/GatewayThingVersion.java

@ -1,48 +0,0 @@ @@ -1,48 +0,0 @@
package com.dji.sdk.common;
import java.util.Objects;
/**
* @author sean
* @version 1.7
* @date 2023/5/19
*/
public class GatewayThingVersion {
private DockThingVersionEnum dockThingVersion;
private RcThingVersionEnum rcThingVersion;
public GatewayThingVersion(DockThingVersionEnum dockThingVersion) {
this.dockThingVersion = dockThingVersion;
}
public GatewayThingVersion(RcThingVersionEnum rcThingVersion) {
this.rcThingVersion = rcThingVersion;
}
public GatewayThingVersion(GatewayTypeEnum type, String thingVersion) {
switch (type) {
case DOCK:
this.dockThingVersion = DockThingVersionEnum.find(thingVersion);
return;
case RC:
this.rcThingVersion = RcThingVersionEnum.find(thingVersion);
return;
}
}
public String getThingVersion() {
if (Objects.nonNull(dockThingVersion)) {
return dockThingVersion.getThingVersion();
}
return rcThingVersion.getThingVersion();
}
public CloudSDKVersionEnum getCloudSDKVersion() {
if (Objects.nonNull(dockThingVersion)) {
return dockThingVersion.getCloudSDKVersion();
}
return rcThingVersion.getCloudSDKVersion();
}
}

2
src/main/java/com/dji/sdk/common/SDKManager.java

@ -4,6 +4,8 @@ import com.dji.sdk.cloudapi.device.DeviceDomainEnum; @@ -4,6 +4,8 @@ import com.dji.sdk.cloudapi.device.DeviceDomainEnum;
import com.dji.sdk.cloudapi.device.DeviceEnum;
import com.dji.sdk.cloudapi.device.DeviceSubTypeEnum;
import com.dji.sdk.cloudapi.device.DeviceTypeEnum;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.config.version.GatewayTypeEnum;
import com.dji.sdk.exception.CloudSDKErrorEnum;
import com.dji.sdk.exception.CloudSDKException;

5
src/main/java/com/dji/sdk/config/CloudSDKHandler.java

@ -2,6 +2,7 @@ package com.dji.sdk.config; @@ -2,6 +2,7 @@ package com.dji.sdk.config;
import com.dji.sdk.annotations.CloudSDKVersion;
import com.dji.sdk.common.*;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.exception.CloudSDKErrorEnum;
import com.dji.sdk.exception.CloudSDKException;
import org.aspectj.lang.JoinPoint;
@ -25,7 +26,7 @@ import java.util.Objects; @@ -25,7 +26,7 @@ import java.util.Objects;
@Component
public class CloudSDKHandler {
@Before("execution(public * com.dji.sdk.cloudapi.*.api.*.*(com.dji.sdk.common.GatewayManager, ..))")
@Before("execution(public * com.dji.sdk.cloudapi.*.api.*.*(com.dji.sdk.config.version.GatewayManager, ..))")
public void checkCloudSDK(JoinPoint point) {
GatewayManager deviceSDK = (GatewayManager) point.getArgs()[0];
CloudSDKVersion since = ((MethodSignature) point.getSignature()).getMethod().getDeclaredAnnotation(CloudSDKVersion.class);
@ -40,7 +41,7 @@ public class CloudSDKHandler { @@ -40,7 +41,7 @@ public class CloudSDKHandler {
}
}
@Before("execution(public * com.dji.sdk.cloudapi.*.api.*.*(com.dji.sdk.common.GatewayManager, com.dji.sdk.common.BaseModel+))")
@Before("execution(public * com.dji.sdk.cloudapi.*.api.*.*(com.dji.sdk.config.version.GatewayManager, com.dji.sdk.common.BaseModel+))")
public void checkRequest(JoinPoint point) {
Common.validateModel((BaseModel) point.getArgs()[1], (GatewayManager) point.getArgs()[0]);
}

6
src/main/java/com/dji/sdk/common/CloudSDKVersionEnum.java → src/main/java/com/dji/sdk/config/version/CloudSDKVersionEnum.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package com.dji.sdk.common;
package com.dji.sdk.config.version;
/**
* @author sean
@ -11,7 +11,9 @@ public enum CloudSDKVersionEnum { @@ -11,7 +11,9 @@ public enum CloudSDKVersionEnum {
V1_0_0("1.0.0"),
DEFAULT("1.0.0"),
V1_0_1("1.0.1"),
DEFAULT("1.0.1"),
V99("99");

41
src/main/java/com/dji/sdk/config/version/Dock2ThingVersionEnum.java

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
package com.dji.sdk.config.version;
import com.dji.sdk.exception.CloudSDKVersionException;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
/**
* @author sean
* @version 1.7
* @date 2023/9/7
*/
public enum Dock2ThingVersionEnum implements IThingVersion {
V1_1_2("1.1.2", CloudSDKVersionEnum.V1_0_1),
;
private final String thingVersion;
private final CloudSDKVersionEnum cloudSDKVersion;
Dock2ThingVersionEnum(String thingVersion, CloudSDKVersionEnum cloudSDKVersion) {
this.thingVersion = thingVersion;
this.cloudSDKVersion = cloudSDKVersion;
}
@JsonValue
public String getThingVersion() {
return thingVersion;
}
public CloudSDKVersionEnum getCloudSDKVersion() {
return cloudSDKVersion;
}
public static Dock2ThingVersionEnum find(String thingVersion) {
return Arrays.stream(values()).filter(thingVersionEnum -> thingVersionEnum.thingVersion.equals(thingVersion))
.findAny().orElseThrow(() -> new CloudSDKVersionException(thingVersion));
}
}

17
src/main/java/com/dji/sdk/common/DockThingVersionEnum.java → src/main/java/com/dji/sdk/config/version/DockThingVersionEnum.java

@ -1,26 +1,23 @@ @@ -1,26 +1,23 @@
package com.dji.sdk.common;
package com.dji.sdk.config.version;
import com.dji.sdk.exception.CloudSDKVersionException;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
import java.util.Optional;
/**
* @author sean
* @version 1.7
* @date 2023/5/19
*/
public enum DockThingVersionEnum {
public enum DockThingVersionEnum implements IThingVersion {
V1_0_0("1.0.0", CloudSDKVersionEnum.V0_0_1),
V1_1_0("1.1.0", CloudSDKVersionEnum.V1_0_0),
V1_1_0("1.1.0", CloudSDKVersionEnum.V0_0_1),
V1_1_2("1.1.2", CloudSDKVersionEnum.V1_0_0),
V1_2_0("1.2.0", CloudSDKVersionEnum.V1_0_0),
;
private final String thingVersion;
@ -42,11 +39,7 @@ public enum DockThingVersionEnum { @@ -42,11 +39,7 @@ public enum DockThingVersionEnum {
}
public static DockThingVersionEnum find(String thingVersion) {
Optional<DockThingVersionEnum> opt = Arrays.stream(values())
.filter(thingVersionEnum -> thingVersionEnum.thingVersion.equals(thingVersion)).findAny();
if (opt.isPresent()) {
return opt.get();
}
throw new CloudSDKVersionException(thingVersion);
return Arrays.stream(values()).filter(thingVersionEnum -> thingVersionEnum.thingVersion.equals(thingVersion))
.findAny().orElseThrow(() -> new CloudSDKVersionException(thingVersion));
}
}

6
src/main/java/com/dji/sdk/common/DroneThingVersionEnum.java → src/main/java/com/dji/sdk/config/version/DroneThingVersionEnum.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package com.dji.sdk.common;
package com.dji.sdk.config.version;
import com.dji.sdk.exception.CloudSDKVersionException;
import com.fasterxml.jackson.annotation.JsonValue;
@ -13,7 +13,7 @@ import java.util.Optional; @@ -13,7 +13,7 @@ import java.util.Optional;
* @version 1.7
* @date 2023/5/19
*/
public enum DroneThingVersionEnum {
public enum DroneThingVersionEnum implements IThingVersion {
V1_0_0("1.0.0", CloudSDKVersionEnum.V0_0_1),
@ -21,8 +21,6 @@ public enum DroneThingVersionEnum { @@ -21,8 +21,6 @@ public enum DroneThingVersionEnum {
V1_1_2("1.1.2", CloudSDKVersionEnum.V1_0_0),
V1_2_0("1.2.0", CloudSDKVersionEnum.V1_0_0),
;
private static final Logger log = LoggerFactory.getLogger(DroneThingVersionEnum.class);

6
src/main/java/com/dji/sdk/common/GatewayManager.java → src/main/java/com/dji/sdk/config/version/GatewayManager.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package com.dji.sdk.common;
package com.dji.sdk.config.version;
import com.dji.sdk.annotations.CloudSDKVersion;
@ -30,10 +30,10 @@ public class GatewayManager { @@ -30,10 +30,10 @@ public class GatewayManager {
this(gatewaySn, droneSn, gatewayType);
this.gatewayThingVersion = new GatewayThingVersion(gatewayType, gatewayThingVersion);
if (GatewayTypeEnum.RC == gatewayType) {
this.sdkVersion = CloudSDKVersionEnum.DEFAULT;
this.sdkVersion = CloudSDKVersionEnum.V0_0_1;
return;
}
if (Objects.isNull(this.droneThingVersion)) {
if (Objects.isNull(droneThingVersion)) {
this.sdkVersion = this.gatewayThingVersion.getCloudSDKVersion();
return;
}

37
src/main/java/com/dji/sdk/config/version/GatewayThingVersion.java

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
package com.dji.sdk.config.version;
/**
* @author sean
* @version 1.7
* @date 2023/5/19
*/
public class GatewayThingVersion {
private IThingVersion thingVersion;
public GatewayThingVersion(IThingVersion thingVersion) {
this.thingVersion = thingVersion;
}
public GatewayThingVersion(GatewayTypeEnum type, String thingVersion) {
switch (type) {
case DOCK:
this.thingVersion = DockThingVersionEnum.find(thingVersion);
return;
case DOCK2:
this.thingVersion = Dock2ThingVersionEnum.find(thingVersion);
return;
case RC:
this.thingVersion = RcThingVersionEnum.find(thingVersion);
return;
}
}
public String getThingVersion() {
return thingVersion.getThingVersion();
}
public CloudSDKVersionEnum getCloudSDKVersion() {
return thingVersion.getCloudSDKVersion();
}
}

7
src/main/java/com/dji/sdk/common/GatewayTypeEnum.java → src/main/java/com/dji/sdk/config/version/GatewayTypeEnum.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package com.dji.sdk.common;
package com.dji.sdk.config.version;
import com.dji.sdk.cloudapi.device.DeviceEnum;
import com.dji.sdk.exception.CloudSDKException;
@ -14,7 +14,10 @@ public enum GatewayTypeEnum { @@ -14,7 +14,10 @@ public enum GatewayTypeEnum {
RC(DeviceEnum.RC, DeviceEnum.RC_PLUS, DeviceEnum.RC_PRO),
DOCK(DeviceEnum.DOCK);
DOCK(DeviceEnum.DOCK),
DOCK2(DeviceEnum.DOCK2),
;
private final DeviceEnum[] gateway;

13
src/main/java/com/dji/sdk/config/version/IThingVersion.java

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
package com.dji.sdk.config.version;
/**
* @author sean
* @version 1.7
* @date 2023/9/7
*/
public interface IThingVersion {
String getThingVersion();
CloudSDKVersionEnum getCloudSDKVersion();
}

4
src/main/java/com/dji/sdk/common/RcThingVersionEnum.java → src/main/java/com/dji/sdk/config/version/RcThingVersionEnum.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package com.dji.sdk.common;
package com.dji.sdk.config.version;
import com.fasterxml.jackson.annotation.JsonValue;
@ -7,7 +7,7 @@ import com.fasterxml.jackson.annotation.JsonValue; @@ -7,7 +7,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
* @version 1.7
* @date 2023/5/19
*/
public enum RcThingVersionEnum {
public enum RcThingVersionEnum implements IThingVersion {
V1_0_0("1.0.0", CloudSDKVersionEnum.V0_0_1);

2
src/main/java/com/dji/sdk/exception/CloudSDKVersionException.java

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
package com.dji.sdk.exception;
import com.dji.sdk.common.CloudSDKVersionEnum;
import com.dji.sdk.config.version.CloudSDKVersionEnum;
/**
* @author sean

2
src/main/java/com/dji/sdk/mqtt/drc/DrcUpSubscribe.java

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
package com.dji.sdk.mqtt.drc;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.mqtt.IMqttTopicService;
import com.dji.sdk.mqtt.TopicConst;
import org.springframework.stereotype.Component;

1
src/main/java/com/dji/sdk/mqtt/events/EventsErrorCode.java

@ -42,6 +42,7 @@ public class EventsErrorCode implements IErrorInfo { @@ -42,6 +42,7 @@ public class EventsErrorCode implements IErrorInfo {
this.sourceCode = code;
if (MqttReply.CODE_SUCCESS == code) {
this.success = true;
this.errorCode = CommonErrorEnum.SUCCESS;
return;
}
this.source = ErrorCodeSourceEnum.find(code / MOD);

2
src/main/java/com/dji/sdk/mqtt/events/EventsSubscribe.java

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
package com.dji.sdk.mqtt.events;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.mqtt.IMqttTopicService;
import com.dji.sdk.mqtt.TopicConst;
import org.springframework.stereotype.Component;

23
src/main/java/com/dji/sdk/mqtt/osd/OsdDeviceTypeEnum.java

@ -4,11 +4,14 @@ import com.dji.sdk.cloudapi.device.OsdDock; @@ -4,11 +4,14 @@ import com.dji.sdk.cloudapi.device.OsdDock;
import com.dji.sdk.cloudapi.device.OsdDockDrone;
import com.dji.sdk.cloudapi.device.OsdRcDrone;
import com.dji.sdk.cloudapi.device.OsdRemoteControl;
import com.dji.sdk.common.GatewayTypeEnum;
import com.dji.sdk.config.version.GatewayTypeEnum;
import com.dji.sdk.exception.CloudSDKException;
import com.dji.sdk.mqtt.ChannelName;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* @author sean
@ -17,30 +20,30 @@ import java.util.Arrays; @@ -17,30 +20,30 @@ import java.util.Arrays;
*/
public enum OsdDeviceTypeEnum {
RC(true, GatewayTypeEnum.RC, OsdRemoteControl.class, ChannelName.INBOUND_OSD_RC),
RC(true, OsdRemoteControl.class, ChannelName.INBOUND_OSD_RC, GatewayTypeEnum.RC),
DOCK(true, GatewayTypeEnum.DOCK, OsdDock.class, ChannelName.INBOUND_OSD_DOCK),
DOCK(true, OsdDock.class, ChannelName.INBOUND_OSD_DOCK, GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2),
RC_DRONE(false, GatewayTypeEnum.RC, OsdRcDrone.class, ChannelName.INBOUND_OSD_RC_DRONE),
RC_DRONE(false, OsdRcDrone.class, ChannelName.INBOUND_OSD_RC_DRONE, GatewayTypeEnum.RC),
DOCK_DRONE(false, GatewayTypeEnum.DOCK, OsdDockDrone.class, ChannelName.INBOUND_OSD_DOCK_DRONE);
DOCK_DRONE(false, OsdDockDrone.class, ChannelName.INBOUND_OSD_DOCK_DRONE, GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2);
private final boolean gateway;
private final GatewayTypeEnum gatewayType;
private final Set<GatewayTypeEnum> gatewayType = new HashSet<>();
private final Class classType;
private final String channelName;
OsdDeviceTypeEnum(boolean gateway, GatewayTypeEnum gatewayType, Class classType, String channelName) {
OsdDeviceTypeEnum(boolean gateway, Class classType, String channelName, GatewayTypeEnum... gatewayType) {
this.gateway = gateway;
this.gatewayType = gatewayType;
this.classType = classType;
this.channelName = channelName;
Collections.addAll(this.gatewayType, gatewayType);
}
public GatewayTypeEnum getGatewayType() {
public Set<GatewayTypeEnum> getGatewayType() {
return gatewayType;
}
@ -57,7 +60,7 @@ public enum OsdDeviceTypeEnum { @@ -57,7 +60,7 @@ public enum OsdDeviceTypeEnum {
}
public static OsdDeviceTypeEnum find(GatewayTypeEnum gatewayType, boolean isGateway) {
return Arrays.stream(values()).filter(osdEnum -> osdEnum.gatewayType == gatewayType && osdEnum.gateway == isGateway).findAny()
return Arrays.stream(values()).filter(osdEnum -> osdEnum.gatewayType.contains(gatewayType) && osdEnum.gateway == isGateway).findAny()
.orElseThrow(() -> new CloudSDKException(OsdDeviceTypeEnum.class, gatewayType, isGateway));
}

10
src/main/java/com/dji/sdk/mqtt/osd/OsdRouter.java

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
package com.dji.sdk.mqtt.osd;
import com.dji.sdk.cloudapi.device.PayloadModelEnum;
import com.dji.sdk.cloudapi.device.PayloadModelConst;
import com.dji.sdk.common.Common;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.common.SDKManager;
import com.dji.sdk.exception.CloudSDKException;
import com.dji.sdk.mqtt.ChannelName;
@ -49,10 +49,10 @@ public class OsdRouter { @@ -49,10 +49,10 @@ public class OsdRouter {
OsdDeviceTypeEnum typeEnum = OsdDeviceTypeEnum.find(gateway.getType(), response.getFrom().equals(response.getGateway()));
Map<String, Object> data = (Map<String, Object>) response.getData();
if (!typeEnum.isGateway()) {
List payloadData = (List) data.getOrDefault(PayloadModelEnum.PAYLOAD_KEY, new ArrayList<>());
PayloadModelEnum.getAllIndexWithPosition().stream().filter(data::containsKey)
List payloadData = (List) data.getOrDefault(PayloadModelConst.PAYLOAD_KEY, new ArrayList<>());
PayloadModelConst.getAllIndexWithPosition().stream().filter(data::containsKey)
.map(data::get).forEach(payloadData::add);
data.put(PayloadModelEnum.PAYLOAD_KEY, payloadData);
data.put(PayloadModelConst.PAYLOAD_KEY, payloadData);
}
return response.setData(Common.getObjectMapper().convertValue(data, typeEnum.getClassType()));
})

2
src/main/java/com/dji/sdk/mqtt/osd/OsdSubscribe.java

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
package com.dji.sdk.mqtt.osd;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.common.SDKManager;
import com.dji.sdk.mqtt.IMqttTopicService;
import com.dji.sdk.mqtt.TopicConst;

2
src/main/java/com/dji/sdk/mqtt/property/PropertySetSubscribe.java

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
package com.dji.sdk.mqtt.property;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.mqtt.IMqttTopicService;
import com.dji.sdk.mqtt.TopicConst;
import org.springframework.stereotype.Component;

2
src/main/java/com/dji/sdk/mqtt/requests/RequestsSubscribe.java

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
package com.dji.sdk.mqtt.requests;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.mqtt.IMqttTopicService;
import com.dji.sdk.mqtt.TopicConst;
import org.springframework.stereotype.Component;

1
src/main/java/com/dji/sdk/mqtt/services/ServicesErrorCode.java

@ -43,6 +43,7 @@ public class ServicesErrorCode implements IErrorInfo { @@ -43,6 +43,7 @@ public class ServicesErrorCode implements IErrorInfo {
this.sourceCode = code;
if (MqttReply.CODE_SUCCESS == code) {
this.success = true;
this.errorCode = CommonErrorEnum.SUCCESS;
return;
}
this.source = ErrorCodeSourceEnum.find(code / MOD);

20
src/main/java/com/dji/sdk/mqtt/services/ServicesPublish.java

@ -34,6 +34,10 @@ public class ServicesPublish { @@ -34,6 +34,10 @@ public class ServicesPublish {
return this.publish(clazz, sn, method, data, retryCount, MqttGatewayPublish.DEFAULT_RETRY_TIMEOUT);
}
public <T> TopicServicesResponse<ServicesReplyData<T>> publish(TypeReference<T> clazz, String sn, String method, Object data, long timeout) {
return this.publish(clazz, sn, method, data, MqttGatewayPublish.DEFAULT_RETRY_COUNT, timeout);
}
public <T> TopicServicesResponse<ServicesReplyData<T>> publish(TypeReference<T> clazz, String sn, String method, Object data, int retryCount, long timeout) {
return this.publish(clazz, sn, method, data, null, retryCount, timeout);
}
@ -46,6 +50,18 @@ public class ServicesPublish { @@ -46,6 +50,18 @@ public class ServicesPublish {
return this.publish(sn, method, data, null);
}
public TopicServicesResponse<ServicesReplyData> publish(String sn, String method, Object data, int retryCount) {
return this.publish(sn, method, data, null, retryCount);
}
public TopicServicesResponse<ServicesReplyData> publish(String sn, String method, Object data, long timeout) {
return this.publish(sn, method, data, null, timeout);
}
public TopicServicesResponse<ServicesReplyData> publish(String sn, String method, Object data, int retryCount, long timeout) {
return this.publish(sn, method, data, null, retryCount, timeout);
}
public TopicServicesResponse<ServicesReplyData> publish(String sn, String method, Object data, String bid) {
return this.publish(sn, method, data, bid, MqttGatewayPublish.DEFAULT_RETRY_COUNT);
}
@ -54,6 +70,10 @@ public class ServicesPublish { @@ -54,6 +70,10 @@ public class ServicesPublish {
return this.publish(sn, method, data, bid, retryCount, MqttGatewayPublish.DEFAULT_RETRY_TIMEOUT);
}
public TopicServicesResponse<ServicesReplyData> publish(String sn, String method, Object data, String bid, long timeout) {
return this.publish(sn, method, data, bid, MqttGatewayPublish.DEFAULT_RETRY_COUNT, timeout);
}
public TopicServicesResponse<ServicesReplyData> publish(String sn, String method, Object data, String bid, int retryCount, long timeout) {
return (TopicServicesResponse) this.publish(null, sn, method, data, bid, retryCount, timeout);
}

2
src/main/java/com/dji/sdk/mqtt/services/ServicesSubscribe.java

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
package com.dji.sdk.mqtt.services;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.mqtt.IMqttTopicService;
import com.dji.sdk.mqtt.TopicConst;
import org.springframework.stereotype.Component;

2
src/main/java/com/dji/sdk/mqtt/state/DockStateDataKeyEnum.java

@ -26,7 +26,7 @@ public enum DockStateDataKeyEnum { @@ -26,7 +26,7 @@ public enum DockStateDataKeyEnum {
WPMZ_VERSION(Set.of("wpmz_version"), DockWpmzVersion.class),
PAYLOAD(PayloadModelEnum.getAllIndexWithPosition(), DockPayload.class)
PAYLOAD(PayloadModelConst.getAllIndexWithPosition(), DockPayload.class)
;
private final Set<String> keys;

2
src/main/java/com/dji/sdk/mqtt/state/RcStateDataKeyEnum.java

@ -24,7 +24,7 @@ public enum RcStateDataKeyEnum { @@ -24,7 +24,7 @@ public enum RcStateDataKeyEnum {
LIVE_STATUS(Set.of("live_status"), RcLiveStatus.class),
PAYLOAD_FIRMWARE(PayloadModelEnum.getAllModelWithPosition(), PayloadFirmwareVersion.class),
PAYLOAD_FIRMWARE(PayloadModelConst.getAllModelWithPosition(), PayloadFirmwareVersion.class),
;
private final Set<String> keys;

1
src/main/java/com/dji/sdk/mqtt/state/StateRouter.java

@ -55,6 +55,7 @@ public class StateRouter { @@ -55,6 +55,7 @@ public class StateRouter {
case RC:
return RcStateDataKeyEnum.find(keys).getClassType();
case DOCK:
case DOCK2:
return DockStateDataKeyEnum.find(keys).getClassType();
default:
throw new CloudSDKException(CloudSDKErrorEnum.WRONG_DATA, "Unexpected value: " + SDKManager.getDeviceSDK(gatewaySn).getType());

2
src/main/java/com/dji/sdk/mqtt/state/StateSubscribe.java

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
package com.dji.sdk.mqtt.state;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.common.SDKManager;
import com.dji.sdk.mqtt.IMqttTopicService;
import com.dji.sdk.mqtt.TopicConst;

2
src/main/java/com/dji/sdk/mqtt/status/StatusSubscribe.java

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
package com.dji.sdk.mqtt.status;
import com.dji.sdk.common.GatewayManager;
import com.dji.sdk.config.version.GatewayManager;
import com.dji.sdk.common.SDKManager;
import com.dji.sdk.mqtt.IMqttTopicService;
import com.dji.sdk.mqtt.TopicConst;

16226
src/main/resources/hms.json

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save