From 73f5ab467dfd533b7b92f88a22e01989182919e2 Mon Sep 17 00:00:00 2001 From: "sean.zhou" Date: Thu, 22 Feb 2024 17:06:28 +0800 Subject: [PATCH] =?UTF-8?q?What's=20new=3F=20=20=20=20=20=20=20=20=201.=20?= =?UTF-8?q?=E6=8B=86=E5=88=86Cloud=20SDK=EF=BC=8C=E5=8D=95=E7=8B=AC?= =?UTF-8?q?=E6=89=93=E5=8C=85=EF=BC=8C=E5=9C=A8sample=20=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=B8=AD=E9=80=9A=E8=BF=87=E5=8C=85=E7=9A=84=E5=BD=A2=E5=BC=8F?= =?UTF-8?q?=E5=BC=95=E5=85=A5Cloud=20SDK=E3=80=82=20=20=20=20=20=20=20=20?= =?UTF-8?q?=202.=20=E5=A2=9E=E5=8A=A0webrtc=20=E5=8A=9F=E8=83=BD=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=EF=BC=8C=E5=B0=86=E7=9B=B4=E6=92=AD=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=94=BE=E5=9C=A8=E5=90=8E=E7=AB=AF=E3=80=82?= =?UTF-8?q?=20=20=20=20=20=20=20=20=203.=20=E5=A2=9E=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E9=A3=9E=E8=A1=8C=E5=8C=BA=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E3=80=82=20=20=20=20=20=20=20=20=204.=20?= =?UTF-8?q?=E5=9C=A8Cloud=20SDK=20=E4=B8=AD=E8=A1=A5=E9=BD=90=E6=89=80?= =?UTF-8?q?=E6=9C=89=E5=BC=80=E6=94=BE=E7=9A=84=E5=8D=8F=E8=AE=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- api/Cloud API Demo.postman_collection.json | 152 +++- cloud-sdk/README.md | 48 ++ {src/main/resources => cloud-sdk}/image/1.png | Bin {src/main/resources => cloud-sdk}/image/2.png | Bin {src/main/resources => cloud-sdk}/image/3.png | Bin {src/main/resources => cloud-sdk}/image/4.png | Bin {src/main/resources => cloud-sdk}/image/5.png | Bin {src/main/resources => cloud-sdk}/image/6.png | Bin {src/main/resources => cloud-sdk}/image/7.png | Bin cloud-sdk/pom.xml | 32 + .../dji/sdk/annotations/CloudSDKVersion.java | 0 .../cloudapi/airsense/AirsenseWarning.java | 178 +++++ .../cloudapi/airsense/AltitudeTypeEnum.java | 39 + .../sdk/cloudapi/airsense/VertTrendEnum.java | 41 ++ .../cloudapi/airsense/WarningLevelEnum.java | 45 ++ .../airsense/api/AbstractAirsenseService.java | 36 + .../sdk/cloudapi/config/ConfigScopeEnum.java | 0 .../sdk/cloudapi/config/ConfigTypeEnum.java | 0 .../config/ProductConfigResponse.java | 0 .../config/RequestsConfigRequest.java | 0 .../config/api/AbstractConfigService.java | 0 .../cloudapi/control/CameraAimRequest.java | 0 .../control/CameraExposureModeSetRequest.java | 68 ++ .../control/CameraExposureSetRequest.java | 68 ++ .../control/CameraFocalLengthSetRequest.java | 0 .../control/CameraFocusModeSetRequest.java | 68 ++ .../control/CameraFocusValueSetRequest.java | 68 ++ .../cloudapi/control/CameraLookAtRequest.java | 98 +++ .../control/CameraModeSwitchRequest.java | 0 .../control/CameraPhotoStopRequest.java | 36 + .../control/CameraPhotoTakeProgress.java | 56 ++ .../control/CameraPhotoTakeRequest.java | 0 .../CameraPointFocusActionRequest.java | 93 +++ .../control/CameraRecordingStartRequest.java | 0 .../control/CameraRecordingStopRequest.java | 0 .../control/CameraScreenSplitRequest.java | 58 ++ .../sdk/cloudapi/control/CameraTypeEnum.java | 0 .../control/CommanderFlightModeEnum.java | 0 .../control/CommanderModeLostActionEnum.java | 0 .../control/ControlErrorCodeEnum.java | 0 .../cloudapi/control/ControlMethodEnum.java | 90 +++ .../sdk/cloudapi/control/DelayInfoPush.java | 0 .../cloudapi/control/DrcModeEnterRequest.java | 0 .../cloudapi/control/DrcModeMqttBroker.java | 0 .../cloudapi/control/DrcStatusErrorEnum.java | 0 .../sdk/cloudapi/control/DrcStatusNotify.java | 0 .../cloudapi/control/DroneControlRequest.java | 0 .../control/DroneControlResponse.java | 0 .../control/ExposureCameraTypeEnum.java | 36 + .../cloudapi/control/ExposureModeEnum.java | 44 ++ .../cloudapi/control/ExposureValueEnum.java | 107 +++ .../cloudapi/control/FlyToPointProgress.java | 0 .../cloudapi/control/FlyToPointRequest.java | 70 ++ .../control/FlyToPointUpdateRequest.java | 59 ++ .../sdk/cloudapi/control/FlyToStatusEnum.java | 0 .../sdk/cloudapi/control/FocusModeEnum.java | 40 + .../cloudapi/control/GimbalResetModeEnum.java | 0 .../cloudapi/control/GimbalResetRequest.java | 0 .../cloudapi/control/HeartBeatRequest.java | 0 .../dji/sdk/cloudapi/control/HsiInfoPush.java | 0 .../control/IrMeteringAreaSetRequest.java | 116 +++ .../control/IrMeteringModeSetRequest.java | 55 ++ .../control/IrMeteringPointSetRequest.java | 80 ++ .../control/JoystickInvalidNotify.java | 0 .../control/JoystickInvalidReasonEnum.java | 0 .../control/LensStorageSettingsEnum.java | 40 + .../sdk/cloudapi/control/LiveviewDelay.java | 0 .../cloudapi/control/MeteringModeEnum.java | 41 ++ .../dji/sdk/cloudapi/control/OsdInfoPush.java | 0 .../control/PayloadAuthorityGrabRequest.java | 0 .../control/PayloadControlMethodEnum.java | 78 ++ .../control/PhotoStorageSetRequest.java | 61 ++ .../control/PhotoTakeProgressData.java | 42 ++ .../control/PhotoTakeProgressExt.java | 32 + .../control/PhotoTakeProgressStepEnum.java | 43 ++ .../control/PoiCircleSpeedSetRequest.java | 35 + .../cloudapi/control/PoiModeEnterRequest.java | 69 ++ .../sdk/cloudapi/control/PoiStatusNotify.java | 80 ++ .../cloudapi/control/PoiStatusReasonEnum.java | 53 ++ .../com/dji/sdk/cloudapi/control/Point.java | 0 .../cloudapi/control/TakeoffStatusEnum.java | 0 .../control/TakeoffToPointProgress.java | 135 ++++ .../control/TakeoffToPointRequest.java | 235 ++++++ .../control/VideoStorageSetRequest.java | 61 ++ .../cloudapi/control/ZoomCameraTypeEnum.java | 0 .../control/api/AbstractControlService.java | 665 +++++++++++++++++ .../AirConditionerModeSwitchActionEnum.java | 0 .../AirConditionerModeSwitchRequest.java | 0 .../debug/AlarmStateSwitchRequest.java | 0 .../BatteryMaintenanceSwitchRequest.java | 0 .../debug/BatteryStoreModeSwitchRequest.java | 0 .../cloudapi/debug/DebugErrorCodeEnum.java | 0 .../sdk/cloudapi/debug/DebugMethodEnum.java | 84 +++ .../cloudapi/debug/DongleDeviceTypeEnum.java | 38 + .../cloudapi/debug/EsimActivateRequest.java | 54 ++ .../debug/EsimOperatorSwitchRequest.java | 71 ++ .../cloudapi/debug/RemoteDebugProgress.java | 0 .../debug/RemoteDebugProgressData.java | 0 .../cloudapi/debug/RemoteDebugResponse.java | 0 .../cloudapi/debug/RemoteDebugStatusEnum.java | 0 .../debug/RemoteDebugStepKeyEnum.java | 0 .../debug/SdrWorkmodeSwitchRequest.java | 0 .../cloudapi/debug/SimSlotSwitchRequest.java | 71 ++ .../debug/api/AbstractDebugService.java | 396 ++++++++++ .../sdk/cloudapi/device/AirConditioner.java | 0 .../device/AirConditionerStateEnum.java | 0 .../cloudapi/device/AlternateLandPoint.java | 0 .../sdk/cloudapi/device/BackupBattery.java | 0 .../com/dji/sdk/cloudapi/device/Battery.java | 0 .../sdk/cloudapi/device/BatteryIndexEnum.java | 0 .../cloudapi/device/BatteryStoreModeEnum.java | 0 .../sdk/cloudapi/device/CameraIsoEnum.java | 61 ++ .../sdk/cloudapi/device/CameraModeEnum.java | 44 ++ .../sdk/cloudapi/device/CameraStateEnum.java | 0 .../cloudapi/device/ControlSourceEnum.java | 0 .../sdk/cloudapi/device/CoverStateEnum.java | 0 .../sdk/cloudapi/device/DeviceDomainEnum.java | 0 .../dji/sdk/cloudapi/device/DeviceEnum.java | 0 .../sdk/cloudapi/device/DeviceModelEnum.java | 0 .../sdk/cloudapi/device/DeviceOsdHost.java | 0 .../cloudapi/device/DeviceOsdWsResponse.java | 0 .../cloudapi/device/DeviceSubTypeEnum.java | 0 .../sdk/cloudapi/device/DeviceTypeEnum.java | 0 .../device/DockDistanceLimitStatus.java | 0 .../device/DockDroneControlSource.java | 0 .../DockDroneCurrentCommanderFlightMode.java | 34 + .../device/DockDroneCurrentRthMode.java | 40 + .../device/DockDroneModeCodeReason.java | 30 + .../sdk/cloudapi/device/DockDronePayload.java | 252 +++++++ ...DockDroneThermalSupportedPaletteStyle.java | 56 ++ .../cloudapi/device/DockDroneWpmzVersion.java | 30 + .../cloudapi/device/DockFirmwareVersion.java | 0 .../cloudapi/device/DockLiveErrorStatus.java | 0 .../sdk/cloudapi/device/DockLiveStatus.java | 0 .../cloudapi/device/DockLiveStatusData.java | 0 .../cloudapi/device/DockMaintainStatus.java | 0 .../sdk/cloudapi/device/DockModeCodeEnum.java | 0 .../device/DockPayloadControlSource.java | 0 .../cloudapi/device/DockPositionState.java | 0 .../sdk/cloudapi/device/DockSilentMode.java | 38 + .../sdk/cloudapi/device/DockSubDevice.java | 0 .../dji/sdk/cloudapi/device/DongleInfo.java | 140 ++++ .../dji/sdk/cloudapi/device/DongleInfos.java | 32 + .../sdk/cloudapi/device/DongleTypeEnum.java | 39 + .../dji/sdk/cloudapi/device/DrcStateEnum.java | 0 .../dji/sdk/cloudapi/device/DroneBattery.java | 0 .../device/DroneBatteryMaintenance.java | 0 .../device/DroneBatteryMaintenanceInfo.java | 76 ++ .../sdk/cloudapi/device/DroneChargeState.java | 0 .../cloudapi/device/DroneMaintainStatus.java | 0 .../cloudapi/device/DroneModeCodeEnum.java | 76 ++ .../cloudapi/device/DronePositionState.java | 0 .../device/EsimActivateStateEnum.java | 39 + .../com/dji/sdk/cloudapi/device/EsimInfo.java | 63 ++ .../device/ExitWaylineWhenRcLostEnum.java | 0 .../sdk/cloudapi/device/FirmwareVersion.java | 31 + .../device/FlighttaskStepCodeEnum.java | 50 ++ .../sdk/cloudapi/device/FocusStateEnum.java | 43 ++ .../com/dji/sdk/cloudapi/device/GearEnum.java | 0 .../sdk/cloudapi/device/HeatStateEnum.java | 41 ++ .../sdk/cloudapi/device/IrMeteringArea.java | 114 +++ .../sdk/cloudapi/device/IrMeteringPoint.java | 54 ++ .../sdk/cloudapi/device/LinkWorkModeEnum.java | 0 .../cloudapi/device/LiveviewWorldRegion.java | 0 .../sdk/cloudapi/device/MaintainTypeEnum.java | 0 .../cloudapi/device/MaintenanceStateEnum.java | 41 ++ .../device/MeasureTargetStateEnum.java | 0 .../sdk/cloudapi/device/MediaFileDetail.java | 0 .../cloudapi/device/ModeCodeReasonEnum.java | 82 +++ .../dji/sdk/cloudapi/device/NetworkState.java | 0 .../device/NetworkStateQualityEnum.java | 0 .../cloudapi/device/NetworkStateTypeEnum.java | 0 .../cloudapi/device/ObstacleAvoidance.java | 0 .../dji/sdk/cloudapi/device/OsdCamera.java | 417 +++++++++++ .../com/dji/sdk/cloudapi/device/OsdDock.java | 493 +++++++++++++ .../dji/sdk/cloudapi/device/OsdDockDrone.java | 472 ++++++++++++ .../device/OsdDockMaintainStatus.java | 0 .../device/OsdDroneMaintainStatus.java | 0 .../dji/sdk/cloudapi/device/OsdRcDrone.java | 0 .../sdk/cloudapi/device/OsdRemoteControl.java | 0 .../device/PayloadFirmwareVersion.java | 0 .../dji/sdk/cloudapi/device/PayloadIndex.java | 0 .../cloudapi/device/PayloadModelConst.java | 35 + .../cloudapi/device/PayloadPositionEnum.java | 0 .../cloudapi/device/PositionFixedEnum.java | 0 .../sdk/cloudapi/device/PutterStateEnum.java | 0 .../dji/sdk/cloudapi/device/RainfallEnum.java | 0 .../device/RcDistanceLimitStatus.java | 0 .../cloudapi/device/RcDroneControlSource.java | 0 .../sdk/cloudapi/device/RcDronePayload.java | 0 .../dji/sdk/cloudapi/device/RcLiveStatus.java | 0 .../sdk/cloudapi/device/RcLiveStatusData.java | 0 .../sdk/cloudapi/device/RcLostActionEnum.java | 0 .../device/RcPayloadControlSource.java | 0 .../sdk/cloudapi/device/ShutterSpeedEnum.java | 169 +++++ .../sdk/cloudapi/device/SimCardStateEnum.java | 39 + .../com/dji/sdk/cloudapi/device/SimInfo.java | 63 ++ .../dji/sdk/cloudapi/device/SimSlotEnum.java | 41 ++ .../dji/sdk/cloudapi/device/SimTypeEnum.java | 41 ++ .../sdk/cloudapi/device/SmartTrackPoint.java | 0 .../com/dji/sdk/cloudapi/device/Storage.java | 0 .../sdk/cloudapi/device/SwitchActionEnum.java | 0 .../cloudapi/device/TelecomOperatorEnum.java | 43 ++ .../cloudapi/device/ThermalGainModeEnum.java | 0 .../device/ThermalPaletteStyleEnum.java | 0 .../cloudapi/device/TrackTargetModeEnum.java | 0 .../dji/sdk/cloudapi/device/UpdateTopo.java | 0 .../cloudapi/device/UpdateTopoSubDevice.java | 0 .../device/UserExperienceImprovementEnum.java | 40 + .../com/dji/sdk/cloudapi/device/VideoId.java | 0 .../cloudapi/device/WindDirectionEnum.java | 0 .../dji/sdk/cloudapi/device/WirelessLink.java | 0 .../device/api/AbstractDeviceService.java | 274 +++++++ .../firmware/FirmwareErrorCodeEnum.java | 0 .../cloudapi/firmware/FirmwareMethodEnum.java | 0 .../firmware/FirmwareUpgradeTypeEnum.java | 0 .../cloudapi/firmware/OtaCreateDevice.java | 0 .../cloudapi/firmware/OtaCreateRequest.java | 39 + .../cloudapi/firmware/OtaCreateResponse.java | 0 .../sdk/cloudapi/firmware/OtaProgress.java | 0 .../cloudapi/firmware/OtaProgressData.java | 0 .../sdk/cloudapi/firmware/OtaProgressExt.java | 0 .../firmware/OtaProgressStatusEnum.java | 0 .../firmware/OtaProgressStepEnum.java | 0 .../firmware/api/AbstractFirmwareService.java | 0 .../cloudapi/flightarea/DroneLocation.java | 54 ++ .../cloudapi/flightarea/FeatureProperty.java | 60 ++ .../flightarea/FlightAreaFeature.java | 83 +++ .../cloudapi/flightarea/FlightAreaFile.java | 48 ++ .../flightarea/FlightAreaGeometry.java | 21 + .../flightarea/FlightAreaGetFile.java | 86 +++ .../cloudapi/flightarea/FlightAreaJson.java | 41 ++ .../flightarea/FlightAreaMethodEnum.java | 27 + .../flightarea/FlightAreaPointGeometry.java | 39 + .../flightarea/FlightAreaPolygonGeometry.java | 39 + .../flightarea/FlightAreaSyncReasonEnum.java | 70 ++ .../flightarea/FlightAreaSyncStatusEnum.java | 51 ++ .../flightarea/FlightAreasDroneLocation.java | 35 + .../flightarea/FlightAreasGetRequest.java | 9 + .../flightarea/FlightAreasGetResponse.java | 40 + .../flightarea/FlightAreasSyncProgress.java | 63 ++ .../cloudapi/flightarea/GeofenceTypeEnum.java | 38 + .../flightarea/GeometrySubTypeEnum.java | 36 + .../cloudapi/flightarea/GeometryTypeEnum.java | 38 + .../api/AbstractFlightAreaService.java | 80 ++ .../com/dji/sdk/cloudapi/hms/DeviceHms.java | 0 .../dji/sdk/cloudapi/hms/DeviceHmsArgs.java | 0 .../java/com/dji/sdk/cloudapi/hms/Hms.java | 0 .../sdk/cloudapi/hms/HmsBatteryIndexEnum.java | 0 .../cloudapi/hms/HmsChargingRodIndexEnum.java | 0 .../cloudapi/hms/HmsDockCoverIndexEnum.java | 0 .../dji/sdk/cloudapi/hms/HmsFaqIdEnum.java | 0 .../sdk/cloudapi/hms/HmsFormatKeyEnum.java | 0 .../dji/sdk/cloudapi/hms/HmsInTheSkyEnum.java | 0 .../dji/sdk/cloudapi/hms/HmsLevelEnum.java | 0 .../cloudapi/hms/HmsMessageLanguageEnum.java | 0 .../dji/sdk/cloudapi/hms/HmsModuleEnum.java | 0 .../cloudapi/hms/api/AbstractHmsService.java | 0 .../CustomDataTransmissionFromEsdk.java | 34 + .../CustomDataTransmissionFromPsdk.java | 34 + .../CustomDataTransmissionToEsdkRequest.java | 41 ++ .../CustomDataTransmissionToPsdkRequest.java | 41 ++ .../InterconnectionMethodEnum.java | 29 + .../api/AbstractInterconnectionService.java | 83 +++ .../cloudapi/livestream/DockLiveCapacity.java | 0 .../livestream/DockLiveCapacityCamera.java | 0 .../livestream/DockLiveCapacityDevice.java | 0 .../livestream/DockLiveCapacityVideo.java | 0 .../DockLivestreamAbilityUpdate.java | 0 .../cloudapi/livestream/ILivestreamUrl.java | 16 + .../livestream/LensChangeVideoTypeEnum.java | 0 .../livestream/LiveErrorCodeEnum.java | 0 .../livestream/LiveLensChangeRequest.java | 0 .../livestream/LiveSetQualityRequest.java | 0 .../livestream/LiveStartPushRequest.java | 94 +++ .../livestream/LiveStopPushRequest.java | 0 .../livestream/LiveStreamMethodEnum.java | 0 .../livestream/LivestreamAgoraUrl.java | 83 +++ .../livestream/LivestreamGb28181Url.java | 127 ++++ .../livestream/LivestreamRtmpUrl.java | 42 ++ .../livestream/LivestreamRtspUrl.java | 68 ++ .../livestream/LivestreamWhipUrl.java | 42 ++ .../cloudapi/livestream/RcLiveCapacity.java | 0 .../livestream/RcLiveCapacityCamera.java | 80 ++ .../livestream/RcLiveCapacityDevice.java | 81 +++ .../livestream/RcLiveCapacityVideo.java | 42 ++ .../livestream/RcLivestreamAbilityUpdate.java | 0 .../sdk/cloudapi/livestream/UrlTypeEnum.java | 43 ++ .../cloudapi/livestream/VideoQualityEnum.java | 0 .../cloudapi/livestream/VideoTypeEnum.java | 0 .../api/AbstractLivestreamService.java | 0 .../sdk/cloudapi/log/FileUploadListFile.java | 0 .../cloudapi/log/FileUploadListRequest.java | 42 ++ .../cloudapi/log/FileUploadListResponse.java | 0 .../sdk/cloudapi/log/FileUploadProgress.java | 0 .../cloudapi/log/FileUploadProgressExt.java | 0 .../cloudapi/log/FileUploadProgressFile.java | 0 .../sdk/cloudapi/log/FileUploadStartFile.java | 74 ++ .../cloudapi/log/FileUploadStartParam.java | 37 + .../cloudapi/log/FileUploadStartRequest.java | 0 .../cloudapi/log/FileUploadStatusEnum.java | 0 .../cloudapi/log/FileUploadUpdateRequest.java | 55 ++ .../log/FileUploadUpdateStatusEnum.java | 0 .../sdk/cloudapi/log/LogErrorCodeEnum.java | 0 .../dji/sdk/cloudapi/log/LogFileIndex.java | 0 .../dji/sdk/cloudapi/log/LogFileProgress.java | 0 .../dji/sdk/cloudapi/log/LogMethodEnum.java | 0 .../dji/sdk/cloudapi/log/LogModuleEnum.java | 0 .../cloudapi/log/api/AbstractLogService.java | 0 .../cloudapi/map/CreateMapElementRequest.java | 0 .../map/CreateMapElementResponse.java | 0 .../cloudapi/map/DockDroneDongleInfos.java | 9 + .../cloudapi/map/ElementCircleGeometry.java | 64 ++ .../dji/sdk/cloudapi/map/ElementContent.java | 61 ++ .../sdk/cloudapi/map/ElementCoordinate.java | 66 ++ .../sdk/cloudapi/map/ElementGeometryType.java | 49 ++ .../map/ElementLineStringGeometry.java | 81 +++ .../cloudapi/map/ElementPointGeometry.java | 77 ++ .../cloudapi/map/ElementPolygonGeometry.java | 81 +++ .../dji/sdk/cloudapi/map/ElementProperty.java | 0 .../dji/sdk/cloudapi/map/ElementResource.java | 0 .../cloudapi/map/ElementResourceTypeEnum.java | 53 ++ .../dji/sdk/cloudapi/map/ElementTypeEnum.java | 61 ++ .../cloudapi/map/GetMapElementsResponse.java | 99 +++ .../dji/sdk/cloudapi/map/GroupTypeEnum.java | 44 ++ .../map/MapElementCreateWsResponse.java | 0 .../map/MapElementDeleteWsResponse.java | 0 .../map/MapElementUpdateWsResponse.java | 0 .../dji/sdk/cloudapi/map/MapGroupElement.java | 0 .../map/MapGroupRefreshWsResponse.java | 0 .../dji/sdk/cloudapi/map/MapMethodEnum.java | 26 + .../dji/sdk/cloudapi/map/OfflineMapFile.java | 84 +++ .../cloudapi/map/OfflineMapGetRequest.java | 9 + .../cloudapi/map/OfflineMapGetResponse.java | 56 ++ .../sdk/cloudapi/map/OfflineMapSyncFile.java | 49 ++ .../cloudapi/map/OfflineMapSyncProgress.java | 63 ++ .../map/OfflineMapSyncReasonEnum.java | 62 ++ .../map/OfflineMapSyncStatusEnum.java | 45 ++ .../cloudapi/map/UpdateMapElementRequest.java | 0 .../map/api/AbstractOfflineMapService.java | 87 +++ .../sdk/cloudapi/map/api/IHttpMapService.java | 0 .../cloudapi/media/FastUploadExtension.java | 0 .../cloudapi/media/FileUploadCallback.java | 0 .../media/FileUploadCallbackFile.java | 0 .../media/FolderUploadCallbackRequest.java | 0 .../media/GetFileFingerprintRequest.java | 0 .../media/GetFileFingerprintResponse.java | 0 .../HighestPriorityUploadFlightTaskMedia.java | 0 .../media/MediaFastUploadRequest.java | 0 .../cloudapi/media/MediaFileExtension.java | 0 .../sdk/cloudapi/media/MediaFileMetadata.java | 0 .../sdk/cloudapi/media/MediaMethodEnum.java | 0 .../cloudapi/media/MediaSubFileTypeEnum.java | 0 .../media/MediaUploadCallbackRequest.java | 0 .../com/dji/sdk/cloudapi/media/Position.java | 0 .../sdk/cloudapi/media/StorageConfigGet.java | 0 .../media/StorageConfigGetModuleEnum.java | 0 .../media/UploadCallbackFileExtension.java | 0 .../media/UploadCallbackFileMetadata.java | 0 .../UploadFlighttaskMediaPrioritize.java | 37 + .../media/api/AbstractMediaService.java | 0 .../cloudapi/media/api/IHttpMediaService.java | 0 .../AirportBindStatusRequest.java | 0 .../AirportBindStatusResponse.java | 39 + .../AirportOrganizationBindRequest.java | 0 .../AirportOrganizationBindResponse.java | 39 + .../AirportOrganizationGetRequest.java | 0 .../AirportOrganizationGetResponse.java | 0 .../organization/BindStatusRequestDevice.java | 0 .../BindStatusResponseDevice.java | 0 .../organization/OrganizationBindDevice.java | 0 .../organization/OrganizationBindInfo.java | 0 .../api/AbstractOrganizationService.java | 0 .../property/DistanceLimitStatusData.java | 0 .../property/DistanceLimitStatusSet.java | 0 .../DockDroneCommanderFlightHeight.java | 41 ++ .../DockDroneCommanderModeLostAction.java | 38 + .../property/DockDroneOfflineMapEnable.java | 37 + .../cloudapi/property/DockDroneRthMode.java | 38 + .../property/ExitWaylineWhenRcLostSet.java | 0 .../sdk/cloudapi/property/HeightLimitSet.java | 0 .../property/NightLightsStateSet.java | 0 .../property/ObstacleAvoidanceSet.java | 0 .../cloudapi/property/PropertySetEnum.java | 106 +++ .../cloudapi/property/RcLostActionSet.java | 0 .../sdk/cloudapi/property/RthAltitudeSet.java | 0 .../sdk/cloudapi/property/SilentModeEnum.java | 39 + .../ThermalCurrentPaletteStyleSet.java | 0 .../cloudapi/property/ThermalGainModeSet.java | 0 .../ThermalIsothermLowerLimitSet.java | 0 .../property/ThermalIsothermStateSet.java | 0 .../ThermalIsothermUpperLimitSet.java | 0 .../UserExperienceImprovementSet.java | 38 + .../property/api/AbstractPropertyService.java | 89 +++ .../cloudapi/storage/CredentialsToken.java | 95 +++ .../dji/sdk/cloudapi/storage/OssTypeEnum.java | 0 .../storage/StsCredentialsResponse.java | 0 .../storage/api/IHttpStorageService.java | 0 .../dji/sdk/cloudapi/tsa/DeviceIconUrl.java | 0 .../dji/sdk/cloudapi/tsa/DeviceTopology.java | 0 .../com/dji/sdk/cloudapi/tsa/IconUrlEnum.java | 0 .../sdk/cloudapi/tsa/TopologyDeviceModel.java | 0 .../dji/sdk/cloudapi/tsa/TopologyList.java | 53 ++ .../sdk/cloudapi/tsa/TopologyResponse.java | 39 + .../sdk/cloudapi/tsa/api/IHttpTsaService.java | 0 .../sdk/cloudapi/wayline/ActionTypeEnum.java | 37 + .../cloudapi/wayline/BreakpointStateEnum.java | 43 ++ .../wayline/DeviceExitHomingNotify.java | 0 .../wayline/ExecutableConditions.java | 0 .../cloudapi/wayline/ExecutionStepEnum.java | 131 ++++ .../wayline/ExitingRTHActionEnum.java | 44 ++ .../wayline/ExitingRTHReasonEnum.java | 61 ++ .../wayline/FlighttaskBreakPoint.java | 0 .../wayline/FlighttaskBreakReasonEnum.java | 201 +++++ .../wayline/FlighttaskCreateFile.java | 0 .../wayline/FlighttaskCreateRequest.java | 0 .../wayline/FlighttaskExecuteRequest.java | 37 + .../sdk/cloudapi/wayline/FlighttaskFile.java | 0 .../wayline/FlighttaskPrepareRequest.java | 260 +++++++ .../cloudapi/wayline/FlighttaskProgress.java | 0 .../wayline/FlighttaskProgressData.java | 0 .../wayline/FlighttaskProgressExt.java | 116 +++ .../sdk/cloudapi/wayline/FlighttaskReady.java | 0 .../wayline/FlighttaskResourceGetRequest.java | 0 .../FlighttaskResourceGetResponse.java | 0 .../wayline/FlighttaskStatusEnum.java | 0 .../wayline/FlighttaskUndoRequest.java | 39 + .../wayline/GetWaylineListOrderBy.java | 50 ++ .../wayline/GetWaylineListRequest.java | 188 +++++ .../wayline/GetWaylineListResponse.java | 237 ++++++ .../cloudapi/wayline/LastPointTypeEnum.java | 39 + .../cloudapi/wayline/OrderByColumnEnum.java | 40 + .../wayline/OutOfControlActionEnum.java | 0 .../wayline/ProgressExtBreakPoint.java | 0 .../sdk/cloudapi/wayline/ReadyConditions.java | 77 ++ .../sdk/cloudapi/wayline/ReturnHomeInfo.java | 74 ++ .../dji/sdk/cloudapi/wayline/RthModeEnum.java | 37 + .../sdk/cloudapi/wayline/SimulateMission.java | 0 .../cloudapi/wayline/SimulateSwitchEnum.java | 0 .../sdk/cloudapi/wayline/TaskTypeEnum.java | 0 .../wayline/WaylineErrorCodeEnum.java | 0 .../cloudapi/wayline/WaylineMethodEnum.java | 0 .../wayline/WaylineMissionStateEnum.java | 62 ++ .../wayline/WaylinePrecisionTypeEnum.java | 38 + .../sdk/cloudapi/wayline/WaylineTypeEnum.java | 0 .../WaylineUploadCallbackMetadata.java | 0 .../wayline/WaylineUploadCallbackRequest.java | 0 .../wayline/api/AbstractWaylineService.java | 206 ++++++ .../wayline/api/IHttpWaylineService.java | 0 .../java/com/dji/sdk/common/BaseModel.java | 0 .../main/java/com/dji/sdk/common/Common.java | 0 .../com/dji/sdk/common/CommonErrorEnum.java | 0 .../dji/sdk/common/ErrorCodeSourceEnum.java | 0 .../dji/sdk/common/HttpResultResponse.java | 0 .../java/com/dji/sdk/common/IErrorInfo.java | 0 .../java/com/dji/sdk/common/Pagination.java | 79 ++ .../com/dji/sdk/common/PaginationData.java | 0 .../java/com/dji/sdk/common/SDKManager.java | 0 .../com/dji/sdk/common/SpringBeanUtils.java | 0 .../com/dji/sdk/config/CloudSDKHandler.java | 0 .../dji/sdk/config/CloudSDKMvcConfigurer.java | 0 .../sdk/config/GetSnakeArgumentProcessor.java | 0 .../dji/sdk/config/GetSnakeDataBinder.java | 109 +++ .../config/version/CloudSDKVersionEnum.java | 39 + .../config/version/Dock2ThingVersionEnum.java | 0 .../config/version/DockThingVersionEnum.java | 47 ++ .../config/version/DroneThingVersionEnum.java | 56 ++ .../sdk/config/version/GatewayManager.java | 0 .../config/version/GatewayThingVersion.java | 0 .../sdk/config/version/GatewayTypeEnum.java | 0 .../dji/sdk/config/version/IThingVersion.java | 0 .../config/version/RcThingVersionEnum.java | 0 .../dji/sdk/exception/CloudSDKErrorEnum.java | 0 .../dji/sdk/exception/CloudSDKException.java | 0 .../exception/CloudSDKVersionException.java | 0 .../src}/main/java/com/dji/sdk/mqtt/Chan.java | 0 .../java/com/dji/sdk/mqtt/ChannelName.java | 181 +++++ .../com/dji/sdk/mqtt/CloudApiTopicEnum.java | 0 .../com/dji/sdk/mqtt/CommonTopicRequest.java | 0 .../com/dji/sdk/mqtt/CommonTopicResponse.java | 0 .../com/dji/sdk/mqtt/IMqttMessageGateway.java | 0 .../com/dji/sdk/mqtt/IMqttTopicService.java | 0 .../dji/sdk/mqtt/InboundMessageRouter.java | 0 .../com/dji/sdk/mqtt/MqttConfiguration.java | 0 .../com/dji/sdk/mqtt/MqttGatewayPublish.java | 104 +++ .../main/java/com/dji/sdk/mqtt/MqttReply.java | 0 .../com/dji/sdk/mqtt/MqttReplyHandler.java | 68 ++ .../dji/sdk/mqtt/MqttTopicServiceImpl.java | 0 .../java/com/dji/sdk/mqtt/TopicConst.java | 0 .../com/dji/sdk/mqtt/drc/DrcDownPublish.java | 0 .../java/com/dji/sdk/mqtt/drc/DrcUpData.java | 0 .../com/dji/sdk/mqtt/drc/DrcUpMethodEnum.java | 0 .../com/dji/sdk/mqtt/drc/DrcUpRouter.java | 0 .../com/dji/sdk/mqtt/drc/DrcUpSubscribe.java | 0 .../com/dji/sdk/mqtt/drc/TopicDrcRequest.java | 0 .../dji/sdk/mqtt/drc/TopicDrcResponse.java | 0 .../sdk/mqtt/events/EventsDataRequest.java | 0 .../dji/sdk/mqtt/events/EventsErrorCode.java | 0 .../dji/sdk/mqtt/events/EventsMethodEnum.java | 132 ++++ .../com/dji/sdk/mqtt/events/EventsRouter.java | 0 .../dji/sdk/mqtt/events/EventsSubscribe.java | 0 .../dji/sdk/mqtt/events/IEventsErrorCode.java | 0 .../sdk/mqtt/events/TopicEventsRequest.java | 0 .../sdk/mqtt/events/TopicEventsResponse.java | 0 .../dji/sdk/mqtt/osd/OsdDeviceTypeEnum.java | 0 .../java/com/dji/sdk/mqtt/osd/OsdRouter.java | 0 .../com/dji/sdk/mqtt/osd/OsdSubscribe.java | 0 .../com/dji/sdk/mqtt/osd/TopicOsdRequest.java | 0 .../sdk/mqtt/property/PropertySetPublish.java | 0 .../property/PropertySetReplyHandler.java | 0 .../property/PropertySetReplyResultEnum.java | 0 .../mqtt/property/PropertySetSubscribe.java | 0 .../property/TopicPropertySetRequest.java | 0 .../property/TopicPropertySetResponse.java | 0 .../sdk/mqtt/requests/RequestsMethodEnum.java | 69 ++ .../dji/sdk/mqtt/requests/RequestsRouter.java | 0 .../sdk/mqtt/requests/RequestsSubscribe.java | 0 .../mqtt/requests/TopicRequestsRequest.java | 0 .../mqtt/requests/TopicRequestsResponse.java | 0 .../sdk/mqtt/services/IServicesErrorCode.java | 0 .../sdk/mqtt/services/ServicesErrorCode.java | 0 .../sdk/mqtt/services/ServicesPublish.java | 0 .../sdk/mqtt/services/ServicesReplyData.java | 0 .../mqtt/services/ServicesReplyHandler.java | 0 .../mqtt/services/ServicesReplyReceiver.java | 0 .../sdk/mqtt/services/ServicesSubscribe.java | 0 .../mqtt/services/TopicServicesRequest.java | 0 .../mqtt/services/TopicServicesResponse.java | 0 .../sdk/mqtt/state/DockStateDataKeyEnum.java | 78 ++ .../sdk/mqtt/state/RcStateDataKeyEnum.java | 53 ++ .../dji/sdk/mqtt/state/StateDataKeyEnum.java | 86 +++ .../com/dji/sdk/mqtt/state/StateRouter.java | 90 +++ .../dji/sdk/mqtt/state/StateSubscribe.java | 0 .../dji/sdk/mqtt/state/TopicStateRequest.java | 96 +++ .../sdk/mqtt/state/TopicStateResponse.java | 68 ++ .../com/dji/sdk/mqtt/status/StatusRouter.java | 0 .../dji/sdk/mqtt/status/StatusSubscribe.java | 0 .../sdk/mqtt/status/TopicStatusRequest.java | 0 .../sdk/mqtt/status/TopicStatusResponse.java | 0 .../com/dji/sdk/swagger/SwaggerConfig.java | 0 .../com/dji/sdk/websocket/BizCodeEnum.java | 0 .../websocket/ConcurrentWebSocketSession.java | 0 .../sdk/websocket/WebSocketConfiguration.java | 0 .../websocket/WebSocketDefaultFactory.java | 0 .../websocket/WebSocketDefaultHandler.java | 0 .../websocket/WebSocketMessageResponse.java | 0 .../websocket/api/WebSocketMessageSend.java | 0 pom.xml | 180 +---- sample/pom.xml | 148 ++++ .../dji/sample/CloudApiSampleApplication.java | 0 .../sample/common/error/CommonErrorEnum.java | 0 .../dji/sample/common/model/CustomClaim.java | 0 .../com/dji/sample/common/util/JwtUtil.java | 0 .../common/util/SpringBeanUtilsTest.java | 0 .../component/ApplicationBootInitial.java | 0 .../dji/sample/component/AuthInterceptor.java | 0 .../com/dji/sample/component/CorsFilter.java | 0 .../component/GlobalExceptionHandler.java | 0 .../component/GlobalScheduleService.java | 0 .../mqtt/config/MqttMessageChannel.java | 0 .../config/MqttPropertyConfiguration.java | 0 .../component/mqtt/model/EventsReceiver.java | 0 .../component/mqtt/model/MapKeyConst.java | 0 .../mqtt/model/MqttClientOptions.java | 0 .../mqtt/model/MqttProtocolEnum.java | 0 .../component/mqtt/model/MqttUseEnum.java | 0 .../mybatis/MybatisPlusConfiguration.java | 0 .../mybatis/MybatisPlusMetaObjectHandler.java | 0 .../component/oss/model/OssConfiguration.java | 0 .../component/oss/service/IOssService.java | 0 .../service/impl/AliyunOssServiceImpl.java | 108 +++ .../oss/service/impl/AmazonS3ServiceImpl.java | 126 ++++ .../oss/service/impl/MinIOServiceImpl.java | 123 ++++ .../oss/service/impl/OssAspectHandler.java | 0 .../oss/service/impl/OssServiceContext.java | 0 .../component/redis/RedisConfiguration.java | 0 .../sample/component/redis/RedisConst.java | 0 .../sample/component/redis/RedisOpsUtils.java | 0 .../config/AuthPrincipalHandler.java | 0 .../config/MyConcurrentWebSocketSession.java | 0 .../websocket/config/MyWebSocketFactory.java | 0 .../websocket/config/MyWebSocketHandler.java | 0 .../websocket/model/BizCodeEnum.java | 93 +++ .../service/IWebSocketManageService.java | 0 .../service/IWebSocketMessageService.java | 0 .../impl/WebSocketManageServiceImpl.java | 0 .../impl/WebSocketMessageServiceImpl.java | 0 .../GlobalThreadPoolConfiguration.java | 0 .../SpringBeanConfiguration.java | 0 .../mvc/GlobalMVCConfigurer.java | 0 .../control/controller/DockController.java | 0 .../control/controller/DrcController.java | 0 .../control/model/dto/AirConditionerMode.java | 0 .../sample/control/model/dto/AlarmState.java | 0 .../control/model/dto/BatteryStoreMode.java | 0 .../sample/control/model/dto/JwtAclDTO.java | 0 .../control/model/dto/LinkWorkMode.java | 0 .../model/dto/RemoteDebugOpenState.java | 0 .../control/model/dto/ResultNotifyDTO.java | 0 .../model/dto/ReturnHomeCancelState.java | 0 .../control/model/dto/ReturnHomeState.java | 0 .../control/model/enums/CameraModeEnum.java | 0 .../control/model/enums/DrcMethodEnum.java | 0 .../model/enums/DroneAuthorityEnum.java | 0 .../model/enums/DroneControlMethodEnum.java | 0 .../model/enums/GimbalResetModeEnum.java | 0 .../model/enums/MqttAclAccessEnum.java | 0 .../model/enums/PayloadCommandsEnum.java | 0 .../model/enums/RemoteDebugMethodEnum.java | 0 .../model/param/DeviceDrcInfoParam.java | 0 .../control/model/param/DrcConnectParam.java | 0 .../control/model/param/DrcModeParam.java | 0 .../model/param/DronePayloadParam.java | 0 .../control/model/param/FlyToPointParam.java | 36 + .../model/param/PayloadCommandsParam.java | 0 .../control/model/param/RemoteDebugParam.java | 0 .../model/param/TakeoffToPointParam.java | 0 .../control/service/IControlService.java | 0 .../sample/control/service/IDrcService.java | 0 .../control/service/impl/CameraAimImpl.java | 0 .../impl/CameraFocalLengthSetImpl.java | 0 .../service/impl/CameraModeSwitchImpl.java | 0 .../service/impl/CameraPhotoTakeImpl.java | 0 .../impl/CameraRecordingStartImpl.java | 0 .../service/impl/CameraRecordingStopImpl.java | 0 .../service/impl/ControlServiceImpl.java | 0 .../control/service/impl/DrcServiceImpl.java | 0 .../control/service/impl/GimbalResetImpl.java | 0 .../service/impl/PayloadCommandsHandler.java | 0 .../service/impl/RemoteDebugHandler.java | 0 .../service/impl/SDKControlService.java | 0 .../control/service/impl/SDKRemoteDebug.java | 0 .../manage/controller/DeviceController.java | 0 .../controller/DeviceFirmwareController.java | 0 .../controller/DeviceHmsController.java | 0 .../controller/DeviceLogsController.java | 0 .../controller/LiveStreamController.java | 0 .../manage/controller/LoginController.java | 0 .../manage/controller/TopologyController.java | 0 .../manage/controller/UserController.java | 0 .../controller/WorkspaceController.java | 0 .../manage/dao/IDeviceDictionaryMapper.java | 0 .../manage/dao/IDeviceFirmwareMapper.java | 0 .../sample/manage/dao/IDeviceHmsMapper.java | 0 .../sample/manage/dao/IDeviceLogsMapper.java | 0 .../dji/sample/manage/dao/IDeviceMapper.java | 0 .../manage/dao/IDevicePayloadMapper.java | 0 .../manage/dao/IFirmwareModelMapper.java | 0 .../manage/dao/ILogsFileIndexMapper.java | 0 .../sample/manage/dao/ILogsFileMapper.java | 0 .../dji/sample/manage/dao/IUserMapper.java | 0 .../sample/manage/dao/IWorkspaceMapper.java | 0 .../model/common/AppLicenseProperties.java | 0 .../manage/model/common/HmsJsonUtil.java | 0 .../manage/model/common/HmsMessage.java | 0 .../model/common/NtpServerProperties.java | 0 .../manage/model/dto/CapacityCameraDTO.java | 0 .../manage/model/dto/CapacityDeviceDTO.java | 0 .../manage/model/dto/CapacityVideoDTO.java | 0 .../manage/model/dto/DeviceAuthorityDTO.java | 0 .../sample/manage/model/dto/DeviceDTO.java | 0 .../manage/model/dto/DeviceDictionaryDTO.java | 0 .../manage/model/dto/DeviceFirmwareDTO.java | 0 .../model/dto/DeviceFirmwareNoteDTO.java | 0 .../model/dto/DeviceFirmwareUpgradeDTO.java | 0 .../sample/manage/model/dto/DeviceHmsDTO.java | 0 .../manage/model/dto/DeviceLogsDTO.java | 0 .../manage/model/dto/DevicePayloadDTO.java | 0 .../model/dto/DevicePayloadReceiver.java | 0 .../model/dto/FirmwareFileProperties.java | 0 .../manage/model/dto/FirmwareModelDTO.java | 0 .../dji/sample/manage/model/dto/LiveDTO.java | 0 .../manage/model/dto/LiveStreamProperty.java | 65 ++ .../sample/manage/model/dto/LiveTypeDTO.java | 30 + .../manage/model/dto/LiveUrlAgoraDTO.java | 0 .../manage/model/dto/LiveUrlGB28181DTO.java | 0 .../manage/model/dto/LiveUrlRTSPDTO.java | 0 .../sample/manage/model/dto/LogsFileDTO.java | 0 .../manage/model/dto/LogsFileUploadDTO.java | 0 .../model/dto/LogsFileUploadListDTO.java | 0 .../model/dto/LogsOutputProgressDTO.java | 0 .../manage/model/dto/LogsProgressDTO.java | 0 .../model/dto/LogsUploadCredentialsDTO.java | 0 .../manage/model/dto/ProductConfigDTO.java | 0 .../sample/manage/model/dto/TelemetryDTO.java | 0 .../manage/model/dto/TopologyDeviceDTO.java | 0 .../dji/sample/manage/model/dto/UserDTO.java | 0 .../sample/manage/model/dto/UserListDTO.java | 0 .../sample/manage/model/dto/UserLoginDTO.java | 21 + .../sample/manage/model/dto/WorkspaceDTO.java | 0 .../model/entity/DeviceDictionaryEntity.java | 0 .../manage/model/entity/DeviceEntity.java | 0 .../model/entity/DeviceFirmwareEntity.java | 0 .../manage/model/entity/DeviceHmsEntity.java | 0 .../manage/model/entity/DeviceLogsEntity.java | 0 .../model/entity/DevicePayloadEntity.java | 0 .../model/entity/FirmwareModelEntity.java | 0 .../manage/model/entity/LogsFileEntity.java | 0 .../model/entity/LogsFileIndexEntity.java | 0 .../manage/model/entity/UserEntity.java | 0 .../manage/model/entity/WorkspaceEntity.java | 0 .../model/enums/CustomizeConfigScopeEnum.java | 0 .../model/enums/DeviceFirmwareStatusEnum.java | 0 .../model/enums/DeviceLogsStatusEnum.java | 0 .../ExitWaylineWhenRcLostActionEnum.java | 0 .../model/enums/FirmwareMethodEnum.java | 0 .../model/enums/LiveStreamMethodEnum.java | 0 .../manage/model/enums/LiveUrlTypeEnum.java | 0 .../model/enums/LiveVideoQualityEnum.java | 0 .../model/enums/LogsFileUpdateMethodEnum.java | 0 .../manage/model/enums/PayloadModelEnum.java | 0 .../model/enums/PropertySetFieldEnum.java | 0 .../manage/model/enums/StateSwitchEnum.java | 0 .../manage/model/enums/UserTypeEnum.java | 0 .../model/param/DeviceFirmwareQueryParam.java | 0 .../param/DeviceFirmwareUpdateParam.java | 0 .../param/DeviceFirmwareUploadParam.java | 0 .../model/param/DeviceHmsQueryParam.java | 0 .../model/param/DeviceLogsCreateParam.java | 0 .../model/param/DeviceLogsGetParam.java | 0 .../model/param/DeviceLogsQueryParam.java | 0 .../manage/model/param/DeviceQueryParam.java | 0 .../model/param/LogsFileUpdateParam.java | 0 .../model/receiver/BasicDeviceProperty.java | 0 .../receiver/CapacityCameraReceiver.java | 0 .../receiver/CapacityDeviceReceiver.java | 0 .../model/receiver/CapacityVideoReceiver.java | 0 .../model/receiver/DeviceBasicReceiver.java | 0 .../DeviceMaintainStatusReceiver.java | 0 .../receiver/DistanceLimitStatusReceiver.java | 0 .../model/receiver/DockSdrReceiver.java | 0 .../receiver/FirmwareVersionReceiver.java | 0 .../model/receiver/HeightLimitReceiver.java | 0 .../model/receiver/LiveCapacityReceiver.java | 0 .../receiver/MaintainStatusReceiver.java | 0 .../receiver/NightLightsStateReceiver.java | 0 .../receiver/ObstacleAvoidanceReceiver.java | 0 .../receiver/OutOfControlActionReceiver.java | 0 .../receiver/OutputLogsProgressReceiver.java | 0 .../model/receiver/RthAltitudeReceiver.java | 0 .../model/receiver/StatusGatewayReceiver.java | 0 .../receiver/StatusSubDeviceReceiver.java | 0 .../receiver/WirelessLinkStateReceiver.java | 0 .../manage/service/ICameraVideoService.java | 0 .../service/ICapacityCameraService.java | 0 .../service/IDeviceDictionaryService.java | 0 .../service/IDeviceFirmwareService.java | 0 .../manage/service/IDeviceHmsService.java | 0 .../manage/service/IDeviceLogsService.java | 0 .../manage/service/IDevicePayloadService.java | 0 .../manage/service/IDeviceRedisService.java | 0 .../sample/manage/service/IDeviceService.java | 0 .../manage/service/IFirmwareModelService.java | 0 .../manage/service/ILiveStreamService.java | 51 ++ .../manage/service/ILogsFileIndexService.java | 0 .../manage/service/ILogsFileService.java | 0 .../service/IRequestsConfigService.java | 0 .../manage/service/ITopologyService.java | 0 .../sample/manage/service/IUserService.java | 0 .../manage/service/IWorkspaceService.java | 0 .../service/impl/CameraVideoServiceImpl.java | 0 .../impl/CapacityCameraServiceImpl.java | 0 .../impl/ConfigProductServiceImpl.java | 0 .../impl/DeviceDictionaryServiceImpl.java | 0 .../impl/DeviceFirmwareServiceImpl.java | 353 +++++++++ .../service/impl/DeviceHmsServiceImpl.java | 292 ++++++++ .../service/impl/DeviceLogsServiceImpl.java | 314 ++++++++ .../impl/DevicePayloadServiceImpl.java | 0 .../service/impl/DeviceRedisServiceImpl.java | 0 .../service/impl/DeviceServiceImpl.java | 684 ++++++++++++++++++ .../impl/FirmwareModelServiceImpl.java | 0 .../service/impl/LiveStreamServiceImpl.java | 233 ++++++ .../impl/LogsFileIndexServiceImpl.java | 0 .../service/impl/LogsFileServiceImpl.java | 0 .../service/impl/RequestConfigContext.java | 0 .../manage/service/impl/SDKDeviceService.java | 500 +++++++++++++ .../service/impl/SDKLivestreamService.java | 0 .../manage/service/impl/SDKLogService.java | 0 .../service/impl/SDKOrganizationService.java | 0 .../service/impl/SDKPropertySetService.java | 0 .../service/impl/TopologyServiceImpl.java | 0 .../manage/service/impl/UserServiceImpl.java | 214 ++++++ .../service/impl/WorkspaceServiceImpl.java | 0 .../map/controller/DeviceDataController.java | 31 + .../map/controller/FlightAreaController.java | 66 ++ .../WorkspaceElementController.java | 121 ++++ .../map/dao/IDeviceFlightAreaMapper.java | 12 + .../map/dao/IElementCoordinateMapper.java | 0 .../sample/map/dao/IFlightAreaFileMapper.java | 12 + .../map/dao/IFlightAreaPropertyMapper.java | 12 + .../sample/map/dao/IGroupElementMapper.java | 0 .../com/dji/sample/map/dao/IGroupMapper.java | 0 .../map/model/dto/DeviceDataStatusDTO.java | 28 + .../map/model/dto/DeviceFlightAreaDTO.java | 32 + .../map/model/dto/FlightAreaContent.java | 32 + .../sample/map/model/dto/FlightAreaDTO.java | 35 + .../map/model/dto/FlightAreaFileDTO.java | 32 + .../map/model/dto/FlightAreaNotifyDTO.java | 26 + .../map/model/dto/FlightAreaPropertyDTO.java | 30 + .../model/dto/FlightAreaPropertyUpdate.java | 25 + .../sample/map/model/dto/FlightAreaWs.java | 36 + .../sample/map/model/dto/GroupElementDTO.java | 0 .../model/entity/DeviceFlightAreaEntity.java | 46 ++ .../model/entity/ElementCoordinateEntity.java | 0 .../model/entity/FlightAreaFileEntity.java | 52 ++ .../entity/FlightAreaPropertyEntity.java | 41 ++ .../map/model/entity/GroupElementEntity.java | 0 .../sample/map/model/entity/GroupEntity.java | 0 .../enums/FlightAreaGeometryTypeEnum.java | 37 + .../model/enums/FlightAreaOpertaionEnum.java | 39 + .../map/model/param/PostFlightAreaParam.java | 30 + .../map/model/param/PutFlightAreaParam.java | 20 + .../map/model/param/SyncFlightAreaParam.java | 21 + .../map/service/IDeviceDataService.java | 19 + .../map/service/IDeviceFlightAreaService.java | 19 + .../service/IElementCoordinateService.java | 0 .../map/service/IFlightAreaFileService.java | 25 + .../service/IFlightAreaPropertyServices.java | 22 + .../map/service/IFlightAreaService.java | 32 + .../map/service/IGroupElementService.java | 0 .../dji/sample/map/service/IGroupService.java | 31 + .../map/service/IWorkspaceElementService.java | 84 +++ .../service/impl/DeviceDataServiceImpl.java | 62 ++ .../impl/DeviceFlightAreaServiceImpl.java | 85 +++ .../impl/ElementCoordinateServiceImpl.java | 0 .../impl/FlightAreaFileServiceImpl.java | 184 +++++ .../impl/FlightAreaPropertyServiceImpl.java | 100 +++ .../service/impl/FlightAreaServiceImpl.java | 335 +++++++++ .../service/impl/GroupElementServiceImpl.java | 216 ++++++ .../map/service/impl/GroupServiceImpl.java | 74 ++ .../service/impl/SDKFlightAreaService.java | 14 + .../impl/WorkspaceElementServiceImpl.java | 149 ++++ .../media/controller/FileController.java | 0 .../media/controller/MediaController.java | 0 .../com/dji/sample/media/dao/IFileMapper.java | 0 .../sample/media/model/MediaFileCountDTO.java | 0 .../dji/sample/media/model/MediaFileDTO.java | 0 .../sample/media/model/MediaFileEntity.java | 0 .../sample/media/model/MediaMethodEnum.java | 0 .../sample/media/service/IFileService.java | 0 .../media/service/IMediaRedisService.java | 0 .../sample/media/service/IMediaService.java | 0 .../media/service/impl/FileServiceImpl.java | 176 +++++ .../service/impl/MediaRedisServiceImpl.java | 0 .../media/service/impl/MediaServiceImpl.java | 0 .../storage/controller/StorageController.java | 0 .../storage/service/IStorageService.java | 0 .../service/impl/StorageServiceImpl.java | 0 .../controller/WaylineFileController.java | 0 .../controller/WaylineJobController.java | 0 .../wayline/dao/IWaylineFileMapper.java | 0 .../sample/wayline/dao/IWaylineJobMapper.java | 0 .../model/dto/ConditionalWaylineJobKey.java | 0 .../model/dto/FlighttaskProgressExt.java | 0 .../model/dto/FlighttaskProgressProgress.java | 0 .../wayline/model/dto/KmzFileProperties.java | 0 .../wayline/model/dto/WaylineFileDTO.java | 0 .../wayline/model/dto/WaylineJobDTO.java | 0 .../model/dto/WaylineTaskConditionDTO.java | 0 .../model/dto/WaylineTaskCreateDTO.java | 0 .../WaylineTaskExecutableConditionDTO.java | 0 .../wayline/model/dto/WaylineTaskFileDTO.java | 0 .../dto/WaylineTaskProgressReceiver.java | 0 .../dto/WaylineTaskReadyConditionDTO.java | 0 .../model/entity/WaylineFileEntity.java | 0 .../model/entity/WaylineJobEntity.java | 0 .../model/enums/WaylineErrorCodeEnum.java | 0 .../model/enums/WaylineJobStatusEnum.java | 0 .../model/enums/WaylineMethodEnum.java | 0 .../model/enums/WaylineTaskStatusEnum.java | 0 .../model/enums/WaylineTemplateTypeEnum.java | 0 .../wayline/model/param/CreateJobParam.java | 0 .../wayline/model/param/UpdateJobParam.java | 0 .../model/param/WaylineQueryParam.java | 0 .../wayline/service/IFlightTaskService.java | 0 .../wayline/service/IWaylineFileService.java | 0 .../wayline/service/IWaylineJobService.java | 0 .../wayline/service/IWaylineRedisService.java | 0 .../service/impl/FlightTaskServiceImpl.java | 0 .../service/impl/SDKWaylineService.java | 0 .../service/impl/WaylineFileServiceImpl.java | 295 ++++++++ .../service/impl/WaylineJobServiceImpl.java | 298 ++++++++ .../service/impl/WaylineRedisServiceImpl.java | 0 sample/src/main/resources/application.yml | 171 +++++ {src => sample/src}/main/resources/hms.json | 0 sql/cloud_sample.sql | 62 +- .../service/impl/AliyunOssServiceImpl.java | 108 --- .../oss/service/impl/AmazonS3ServiceImpl.java | 125 ---- .../oss/service/impl/MinIOServiceImpl.java | 121 ---- .../websocket/model/BizCodeEnum.java | 86 --- .../control/model/param/FlyToPointParam.java | 37 - .../sample/manage/model/dto/LiveTypeDTO.java | 31 - .../sample/manage/model/dto/UserLoginDTO.java | 17 - .../manage/service/ILiveStreamService.java | 50 -- .../impl/DeviceFirmwareServiceImpl.java | 353 --------- .../service/impl/DeviceHmsServiceImpl.java | 292 -------- .../service/impl/DeviceLogsServiceImpl.java | 314 -------- .../service/impl/DeviceServiceImpl.java | 684 ------------------ .../service/impl/LiveStreamServiceImpl.java | 253 ------- .../manage/service/impl/SDKDeviceService.java | 501 ------------- .../manage/service/impl/UserServiceImpl.java | 214 ------ .../WorkspaceElementController.java | 121 ---- .../map/model/enums/ElementTypeEnum.java | 61 -- .../dji/sample/map/service/IGroupService.java | 24 - .../map/service/IWorkspaceElementService.java | 81 --- .../service/impl/GroupElementServiceImpl.java | 216 ------ .../map/service/impl/GroupServiceImpl.java | 62 -- .../impl/WorkspaceElementServiceImpl.java | 143 ---- .../media/service/impl/FileServiceImpl.java | 176 ----- .../service/impl/WaylineFileServiceImpl.java | 283 -------- .../service/impl/WaylineJobServiceImpl.java | 298 -------- src/main/java/com/dji/sdk/README.md | 48 -- .../cloudapi/control/ControlMethodEnum.java | 54 -- .../cloudapi/control/FlyToPointRequest.java | 71 -- .../control/PayloadControlMethodEnum.java | 51 -- .../control/TakeoffToPointProgress.java | 80 -- .../control/TakeoffToPointRequest.java | 218 ------ .../control/api/AbstractControlService.java | 401 ---------- .../sdk/cloudapi/debug/DebugMethodEnum.java | 76 -- .../debug/api/AbstractDebugService.java | 349 --------- .../sdk/cloudapi/device/CameraModeEnum.java | 36 - .../sdk/cloudapi/device/DockDronePayload.java | 236 ------ .../dji/sdk/cloudapi/device/DockPayload.java | 56 -- .../sdk/cloudapi/device/DockWpmzVersion.java | 30 - .../device/DroneBatteryMaintenanceInfo.java | 32 - .../cloudapi/device/DroneModeCodeEnum.java | 66 -- .../device/FlighttaskStepCodeEnum.java | 49 -- .../cloudapi/device/ModeCodeReasonEnum.java | 79 -- .../dji/sdk/cloudapi/device/OsdCamera.java | 138 ---- .../com/dji/sdk/cloudapi/device/OsdDock.java | 474 ------------ .../dji/sdk/cloudapi/device/OsdDockDrone.java | 469 ------------ .../cloudapi/device/PayloadModelConst.java | 38 - .../cloudapi/device/RcFirmwareVersion.java | 31 - .../device/api/AbstractDeviceService.java | 177 ----- .../cloudapi/firmware/OtaCreateRequest.java | 40 - .../livestream/LiveStartPushRequest.java | 93 --- .../livestream/RcLiveCapacityCamera.java | 80 -- .../livestream/RcLiveCapacityDevice.java | 81 --- .../livestream/RcLiveCapacityVideo.java | 42 -- .../sdk/cloudapi/livestream/UrlTypeEnum.java | 40 - .../cloudapi/log/FileUploadListRequest.java | 43 -- .../sdk/cloudapi/log/FileUploadStartFile.java | 75 -- .../cloudapi/log/FileUploadStartParam.java | 38 - .../cloudapi/log/FileUploadUpdateRequest.java | 56 -- .../dji/sdk/cloudapi/map/ElementContent.java | 66 -- .../sdk/cloudapi/map/ElementCoordinate.java | 64 -- .../sdk/cloudapi/map/ElementGeometryType.java | 53 -- .../map/ElementLineStringGeometry.java | 81 --- .../cloudapi/map/ElementPointGeometry.java | 77 -- .../cloudapi/map/ElementPolygonGeometry.java | 82 --- .../cloudapi/map/ElementResourceTypeEnum.java | 48 -- .../cloudapi/map/GetMapElementsResponse.java | 100 --- .../dji/sdk/cloudapi/map/GroupTypeEnum.java | 44 -- .../UploadFlighttaskMediaPrioritize.java | 37 - .../AirportBindStatusResponse.java | 40 - .../AirportOrganizationBindResponse.java | 40 - .../cloudapi/property/PropertySetEnum.java | 62 -- .../property/api/AbstractPropertyService.java | 78 -- .../cloudapi/storage/CredentialsToken.java | 111 --- .../dji/sdk/cloudapi/tsa/TopologyList.java | 55 -- .../sdk/cloudapi/tsa/TopologyResponse.java | 40 - .../cloudapi/wayline/BreakpointStateEnum.java | 43 -- .../cloudapi/wayline/ExecutionStepEnum.java | 66 -- .../wayline/ExitingRTHActionEnum.java | 44 -- .../wayline/ExitingRTHReasonEnum.java | 61 -- .../wayline/FlighttaskBreakReasonEnum.java | 201 ----- .../wayline/FlighttaskExecuteRequest.java | 37 - .../wayline/FlighttaskPrepareRequest.java | 245 ------- .../wayline/FlighttaskProgressExt.java | 80 -- .../wayline/FlighttaskUndoRequest.java | 39 - .../wayline/GetWaylineListRequest.java | 116 --- .../wayline/GetWaylineListResponse.java | 203 ------ .../sdk/cloudapi/wayline/ReadyConditions.java | 77 -- .../dji/sdk/cloudapi/wayline/RthModeEnum.java | 37 - .../wayline/api/AbstractWaylineService.java | 195 ----- .../java/com/dji/sdk/common/Pagination.java | 80 -- .../dji/sdk/config/GetSnakeDataBinder.java | 110 --- .../config/version/CloudSDKVersionEnum.java | 37 - .../config/version/DockThingVersionEnum.java | 45 -- .../config/version/DroneThingVersionEnum.java | 54 -- .../java/com/dji/sdk/mqtt/ChannelName.java | 137 ---- .../com/dji/sdk/mqtt/MqttGatewayPublish.java | 101 --- .../com/dji/sdk/mqtt/MqttReplyHandler.java | 60 -- .../dji/sdk/mqtt/events/EventsMethodEnum.java | 105 --- .../sdk/mqtt/requests/RequestsMethodEnum.java | 63 -- .../sdk/mqtt/state/DockStateDataKeyEnum.java | 55 -- .../sdk/mqtt/state/RcStateDataKeyEnum.java | 53 -- .../dji/sdk/mqtt/state/StateDataKeyEnum.java | 64 -- .../com/dji/sdk/mqtt/state/StateRouter.java | 64 -- .../dji/sdk/mqtt/state/TopicStateRequest.java | 83 --- src/main/resources/application.yml | 141 ---- 992 files changed, 22092 insertions(+), 12431 deletions(-) create mode 100644 cloud-sdk/README.md rename {src/main/resources => cloud-sdk}/image/1.png (100%) rename {src/main/resources => cloud-sdk}/image/2.png (100%) rename {src/main/resources => cloud-sdk}/image/3.png (100%) rename {src/main/resources => cloud-sdk}/image/4.png (100%) rename {src/main/resources => cloud-sdk}/image/5.png (100%) rename {src/main/resources => cloud-sdk}/image/6.png (100%) rename {src/main/resources => cloud-sdk}/image/7.png (100%) create mode 100644 cloud-sdk/pom.xml rename {src => cloud-sdk/src}/main/java/com/dji/sdk/annotations/CloudSDKVersion.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/AirsenseWarning.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/AltitudeTypeEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/VertTrendEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/WarningLevelEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/api/AbstractAirsenseService.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/config/ConfigScopeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/config/ConfigTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/config/ProductConfigResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/config/RequestsConfigRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/config/api/AbstractConfigService.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/CameraAimRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraExposureModeSetRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraExposureSetRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/CameraFocalLengthSetRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraFocusModeSetRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraFocusValueSetRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraLookAtRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/CameraModeSwitchRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPhotoStopRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPhotoTakeProgress.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/CameraPhotoTakeRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPointFocusActionRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/CameraRecordingStartRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/CameraRecordingStopRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraScreenSplitRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/CameraTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/CommanderFlightModeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/CommanderModeLostActionEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/ControlErrorCodeEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ControlMethodEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/DelayInfoPush.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/DrcModeEnterRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/DrcModeMqttBroker.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/DrcStatusErrorEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/DrcStatusNotify.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/DroneControlRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/DroneControlResponse.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ExposureCameraTypeEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ExposureModeEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ExposureValueEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/FlyToPointProgress.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointUpdateRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/FlyToStatusEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FocusModeEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/GimbalResetModeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/GimbalResetRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/HeartBeatRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/HsiInfoPush.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/IrMeteringAreaSetRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/IrMeteringModeSetRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/IrMeteringPointSetRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/JoystickInvalidNotify.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/JoystickInvalidReasonEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/LensStorageSettingsEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/LiveviewDelay.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/MeteringModeEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/OsdInfoPush.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/PayloadAuthorityGrabRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PayloadControlMethodEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoStorageSetRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoTakeProgressData.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoTakeProgressExt.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoTakeProgressStepEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiCircleSpeedSetRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiModeEnterRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiStatusNotify.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiStatusReasonEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/Point.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/TakeoffStatusEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointProgress.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/VideoStorageSetRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/control/ZoomCameraTypeEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/api/AbstractControlService.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/debug/AirConditionerModeSwitchActionEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/debug/AirConditionerModeSwitchRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/debug/AlarmStateSwitchRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/debug/BatteryMaintenanceSwitchRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/debug/BatteryStoreModeSwitchRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/debug/DebugErrorCodeEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/DebugMethodEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/DongleDeviceTypeEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/EsimActivateRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/EsimOperatorSwitchRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugProgress.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugProgressData.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugStatusEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugStepKeyEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/debug/SdrWorkmodeSwitchRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/SimSlotSwitchRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/api/AbstractDebugService.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/AirConditioner.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/AirConditionerStateEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/AlternateLandPoint.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/BackupBattery.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/Battery.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/BatteryIndexEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/BatteryStoreModeEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/CameraIsoEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/CameraModeEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/CameraStateEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/ControlSourceEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/CoverStateEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DeviceDomainEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DeviceEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DeviceModelEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DeviceOsdHost.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DeviceOsdWsResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DeviceSubTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DeviceTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DockDistanceLimitStatus.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DockDroneControlSource.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneCurrentCommanderFlightMode.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneCurrentRthMode.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneModeCodeReason.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDronePayload.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneThermalSupportedPaletteStyle.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneWpmzVersion.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DockFirmwareVersion.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DockLiveErrorStatus.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DockLiveStatus.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DockLiveStatusData.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DockMaintainStatus.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DockModeCodeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DockPayloadControlSource.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DockPositionState.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockSilentMode.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DockSubDevice.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DongleInfo.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DongleInfos.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DongleTypeEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DrcStateEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DroneBattery.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenance.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenanceInfo.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DroneChargeState.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DroneMaintainStatus.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneModeCodeEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/DronePositionState.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/EsimActivateStateEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/EsimInfo.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/ExitWaylineWhenRcLostEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/FirmwareVersion.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/FlighttaskStepCodeEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/FocusStateEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/GearEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/HeatStateEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/IrMeteringArea.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/IrMeteringPoint.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/LinkWorkModeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/LiveviewWorldRegion.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/MaintainTypeEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/MaintenanceStateEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/MeasureTargetStateEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/MediaFileDetail.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ModeCodeReasonEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/NetworkState.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/NetworkStateQualityEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/NetworkStateTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/ObstacleAvoidance.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdCamera.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdDock.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdDockDrone.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/OsdDockMaintainStatus.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/OsdDroneMaintainStatus.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/OsdRcDrone.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/OsdRemoteControl.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/PayloadFirmwareVersion.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/PayloadIndex.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PayloadModelConst.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/PayloadPositionEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/PositionFixedEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/PutterStateEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/RainfallEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/RcDistanceLimitStatus.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/RcDroneControlSource.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/RcDronePayload.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/RcLiveStatus.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/RcLiveStatusData.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/RcLostActionEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/RcPayloadControlSource.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ShutterSpeedEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimCardStateEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimInfo.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimSlotEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimTypeEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/SmartTrackPoint.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/Storage.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/SwitchActionEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/TelecomOperatorEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/ThermalGainModeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/ThermalPaletteStyleEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/TrackTargetModeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/UpdateTopo.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/UpdateTopoSubDevice.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/UserExperienceImprovementEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/VideoId.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/WindDirectionEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/device/WirelessLink.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/api/AbstractDeviceService.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/firmware/FirmwareErrorCodeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/firmware/FirmwareMethodEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/firmware/FirmwareUpgradeTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateDevice.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/firmware/OtaProgress.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressData.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressExt.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressStatusEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressStepEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/firmware/api/AbstractFirmwareService.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/DroneLocation.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FeatureProperty.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaFeature.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaFile.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaGeometry.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaGetFile.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaJson.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaMethodEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaPointGeometry.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaPolygonGeometry.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaSyncReasonEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaSyncStatusEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasDroneLocation.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasGetRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasGetResponse.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasSyncProgress.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/GeofenceTypeEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/GeometrySubTypeEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/GeometryTypeEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/api/AbstractFlightAreaService.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/DeviceHms.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/DeviceHmsArgs.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/Hms.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/HmsBatteryIndexEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/HmsChargingRodIndexEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/HmsDockCoverIndexEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/HmsFaqIdEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/HmsFormatKeyEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/HmsInTheSkyEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/HmsLevelEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/HmsMessageLanguageEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/HmsModuleEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/hms/api/AbstractHmsService.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionFromEsdk.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionFromPsdk.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionToEsdkRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionToPsdkRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/InterconnectionMethodEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/api/AbstractInterconnectionService.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacity.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityCamera.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityDevice.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityVideo.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/DockLivestreamAbilityUpdate.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/ILivestreamUrl.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/LensChangeVideoTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/LiveErrorCodeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/LiveLensChangeRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/LiveSetQualityRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStartPushRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/LiveStopPushRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/LiveStreamMethodEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamAgoraUrl.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamGb28181Url.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamRtmpUrl.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamRtspUrl.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamWhipUrl.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacity.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityCamera.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityDevice.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityVideo.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/RcLivestreamAbilityUpdate.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/UrlTypeEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/VideoQualityEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/VideoTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/livestream/api/AbstractLivestreamService.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/FileUploadListFile.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/FileUploadListResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/FileUploadProgress.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/FileUploadProgressExt.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/FileUploadProgressFile.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartFile.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartParam.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/FileUploadStartRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/FileUploadStatusEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateStatusEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/LogErrorCodeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/LogFileIndex.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/LogFileProgress.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/LogMethodEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/LogModuleEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/log/api/AbstractLogService.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/map/CreateMapElementRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/map/CreateMapElementResponse.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/DockDroneDongleInfos.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementCircleGeometry.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementContent.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementCoordinate.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementGeometryType.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementLineStringGeometry.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementPointGeometry.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementPolygonGeometry.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/map/ElementProperty.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/map/ElementResource.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementResourceTypeEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementTypeEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/GetMapElementsResponse.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/GroupTypeEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/map/MapElementCreateWsResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/map/MapElementDeleteWsResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/map/MapElementUpdateWsResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/map/MapGroupElement.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/map/MapGroupRefreshWsResponse.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapMethodEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapFile.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapGetRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapGetResponse.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncFile.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncProgress.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncReasonEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncStatusEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/map/UpdateMapElementRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/api/AbstractOfflineMapService.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/map/api/IHttpMapService.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/FastUploadExtension.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/FileUploadCallback.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/FileUploadCallbackFile.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/FolderUploadCallbackRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/GetFileFingerprintRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/GetFileFingerprintResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/HighestPriorityUploadFlightTaskMedia.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/MediaFastUploadRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/MediaFileExtension.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/MediaFileMetadata.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/MediaMethodEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/MediaSubFileTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/MediaUploadCallbackRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/Position.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/StorageConfigGet.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/StorageConfigGetModuleEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/UploadCallbackFileExtension.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/UploadCallbackFileMetadata.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/UploadFlighttaskMediaPrioritize.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/api/AbstractMediaService.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/media/api/IHttpMediaService.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusResponse.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindResponse.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationGetRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationGetResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/organization/BindStatusRequestDevice.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/organization/BindStatusResponseDevice.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/organization/OrganizationBindDevice.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/organization/OrganizationBindInfo.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/organization/api/AbstractOrganizationService.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/DistanceLimitStatusData.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/DistanceLimitStatusSet.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneCommanderFlightHeight.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneCommanderModeLostAction.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneOfflineMapEnable.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneRthMode.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/ExitWaylineWhenRcLostSet.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/HeightLimitSet.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/NightLightsStateSet.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/ObstacleAvoidanceSet.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/PropertySetEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/RcLostActionSet.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/RthAltitudeSet.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/SilentModeEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/ThermalCurrentPaletteStyleSet.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/ThermalGainModeSet.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermLowerLimitSet.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermStateSet.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermUpperLimitSet.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/UserExperienceImprovementSet.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/api/AbstractPropertyService.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/storage/CredentialsToken.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/storage/OssTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/storage/StsCredentialsResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/storage/api/IHttpStorageService.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/tsa/DeviceIconUrl.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/tsa/DeviceTopology.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/tsa/IconUrlEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/tsa/TopologyDeviceModel.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyList.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyResponse.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/tsa/api/IHttpTsaService.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ActionTypeEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/BreakpointStateEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/DeviceExitHomingNotify.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/ExecutableConditions.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExecutionStepEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHActionEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHReasonEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakPoint.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakReasonEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskCreateFile.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskCreateRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskExecuteRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskFile.java (100%) create mode 100755 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskPrepareRequest.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgress.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressData.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressExt.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskReady.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskResourceGetRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskResourceGetResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskStatusEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskUndoRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListOrderBy.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListResponse.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/LastPointTypeEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/OrderByColumnEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/OutOfControlActionEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/ProgressExtBreakPoint.java (100%) create mode 100755 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ReadyConditions.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ReturnHomeInfo.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/RthModeEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/SimulateMission.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/SimulateSwitchEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/TaskTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/WaylineErrorCodeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/WaylineMethodEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineMissionStateEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylinePrecisionTypeEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/WaylineTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/WaylineUploadCallbackMetadata.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/WaylineUploadCallbackRequest.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/api/AbstractWaylineService.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/cloudapi/wayline/api/IHttpWaylineService.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/common/BaseModel.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/common/Common.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/common/CommonErrorEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/common/ErrorCodeSourceEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/common/HttpResultResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/common/IErrorInfo.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/common/Pagination.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/common/PaginationData.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/common/SDKManager.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/common/SpringBeanUtils.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/config/CloudSDKHandler.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/config/CloudSDKMvcConfigurer.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/config/GetSnakeArgumentProcessor.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/config/GetSnakeDataBinder.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/config/version/CloudSDKVersionEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/config/version/Dock2ThingVersionEnum.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/config/version/DockThingVersionEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/config/version/DroneThingVersionEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/config/version/GatewayManager.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/config/version/GatewayThingVersion.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/config/version/GatewayTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/config/version/IThingVersion.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/config/version/RcThingVersionEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/exception/CloudSDKErrorEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/exception/CloudSDKException.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/exception/CloudSDKVersionException.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/Chan.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/mqtt/ChannelName.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/CloudApiTopicEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/CommonTopicRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/CommonTopicResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/IMqttMessageGateway.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/IMqttTopicService.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/InboundMessageRouter.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/MqttConfiguration.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttGatewayPublish.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/MqttReply.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttReplyHandler.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/MqttTopicServiceImpl.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/TopicConst.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/drc/DrcDownPublish.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/drc/DrcUpData.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/drc/DrcUpMethodEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/drc/DrcUpRouter.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/drc/DrcUpSubscribe.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/drc/TopicDrcRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/drc/TopicDrcResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/events/EventsDataRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/events/EventsErrorCode.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsMethodEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/events/EventsRouter.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/events/EventsSubscribe.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/events/IEventsErrorCode.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/events/TopicEventsRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/events/TopicEventsResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/osd/OsdDeviceTypeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/osd/OsdRouter.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/osd/OsdSubscribe.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/osd/TopicOsdRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/property/PropertySetPublish.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/property/PropertySetReplyHandler.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/property/PropertySetReplyResultEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/property/PropertySetSubscribe.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/property/TopicPropertySetRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/property/TopicPropertySetResponse.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/mqtt/requests/RequestsMethodEnum.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/requests/RequestsRouter.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/requests/RequestsSubscribe.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/requests/TopicRequestsRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/requests/TopicRequestsResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/services/IServicesErrorCode.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/services/ServicesErrorCode.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/services/ServicesPublish.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/services/ServicesReplyData.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/services/ServicesReplyHandler.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/services/ServicesReplyReceiver.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/services/ServicesSubscribe.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/services/TopicServicesRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/services/TopicServicesResponse.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/DockStateDataKeyEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/RcStateDataKeyEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/StateDataKeyEnum.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/StateRouter.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/state/StateSubscribe.java (100%) create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/TopicStateRequest.java create mode 100644 cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/TopicStateResponse.java rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/status/StatusRouter.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/status/StatusSubscribe.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/status/TopicStatusRequest.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/mqtt/status/TopicStatusResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/swagger/SwaggerConfig.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/websocket/BizCodeEnum.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/websocket/ConcurrentWebSocketSession.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/websocket/WebSocketConfiguration.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/websocket/WebSocketDefaultFactory.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/websocket/WebSocketDefaultHandler.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/websocket/WebSocketMessageResponse.java (100%) rename {src => cloud-sdk/src}/main/java/com/dji/sdk/websocket/api/WebSocketMessageSend.java (100%) create mode 100644 sample/pom.xml rename {src => sample/src}/main/java/com/dji/sample/CloudApiSampleApplication.java (100%) rename {src => sample/src}/main/java/com/dji/sample/common/error/CommonErrorEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/common/model/CustomClaim.java (100%) rename {src => sample/src}/main/java/com/dji/sample/common/util/JwtUtil.java (100%) rename {src => sample/src}/main/java/com/dji/sample/common/util/SpringBeanUtilsTest.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/ApplicationBootInitial.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/AuthInterceptor.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/CorsFilter.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/GlobalExceptionHandler.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/GlobalScheduleService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/mqtt/config/MqttMessageChannel.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/mqtt/config/MqttPropertyConfiguration.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/mqtt/model/EventsReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/mqtt/model/MapKeyConst.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/mqtt/model/MqttClientOptions.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/mqtt/model/MqttProtocolEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/mqtt/model/MqttUseEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/mybatis/MybatisPlusConfiguration.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/mybatis/MybatisPlusMetaObjectHandler.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/oss/model/OssConfiguration.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/oss/service/IOssService.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/component/oss/service/impl/AliyunOssServiceImpl.java create mode 100644 sample/src/main/java/com/dji/sample/component/oss/service/impl/AmazonS3ServiceImpl.java create mode 100644 sample/src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java rename {src => sample/src}/main/java/com/dji/sample/component/oss/service/impl/OssAspectHandler.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/oss/service/impl/OssServiceContext.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/redis/RedisConfiguration.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/redis/RedisConst.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/redis/RedisOpsUtils.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/websocket/config/AuthPrincipalHandler.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/websocket/config/MyConcurrentWebSocketSession.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/websocket/config/MyWebSocketFactory.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/websocket/config/MyWebSocketHandler.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/component/websocket/model/BizCodeEnum.java rename {src => sample/src}/main/java/com/dji/sample/component/websocket/service/IWebSocketManageService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/websocket/service/IWebSocketMessageService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/component/websocket/service/impl/WebSocketMessageServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/configuration/GlobalThreadPoolConfiguration.java (100%) rename {src => sample/src}/main/java/com/dji/sample/configuration/SpringBeanConfiguration.java (100%) rename {src => sample/src}/main/java/com/dji/sample/configuration/mvc/GlobalMVCConfigurer.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/controller/DockController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/controller/DrcController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/dto/AirConditionerMode.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/dto/AlarmState.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/dto/BatteryStoreMode.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/dto/JwtAclDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/dto/LinkWorkMode.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/dto/RemoteDebugOpenState.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/dto/ResultNotifyDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/dto/ReturnHomeCancelState.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/dto/ReturnHomeState.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/enums/CameraModeEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/enums/DrcMethodEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/enums/DroneAuthorityEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/enums/DroneControlMethodEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/enums/GimbalResetModeEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/enums/MqttAclAccessEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/enums/PayloadCommandsEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/enums/RemoteDebugMethodEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/param/DeviceDrcInfoParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/param/DrcConnectParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/param/DrcModeParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/param/DronePayloadParam.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/control/model/param/FlyToPointParam.java rename {src => sample/src}/main/java/com/dji/sample/control/model/param/PayloadCommandsParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/param/RemoteDebugParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/model/param/TakeoffToPointParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/IControlService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/IDrcService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/CameraAimImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/CameraFocalLengthSetImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/CameraModeSwitchImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/CameraPhotoTakeImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/CameraRecordingStartImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/CameraRecordingStopImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/ControlServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/DrcServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/GimbalResetImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/PayloadCommandsHandler.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/RemoteDebugHandler.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/SDKControlService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/control/service/impl/SDKRemoteDebug.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/controller/DeviceController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/controller/DeviceFirmwareController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/controller/DeviceHmsController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/controller/DeviceLogsController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/controller/LiveStreamController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/controller/LoginController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/controller/TopologyController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/controller/UserController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/controller/WorkspaceController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/dao/IDeviceDictionaryMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/dao/IDeviceFirmwareMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/dao/IDeviceHmsMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/dao/IDeviceLogsMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/dao/IDeviceMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/dao/IDevicePayloadMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/dao/IFirmwareModelMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/dao/ILogsFileIndexMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/dao/ILogsFileMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/dao/IUserMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/dao/IWorkspaceMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/common/AppLicenseProperties.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/common/HmsJsonUtil.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/common/HmsMessage.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/common/NtpServerProperties.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/CapacityCameraDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/CapacityDeviceDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/CapacityVideoDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/DeviceAuthorityDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/DeviceDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/DeviceDictionaryDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareNoteDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareUpgradeDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/DeviceHmsDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/DeviceLogsDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/DevicePayloadDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/DevicePayloadReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/FirmwareFileProperties.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/FirmwareModelDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/LiveDTO.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/manage/model/dto/LiveStreamProperty.java create mode 100644 sample/src/main/java/com/dji/sample/manage/model/dto/LiveTypeDTO.java rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/LiveUrlAgoraDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/LiveUrlGB28181DTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/LiveUrlRTSPDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/LogsFileDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/LogsFileUploadDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/LogsFileUploadListDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/LogsOutputProgressDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/LogsProgressDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/LogsUploadCredentialsDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/ProductConfigDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/TelemetryDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/TopologyDeviceDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/UserDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/UserListDTO.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/manage/model/dto/UserLoginDTO.java rename {src => sample/src}/main/java/com/dji/sample/manage/model/dto/WorkspaceDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/entity/DeviceDictionaryEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/entity/DeviceEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/entity/DeviceFirmwareEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/entity/DeviceHmsEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/entity/DeviceLogsEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/entity/DevicePayloadEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/entity/FirmwareModelEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/entity/LogsFileEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/entity/LogsFileIndexEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/entity/UserEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/entity/WorkspaceEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/CustomizeConfigScopeEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/DeviceFirmwareStatusEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/DeviceLogsStatusEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/ExitWaylineWhenRcLostActionEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/FirmwareMethodEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/LiveStreamMethodEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/LiveUrlTypeEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/LiveVideoQualityEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/LogsFileUpdateMethodEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/PayloadModelEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/PropertySetFieldEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/StateSwitchEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/enums/UserTypeEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/param/DeviceFirmwareQueryParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/param/DeviceFirmwareUpdateParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/param/DeviceFirmwareUploadParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/param/DeviceHmsQueryParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/param/DeviceLogsCreateParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/param/DeviceLogsGetParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/param/DeviceLogsQueryParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/param/DeviceQueryParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/param/LogsFileUpdateParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/BasicDeviceProperty.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/CapacityCameraReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/CapacityDeviceReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/CapacityVideoReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/DeviceBasicReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/DeviceMaintainStatusReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/DistanceLimitStatusReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/DockSdrReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/FirmwareVersionReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/HeightLimitReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/LiveCapacityReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/MaintainStatusReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/NightLightsStateReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/ObstacleAvoidanceReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/OutOfControlActionReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/OutputLogsProgressReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/RthAltitudeReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/StatusGatewayReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/StatusSubDeviceReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/model/receiver/WirelessLinkStateReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/ICameraVideoService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/ICapacityCameraService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/IDeviceDictionaryService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/IDeviceFirmwareService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/IDeviceHmsService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/IDeviceLogsService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/IDevicePayloadService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/IDeviceRedisService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/IDeviceService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/IFirmwareModelService.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/manage/service/ILiveStreamService.java rename {src => sample/src}/main/java/com/dji/sample/manage/service/ILogsFileIndexService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/ILogsFileService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/IRequestsConfigService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/ITopologyService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/IUserService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/IWorkspaceService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/CameraVideoServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/CapacityCameraServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/ConfigProductServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/DeviceDictionaryServiceImpl.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/manage/service/impl/DeviceFirmwareServiceImpl.java create mode 100644 sample/src/main/java/com/dji/sample/manage/service/impl/DeviceHmsServiceImpl.java create mode 100644 sample/src/main/java/com/dji/sample/manage/service/impl/DeviceLogsServiceImpl.java rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/DevicePayloadServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/DeviceRedisServiceImpl.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/FirmwareModelServiceImpl.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/LogsFileIndexServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/LogsFileServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/RequestConfigContext.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/SDKLivestreamService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/SDKLogService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/SDKOrganizationService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/SDKPropertySetService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/TopologyServiceImpl.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/manage/service/impl/UserServiceImpl.java rename {src => sample/src}/main/java/com/dji/sample/manage/service/impl/WorkspaceServiceImpl.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/map/controller/DeviceDataController.java create mode 100644 sample/src/main/java/com/dji/sample/map/controller/FlightAreaController.java create mode 100644 sample/src/main/java/com/dji/sample/map/controller/WorkspaceElementController.java create mode 100644 sample/src/main/java/com/dji/sample/map/dao/IDeviceFlightAreaMapper.java rename {src => sample/src}/main/java/com/dji/sample/map/dao/IElementCoordinateMapper.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/map/dao/IFlightAreaFileMapper.java create mode 100644 sample/src/main/java/com/dji/sample/map/dao/IFlightAreaPropertyMapper.java rename {src => sample/src}/main/java/com/dji/sample/map/dao/IGroupElementMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/map/dao/IGroupMapper.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/map/model/dto/DeviceDataStatusDTO.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/dto/DeviceFlightAreaDTO.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaContent.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaDTO.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaFileDTO.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaNotifyDTO.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaPropertyDTO.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaPropertyUpdate.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaWs.java rename {src => sample/src}/main/java/com/dji/sample/map/model/dto/GroupElementDTO.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/map/model/entity/DeviceFlightAreaEntity.java rename {src => sample/src}/main/java/com/dji/sample/map/model/entity/ElementCoordinateEntity.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/map/model/entity/FlightAreaFileEntity.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/entity/FlightAreaPropertyEntity.java rename {src => sample/src}/main/java/com/dji/sample/map/model/entity/GroupElementEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/map/model/entity/GroupEntity.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/map/model/enums/FlightAreaGeometryTypeEnum.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/enums/FlightAreaOpertaionEnum.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/param/PostFlightAreaParam.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/param/PutFlightAreaParam.java create mode 100644 sample/src/main/java/com/dji/sample/map/model/param/SyncFlightAreaParam.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/IDeviceDataService.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/IDeviceFlightAreaService.java rename {src => sample/src}/main/java/com/dji/sample/map/service/IElementCoordinateService.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/map/service/IFlightAreaFileService.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/IFlightAreaPropertyServices.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/IFlightAreaService.java rename {src => sample/src}/main/java/com/dji/sample/map/service/IGroupElementService.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/map/service/IGroupService.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/IWorkspaceElementService.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/impl/DeviceDataServiceImpl.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/impl/DeviceFlightAreaServiceImpl.java rename {src => sample/src}/main/java/com/dji/sample/map/service/impl/ElementCoordinateServiceImpl.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaFileServiceImpl.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaPropertyServiceImpl.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaServiceImpl.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/impl/GroupElementServiceImpl.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/impl/GroupServiceImpl.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/impl/SDKFlightAreaService.java create mode 100644 sample/src/main/java/com/dji/sample/map/service/impl/WorkspaceElementServiceImpl.java rename {src => sample/src}/main/java/com/dji/sample/media/controller/FileController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/media/controller/MediaController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/media/dao/IFileMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/media/model/MediaFileCountDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/media/model/MediaFileDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/media/model/MediaFileEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/media/model/MediaMethodEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/media/service/IFileService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/media/service/IMediaRedisService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/media/service/IMediaService.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java rename {src => sample/src}/main/java/com/dji/sample/media/service/impl/MediaRedisServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/storage/controller/StorageController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/storage/service/IStorageService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/storage/service/impl/StorageServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/controller/WaylineFileController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/controller/WaylineJobController.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/dao/IWaylineFileMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/dao/IWaylineJobMapper.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/dto/ConditionalWaylineJobKey.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/dto/FlighttaskProgressExt.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/dto/FlighttaskProgressProgress.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/dto/KmzFileProperties.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/dto/WaylineFileDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/dto/WaylineJobDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/dto/WaylineTaskConditionDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/dto/WaylineTaskCreateDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/dto/WaylineTaskExecutableConditionDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/dto/WaylineTaskFileDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/dto/WaylineTaskProgressReceiver.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/dto/WaylineTaskReadyConditionDTO.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/entity/WaylineFileEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/entity/WaylineJobEntity.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/enums/WaylineErrorCodeEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/enums/WaylineJobStatusEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/enums/WaylineMethodEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/enums/WaylineTaskStatusEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/enums/WaylineTemplateTypeEnum.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/param/CreateJobParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/param/UpdateJobParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/model/param/WaylineQueryParam.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/service/IFlightTaskService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/service/IWaylineFileService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/service/IWaylineJobService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/service/IWaylineRedisService.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/service/impl/FlightTaskServiceImpl.java (100%) rename {src => sample/src}/main/java/com/dji/sample/wayline/service/impl/SDKWaylineService.java (100%) create mode 100644 sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java create mode 100644 sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java rename {src => sample/src}/main/java/com/dji/sample/wayline/service/impl/WaylineRedisServiceImpl.java (100%) create mode 100644 sample/src/main/resources/application.yml rename {src => sample/src}/main/resources/hms.json (100%) delete mode 100644 src/main/java/com/dji/sample/component/oss/service/impl/AliyunOssServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/component/oss/service/impl/AmazonS3ServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/component/websocket/model/BizCodeEnum.java delete mode 100644 src/main/java/com/dji/sample/control/model/param/FlyToPointParam.java delete mode 100644 src/main/java/com/dji/sample/manage/model/dto/LiveTypeDTO.java delete mode 100644 src/main/java/com/dji/sample/manage/model/dto/UserLoginDTO.java delete mode 100644 src/main/java/com/dji/sample/manage/service/ILiveStreamService.java delete mode 100644 src/main/java/com/dji/sample/manage/service/impl/DeviceFirmwareServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/manage/service/impl/DeviceHmsServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/manage/service/impl/DeviceLogsServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java delete mode 100644 src/main/java/com/dji/sample/manage/service/impl/UserServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/map/controller/WorkspaceElementController.java delete mode 100644 src/main/java/com/dji/sample/map/model/enums/ElementTypeEnum.java delete mode 100644 src/main/java/com/dji/sample/map/service/IGroupService.java delete mode 100644 src/main/java/com/dji/sample/map/service/IWorkspaceElementService.java delete mode 100644 src/main/java/com/dji/sample/map/service/impl/GroupElementServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/map/service/impl/GroupServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/map/service/impl/WorkspaceElementServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java delete mode 100644 src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java delete mode 100644 src/main/java/com/dji/sdk/README.md delete mode 100644 src/main/java/com/dji/sdk/cloudapi/control/ControlMethodEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/control/FlyToPointRequest.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/control/PayloadControlMethodEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointProgress.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointRequest.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/control/api/AbstractControlService.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/debug/DebugMethodEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/debug/api/AbstractDebugService.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/CameraModeEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/DockDronePayload.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/DockPayload.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/DockWpmzVersion.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenanceInfo.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/DroneModeCodeEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/FlighttaskStepCodeEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/ModeCodeReasonEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/OsdCamera.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/OsdDock.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/OsdDockDrone.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/PayloadModelConst.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/RcFirmwareVersion.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/device/api/AbstractDeviceService.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateRequest.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/livestream/LiveStartPushRequest.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityCamera.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityDevice.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityVideo.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/livestream/UrlTypeEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/log/FileUploadListRequest.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartFile.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartParam.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateRequest.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/map/ElementContent.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/map/ElementCoordinate.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/map/ElementGeometryType.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/map/ElementLineStringGeometry.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/map/ElementPointGeometry.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/map/ElementPolygonGeometry.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/map/ElementResourceTypeEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/map/GetMapElementsResponse.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/map/GroupTypeEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/media/UploadFlighttaskMediaPrioritize.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusResponse.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindResponse.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/property/PropertySetEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/property/api/AbstractPropertyService.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/storage/CredentialsToken.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/tsa/TopologyList.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/tsa/TopologyResponse.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/wayline/BreakpointStateEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/wayline/ExecutionStepEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHActionEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHReasonEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakReasonEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskExecuteRequest.java delete mode 100755 src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskPrepareRequest.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressExt.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskUndoRequest.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListRequest.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListResponse.java delete mode 100755 src/main/java/com/dji/sdk/cloudapi/wayline/ReadyConditions.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/wayline/RthModeEnum.java delete mode 100644 src/main/java/com/dji/sdk/cloudapi/wayline/api/AbstractWaylineService.java delete mode 100644 src/main/java/com/dji/sdk/common/Pagination.java delete mode 100644 src/main/java/com/dji/sdk/config/GetSnakeDataBinder.java delete mode 100644 src/main/java/com/dji/sdk/config/version/CloudSDKVersionEnum.java delete mode 100644 src/main/java/com/dji/sdk/config/version/DockThingVersionEnum.java delete mode 100644 src/main/java/com/dji/sdk/config/version/DroneThingVersionEnum.java delete mode 100644 src/main/java/com/dji/sdk/mqtt/ChannelName.java delete mode 100644 src/main/java/com/dji/sdk/mqtt/MqttGatewayPublish.java delete mode 100644 src/main/java/com/dji/sdk/mqtt/MqttReplyHandler.java delete mode 100644 src/main/java/com/dji/sdk/mqtt/events/EventsMethodEnum.java delete mode 100644 src/main/java/com/dji/sdk/mqtt/requests/RequestsMethodEnum.java delete mode 100644 src/main/java/com/dji/sdk/mqtt/state/DockStateDataKeyEnum.java delete mode 100644 src/main/java/com/dji/sdk/mqtt/state/RcStateDataKeyEnum.java delete mode 100644 src/main/java/com/dji/sdk/mqtt/state/StateDataKeyEnum.java delete mode 100644 src/main/java/com/dji/sdk/mqtt/state/StateRouter.java delete mode 100644 src/main/java/com/dji/sdk/mqtt/state/TopicStateRequest.java delete mode 100644 src/main/resources/application.yml diff --git a/README.md b/README.md index 79abe85..27b59c7 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ For more documentation, please visit the [DJI Developer Documentation](https://d ## Latest Release -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/). +Cloud API 1.8.0 was released on 22 Feb 2024. For more information, please visit the [Release Note](https://developer.dji.com/doc/cloud-api-tutorial/cn/). ## License diff --git a/api/Cloud API Demo.postman_collection.json b/api/Cloud API Demo.postman_collection.json index 6bfd878..0129ef9 100644 --- a/api/Cloud API Demo.postman_collection.json +++ b/api/Cloud API Demo.postman_collection.json @@ -1050,6 +1050,150 @@ } }, "response": [] + }, + { + "name": "Get Flight Areas", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}{{map_version}}/workspaces/{{workspace_id}}/flight-areas", + "host": [ + "{{base_url}}{{map_version}}" + ], + "path": [ + "workspaces", + "{{workspace_id}}", + "flight-areas" + ] + } + }, + "response": [] + }, + { + "name": "Add Flight Area", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"name\": \"123\",\r\n \"type\": \"dfence\",\r\n \"content\": {\r\n \"properties\": {\r\n \"clampToGround\": true,\r\n \"color\": \"#FF0000\"\r\n },\r\n \"geometry\": {\r\n \"type\": \"Circle\",\r\n \"coordinates\": [\r\n 25.41512807678825,\r\n 4.642350757553345\r\n ],\r\n \"radius\": 12.2\r\n }\r\n }\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{base_url}}{{map_version}}/workspaces/{{workspace_id}}/flight-area", + "host": [ + "{{base_url}}{{map_version}}" + ], + "path": [ + "workspaces", + "{{workspace_id}}", + "flight-area" + ] + } + }, + "response": [] + }, + { + "name": "Update Flight Area", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"name\": \"123\",\r\n \"status\": false,\r\n \"content\": {\r\n \"properties\": {\r\n \"clampToGround\": true,\r\n \"color\": \"#FF0000\"\r\n },\r\n \"geometry\": {\r\n \"type\": \"Circle\",\r\n \"coordinates\": [\r\n 25.41512807678825,\r\n 4.642350757553345\r\n ],\r\n \"radius\": 12.2\r\n }\r\n }\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{base_url}}{{map_version}}/workspaces/{{workspace_id}}/flight-area/{{area_id}}", + "host": [ + "{{base_url}}{{map_version}}" + ], + "path": [ + "workspaces", + "{{workspace_id}}", + "flight-area", + "{{area_id}}" + ] + } + }, + "response": [] + }, + { + "name": "Delete Flight Area", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{base_url}}{{map_version}}/workspaces/{{workspace_id}}/flight-area/{{area_id}}", + "host": [ + "{{base_url}}{{map_version}}" + ], + "path": [ + "workspaces", + "{{workspace_id}}", + "flight-area", + "{{area_id}}" + ] + } + }, + "response": [] + }, + { + "name": "Sync Device Flight Area", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"device_sn\": [\"123\"]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{base_url}}{{map_version}}/workspaces/{{workspace_id}}/flight-area/sync", + "host": [ + "{{base_url}}{{map_version}}" + ], + "path": [ + "workspaces", + "{{workspace_id}}", + "flight-area", + "sync" + ] + } + }, + "response": [] + }, + { + "name": "Device Flight Area Status", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}{{map_version}}/workspaces/{{workspace_id}}/device-status", + "host": [ + "{{base_url}}{{map_version}}" + ], + "path": [ + "workspaces", + "{{workspace_id}}", + "device-status" + ] + } + }, + "response": [] } ], "auth": { @@ -1411,7 +1555,7 @@ "method": "DELETE", "header": [], "url": { - "raw": "{{base_url}}{{wayline_version}}/workspaces/{{workspace_id}}/favorites?ids=uuid,uuid1", + "raw": "{{base_url}}{{wayline_version}}/workspaces/{{workspace_id}}/favorites?id=uuid,uuid1", "host": [ "{{base_url}}{{wayline_version}}" ], @@ -1422,7 +1566,7 @@ ], "query": [ { - "key": "ids", + "key": "id", "value": "uuid,uuid1" } ] @@ -1436,7 +1580,7 @@ "method": "POST", "header": [], "url": { - "raw": "{{base_url}}{{wayline_version}}/workspaces/{{workspace_id}}/favorites?ids=uuid,uuid1", + "raw": "{{base_url}}{{wayline_version}}/workspaces/{{workspace_id}}/favorites?id=uuid,uuid1", "host": [ "{{base_url}}{{wayline_version}}" ], @@ -1447,7 +1591,7 @@ ], "query": [ { - "key": "ids", + "key": "id", "value": "uuid,uuid1" } ] diff --git a/cloud-sdk/README.md b/cloud-sdk/README.md new file mode 100644 index 0000000..f2f7aa5 --- /dev/null +++ b/cloud-sdk/README.md @@ -0,0 +1,48 @@ +# 如何接入CloudSDK +### 1. 在组件扫描中增加包名:com.dji.sdk +### [2. 连接MQTT](#如何连接MQTT) +### [3. 实现SDK 的方法](#如何实现SDK的方法) +### [4. 调用SDK 的方法](#如何调用SDK的方法) + + +## 如何连接MQTT +- 在spring容器中注入MqttConnectOptions和MqttPahoClientFactory; + ![1](./image/6.png) + +- 在application.yml中配置cloud-sdk.mqtt.inbound-topic,未配置则不进行初始化订阅。 + + +## 如何实现SDK的方法 + - 定义一个类,继承com.dji.sdk.cloudapi.*.api包中的抽象类; + - 重写具体的方法以实现功能; + - 将定义的类放入spring容器中,由spring管理bean的生命周期。 +### 【设备上线】示例: + - 定义一个类:SDKDeviceService 继承AbstractDeviceService; +![1](./image/1.png) + - 重写方法updateTopoOnline,实现设备上线功能。 +![1](./image/2.png) + +## 如何调用SDK的方法 + - 定义一个类,继承com.dji.sdk.cloudapi.*.api包中的抽象类; + - 在需要调用的类中注入该类; + - 调用具体的方法。 +### 【航线预下发命令】示例: + - 定义一个类:SDKWaylineService 继承 AbstractWaylineService; +![1](./image/3.png) + - 在WaylineJobServiceImpl中注入该类; +![1](./image/4.png) + - 调用下发命令的方法: +![1](./image/5.png) + +## 如何实现CloudAPI 定义的http 接口 + - 定义一个类,实现com.dji.sdk.cloudapi.*.api包中的http接口类; + - 重写具体的方法以实现接口,无需定义请求地址和方法等数据。 + ![1](./image/7.png) + +## 如何查看CloudAPI 定义的所有http 接口 + - 启动程序 + - 浏览器打开:http://localhost:6789/swagger-ui/index.html + +## 如何接入WebSocket + - CloudSDK 已经定义了WebSocket服务,但是没有实现WebSocket管理。默认地址为:http://localhost:6789/api/v1/ws + - 自定义接入参考:com.dji.sample.component.websocket.config \ No newline at end of file diff --git a/src/main/resources/image/1.png b/cloud-sdk/image/1.png similarity index 100% rename from src/main/resources/image/1.png rename to cloud-sdk/image/1.png diff --git a/src/main/resources/image/2.png b/cloud-sdk/image/2.png similarity index 100% rename from src/main/resources/image/2.png rename to cloud-sdk/image/2.png diff --git a/src/main/resources/image/3.png b/cloud-sdk/image/3.png similarity index 100% rename from src/main/resources/image/3.png rename to cloud-sdk/image/3.png diff --git a/src/main/resources/image/4.png b/cloud-sdk/image/4.png similarity index 100% rename from src/main/resources/image/4.png rename to cloud-sdk/image/4.png diff --git a/src/main/resources/image/5.png b/cloud-sdk/image/5.png similarity index 100% rename from src/main/resources/image/5.png rename to cloud-sdk/image/5.png diff --git a/src/main/resources/image/6.png b/cloud-sdk/image/6.png similarity index 100% rename from src/main/resources/image/6.png rename to cloud-sdk/image/6.png diff --git a/src/main/resources/image/7.png b/cloud-sdk/image/7.png similarity index 100% rename from src/main/resources/image/7.png rename to cloud-sdk/image/7.png diff --git a/cloud-sdk/pom.xml b/cloud-sdk/pom.xml new file mode 100644 index 0000000..93cd140 --- /dev/null +++ b/cloud-sdk/pom.xml @@ -0,0 +1,32 @@ + + + + cloud-api-sample + com.dji + ${revision} + + 4.0.0 + + cloud-sdk + ${cloud-sdk.revision} + + + + org.springdoc + springdoc-openapi-ui + 1.7.0 + + + + org.springframework.boot + spring-boot-starter-aop + + + + org.springframework.boot + spring-boot-starter-websocket + + + \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/annotations/CloudSDKVersion.java b/cloud-sdk/src/main/java/com/dji/sdk/annotations/CloudSDKVersion.java similarity index 100% rename from src/main/java/com/dji/sdk/annotations/CloudSDKVersion.java rename to cloud-sdk/src/main/java/com/dji/sdk/annotations/CloudSDKVersion.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/AirsenseWarning.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/AirsenseWarning.java new file mode 100644 index 0000000..a86d1f8 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/AirsenseWarning.java @@ -0,0 +1,178 @@ +package com.dji.sdk.cloudapi.airsense; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/16 + */ +public class AirsenseWarning { + + /** + * ICAO civil aviation aircraft address + */ + private String icao; + + /** + * The higher the danger level, the more dangerous it is. + * For levels greater than or equal to 3, it is recommended for aircraft to take evasive action. + */ + private WarningLevelEnum warningLevel; + + /** + * The latitude of aircraft location is angular values. + * Negative values for south latitude and positive values for north latitude. + * It is accurate to six decimal places. + */ + private Float latitude; + + /** + * The longitude of aircraft location is angular values. + * Negative values for west longitude and positive values for east longitude. + * It is accurate to six decimal places. + */ + private Float longitude; + + /** + * Absolute height of flight. + * Unit: meter + */ + private Integer altitude; + + /** + * Absolute height type + */ + private AltitudeTypeEnum altitudeType; + + /** + * The angle of heading is angular values. + * 0 is north. 90 is east. + * It is accurate to one decimal places. + */ + private Float heading; + + /** + * Relative height of flight to aircraft. + * Unit: meter + */ + private Integer relativeAltitude; + + /** + * Relative height change trend + */ + private VertTrendEnum vertTrend; + + /** + * Horizontal distance to aircraft. + * Unit: meter + */ + private Integer distance; + + public AirsenseWarning() { + } + + @Override + public String toString() { + return "AirsenseWarning{" + + "icao='" + icao + '\'' + + ", warningLevel=" + warningLevel + + ", latitude=" + latitude + + ", longitude=" + longitude + + ", altitude=" + altitude + + ", altitudeType=" + altitudeType + + ", heading=" + heading + + ", relativeAltitude=" + relativeAltitude + + ", vertTrend=" + vertTrend + + ", distance=" + distance + + '}'; + } + + public String getIcao() { + return icao; + } + + public AirsenseWarning setIcao(String icao) { + this.icao = icao; + return this; + } + + public WarningLevelEnum getWarningLevel() { + return warningLevel; + } + + public AirsenseWarning setWarningLevel(WarningLevelEnum warningLevel) { + this.warningLevel = warningLevel; + return this; + } + + public Float getLatitude() { + return latitude; + } + + public AirsenseWarning setLatitude(Float latitude) { + this.latitude = latitude; + return this; + } + + public Float getLongitude() { + return longitude; + } + + public AirsenseWarning setLongitude(Float longitude) { + this.longitude = longitude; + return this; + } + + public Integer getAltitude() { + return altitude; + } + + public AirsenseWarning setAltitude(Integer altitude) { + this.altitude = altitude; + return this; + } + + public AltitudeTypeEnum getAltitudeType() { + return altitudeType; + } + + public AirsenseWarning setAltitudeType(AltitudeTypeEnum altitudeType) { + this.altitudeType = altitudeType; + return this; + } + + public Float getHeading() { + return heading; + } + + public AirsenseWarning setHeading(Float heading) { + this.heading = heading; + return this; + } + + public Integer getRelativeAltitude() { + return relativeAltitude; + } + + public AirsenseWarning setRelativeAltitude(Integer relativeAltitude) { + this.relativeAltitude = relativeAltitude; + return this; + } + + public VertTrendEnum getVertTrend() { + return vertTrend; + } + + public AirsenseWarning setVertTrend(VertTrendEnum vertTrend) { + this.vertTrend = vertTrend; + return this; + } + + public Integer getDistance() { + return distance; + } + + public AirsenseWarning setDistance(Integer distance) { + this.distance = distance; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/AltitudeTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/AltitudeTypeEnum.java new file mode 100644 index 0000000..e5f109a --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/AltitudeTypeEnum.java @@ -0,0 +1,39 @@ +package com.dji.sdk.cloudapi.airsense; + +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 + * @date 2023/10/16 + */ +public enum AltitudeTypeEnum { + + ELLIPSOID_HEIGHT(0), + + ABOVE_SEA_LEVEL(1), + + ; + + private final int type; + + AltitudeTypeEnum(int type) { + this.type = type; + } + + @JsonValue + public int getType() { + return type; + } + + @JsonCreator + public static AltitudeTypeEnum find(int type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny() + .orElseThrow(() -> new CloudSDKException(AltitudeTypeEnum.class, type)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/VertTrendEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/VertTrendEnum.java new file mode 100644 index 0000000..b2dacb7 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/VertTrendEnum.java @@ -0,0 +1,41 @@ +package com.dji.sdk.cloudapi.airsense; + +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 + * @date 2023/10/16 + */ +public enum VertTrendEnum { + + RELATIVE_HEIGHT_UNCHANGED(0), + + RELATIVE_HEIGHT_INCREASE(1), + + RELATIVE_HEIGHT_DECREASE(2), + + ; + + private final int trend; + + VertTrendEnum(int trend) { + this.trend = trend; + } + + @JsonValue + public int getTrend() { + return trend; + } + + @JsonCreator + public static VertTrendEnum find(int trend) { + return Arrays.stream(values()).filter(trendEnum -> trendEnum.trend == trend).findAny() + .orElseThrow(() -> new CloudSDKException(VertTrendEnum.class, trend)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/WarningLevelEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/WarningLevelEnum.java new file mode 100644 index 0000000..d266c20 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/WarningLevelEnum.java @@ -0,0 +1,45 @@ +package com.dji.sdk.cloudapi.airsense; + +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 + * @date 2023/10/16 + */ +public enum WarningLevelEnum { + + ZERO(0), + + ONE(1), + + TWO(2), + + THREE(3), + + FOUR(4), + + ; + + private final int level; + + WarningLevelEnum(int level) { + this.level = level; + } + + @JsonValue + public int getLevel() { + return level; + } + + @JsonCreator + public static WarningLevelEnum find(int level) { + return Arrays.stream(values()).filter(levelEnum -> levelEnum.level == level).findAny() + .orElseThrow(() -> new CloudSDKException(WarningLevelEnum.class, level)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/api/AbstractAirsenseService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/api/AbstractAirsenseService.java new file mode 100644 index 0000000..8a75ce1 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/airsense/api/AbstractAirsenseService.java @@ -0,0 +1,36 @@ +package com.dji.sdk.cloudapi.airsense.api; + +import com.dji.sdk.annotations.CloudSDKVersion; +import com.dji.sdk.cloudapi.airsense.AirsenseWarning; +import com.dji.sdk.config.version.CloudSDKVersionEnum; +import com.dji.sdk.mqtt.ChannelName; +import com.dji.sdk.mqtt.MqttReply; +import com.dji.sdk.mqtt.events.TopicEventsRequest; +import com.dji.sdk.mqtt.events.TopicEventsResponse; +import org.springframework.integration.annotation.ServiceActivator; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageHeaders; + +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/16 + */ +public abstract class AbstractAirsenseService { + + + /** + * cloud-custom data transmit from psdk + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_AIRSENSE_WARNING, outputChannel = ChannelName.OUTBOUND_EVENTS) + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + public TopicEventsResponse airsenseWarning(TopicEventsRequest> request, MessageHeaders headers) { + throw new UnsupportedOperationException("airsenseWarning not implemented"); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/config/ConfigScopeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/config/ConfigScopeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/config/ConfigScopeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/config/ConfigScopeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/config/ConfigTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/config/ConfigTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/config/ConfigTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/config/ConfigTypeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/config/ProductConfigResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/config/ProductConfigResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/config/ProductConfigResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/config/ProductConfigResponse.java diff --git a/src/main/java/com/dji/sdk/cloudapi/config/RequestsConfigRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/config/RequestsConfigRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/config/RequestsConfigRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/config/RequestsConfigRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/config/api/AbstractConfigService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/config/api/AbstractConfigService.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/config/api/AbstractConfigService.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/config/api/AbstractConfigService.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/CameraAimRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraAimRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/CameraAimRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraAimRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraExposureModeSetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraExposureModeSetRequest.java new file mode 100644 index 0000000..6c8e6ec --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraExposureModeSetRequest.java @@ -0,0 +1,68 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class CameraExposureModeSetRequest extends BaseModel { + + /** + * Camera enumeration. + * It is unofficial device_mode_key. + * The format is *{type-subtype-gimbalindex}*. + * Please read [Product Supported](https://developer.dji.com/doc/cloud-api-tutorial/en/overview/product-support.html) + */ + @NotNull + private PayloadIndex payloadIndex; + + @NotNull + private ExposureCameraTypeEnum cameraType; + + @NotNull + private ExposureModeEnum exposureMode; + + public CameraExposureModeSetRequest() { + } + + @Override + public String toString() { + return "CameraExposureModeSetRequest{" + + "payloadIndex=" + payloadIndex + + ", cameraType=" + cameraType + + ", exposureMode=" + exposureMode + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public CameraExposureModeSetRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public ExposureCameraTypeEnum getCameraType() { + return cameraType; + } + + public CameraExposureModeSetRequest setCameraType(ExposureCameraTypeEnum cameraType) { + this.cameraType = cameraType; + return this; + } + + public ExposureModeEnum getExposureMode() { + return exposureMode; + } + + public CameraExposureModeSetRequest setExposureMode(ExposureModeEnum exposureMode) { + this.exposureMode = exposureMode; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraExposureSetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraExposureSetRequest.java new file mode 100644 index 0000000..a6bc91b --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraExposureSetRequest.java @@ -0,0 +1,68 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class CameraExposureSetRequest extends BaseModel { + + /** + * Camera enumeration. + * It is unofficial device_mode_key. + * The format is *{type-subtype-gimbalindex}*. + * Please read [Product Supported](https://developer.dji.com/doc/cloud-api-tutorial/en/overview/product-support.html) + */ + @NotNull + private PayloadIndex payloadIndex; + + @NotNull + private ExposureCameraTypeEnum cameraType; + + @NotNull + private ExposureValueEnum exposureValue; + + public CameraExposureSetRequest() { + } + + @Override + public String toString() { + return "CameraExposureSetRequest{" + + "payloadIndex=" + payloadIndex + + ", cameraType=" + cameraType + + ", exposureValue=" + exposureValue + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public CameraExposureSetRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public ExposureCameraTypeEnum getCameraType() { + return cameraType; + } + + public CameraExposureSetRequest setCameraType(ExposureCameraTypeEnum cameraType) { + this.cameraType = cameraType; + return this; + } + + public ExposureValueEnum getExposureValue() { + return exposureValue; + } + + public CameraExposureSetRequest setExposureValue(ExposureValueEnum exposureValue) { + this.exposureValue = exposureValue; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/CameraFocalLengthSetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraFocalLengthSetRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/CameraFocalLengthSetRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraFocalLengthSetRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraFocusModeSetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraFocusModeSetRequest.java new file mode 100644 index 0000000..845e6b5 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraFocusModeSetRequest.java @@ -0,0 +1,68 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class CameraFocusModeSetRequest extends BaseModel { + + /** + * Camera enumeration. + * It is unofficial device_mode_key. + * The format is *{type-subtype-gimbalindex}*. + * Please read [Product Supported](https://developer.dji.com/doc/cloud-api-tutorial/en/overview/product-support.html) + */ + @NotNull + private PayloadIndex payloadIndex; + + @NotNull + private ExposureCameraTypeEnum cameraType; + + @NotNull + private FocusModeEnum focusMode; + + public CameraFocusModeSetRequest() { + } + + @Override + public String toString() { + return "CameraFocusModeSetRequest{" + + "payloadIndex=" + payloadIndex + + ", cameraType=" + cameraType + + ", focusMode=" + focusMode + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public CameraFocusModeSetRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public ExposureCameraTypeEnum getCameraType() { + return cameraType; + } + + public CameraFocusModeSetRequest setCameraType(ExposureCameraTypeEnum cameraType) { + this.cameraType = cameraType; + return this; + } + + public FocusModeEnum getFocusMode() { + return focusMode; + } + + public CameraFocusModeSetRequest setFocusMode(FocusModeEnum focusMode) { + this.focusMode = focusMode; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraFocusValueSetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraFocusValueSetRequest.java new file mode 100644 index 0000000..f137367 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraFocusValueSetRequest.java @@ -0,0 +1,68 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class CameraFocusValueSetRequest extends BaseModel { + + /** + * Camera enumeration. + * It is unofficial device_mode_key. + * The format is *{type-subtype-gimbalindex}*. + * Please read [Product Supported](https://developer.dji.com/doc/cloud-api-tutorial/en/overview/product-support.html) + */ + @NotNull + private PayloadIndex payloadIndex; + + @NotNull + private ExposureCameraTypeEnum cameraType; + + @NotNull + private Integer focusValue; + + public CameraFocusValueSetRequest() { + } + + @Override + public String toString() { + return "CameraFocusValueSetRequest{" + + "payloadIndex=" + payloadIndex + + ", cameraType=" + cameraType + + ", focusValue=" + focusValue + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public CameraFocusValueSetRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public ExposureCameraTypeEnum getCameraType() { + return cameraType; + } + + public CameraFocusValueSetRequest setCameraType(ExposureCameraTypeEnum cameraType) { + this.cameraType = cameraType; + return this; + } + + public Integer getFocusValue() { + return focusValue; + } + + public CameraFocusValueSetRequest setFocusValue(Integer focusValue) { + this.focusValue = focusValue; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraLookAtRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraLookAtRequest.java new file mode 100644 index 0000000..634c48b --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraLookAtRequest.java @@ -0,0 +1,98 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/12 + */ +public class CameraLookAtRequest extends BaseModel { + + /** + * Camera enumeration. + * It is unofficial device_mode_key. + * The format is *{type-subtype-gimbalindex}*. + * Please read [Product Supported](https://developer.dji.com/doc/cloud-api-tutorial/en/overview/product-support.html) + */ + @NotNull + private PayloadIndex payloadIndex; + + /** + * Whether the relative location of drone head and gimbal is locked + */ + @NotNull + private Boolean locked; + + /** + * The latitude of target point is angular values. + * Negative values for south latitude and positive values for north latitude. + * It is accurate to six decimal places. + */ + @Min(-90) + @Max(90) + @NotNull + private Float latitude; + + /** + * The latitude of target point is angular values. + * Negative values for west longitude and positive values for east longitude. + * It is accurate to six decimal places. + */ + @NotNull + @Min(-180) + @Max(180) + private Float longitude; + + /** + * Ellipsoid height + */ + @NotNull + @Min(2) + @Max(10000) + private Float height; + + public CameraLookAtRequest() { + } + + @Override + public String toString() { + return "CameraLookAtRequest{" + + "payloadIndex=" + payloadIndex + + ", locked=" + locked + + ", latitude=" + latitude + + ", longitude=" + longitude + + ", height=" + height + + '}'; + } + + public CameraLookAtRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public CameraLookAtRequest setLocked(Boolean locked) { + this.locked = locked; + return this; + } + + public CameraLookAtRequest setLatitude(Float latitude) { + this.latitude = latitude; + return this; + } + + public CameraLookAtRequest setLongitude(Float longitude) { + this.longitude = longitude; + return this; + } + + public CameraLookAtRequest setHeight(Float height) { + this.height = height; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/CameraModeSwitchRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraModeSwitchRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/CameraModeSwitchRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraModeSwitchRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPhotoStopRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPhotoStopRequest.java new file mode 100644 index 0000000..a20ae8a --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPhotoStopRequest.java @@ -0,0 +1,36 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class CameraPhotoStopRequest extends BaseModel { + + @NotNull + private PayloadIndex payloadIndex; + + public CameraPhotoStopRequest() { + } + + @Override + public String toString() { + return "CameraPhotoStopRequest{" + + "payloadIndex=" + payloadIndex + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public CameraPhotoStopRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPhotoTakeProgress.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPhotoTakeProgress.java new file mode 100644 index 0000000..7d87907 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPhotoTakeProgress.java @@ -0,0 +1,56 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.wayline.FlighttaskStatusEnum; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class CameraPhotoTakeProgress { + + private PhotoTakeProgressExt ext; + + private PhotoTakeProgressData progress; + + private FlighttaskStatusEnum status; + + public CameraPhotoTakeProgress() { + } + + @Override + public String toString() { + return "CameraPhotoTakeProgress{" + + "ext=" + ext + + ", progress=" + progress + + ", status=" + status + + '}'; + } + + public PhotoTakeProgressExt getExt() { + return ext; + } + + public CameraPhotoTakeProgress setExt(PhotoTakeProgressExt ext) { + this.ext = ext; + return this; + } + + public PhotoTakeProgressData getProgress() { + return progress; + } + + public CameraPhotoTakeProgress setProgress(PhotoTakeProgressData progress) { + this.progress = progress; + return this; + } + + public FlighttaskStatusEnum getStatus() { + return status; + } + + public CameraPhotoTakeProgress setStatus(FlighttaskStatusEnum status) { + this.status = status; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/CameraPhotoTakeRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPhotoTakeRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/CameraPhotoTakeRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPhotoTakeRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPointFocusActionRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPointFocusActionRequest.java new file mode 100644 index 0000000..2b3b27c --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraPointFocusActionRequest.java @@ -0,0 +1,93 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class CameraPointFocusActionRequest extends BaseModel { + + /** + * Camera enumeration. + * It is unofficial device_mode_key. + * The format is *{type-subtype-gimbalindex}*. + * Please read [Product Supported](https://developer.dji.com/doc/cloud-api-tutorial/en/overview/product-support.html) + */ + @NotNull + private PayloadIndex payloadIndex; + + @NotNull + private ExposureCameraTypeEnum cameraType; + + /** + * The coordinate x of the temperature measurement point is the upper left corner of the lens as the coordinate center point, and the horizontal direction is x. + */ + @NotNull + @Min(0) + @Max(1) + private Float x; + + /** + * The coordinate y of the temperature measurement point is the upper left corner of the lens as the coordinate center point, and the vertical direction is y. + */ + @NotNull + @Min(0) + @Max(1) + private Float y; + + public CameraPointFocusActionRequest() { + } + + @Override + public String toString() { + return "CameraPointFocusActionRequest{" + + "payloadIndex=" + payloadIndex + + ", cameraType=" + cameraType + + ", x=" + x + + ", y=" + y + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public CameraPointFocusActionRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public ExposureCameraTypeEnum getCameraType() { + return cameraType; + } + + public CameraPointFocusActionRequest setCameraType(ExposureCameraTypeEnum cameraType) { + this.cameraType = cameraType; + return this; + } + + public Float getX() { + return x; + } + + public CameraPointFocusActionRequest setX(Float x) { + this.x = x; + return this; + } + + public Float getY() { + return y; + } + + public CameraPointFocusActionRequest setY(Float y) { + this.y = y; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/CameraRecordingStartRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraRecordingStartRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/CameraRecordingStartRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraRecordingStartRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/CameraRecordingStopRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraRecordingStopRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/CameraRecordingStopRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraRecordingStopRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraScreenSplitRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraScreenSplitRequest.java new file mode 100644 index 0000000..cbc49e4 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraScreenSplitRequest.java @@ -0,0 +1,58 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/12 + */ +public class CameraScreenSplitRequest extends BaseModel { + + /** + * Camera enumeration. + * It is unofficial device_mode_key. + * The format is *{type-subtype-gimbalindex}*. + * Please read [Product Supported](https://developer.dji.com/doc/cloud-api-tutorial/en/overview/product-support.html) + */ + @NotNull + private PayloadIndex payloadIndex; + + /** + * Whether enable the screen split + */ + @NotNull + private Boolean enable; + + public CameraScreenSplitRequest() { + } + + @Override + public String toString() { + return "CameraScreenSplitRequest{" + + "payloadIndex=" + payloadIndex + + ", enable=" + enable + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public CameraScreenSplitRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public Boolean getEnable() { + return enable; + } + + public CameraScreenSplitRequest setEnable(Boolean enable) { + this.enable = enable; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/CameraTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/CameraTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CameraTypeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/CommanderFlightModeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CommanderFlightModeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/CommanderFlightModeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CommanderFlightModeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/CommanderModeLostActionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CommanderModeLostActionEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/CommanderModeLostActionEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/CommanderModeLostActionEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/ControlErrorCodeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ControlErrorCodeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/ControlErrorCodeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ControlErrorCodeEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ControlMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ControlMethodEnum.java new file mode 100644 index 0000000..4f870ab --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ControlMethodEnum.java @@ -0,0 +1,90 @@ +package com.dji.sdk.cloudapi.control; + +/** + * @author sean + * @version 1.4 + * @date 2023/3/2 + */ +public enum ControlMethodEnum { + + FLIGHT_AUTHORITY_GRAB("flight_authority_grab"), + + PAYLOAD_AUTHORITY_GRAB("payload_authority_grab"), + + DRC_MODE_ENTER("drc_mode_enter"), + + DRC_MODE_EXIT("drc_mode_exit"), + + FLY_TO_POINT("fly_to_point"), + + FLY_TO_POINT_STOP("fly_to_point_stop"), + + FLY_TO_POINT_UPDATE("fly_to_point_update"), + + TAKEOFF_TO_POINT("takeoff_to_point"), + + CAMERA_MODE_SWITCH("camera_mode_switch"), + + CAMERA_PHOTO_TAKE("camera_photo_take"), + + CAMERA_PHOTO_STOP("camera_photo_stop"), + + CAMERA_RECORDING_START("camera_recording_start"), + + CAMERA_RECORDING_STOP("camera_recording_stop"), + + CAMERA_AIM("camera_aim"), + + CAMERA_FOCAL_LENGTH_SET("camera_focal_length_set"), + + GIMBAL_RESET("gimbal_reset"), + + CAMERA_LOOK_AT("camera_look_at"), + + CAMERA_SCREEN_SPLIT("camera_screen_split"), + + PHOTO_STORAGE_SET("photo_storage_set"), + + VIDEO_STORAGE_SET("video_storage_set"), + + CAMERA_EXPOSURE_SET("camera_exposure_set"), + + CAMERA_EXPOSURE_MODE_SET("camera_exposure_mode_set"), + + CAMERA_FOCUS_MODE_SET("camera_focus_mode_set"), + + CAMERA_FOCUS_VALUE_SET("camera_focus_value_set"), + + IR_METERING_MODE_SET("ir_metering_mode_set"), + + IR_METERING_POINT_SET("ir_metering_point_set"), + + IR_METERING_AREA_SET("ir_metering_area_set"), + + CAMERA_POINT_FOCUS_ACTION("camera_point_focus_action"), + + DRONE_CONTROL("drone_control"), + + DRONE_EMERGENCY_STOP("drone_emergency_stop"), + + HEART_BEAT("heart_beat"), + + POI_MODE_ENTER("poi_mode_enter"), + + POI_MODE_EXIT("poi_mode_exit"), + + POI_CIRCLE_SPEED_SET("poi_circle_speed_set"), + + ; + + private final String method; + + ControlMethodEnum(String method) { + this.method = method; + } + + public String getMethod() { + return method; + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/DelayInfoPush.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DelayInfoPush.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/DelayInfoPush.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DelayInfoPush.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/DrcModeEnterRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DrcModeEnterRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/DrcModeEnterRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DrcModeEnterRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/DrcModeMqttBroker.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DrcModeMqttBroker.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/DrcModeMqttBroker.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DrcModeMqttBroker.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/DrcStatusErrorEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DrcStatusErrorEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/DrcStatusErrorEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DrcStatusErrorEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/DrcStatusNotify.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DrcStatusNotify.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/DrcStatusNotify.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DrcStatusNotify.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/DroneControlRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DroneControlRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/DroneControlRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DroneControlRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/DroneControlResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DroneControlResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/DroneControlResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/DroneControlResponse.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ExposureCameraTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ExposureCameraTypeEnum.java new file mode 100644 index 0000000..81233ef --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ExposureCameraTypeEnum.java @@ -0,0 +1,36 @@ +package com.dji.sdk.cloudapi.control; + +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.9 + * @date 2023/12/12 + */ +public enum ExposureCameraTypeEnum { + + ZOOM("zoom"), + + WIDE("wide"); + + private final String type; + + ExposureCameraTypeEnum(String type) { + this.type = type; + } + + @JsonValue + public String getType() { + return type; + } + + @JsonCreator + public static ExposureCameraTypeEnum find(String type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type.equals(type)).findAny() + .orElseThrow(() -> new CloudSDKException(ExposureCameraTypeEnum.class, type)); + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ExposureModeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ExposureModeEnum.java new file mode 100644 index 0000000..6861a2e --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ExposureModeEnum.java @@ -0,0 +1,44 @@ +package com.dji.sdk.cloudapi.control; + +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.9 + * @date 2023/12/12 + */ +public enum ExposureModeEnum { + + AUTO(1), + + SHUTTER_PRIORITY(2), + + APERTURE_PRIORITY(3), + + MANUAL(4), + + ; + + + private final int mode; + + ExposureModeEnum(int mode) { + this.mode = mode; + } + + @JsonValue + public int getMode() { + return mode; + } + + @JsonCreator + public static ExposureModeEnum find(int mode) { + return Arrays.stream(values()).filter(modeEnum -> modeEnum.mode == mode).findAny() + .orElseThrow(() -> new CloudSDKException(ExposureModeEnum.class, mode)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ExposureValueEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ExposureValueEnum.java new file mode 100644 index 0000000..aa3961b --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ExposureValueEnum.java @@ -0,0 +1,107 @@ +package com.dji.sdk.cloudapi.control; + +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.9 + * @date 2023/12/12 + */ +public enum ExposureValueEnum { + + MINUS_5_DOT_0(1, "-5.0EV"), + + MINUS_4_DOT_7(2, "-4.7EV"), + + MINUS_4_DOT_3(3, "-4.3EV"), + + MINUS_4_DOT_0(4, "-4.0EV"), + + MINUS_3_DOT_7(5, "-3.7EV"), + + MINUS_3_DOT_3(6, "-3.3EV"), + + MINUS_3_DOT_0(7, "-3.0EV"), + + MINUS_2_DOT_7(8, "-2.7EV"), + + MINUS_2_DOT_3(9, "-2.3EV"), + + MINUS_2_DOT_0(10, "-2.0EV"), + + MINUS_1_DOT_7(11, "-1.7EV"), + + MINUS_1_DOT_3(12, "-1.3EV"), + + MINUS_1_DOT_0(13, "-1.0EV"), + + MINUS_0_DOT_7(14, "-0.7EV"), + + MINUS_0_DOT_3(15, "-0.3EV"), + + _0(16, "0EV"), + + _0_DOT_3(17, "0.3EV"), + + _0_DOT_7(18, "0.7EV"), + + _1_DOT_0(19, "1.0EV"), + + _1_DOT_3(20, "1.3EV"), + + _1_DOT_7(21, "1.7EV"), + + _2_DOT_0(22, "2.0EV"), + + _2_DOT_3(23, "2.3EV"), + + _2_DOT_7(24, "2.7EV"), + + _3_DOT_0(25, "3.0EV"), + + _3_DOT_3(26, "3.3EV"), + + _3_DOT_7(27, "3.7EV"), + + _4_DOT_0(28, "4.0EV"), + + _4_DOT_3(29, "4.3EV"), + + _4_DOT_7(30, "4.7EV"), + + _5_DOT_0(31, "5.0EV"), + + FIXED(255, "FIXED"), + + ; + + + private final int value; + + private final String desc; + + ExposureValueEnum(int value, String desc) { + this.value = value; + this.desc = desc; + } + + @JsonValue + public int getValue() { + return value; + } + + public String getDesc() { + return desc; + } + + @JsonCreator + public static ExposureValueEnum find(int value) { + return Arrays.stream(values()).filter(valueEnum -> valueEnum.value == value).findAny() + .orElseThrow(() -> new CloudSDKException(ExposureValueEnum.class, value)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointProgress.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointProgress.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/FlyToPointProgress.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointProgress.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointRequest.java new file mode 100644 index 0000000..81c99d4 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointRequest.java @@ -0,0 +1,70 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; + +/** + * @author sean + * @version 1.3 + * @date 2023/2/14 + */ +public class FlyToPointRequest extends BaseModel { + + @Pattern(regexp = "^[^<>:\"/|?*._\\\\]+$") + @NotNull + private String flyToId; + + @Min(1) + @Max(15) + @NotNull + private Integer maxSpeed; + + /** + * The M30 series only support one point. + */ + @Size(min = 1) + @NotNull + private List<@Valid Point> points; + + public FlyToPointRequest() { + } + + @Override + public String toString() { + return "FlyToPointRequest{" + + "flyToId='" + flyToId + '\'' + + ", maxSpeed=" + maxSpeed + + ", points=" + points + + '}'; + } + + public String getFlyToId() { + return flyToId; + } + + public FlyToPointRequest setFlyToId(String flyToId) { + this.flyToId = flyToId; + return this; + } + + public Integer getMaxSpeed() { + return maxSpeed; + } + + public FlyToPointRequest setMaxSpeed(Integer maxSpeed) { + this.maxSpeed = maxSpeed; + return this; + } + + public List getPoints() { + return points; + } + + public FlyToPointRequest setPoints(List points) { + this.points = points; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointUpdateRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointUpdateRequest.java new file mode 100644 index 0000000..3bbb205 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointUpdateRequest.java @@ -0,0 +1,59 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.Valid; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class FlyToPointUpdateRequest extends BaseModel { + + @Min(1) + @Max(15) + @NotNull + private Integer maxSpeed; + + /** + * The M30 series only support one point. + */ + @Size(min = 1, max = 1) + @NotNull + private List<@Valid Point> points; + + public FlyToPointUpdateRequest() { + } + + @Override + public String toString() { + return "FlyToPointUpdateRequest{" + + "maxSpeed=" + maxSpeed + + ", points=" + points + + '}'; + } + + public Integer getMaxSpeed() { + return maxSpeed; + } + + public FlyToPointUpdateRequest setMaxSpeed(Integer maxSpeed) { + this.maxSpeed = maxSpeed; + return this; + } + + public List getPoints() { + return points; + } + + public FlyToPointUpdateRequest setPoints(List points) { + this.points = points; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/FlyToStatusEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FlyToStatusEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/FlyToStatusEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FlyToStatusEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FocusModeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FocusModeEnum.java new file mode 100644 index 0000000..aed4427 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/FocusModeEnum.java @@ -0,0 +1,40 @@ +package com.dji.sdk.cloudapi.control; + +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.9 + * @date 2023/12/12 + */ +public enum FocusModeEnum { + + MF(0), + + AFS(1), + + AFC(2), + + ; + private final int mode; + + FocusModeEnum(int mode) { + this.mode = mode; + } + + @JsonValue + public int getMode() { + return mode; + } + + @JsonCreator + public static FocusModeEnum find(int mode) { + return Arrays.stream(values()).filter(modeEnum -> modeEnum.mode == mode).findAny() + .orElseThrow(() -> new CloudSDKException(FocusModeEnum.class, mode)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/GimbalResetModeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/GimbalResetModeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/GimbalResetModeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/GimbalResetModeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/GimbalResetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/GimbalResetRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/GimbalResetRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/GimbalResetRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/HeartBeatRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/HeartBeatRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/HeartBeatRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/HeartBeatRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/HsiInfoPush.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/HsiInfoPush.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/HsiInfoPush.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/HsiInfoPush.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/IrMeteringAreaSetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/IrMeteringAreaSetRequest.java new file mode 100644 index 0000000..6d8ad5d --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/IrMeteringAreaSetRequest.java @@ -0,0 +1,116 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class IrMeteringAreaSetRequest extends BaseModel { + + /** + * Camera enumeration. + * It is unofficial device_mode_key. + * The format is *{type-subtype-gimbalindex}*. + * Please read [Product Supported](https://developer.dji.com/doc/cloud-api-tutorial/en/overview/product-support.html) + */ + @NotNull + private PayloadIndex payloadIndex; + + /** + * The coordinate x of the temperature measurement point is the upper left corner of the lens as the coordinate center point, and the horizontal direction is x. + */ + @NotNull + @Min(0) + @Max(1) + private Float x; + + /** + * The coordinate y of the temperature measurement point is the upper left corner of the lens as the coordinate center point, and the vertical direction is y. + */ + @NotNull + @Min(0) + @Max(1) + private Float y; + + /** + * Temperature measurement area width + */ + @NotNull + @Min(0) + @Max(1) + private Float width; + + /** + * Temperature measurement area height + */ + @NotNull + @Min(0) + @Max(1) + private Float height; + + public IrMeteringAreaSetRequest() { + } + + @Override + public String toString() { + return "IrMeteringAreaSetRequest{" + + "payloadIndex=" + payloadIndex + + ", x=" + x + + ", y=" + y + + ", width=" + width + + ", height=" + height + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public IrMeteringAreaSetRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public Float getX() { + return x; + } + + public IrMeteringAreaSetRequest setX(Float x) { + this.x = x; + return this; + } + + public Float getY() { + return y; + } + + public IrMeteringAreaSetRequest setY(Float y) { + this.y = y; + return this; + } + + public Float getWidth() { + return width; + } + + public IrMeteringAreaSetRequest setWidth(Float width) { + this.width = width; + return this; + } + + public Float getHeight() { + return height; + } + + public IrMeteringAreaSetRequest setHeight(Float height) { + this.height = height; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/IrMeteringModeSetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/IrMeteringModeSetRequest.java new file mode 100644 index 0000000..6510068 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/IrMeteringModeSetRequest.java @@ -0,0 +1,55 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class IrMeteringModeSetRequest extends BaseModel { + + /** + * Camera enumeration. + * It is unofficial device_mode_key. + * The format is *{type-subtype-gimbalindex}*. + * Please read [Product Supported](https://developer.dji.com/doc/cloud-api-tutorial/en/overview/product-support.html) + */ + @NotNull + private PayloadIndex payloadIndex; + + @NotNull + private MeteringModeEnum mode; + + public IrMeteringModeSetRequest() { + } + + @Override + public String toString() { + return "IrMeteringModeSetRequest{" + + "payloadIndex=" + payloadIndex + + ", mode=" + mode + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public IrMeteringModeSetRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public MeteringModeEnum getMode() { + return mode; + } + + public IrMeteringModeSetRequest setMode(MeteringModeEnum mode) { + this.mode = mode; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/IrMeteringPointSetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/IrMeteringPointSetRequest.java new file mode 100644 index 0000000..f2bc6d5 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/IrMeteringPointSetRequest.java @@ -0,0 +1,80 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class IrMeteringPointSetRequest extends BaseModel { + + /** + * Camera enumeration. + * It is unofficial device_mode_key. + * The format is *{type-subtype-gimbalindex}*. + * Please read [Product Supported](https://developer.dji.com/doc/cloud-api-tutorial/en/overview/product-support.html) + */ + @NotNull + private PayloadIndex payloadIndex; + + /** + * The coordinate x of the temperature measurement point is the upper left corner of the lens as the coordinate center point, and the horizontal direction is x. + */ + @NotNull + @Min(0) + @Max(1) + private Float x; + + /** + * The coordinate y of the temperature measurement point is the upper left corner of the lens as the coordinate center point, and the vertical direction is y. + */ + @NotNull + @Min(0) + @Max(1) + private Float y; + + public IrMeteringPointSetRequest() { + } + + @Override + public String toString() { + return "IrMeteringPointSetRequest{" + + "payloadIndex=" + payloadIndex + + ", x=" + x + + ", y=" + y + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public IrMeteringPointSetRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public Float getX() { + return x; + } + + public IrMeteringPointSetRequest setX(Float x) { + this.x = x; + return this; + } + + public Float getY() { + return y; + } + + public IrMeteringPointSetRequest setY(Float y) { + this.y = y; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/JoystickInvalidNotify.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/JoystickInvalidNotify.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/JoystickInvalidNotify.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/JoystickInvalidNotify.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/JoystickInvalidReasonEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/JoystickInvalidReasonEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/JoystickInvalidReasonEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/JoystickInvalidReasonEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/LensStorageSettingsEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/LensStorageSettingsEnum.java new file mode 100644 index 0000000..869c5ea --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/LensStorageSettingsEnum.java @@ -0,0 +1,40 @@ +package com.dji.sdk.cloudapi.control; + +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 + * @date 2023/10/12 + */ +public enum LensStorageSettingsEnum { + + CURRENT("current"), + + ZOOM("zoom"), + + WIDE("wide"), + + INFRARED("ir"); + + private final String lens; + + LensStorageSettingsEnum(String lens) { + this.lens = lens; + } + + @JsonValue + public String getLens() { + return lens; + } + + @JsonCreator + public static LensStorageSettingsEnum find(String lens) { + return Arrays.stream(values()).filter(lensEnum -> lensEnum.lens.equals(lens)).findAny() + .orElseThrow(() -> new CloudSDKException(LensStorageSettingsEnum.class, lens)); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/LiveviewDelay.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/LiveviewDelay.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/LiveviewDelay.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/LiveviewDelay.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/MeteringModeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/MeteringModeEnum.java new file mode 100644 index 0000000..57c690f --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/MeteringModeEnum.java @@ -0,0 +1,41 @@ +package com.dji.sdk.cloudapi.control; + +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.9 + * @date 2023/12/12 + */ +public enum MeteringModeEnum { + + DISABLE(0), + + SPOT(1), + + AREA(2), + + ; + + private final int mode; + + MeteringModeEnum(int mode) { + this.mode = mode; + } + + @JsonValue + public int getMode() { + return mode; + } + + @JsonCreator + public static MeteringModeEnum find(int mode) { + return Arrays.stream(values()).filter(modeEnum -> modeEnum.mode == mode).findAny() + .orElseThrow(() -> new CloudSDKException(MeteringModeEnum.class, mode)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/OsdInfoPush.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/OsdInfoPush.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/OsdInfoPush.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/OsdInfoPush.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/PayloadAuthorityGrabRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PayloadAuthorityGrabRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/PayloadAuthorityGrabRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PayloadAuthorityGrabRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PayloadControlMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PayloadControlMethodEnum.java new file mode 100644 index 0000000..7f23ea4 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PayloadControlMethodEnum.java @@ -0,0 +1,78 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.common.BaseModel; +import com.dji.sdk.exception.CloudSDKException; + +import java.util.Arrays; + +/** + * @author sean + * @version 1.4 + * @date 2023/3/2 + */ +public enum PayloadControlMethodEnum { + + CAMERA_MODE_SWITCH(ControlMethodEnum.CAMERA_MODE_SWITCH, CameraModeSwitchRequest.class), + + CAMERA_PHOTO_TAKE(ControlMethodEnum.CAMERA_PHOTO_TAKE, CameraPhotoTakeRequest.class), + + CAMERA_PHOTO_STOP(ControlMethodEnum.CAMERA_PHOTO_STOP, CameraPhotoStopRequest.class), + + CAMERA_RECORDING_START(ControlMethodEnum.CAMERA_RECORDING_START, CameraRecordingStartRequest.class), + + CAMERA_RECORDING_STOP(ControlMethodEnum.CAMERA_RECORDING_STOP, CameraRecordingStopRequest.class), + + CAMERA_AIM(ControlMethodEnum.CAMERA_AIM, CameraAimRequest.class), + + CAMERA_FOCAL_LENGTH_SET(ControlMethodEnum.CAMERA_FOCAL_LENGTH_SET, CameraFocalLengthSetRequest.class), + + GIMBAL_RESET(ControlMethodEnum.GIMBAL_RESET, GimbalResetRequest.class), + + CAMERA_LOOK_AT(ControlMethodEnum.CAMERA_LOOK_AT, CameraLookAtRequest.class), + + CAMERA_SCREEN_SPLIT(ControlMethodEnum.CAMERA_SCREEN_SPLIT, CameraScreenSplitRequest.class), + + PHOTO_STORAGE_SET(ControlMethodEnum.PHOTO_STORAGE_SET, PhotoStorageSetRequest.class), + + VIDEO_STORAGE_SET(ControlMethodEnum.VIDEO_STORAGE_SET, VideoStorageSetRequest.class), + + CAMERA_EXPOSURE_SET(ControlMethodEnum.CAMERA_EXPOSURE_SET, CameraExposureSetRequest.class), + + CAMERA_EXPOSURE_MODE_SET(ControlMethodEnum.CAMERA_EXPOSURE_MODE_SET, CameraExposureModeSetRequest.class), + + CAMERA_FOCUS_MODE_SET(ControlMethodEnum.CAMERA_FOCUS_MODE_SET, CameraFocusModeSetRequest.class), + + CAMERA_FOCUS_VALUE_SET(ControlMethodEnum.CAMERA_FOCUS_VALUE_SET, CameraFocusValueSetRequest.class), + + IR_METERING_MODE_SET(ControlMethodEnum.IR_METERING_MODE_SET, IrMeteringModeSetRequest.class), + + IR_METERING_POINT_SET(ControlMethodEnum.IR_METERING_POINT_SET, IrMeteringPointSetRequest.class), + + IR_METERING_AREA_SET(ControlMethodEnum.IR_METERING_AREA_SET, IrMeteringAreaSetRequest.class), + + CAMERA_POINT_FOCUS_ACTION(ControlMethodEnum.CAMERA_POINT_FOCUS_ACTION, CameraPointFocusActionRequest.class), + + ; + + private final ControlMethodEnum payloadMethod; + + private final Class clazz; + + PayloadControlMethodEnum(ControlMethodEnum payloadMethod, Class clazz) { + this.payloadMethod = payloadMethod; + this.clazz = clazz; + } + + public ControlMethodEnum getPayloadMethod() { + return payloadMethod; + } + + public Class getClazz() { + return clazz; + } + + public static PayloadControlMethodEnum find(String method) { + return Arrays.stream(values()).filter(methodEnum -> methodEnum.payloadMethod.getMethod().equals(method)).findAny() + .orElseThrow(() -> new CloudSDKException(PayloadControlMethodEnum.class, method)); + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoStorageSetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoStorageSetRequest.java new file mode 100644 index 0000000..fc546ab --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoStorageSetRequest.java @@ -0,0 +1,61 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/12 + */ +public class PhotoStorageSetRequest extends BaseModel { + + /** + * Camera enumeration. + * It is unofficial device_mode_key. + * The format is *{type-subtype-gimbalindex}*. + * Please read [Product Supported](https://developer.dji.com/doc/cloud-api-tutorial/en/overview/product-support.html) + */ + @NotNull + private PayloadIndex payloadIndex; + + /** + * Photo storage type. Multi-selection. + */ + @NotNull + @Size(min = 1) + private List photoStorageSettings; + + public PhotoStorageSetRequest() { + } + + @Override + public String toString() { + return "PhotoStorageSetRequest{" + + "payloadIndex=" + payloadIndex + + ", photoStorageSettings=" + photoStorageSettings + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public PhotoStorageSetRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public List getPhotoStorageSettings() { + return photoStorageSettings; + } + + public PhotoStorageSetRequest setPhotoStorageSettings(List photoStorageSettings) { + this.photoStorageSettings = photoStorageSettings; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoTakeProgressData.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoTakeProgressData.java new file mode 100644 index 0000000..56476ca --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoTakeProgressData.java @@ -0,0 +1,42 @@ +package com.dji.sdk.cloudapi.control; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class PhotoTakeProgressData { + + private PhotoTakeProgressStepEnum currentStep; + + private Integer percent; + + public PhotoTakeProgressData() { + } + + @Override + public String toString() { + return "PhotoTakeProgressData{" + + "currentStep=" + currentStep + + ", percent=" + percent + + '}'; + } + + public PhotoTakeProgressStepEnum getCurrentStep() { + return currentStep; + } + + public PhotoTakeProgressData setCurrentStep(PhotoTakeProgressStepEnum currentStep) { + this.currentStep = currentStep; + return this; + } + + public Integer getPercent() { + return percent; + } + + public PhotoTakeProgressData setPercent(Integer percent) { + this.percent = percent; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoTakeProgressExt.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoTakeProgressExt.java new file mode 100644 index 0000000..18963b4 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoTakeProgressExt.java @@ -0,0 +1,32 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.CameraModeEnum; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class PhotoTakeProgressExt { + + private CameraModeEnum cameraMode; + + public PhotoTakeProgressExt() { + } + + @Override + public String toString() { + return "PhotoTakeProgressExt{" + + "cameraMode=" + cameraMode + + '}'; + } + + public CameraModeEnum getCameraMode() { + return cameraMode; + } + + public PhotoTakeProgressExt setCameraMode(CameraModeEnum cameraMode) { + this.cameraMode = cameraMode; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoTakeProgressStepEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoTakeProgressStepEnum.java new file mode 100644 index 0000000..d3dcc02 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PhotoTakeProgressStepEnum.java @@ -0,0 +1,43 @@ +package com.dji.sdk.cloudapi.control; + +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.9 + * @date 2023/12/12 + */ +public enum PhotoTakeProgressStepEnum { + + NORMAL(0), + + PANORAMA_NOT_STARTED_OR_ENDED(3000), + + PANORAMA_TAKING(3002), + + PANORAMA_COMPOSITING(3005), + + ; + + private final int step; + + PhotoTakeProgressStepEnum(int step) { + this.step = step; + } + + @JsonValue + public int getStep() { + return step; + } + + @JsonCreator + public static PhotoTakeProgressStepEnum find(int step) { + return Arrays.stream(values()).filter(stepEnum -> stepEnum.step == step).findAny() + .orElseThrow(() -> new CloudSDKException(PhotoTakeProgressStepEnum.class, step)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiCircleSpeedSetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiCircleSpeedSetRequest.java new file mode 100644 index 0000000..9898b20 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiCircleSpeedSetRequest.java @@ -0,0 +1,35 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class PoiCircleSpeedSetRequest extends BaseModel { + + @NotNull + private Float circleSpeed; + + public PoiCircleSpeedSetRequest() { + } + + @Override + public String toString() { + return "PoiCircleSpeedSetRequest{" + + "circleSpeed=" + circleSpeed + + '}'; + } + + public Float getCircleSpeed() { + return circleSpeed; + } + + public PoiCircleSpeedSetRequest setCircleSpeed(Float circleSpeed) { + this.circleSpeed = circleSpeed; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiModeEnterRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiModeEnterRequest.java new file mode 100644 index 0000000..e950483 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiModeEnterRequest.java @@ -0,0 +1,69 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class PoiModeEnterRequest extends BaseModel { + + @Min(-90) + @Max(90) + @NotNull + private Float latitude; + + @NotNull + @Min(-180) + @Max(180) + private Float longitude; + + @NotNull + @Min(2) + @Max(10000) + private Float height; + + public PoiModeEnterRequest() { + } + + @Override + public String toString() { + return "PoiModeEnterRequest{" + + "latitude=" + latitude + + ", longitude=" + longitude + + ", height=" + height + + '}'; + } + + public Float getLatitude() { + return latitude; + } + + public PoiModeEnterRequest setLatitude(Float latitude) { + this.latitude = latitude; + return this; + } + + public Float getLongitude() { + return longitude; + } + + public PoiModeEnterRequest setLongitude(Float longitude) { + this.longitude = longitude; + return this; + } + + public Float getHeight() { + return height; + } + + public PoiModeEnterRequest setHeight(Float height) { + this.height = height; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiStatusNotify.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiStatusNotify.java new file mode 100644 index 0000000..c0154b1 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiStatusNotify.java @@ -0,0 +1,80 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.wayline.FlighttaskStatusEnum; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class PoiStatusNotify { + + private FlighttaskStatusEnum status; + + private PoiStatusReasonEnum reason; + + private Float circleRadius; + + private Float circleSpeed; + + private Float maxCircleSpeed; + + public PoiStatusNotify() { + } + + @Override + public String toString() { + return "PoiStatusNotify{" + + "status=" + status + + ", reason=" + reason + + ", circleRadius=" + circleRadius + + ", circleSpeed=" + circleSpeed + + ", maxCircleSpeed=" + maxCircleSpeed + + '}'; + } + + public FlighttaskStatusEnum getStatus() { + return status; + } + + public PoiStatusNotify setStatus(FlighttaskStatusEnum status) { + this.status = status; + return this; + } + + public PoiStatusReasonEnum getReason() { + return reason; + } + + public PoiStatusNotify setReason(PoiStatusReasonEnum reason) { + this.reason = reason; + return this; + } + + public Float getCircleRadius() { + return circleRadius; + } + + public PoiStatusNotify setCircleRadius(Float circleRadius) { + this.circleRadius = circleRadius; + return this; + } + + public Float getCircleSpeed() { + return circleSpeed; + } + + public PoiStatusNotify setCircleSpeed(Float circleSpeed) { + this.circleSpeed = circleSpeed; + return this; + } + + public Float getMaxCircleSpeed() { + return maxCircleSpeed; + } + + public PoiStatusNotify setMaxCircleSpeed(Float maxCircleSpeed) { + this.maxCircleSpeed = maxCircleSpeed; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiStatusReasonEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiStatusReasonEnum.java new file mode 100644 index 0000000..35432df --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/PoiStatusReasonEnum.java @@ -0,0 +1,53 @@ +package com.dji.sdk.cloudapi.control; + +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.9 + * @date 2023/12/12 + */ +public enum PoiStatusReasonEnum { + + NORMAL(0), + + UNADAPTED_PAYLOAD(1), + + CAMERA_MODE_NOT_SUPPORTED(2), + + ILLEGAL_CMD(3), + + POSITIONING_FAILED(4), + + ON_THE_GROUND(5), + + DRONE_MODE_ERROR(6), + + NOT_AVAILABLE_MODE(7), + + RC_DISCONNECTED(8), + + ; + + private final int reason; + + PoiStatusReasonEnum(int reason) { + this.reason = reason; + } + + @JsonValue + public int getReason() { + return reason; + } + + @JsonCreator + public static PoiStatusReasonEnum find(int reason) { + return Arrays.stream(values()).filter(reasonEnum -> reasonEnum.reason == reason).findAny() + .orElseThrow(() -> new CloudSDKException(PoiStatusReasonEnum.class, reason)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/Point.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/Point.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/Point.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/Point.java diff --git a/src/main/java/com/dji/sdk/cloudapi/control/TakeoffStatusEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/TakeoffStatusEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/TakeoffStatusEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/TakeoffStatusEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointProgress.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointProgress.java new file mode 100644 index 0000000..50b7042 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointProgress.java @@ -0,0 +1,135 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.annotations.CloudSDKVersion; +import com.dji.sdk.cloudapi.wayline.WaylineErrorCodeEnum; +import com.dji.sdk.config.version.CloudSDKVersionEnum; + +import java.util.List; + +/** + * @author sean + * @version 1.4 + * @date 2023/3/14 + */ +public class TakeoffToPointProgress { + + private WaylineErrorCodeEnum result; + + private TakeoffStatusEnum status; + + private String flightId; + + private String trackId; + + private Integer wayPointIndex; + + /** + * Remaining mission distance + * unit: m + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + private Float remainingDistance; + + /** + * Remaining mission time + * unit: s + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + private Integer remainingTime; + + /** + * Planned trajectory point list + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + private List plannedPathPoints; + + + public TakeoffToPointProgress() { + } + + @Override + public String toString() { + return "TakeoffToPointProgress{" + + "result=" + result + + ", status=" + status + + ", flightId='" + flightId + '\'' + + ", trackId='" + trackId + '\'' + + ", wayPointIndex=" + wayPointIndex + + ", remainingDistance=" + remainingDistance + + ", remainingTime=" + remainingTime + + ", plannedPathPoints=" + plannedPathPoints + + '}'; + } + + public WaylineErrorCodeEnum getResult() { + return result; + } + + public TakeoffToPointProgress setResult(WaylineErrorCodeEnum result) { + this.result = result; + return this; + } + + public TakeoffStatusEnum getStatus() { + return status; + } + + public TakeoffToPointProgress setStatus(TakeoffStatusEnum status) { + this.status = status; + return this; + } + + public String getFlightId() { + return flightId; + } + + public TakeoffToPointProgress setFlightId(String flightId) { + this.flightId = flightId; + return this; + } + + public String getTrackId() { + return trackId; + } + + public TakeoffToPointProgress setTrackId(String trackId) { + this.trackId = trackId; + return this; + } + + public Integer getWayPointIndex() { + return wayPointIndex; + } + + public TakeoffToPointProgress setWayPointIndex(Integer wayPointIndex) { + this.wayPointIndex = wayPointIndex; + return this; + } + + public Float getRemainingDistance() { + return remainingDistance; + } + + public TakeoffToPointProgress setRemainingDistance(Float remainingDistance) { + this.remainingDistance = remainingDistance; + return this; + } + + public Integer getRemainingTime() { + return remainingTime; + } + + public TakeoffToPointProgress setRemainingTime(Integer remainingTime) { + this.remainingTime = remainingTime; + return this; + } + + public List getPlannedPathPoints() { + return plannedPathPoints; + } + + public TakeoffToPointProgress setPlannedPathPoints(List plannedPathPoints) { + this.plannedPathPoints = plannedPathPoints; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointRequest.java new file mode 100644 index 0000000..f5a1692 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointRequest.java @@ -0,0 +1,235 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.annotations.CloudSDKVersion; +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.cloudapi.wayline.SimulateMission; +import com.dji.sdk.common.BaseModel; +import com.dji.sdk.config.version.CloudSDKVersionEnum; + +import javax.validation.Valid; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +/** + * @author sean + * @version 1.4 + * @date 2023/3/1 + */ +public class TakeoffToPointRequest extends BaseModel { + + @Pattern(regexp = "^[^<>:\"/|?*._\\\\]+$") + @NotNull + private String flightId; + + @Min(-180) + @Max(180) + @NotNull + private Float targetLongitude; + + @Min(-90) + @Max(90) + @NotNull + private Float targetLatitude; + + @Min(2) + @Max(10000) + @NotNull + private Float targetHeight; + + @Min(20) + @Max(1500) + @NotNull + private Float securityTakeoffHeight; + + @Min(2) + @Max(1500) + @NotNull + private Float rthAltitude; + + @NotNull + private RcLostActionEnum rcLostAction; + + @NotNull + @CloudSDKVersion(deprecated = CloudSDKVersionEnum.V1_0_0) + private ExitWaylineWhenRcLostEnum exitWaylineWhenRcLost; + + @Min(1) + @Max(15) + @NotNull + private Integer maxSpeed; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + @NotNull + private RthModeEnum rthMode; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + @NotNull + private CommanderModeLostActionEnum commanderModeLostAction; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + @NotNull + private CommanderFlightModeEnum commanderFlightMode; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + @NotNull + @Min(2) + @Max(3000) + private Float commanderFlightHeight; + + @Valid + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + private SimulateMission simulateMission; + + public TakeoffToPointRequest() { + } + + @Override + public String toString() { + return "TakeoffToPointRequest{" + + "flightId='" + flightId + '\'' + + ", targetLongitude=" + targetLongitude + + ", targetLatitude=" + targetLatitude + + ", targetHeight=" + targetHeight + + ", securityTakeoffHeight=" + securityTakeoffHeight + + ", rthAltitude=" + rthAltitude + + ", rcLostAction=" + rcLostAction + + ", exitWaylineWhenRcLost=" + exitWaylineWhenRcLost + + ", maxSpeed=" + maxSpeed + + ", rthMode=" + rthMode + + ", commanderModeLostAction=" + commanderModeLostAction + + ", commanderFlightMode=" + commanderFlightMode + + ", commanderFlightHeight=" + commanderFlightHeight + + ", simulateMission=" + simulateMission + + '}'; + } + + public String getFlightId() { + return flightId; + } + + public TakeoffToPointRequest setFlightId(String flightId) { + this.flightId = flightId; + return this; + } + + public Float getTargetLongitude() { + return targetLongitude; + } + + public TakeoffToPointRequest setTargetLongitude(Float targetLongitude) { + this.targetLongitude = targetLongitude; + return this; + } + + public Float getTargetLatitude() { + return targetLatitude; + } + + public TakeoffToPointRequest setTargetLatitude(Float targetLatitude) { + this.targetLatitude = targetLatitude; + return this; + } + + public Float getTargetHeight() { + return targetHeight; + } + + public TakeoffToPointRequest setTargetHeight(Float targetHeight) { + this.targetHeight = targetHeight; + return this; + } + + public Float getSecurityTakeoffHeight() { + return securityTakeoffHeight; + } + + public TakeoffToPointRequest setSecurityTakeoffHeight(Float securityTakeoffHeight) { + this.securityTakeoffHeight = securityTakeoffHeight; + return this; + } + + public Float getRthAltitude() { + return rthAltitude; + } + + public TakeoffToPointRequest setRthAltitude(Float rthAltitude) { + this.rthAltitude = rthAltitude; + return this; + } + + public RcLostActionEnum getRcLostAction() { + return rcLostAction; + } + + public TakeoffToPointRequest setRcLostAction(RcLostActionEnum rcLostAction) { + this.rcLostAction = rcLostAction; + return this; + } + + public ExitWaylineWhenRcLostEnum getExitWaylineWhenRcLost() { + return exitWaylineWhenRcLost; + } + + public TakeoffToPointRequest setExitWaylineWhenRcLost(ExitWaylineWhenRcLostEnum exitWaylineWhenRcLost) { + this.exitWaylineWhenRcLost = exitWaylineWhenRcLost; + return this; + } + + public Integer getMaxSpeed() { + return maxSpeed; + } + + public RthModeEnum getRthMode() { + return rthMode; + } + + public TakeoffToPointRequest setRthMode(RthModeEnum rthMode) { + this.rthMode = rthMode; + return this; + } + + public CommanderModeLostActionEnum getCommanderModeLostAction() { + return commanderModeLostAction; + } + + public TakeoffToPointRequest setCommanderModeLostAction(CommanderModeLostActionEnum commanderModeLostAction) { + this.commanderModeLostAction = commanderModeLostAction; + return this; + } + + public CommanderFlightModeEnum getCommanderFlightMode() { + return commanderFlightMode; + } + + public TakeoffToPointRequest setCommanderFlightMode(CommanderFlightModeEnum commanderFlightMode) { + this.commanderFlightMode = commanderFlightMode; + return this; + } + + public Float getCommanderFlightHeight() { + return commanderFlightHeight; + } + + public TakeoffToPointRequest setCommanderFlightHeight(Float commanderFlightHeight) { + this.commanderFlightHeight = commanderFlightHeight; + return this; + } + + public TakeoffToPointRequest setMaxSpeed(Integer maxSpeed) { + this.maxSpeed = maxSpeed; + return this; + } + + public SimulateMission getSimulateMission() { + return simulateMission; + } + + public TakeoffToPointRequest setSimulateMission(SimulateMission simulateMission) { + this.simulateMission = simulateMission; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/VideoStorageSetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/VideoStorageSetRequest.java new file mode 100644 index 0000000..eaba3e1 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/VideoStorageSetRequest.java @@ -0,0 +1,61 @@ +package com.dji.sdk.cloudapi.control; + +import com.dji.sdk.cloudapi.device.PayloadIndex; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/12 + */ +public class VideoStorageSetRequest extends BaseModel { + + /** + * Camera enumeration. + * It is unofficial device_mode_key. + * The format is *{type-subtype-gimbalindex}*. + * Please read [Product Supported](https://developer.dji.com/doc/cloud-api-tutorial/en/overview/product-support.html) + */ + @NotNull + private PayloadIndex payloadIndex; + + /** + * Video storage type. Multi-selection. + */ + @NotNull + @Size(min = 1) + private List videoStorageSettings; + + public VideoStorageSetRequest() { + } + + @Override + public String toString() { + return "VideoStorageSetRequest{" + + "payloadIndex=" + payloadIndex + + ", videoStorageSettings=" + videoStorageSettings + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public VideoStorageSetRequest setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public List getVideoStorageSettings() { + return videoStorageSettings; + } + + public VideoStorageSetRequest setVideoStorageSettings(List videoStorageSettings) { + this.videoStorageSettings = videoStorageSettings; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/ZoomCameraTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ZoomCameraTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/control/ZoomCameraTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/ZoomCameraTypeEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/api/AbstractControlService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/api/AbstractControlService.java new file mode 100644 index 0000000..e409615 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/control/api/AbstractControlService.java @@ -0,0 +1,665 @@ +package com.dji.sdk.cloudapi.control.api; + +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.SpringBeanUtils; +import com.dji.sdk.config.version.CloudSDKVersionEnum; +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; +import com.dji.sdk.mqtt.drc.DrcDownPublish; +import com.dji.sdk.mqtt.drc.DrcUpData; +import com.dji.sdk.mqtt.drc.TopicDrcRequest; +import com.dji.sdk.mqtt.events.EventsDataRequest; +import com.dji.sdk.mqtt.events.TopicEventsRequest; +import com.dji.sdk.mqtt.events.TopicEventsResponse; +import com.dji.sdk.mqtt.services.ServicesPublish; +import com.dji.sdk.mqtt.services.ServicesReplyData; +import com.dji.sdk.mqtt.services.TopicServicesResponse; +import org.springframework.integration.annotation.ServiceActivator; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageHeaders; + +import javax.annotation.Resource; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/29 + */ +public abstract class AbstractControlService { + + @Resource + private ServicesPublish servicesPublish; + + @Resource + private DrcDownPublish drcDownPublish; + + /** + * Event notification of flyto result + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_FLY_TO_POINT_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS) + public TopicEventsResponse flyToPointProgress(TopicEventsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("flyToPointProgress not implemented"); + } + + /** + * Event notification of one-key taking off result + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_TAKEOFF_TO_POINT_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS) + public TopicEventsResponse takeoffToPointProgress(TopicEventsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("takeoffToPointProgress not implemented"); + } + + /** + * Notification of DRC link state + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_DRC_STATUS_NOTIFY, outputChannel = ChannelName.OUTBOUND_EVENTS) + public TopicEventsResponse drcStatusNotify(TopicEventsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("drcStatusNotify not implemented"); + } + + /** + * Reason notification of invalid Joystick control + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_JOYSTICK_INVALID_NOTIFY, outputChannel = ChannelName.OUTBOUND_EVENTS) + public TopicEventsResponse joystickInvalidNotify(TopicEventsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("joystickInvalidNotify not implemented"); + } + + /** + * Flight control authority grabbing + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse flightAuthorityGrab(GatewayManager gateway) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.FLIGHT_AUTHORITY_GRAB.getMethod()); + } + + /** + * Payload control authority grabbing + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse payloadAuthorityGrab(GatewayManager gateway, PayloadAuthorityGrabRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.PAYLOAD_AUTHORITY_GRAB.getMethod(), + request); + } + + /** + * Enter the live flight controls mode + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse drcModeEnter(GatewayManager gateway, DrcModeEnterRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.DRC_MODE_ENTER.getMethod(), + request); + } + + /** + * Exit the live flight controls mode + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse drcModeExit(GatewayManager gateway) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.DRC_MODE_EXIT.getMethod()); + } + + /** + * One-key taking off + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse takeoffToPoint(GatewayManager gateway, TakeoffToPointRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.TAKEOFF_TO_POINT.getMethod(), + request); + } + + /** + * flyto target point + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse flyToPoint(GatewayManager gateway, FlyToPointRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.FLY_TO_POINT.getMethod(), + request); + } + + /** + * Quickly update target points + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, exclude = GatewayTypeEnum.RC, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse flyToPointUpdate(GatewayManager gateway, FlyToPointUpdateRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.FLY_TO_POINT_UPDATE.getMethod(), + request); + } + + /** + * End the task of flying to target point + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse flyToPointStop(GatewayManager gateway) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.FLY_TO_POINT_STOP.getMethod()); + } + + /** + * Payload control - switch the camera mode + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse cameraModeSwitch(GatewayManager gateway, CameraModeSwitchRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_MODE_SWITCH.getMethod(), + request); + } + + /** + * Payload control - take single photo + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse cameraPhotoTake(GatewayManager gateway, CameraPhotoTakeRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_PHOTO_TAKE.getMethod(), + request); + } + + /** + * Payload control - stop taking photo + * Currently only panoramic photo mode is supported. + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, exclude = GatewayTypeEnum.RC, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse cameraPhotoStop(GatewayManager gateway, CameraPhotoStopRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_PHOTO_STOP.getMethod(), + request); + } + + /** + * Event notification of camera photo progress information + * Currently only panoramic photo mode is supported. + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_CAMERA_PHOTO_TAKE_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS) + public TopicEventsResponse cameraPhotoTakeProgress(TopicEventsRequest> request, MessageHeaders headers) { + throw new UnsupportedOperationException("cameraPhotoTakeProgress not implemented"); + } + + /** + * Payload control - start recording + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse cameraRecordingStart(GatewayManager gateway, CameraRecordingStartRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_RECORDING_START.getMethod(), + request); + } + + /** + * Payload control - stop recording + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse cameraRecordingStop(GatewayManager gateway, CameraRecordingStopRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_RECORDING_STOP.getMethod(), + request); + } + + /** + * Payload control - double tab to become AIM + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse cameraAim(GatewayManager gateway, CameraAimRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_AIM.getMethod(), + request); + } + + /** + * Payload control - zoom + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse cameraFocalLengthSet(GatewayManager gateway, CameraFocalLengthSetRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_FOCAL_LENGTH_SET.getMethod(), + request); + } + + /** + * Payload control - reset the gimbal + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse gimbalReset(GatewayManager gateway, GimbalResetRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.GIMBAL_RESET.getMethod(), + request); + } + + /** + * The `lookat` function refers to the aircraft turning itself from its current heading to point at a specified location of actual latitude, longitude, and altitude. + * For M30/M30T models, it is recommended to use a method that locks the gimbal when using the `lookat` function. + * When the gimbal reaches its limits, the `lookat` function may behave abnormally. + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0, exclude = GatewayTypeEnum.RC) + public TopicServicesResponse cameraLookAt(GatewayManager gateway, CameraLookAtRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_LOOK_AT.getMethod(), + request); + } + + /** + * Payload control - screen split + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0, exclude = GatewayTypeEnum.RC) + public TopicServicesResponse cameraScreenSplit(GatewayManager gateway, CameraScreenSplitRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_SCREEN_SPLIT.getMethod(), + request); + } + + /** + * Payload control - photo storage setting + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0, exclude = GatewayTypeEnum.RC) + public TopicServicesResponse photoStorageSet(GatewayManager gateway, PhotoStorageSetRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.PHOTO_STORAGE_SET.getMethod(), + request); + } + + /** + * Payload control - video storage setting + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0, exclude = GatewayTypeEnum.RC) + public TopicServicesResponse videoStorageSet(GatewayManager gateway, VideoStorageSetRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.VIDEO_STORAGE_SET.getMethod(), + request); + } + + /** + * Payload control - camera exposure setting + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse cameraExposureSet(GatewayManager gateway, CameraExposureSetRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_EXPOSURE_SET.getMethod(), + request); + } + + /** + * Payload control - camera exposure mode setting + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse cameraExposureModeSet(GatewayManager gateway, CameraExposureModeSetRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_EXPOSURE_MODE_SET.getMethod(), + request); + } + + /** + * Payload control - camera focus mode setting + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse cameraFocusModeSet(GatewayManager gateway, CameraFocusModeSetRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_FOCUS_MODE_SET.getMethod(), + request); + } + + /** + * Payload control - camera focus value setting + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse cameraFocusValueSet(GatewayManager gateway, CameraFocusValueSetRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_FOCUS_VALUE_SET.getMethod(), + request); + } + + /** + * Payload control - ir metering mode setting + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse irMeteringModeSet(GatewayManager gateway, IrMeteringModeSetRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.IR_METERING_MODE_SET.getMethod(), + request); + } + + /** + * Payload control - ir metering point setting + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse irMeteringPointSet(GatewayManager gateway, IrMeteringPointSetRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.IR_METERING_POINT_SET.getMethod(), + request); + } + + /** + * Payload control - ir metering area setting + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse irMeteringAreaSet(GatewayManager gateway, IrMeteringAreaSetRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.IR_METERING_AREA_SET.getMethod(), + request); + } + + /** + * Payload control - camera point focus + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse cameraPointFocusAction(GatewayManager gateway, CameraPointFocusActionRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.CAMERA_POINT_FOCUS_ACTION.getMethod(), + request); + } + + /** + * Payload control + * @param gateway + * @param request data + * @return services_reply + */ + public TopicServicesResponse payloadControl(GatewayManager gateway, PayloadControlMethodEnum methodEnum, BaseModel request) { + try { + AbstractControlService abstractControlService = SpringBeanUtils.getBean(this.getClass()); + Method method = abstractControlService.getClass().getDeclaredMethod( + Common.convertSnake(methodEnum.getPayloadMethod().getMethod()),GatewayManager.class, methodEnum.getClazz()); + return (TopicServicesResponse) method.invoke(abstractControlService, gateway, request); + } catch (NoSuchMethodException | IllegalAccessException e) { + throw new CloudSDKException(e); + } catch (InvocationTargetException e) { + throw new CloudSDKException(e.getTargetException()); + } + } + + /** + * Event notification of poi surround information + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_POI_STATUS_NOTIFY, outputChannel = ChannelName.OUTBOUND_EVENTS) + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, include = GatewayTypeEnum.DOCK) + public TopicEventsResponse poiStatusNotify(TopicEventsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("poiStatusNotify not implemented"); + } + + /** + * Enter the poi surround mode + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, exclude = GatewayTypeEnum.RC, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse poiModeEnter(GatewayManager gateway, PoiModeEnterRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.POI_MODE_ENTER.getMethod(), + request); + } + + /** + * Exit the poi surround mode + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, exclude = GatewayTypeEnum.RC, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse poiModeExit(GatewayManager gateway) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.POI_MODE_EXIT.getMethod()); + } + + /** + * poi speed setting + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, exclude = GatewayTypeEnum.RC, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse poiCircleSpeedSet(GatewayManager gateway, PoiCircleSpeedSetRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.POI_CIRCLE_SPEED_SET.getMethod(), + request); + } + + /** + * DRC-flight control + * @param gateway + * @param request data + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + protected void droneControlDown(GatewayManager gateway, DroneControlRequest request) { + drcDownPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.DRONE_CONTROL.getMethod(), + request); + } + + /** + * Drc up notification of drone control result + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_DRC_UP_DRONE_CONTROL) + public void droneControlUp(TopicDrcRequest> request, MessageHeaders headers) { + throw new UnsupportedOperationException("droneControlUp not implemented"); + } + + /** + * DRC-drone emergency stop + * @param gateway + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public void droneEmergencyStopDown(GatewayManager gateway) { + drcDownPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.DRONE_EMERGENCY_STOP.getMethod()); + } + + /** + * Drc up notification of drone emergency stop result + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_DRC_UP_DRONE_EMERGENCY_STOP) + public void droneEmergencyStopUp(TopicDrcRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("droneEmergencyStopUp not implemented"); + } + + + /** + * DRC-heart beat + * @param gateway + * @param request data + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public void heartBeatDown(GatewayManager gateway, HeartBeatRequest request) { + drcDownPublish.publish( + gateway.getGatewaySn(), + ControlMethodEnum.HEART_BEAT.getMethod(), + request); + } + + /** + * Drc up notification of heart beat result + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_DRC_UP_HEART_BEAT) + public void heartBeatUp(TopicDrcRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("heartBeatUp not implemented"); + } + + /** + * DRC-obstacle avoidance information pushing + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_DRC_UP_HSI_INFO_PUSH) + public void hsiInfoPush(TopicDrcRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("hsiInfoPush not implemented"); + } + + /** + * DRC-delay information pushing of image transmission link + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_DRC_UP_DELAY_INFO_PUSH) + public void delayInfoPush(TopicDrcRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("delayInfoPush not implemented"); + } + + /** + * DRC-high frequency osd information pushing + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_DRC_UP_OSD_INFO_PUSH) + public void osdInfoPush(TopicDrcRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("osdInfoPush not implemented"); + } + + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/AirConditionerModeSwitchActionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/AirConditionerModeSwitchActionEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/debug/AirConditionerModeSwitchActionEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/AirConditionerModeSwitchActionEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/AirConditionerModeSwitchRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/AirConditionerModeSwitchRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/debug/AirConditionerModeSwitchRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/AirConditionerModeSwitchRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/AlarmStateSwitchRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/AlarmStateSwitchRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/debug/AlarmStateSwitchRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/AlarmStateSwitchRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/BatteryMaintenanceSwitchRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/BatteryMaintenanceSwitchRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/debug/BatteryMaintenanceSwitchRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/BatteryMaintenanceSwitchRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/BatteryStoreModeSwitchRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/BatteryStoreModeSwitchRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/debug/BatteryStoreModeSwitchRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/BatteryStoreModeSwitchRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/DebugErrorCodeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/DebugErrorCodeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/debug/DebugErrorCodeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/DebugErrorCodeEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/DebugMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/DebugMethodEnum.java new file mode 100644 index 0000000..de75e1f --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/DebugMethodEnum.java @@ -0,0 +1,84 @@ +package com.dji.sdk.cloudapi.debug; + +import com.dji.sdk.common.BaseModel; +import com.dji.sdk.exception.CloudSDKException; + +import java.util.Arrays; + +/** + * @author sean + * @version 1.3 + * @date 2022/11/14 + */ +public enum DebugMethodEnum { + + DEBUG_MODE_OPEN("debug_mode_open", null), + + DEBUG_MODE_CLOSE("debug_mode_close", null), + + SUPPLEMENT_LIGHT_OPEN("supplement_light_open", null), + + SUPPLEMENT_LIGHT_CLOSE("supplement_light_close", null), + + DEVICE_REBOOT("device_reboot", null), + + DRONE_OPEN("drone_open", null), + + DRONE_CLOSE("drone_close", null), + + DRONE_FORMAT("drone_format", null), + + DEVICE_FORMAT("device_format", null), + + COVER_OPEN("cover_open", null), + + COVER_CLOSE("cover_close", null), + + PUTTER_OPEN("putter_open", null), + + PUTTER_CLOSE("putter_close", null), + + CHARGE_OPEN("charge_open", null), + + CHARGE_CLOSE("charge_close", null), + + BATTERY_MAINTENANCE_SWITCH("battery_maintenance_switch", BatteryMaintenanceSwitchRequest.class), + + ALARM_STATE_SWITCH("alarm_state_switch", AlarmStateSwitchRequest.class), + + BATTERY_STORE_MODE_SWITCH("battery_store_mode_switch", BatteryStoreModeSwitchRequest.class), + + SDR_WORKMODE_SWITCH("sdr_workmode_switch", SdrWorkmodeSwitchRequest.class), + + AIR_CONDITIONER_MODE_SWITCH("air_conditioner_mode_switch", AirConditionerModeSwitchRequest.class), + + ESIM_ACTIVATE("esim_activate", EsimActivateRequest.class), + + SIM_SLOT_SWITCH("sim_slot_switch", SimSlotSwitchRequest.class), + + ESIM_OPERATOR_SWITCH("esim_operator_switch", EsimOperatorSwitchRequest.class), + + ; + + private final String method; + + private final Class clazz; + + DebugMethodEnum(String method, Class clazz) { + this.method = method; + this.clazz = clazz; + } + + public String getMethod() { + return method; + } + + public Class getClazz() { + return clazz; + } + + public static DebugMethodEnum find(String method) { + return Arrays.stream(values()).filter(methodEnum -> methodEnum.method.equals(method)).findAny() + .orElseThrow(() -> new CloudSDKException(DebugMethodEnum.class, method)); + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/DongleDeviceTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/DongleDeviceTypeEnum.java new file mode 100644 index 0000000..a7c1a9f --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/DongleDeviceTypeEnum.java @@ -0,0 +1,38 @@ +package com.dji.sdk.cloudapi.debug; + +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 + * @date 2023/10/20 + */ +public enum DongleDeviceTypeEnum { + + DOCK("dock"), + + DRONE("drone"), + + ; + + private final String type; + + DongleDeviceTypeEnum(String type) { + this.type = type; + } + + @JsonValue + public String getType() { + return type; + } + + @JsonCreator + public static DongleDeviceTypeEnum find(String type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type.equals(type)).findAny() + .orElseThrow(() -> new CloudSDKException(DongleDeviceTypeEnum.class, type)); + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/EsimActivateRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/EsimActivateRequest.java new file mode 100644 index 0000000..59b5c65 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/EsimActivateRequest.java @@ -0,0 +1,54 @@ +package com.dji.sdk.cloudapi.debug; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class EsimActivateRequest extends BaseModel { + + /** + * Identifies the dongle to be operated on. + */ + @NotNull + private String imei; + + /** + * Identifies the target device to operate on. + */ + @NotNull + private DongleDeviceTypeEnum deviceType; + + public EsimActivateRequest() { + } + + @Override + public String toString() { + return "EsimActivateRequest{" + + "imei='" + imei + '\'' + + ", deviceType=" + deviceType + + '}'; + } + + public String getImei() { + return imei; + } + + public EsimActivateRequest setImei(String imei) { + this.imei = imei; + return this; + } + + public DongleDeviceTypeEnum getDeviceType() { + return deviceType; + } + + public EsimActivateRequest setDeviceType(DongleDeviceTypeEnum deviceType) { + this.deviceType = deviceType; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/EsimOperatorSwitchRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/EsimOperatorSwitchRequest.java new file mode 100644 index 0000000..753c992 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/EsimOperatorSwitchRequest.java @@ -0,0 +1,71 @@ +package com.dji.sdk.cloudapi.debug; + +import com.dji.sdk.cloudapi.device.TelecomOperatorEnum; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class EsimOperatorSwitchRequest extends BaseModel { + + /** + * Identifies the dongle to be operated on. + */ + @NotNull + private String imei; + + /** + * Identifies the target device to operate on. + */ + @NotNull + private DongleDeviceTypeEnum deviceType; + + /** + * Target carrier for switching. + */ + @NotNull + private TelecomOperatorEnum telecomOperator; + + public EsimOperatorSwitchRequest() { + } + + @Override + public String toString() { + return "EsimOperatorSwitchRequest{" + + "imei='" + imei + '\'' + + ", deviceType=" + deviceType + + ", telecomOperator=" + telecomOperator + + '}'; + } + + public String getImei() { + return imei; + } + + public EsimOperatorSwitchRequest setImei(String imei) { + this.imei = imei; + return this; + } + + public DongleDeviceTypeEnum getDeviceType() { + return deviceType; + } + + public EsimOperatorSwitchRequest setDeviceType(DongleDeviceTypeEnum deviceType) { + this.deviceType = deviceType; + return this; + } + + public TelecomOperatorEnum getTelecomOperator() { + return telecomOperator; + } + + public EsimOperatorSwitchRequest setTelecomOperator(TelecomOperatorEnum telecomOperator) { + this.telecomOperator = telecomOperator; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugProgress.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugProgress.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugProgress.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugProgress.java diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugProgressData.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugProgressData.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugProgressData.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugProgressData.java diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugResponse.java diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugStatusEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugStatusEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugStatusEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugStatusEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugStepKeyEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugStepKeyEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugStepKeyEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/RemoteDebugStepKeyEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/SdrWorkmodeSwitchRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/SdrWorkmodeSwitchRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/debug/SdrWorkmodeSwitchRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/SdrWorkmodeSwitchRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/SimSlotSwitchRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/SimSlotSwitchRequest.java new file mode 100644 index 0000000..3f7c7b4 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/SimSlotSwitchRequest.java @@ -0,0 +1,71 @@ +package com.dji.sdk.cloudapi.debug; + +import com.dji.sdk.cloudapi.device.SimSlotEnum; +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class SimSlotSwitchRequest extends BaseModel { + + /** + * Identifies the dongle to be operated on. + */ + @NotNull + private String imei; + + /** + * Identifies the target device to operate on. + */ + @NotNull + private DongleDeviceTypeEnum deviceType; + + /** + * Switch between using physical sim card and using esim. + */ + @NotNull + private SimSlotEnum simSlot; + + public SimSlotSwitchRequest() { + } + + @Override + public String toString() { + return "SimSlotSwitchRequest{" + + "imei='" + imei + '\'' + + ", deviceType=" + deviceType + + ", simSlot=" + simSlot + + '}'; + } + + public String getImei() { + return imei; + } + + public SimSlotSwitchRequest setImei(String imei) { + this.imei = imei; + return this; + } + + public DongleDeviceTypeEnum getDeviceType() { + return deviceType; + } + + public SimSlotSwitchRequest setDeviceType(DongleDeviceTypeEnum deviceType) { + this.deviceType = deviceType; + return this; + } + + public SimSlotEnum getSimSlot() { + return simSlot; + } + + public SimSlotSwitchRequest setSimSlot(SimSlotEnum simSlot) { + this.simSlot = simSlot; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/api/AbstractDebugService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/api/AbstractDebugService.java new file mode 100644 index 0000000..a8de7e7 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/debug/api/AbstractDebugService.java @@ -0,0 +1,396 @@ +package com.dji.sdk.cloudapi.debug.api; + +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.SpringBeanUtils; +import com.dji.sdk.config.version.CloudSDKVersionEnum; +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; +import com.dji.sdk.mqtt.events.EventsDataRequest; +import com.dji.sdk.mqtt.events.TopicEventsRequest; +import com.dji.sdk.mqtt.events.TopicEventsResponse; +import com.dji.sdk.mqtt.services.ServicesPublish; +import com.dji.sdk.mqtt.services.ServicesReplyData; +import com.dji.sdk.mqtt.services.TopicServicesResponse; +import com.fasterxml.jackson.core.type.TypeReference; +import org.springframework.integration.annotation.ServiceActivator; +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; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/29 + */ +public abstract class AbstractDebugService { + + @Resource + private ServicesPublish servicesPublish; + + /** + * Open the debug mode + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> debugModeOpen(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.DEBUG_MODE_OPEN.getMethod()); + } + + /** + * Close the debug mode + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> debugModeClose(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.DEBUG_MODE_CLOSE.getMethod()); + } + + /** + * Open the supplement light + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> supplementLightOpen(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.SUPPLEMENT_LIGHT_OPEN.getMethod()); + } + + /** + * Close the supplement light + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> supplementLightClose(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.SUPPLEMENT_LIGHT_CLOSE.getMethod()); + } + + /** + * Maintenance state switch of battery + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> batteryMaintenanceSwitch(GatewayManager gateway, BatteryMaintenanceSwitchRequest request) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.BATTERY_MAINTENANCE_SWITCH.getMethod(), + request); + } + + /** + * Air conditioner working mode switch of dock + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> airConditionerModeSwitch(GatewayManager gateway, AirConditionerModeSwitchRequest request) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.AIR_CONDITIONER_MODE_SWITCH.getMethod(), + request); + } + + /** + * Sound and light alarm switch of dock + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> alarmStateSwitch(GatewayManager gateway, AlarmStateSwitchRequest request) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.ALARM_STATE_SWITCH.getMethod(), + request); + } + + /** + * Battery storage mode switch of dock + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> batteryStoreModeSwitch(GatewayManager gateway, BatteryStoreModeSwitchRequest request) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.BATTERY_STORE_MODE_SWITCH.getMethod(), + request); + } + + /** + * Reboot the dock + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> deviceReboot(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.DEVICE_REBOOT.getMethod()); + } + + /** + * Power on the aircraft + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> droneOpen(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.DRONE_OPEN.getMethod()); + } + + /** + * Power off the aircraft + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> droneClose(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.DRONE_CLOSE.getMethod()); + } + + /** + * Format the dock data + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> deviceFormat(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.DEVICE_FORMAT.getMethod()); + } + + /** + * Format the aircraft data + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> droneFormat(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.DRONE_FORMAT.getMethod()); + } + + /** + * Open the dock cover + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> coverOpen(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.COVER_OPEN.getMethod()); + } + + /** + * Close the dock cover + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> coverClose(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.COVER_CLOSE.getMethod()); + } + + /** + * Open the putter + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = {GatewayTypeEnum.RC, GatewayTypeEnum.DOCK2}) + public TopicServicesResponse> putterOpen(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.PUTTER_OPEN.getMethod()); + } + + /** + * Close the putter + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = {GatewayTypeEnum.RC, GatewayTypeEnum.DOCK2}) + public TopicServicesResponse> putterClose(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.PUTTER_CLOSE.getMethod()); + } + + /** + * Turn on charging + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> chargeOpen(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.CHARGE_OPEN.getMethod()); + } + + /** + * Turn off charging + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> chargeClose(GatewayManager gateway) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.CHARGE_CLOSE.getMethod()); + } + + /** + * Switch of 4G enhancement mode + * @param gateway + * @param request data + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse> sdrWorkmodeSwitch(GatewayManager gateway, SdrWorkmodeSwitchRequest request) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.SDR_WORKMODE_SWITCH.getMethod(), + request); + } + + /** + * Common interface for remote debugging + * @param gateway + * @param methodEnum + * @param request data + * @return services_reply + */ + public TopicServicesResponse> remoteDebug(GatewayManager gateway, DebugMethodEnum methodEnum, BaseModel request) { + try { + List clazz = new ArrayList<>(); + List args = new ArrayList<>(); + clazz.add(GatewayManager.class); + args.add(gateway); + if (Objects.nonNull(request)) { + clazz.add(request.getClass()); + args.add(request); + } + AbstractDebugService abstractDebugService = SpringBeanUtils.getBean(this.getClass()); + Method method = abstractDebugService.getClass().getDeclaredMethod(Common.convertSnake(methodEnum.getMethod()), clazz.toArray(Class[]::new)); + return (TopicServicesResponse>) method.invoke(abstractDebugService, args.toArray()); + } catch (NoSuchMethodException | IllegalAccessException e) { + throw new CloudSDKException(e); + } catch (InvocationTargetException e) { + throw new CloudSDKException(e.getTargetException()); + } + } + + /** + * Inform of remote debug progress + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS) + public TopicEventsResponse remoteDebugProgress(TopicEventsRequest> request, MessageHeaders headers) { + throw new UnsupportedOperationException("remoteDebugProgress not implemented"); + } + + /** + * esim activation + * @param gateway gateway device + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_1, include = GatewayTypeEnum.DOCK2) + public TopicServicesResponse> esimActivate(GatewayManager gateway, EsimActivateRequest request) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.ESIM_ACTIVATE.getMethod(), + request); + } + + /** + * esim and sim switching + * @param gateway gateway device + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_1, include = GatewayTypeEnum.DOCK2) + public TopicServicesResponse> simSlotSwitch(GatewayManager gateway, SimSlotSwitchRequest request) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.SIM_SLOT_SWITCH.getMethod(), + request); + } + + /** + * esim operator switching + * @param gateway gateway device + * @param request data + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_1, include = GatewayTypeEnum.DOCK2) + public TopicServicesResponse> esimOperatorSwitch(GatewayManager gateway, EsimOperatorSwitchRequest request) { + return servicesPublish.publish( + new TypeReference() {}, + gateway.getGatewaySn(), + DebugMethodEnum.ESIM_OPERATOR_SWITCH.getMethod(), + request); + } + + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/AirConditioner.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/AirConditioner.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/AirConditioner.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/AirConditioner.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/AirConditionerStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/AirConditionerStateEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/AirConditionerStateEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/AirConditionerStateEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/AlternateLandPoint.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/AlternateLandPoint.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/AlternateLandPoint.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/AlternateLandPoint.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/BackupBattery.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/BackupBattery.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/BackupBattery.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/BackupBattery.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/Battery.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/Battery.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/Battery.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/Battery.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/BatteryIndexEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/BatteryIndexEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/BatteryIndexEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/BatteryIndexEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/BatteryStoreModeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/BatteryStoreModeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/BatteryStoreModeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/BatteryStoreModeEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/CameraIsoEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/CameraIsoEnum.java new file mode 100644 index 0000000..8a4b7dd --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/CameraIsoEnum.java @@ -0,0 +1,61 @@ +package com.dji.sdk.cloudapi.device; + +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.9 + * @date 2023/12/12 + */ +public enum CameraIsoEnum { + + AUTO(0), + + AUTO_HIGH_SENSE(1), + + _50(2), + + _100(3), + + _200(4), + + _400(5), + + _800(6), + + _1600(7), + + _3200(8), + + _6400(9), + + _12800(10), + + _25600(11), + + FIXED(255), + + ; + + private final int iso; + + CameraIsoEnum(int iso) { + this.iso = iso; + } + + @JsonValue + public int getIso() { + return iso; + } + + @JsonCreator + public static CameraIsoEnum find(int iso) { + return Arrays.stream(values()).filter(isoEnum -> isoEnum.iso == iso).findAny() + .orElseThrow(() -> new CloudSDKException(CameraIsoEnum.class, iso)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/CameraModeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/CameraModeEnum.java new file mode 100644 index 0000000..a7a1869 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/CameraModeEnum.java @@ -0,0 +1,44 @@ +package com.dji.sdk.cloudapi.device; + +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.4 + * @date 2023/3/3 + */ +public enum CameraModeEnum { + + PHOTO(0), + + VIDEO(1), + + LOW_LIGHT_INTELLIGENCE(2), + + PANORAMA(3), + + UNSUPPORTED(-1), + + ; + + private final int mode; + + CameraModeEnum(int mode) { + this.mode = mode; + } + + @JsonValue + public int getMode() { + return mode; + } + + @JsonCreator + public static CameraModeEnum find(int mode) { + return Arrays.stream(values()).filter(modeEnum -> modeEnum.mode == mode).findAny() + .orElseThrow(() -> new CloudSDKException(CameraModeEnum.class, mode)); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/CameraStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/CameraStateEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/CameraStateEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/CameraStateEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/ControlSourceEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ControlSourceEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/ControlSourceEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ControlSourceEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/CoverStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/CoverStateEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/CoverStateEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/CoverStateEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DeviceDomainEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceDomainEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DeviceDomainEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceDomainEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DeviceEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DeviceEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DeviceModelEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceModelEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DeviceModelEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceModelEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DeviceOsdHost.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceOsdHost.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DeviceOsdHost.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceOsdHost.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DeviceOsdWsResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceOsdWsResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DeviceOsdWsResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceOsdWsResponse.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DeviceSubTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceSubTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DeviceSubTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceSubTypeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DeviceTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DeviceTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceTypeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockDistanceLimitStatus.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDistanceLimitStatus.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DockDistanceLimitStatus.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDistanceLimitStatus.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockDroneControlSource.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneControlSource.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DockDroneControlSource.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneControlSource.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneCurrentCommanderFlightMode.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneCurrentCommanderFlightMode.java new file mode 100644 index 0000000..b63029a --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneCurrentCommanderFlightMode.java @@ -0,0 +1,34 @@ +package com.dji.sdk.cloudapi.device; + +import com.dji.sdk.cloudapi.control.CommanderFlightModeEnum; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class DockDroneCurrentCommanderFlightMode { + + @JsonProperty("current_commander_flight_mode") + private CommanderFlightModeEnum currentCommanderFlightMode; + + public DockDroneCurrentCommanderFlightMode() { + } + + @Override + public String toString() { + return "DockDroneCurrentCommanderFlightMode{" + + "currentCommanderFlightMode=" + currentCommanderFlightMode + + '}'; + } + + public CommanderFlightModeEnum getCurrentCommanderFlightMode() { + return currentCommanderFlightMode; + } + + public DockDroneCurrentCommanderFlightMode setCurrentCommanderFlightMode(CommanderFlightModeEnum currentCommanderFlightMode) { + this.currentCommanderFlightMode = currentCommanderFlightMode; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneCurrentRthMode.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneCurrentRthMode.java new file mode 100644 index 0000000..b70fcba --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneCurrentRthMode.java @@ -0,0 +1,40 @@ +package com.dji.sdk.cloudapi.device; + +import com.dji.sdk.cloudapi.wayline.RthModeEnum; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/11 + */ +public class DockDroneCurrentRthMode { + + /** + * Current RTH height mode + */ + @JsonProperty("current_rth_mode") + @NotNull + private RthModeEnum currentRthMode; + + public DockDroneCurrentRthMode() { + } + + @Override + public String toString() { + return "DockDroneCurrentRthMode{" + + "currentRthMode=" + currentRthMode + + '}'; + } + + public RthModeEnum getCurrentRthMode() { + return currentRthMode; + } + + public DockDroneCurrentRthMode setCurrentRthMode(RthModeEnum currentRthMode) { + this.currentRthMode = currentRthMode; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneModeCodeReason.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneModeCodeReason.java new file mode 100644 index 0000000..36a3436 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneModeCodeReason.java @@ -0,0 +1,30 @@ +package com.dji.sdk.cloudapi.device; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class DockDroneModeCodeReason { + + private ModeCodeReasonEnum modeCodeReason; + + public DockDroneModeCodeReason() { + } + + @Override + public String toString() { + return "DockDroneModeCodeReason{" + + "modeCodeReason=" + modeCodeReason + + '}'; + } + + public ModeCodeReasonEnum getModeCodeReason() { + return modeCodeReason; + } + + public DockDroneModeCodeReason setModeCodeReason(ModeCodeReasonEnum modeCodeReason) { + this.modeCodeReason = modeCodeReason; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDronePayload.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDronePayload.java new file mode 100644 index 0000000..8e77fd3 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDronePayload.java @@ -0,0 +1,252 @@ +package com.dji.sdk.cloudapi.device; + +import com.dji.sdk.annotations.CloudSDKVersion; +import com.dji.sdk.config.version.GatewayTypeEnum; + +import java.util.List; + +/** + * @author sean + * @version 1.0 + * @date 2022/5/6 + */ +public class DockDronePayload { + + private PayloadIndex payloadIndex; + + private Float gimbalPitch; + + private Float gimbalRoll; + + private Float gimbalYaw; + + private Float measureTargetAltitude; + + private Float measureTargetDistance; + + private Float measureTargetLatitude; + + private Float measureTargetLongitude; + + private MeasureTargetStateEnum measureTargetErrorState; + + private Integer version; + + private ThermalPaletteStyleEnum thermalCurrentPaletteStyle; + + private ThermalGainModeEnum thermalGainMode; + + private Float thermalGlobalTemperatureMax; + + private Float thermalGlobalTemperatureMin; + + private Integer thermalIsothermLowerLimit; + + private SwitchActionEnum thermalIsothermState; + + private Integer thermalIsothermUpperLimit; + + private List smartTrackPoint; + + @CloudSDKVersion(include = GatewayTypeEnum.DOCK2) + private Float zoomFactor; + + public DockDronePayload() { + } + + @Override + public String toString() { + return "DockDronePayload{" + + "payloadIndex=" + payloadIndex + + ", gimbalPitch=" + gimbalPitch + + ", gimbalRoll=" + gimbalRoll + + ", gimbalYaw=" + gimbalYaw + + ", measureTargetAltitude=" + measureTargetAltitude + + ", measureTargetDistance=" + measureTargetDistance + + ", measureTargetLatitude=" + measureTargetLatitude + + ", measureTargetLongitude=" + measureTargetLongitude + + ", measureTargetErrorState=" + measureTargetErrorState + + ", version=" + version + + ", thermalCurrentPaletteStyle=" + thermalCurrentPaletteStyle + + ", thermalGainMode=" + thermalGainMode + + ", thermalGlobalTemperatureMax=" + thermalGlobalTemperatureMax + + ", thermalGlobalTemperatureMin=" + thermalGlobalTemperatureMin + + ", thermalIsothermLowerLimit=" + thermalIsothermLowerLimit + + ", thermalIsothermState=" + thermalIsothermState + + ", thermalIsothermUpperLimit=" + thermalIsothermUpperLimit + + ", smartTrackPoint=" + smartTrackPoint + + ", zoomFactor=" + zoomFactor + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public DockDronePayload setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public Float getGimbalPitch() { + return gimbalPitch; + } + + public DockDronePayload setGimbalPitch(Float gimbalPitch) { + this.gimbalPitch = gimbalPitch; + return this; + } + + public Float getGimbalRoll() { + return gimbalRoll; + } + + public DockDronePayload setGimbalRoll(Float gimbalRoll) { + this.gimbalRoll = gimbalRoll; + return this; + } + + public Float getGimbalYaw() { + return gimbalYaw; + } + + public DockDronePayload setGimbalYaw(Float gimbalYaw) { + this.gimbalYaw = gimbalYaw; + return this; + } + + public Float getMeasureTargetAltitude() { + return measureTargetAltitude; + } + + public DockDronePayload setMeasureTargetAltitude(Float measureTargetAltitude) { + this.measureTargetAltitude = measureTargetAltitude; + return this; + } + + public Float getMeasureTargetDistance() { + return measureTargetDistance; + } + + public DockDronePayload setMeasureTargetDistance(Float measureTargetDistance) { + this.measureTargetDistance = measureTargetDistance; + return this; + } + + public Float getMeasureTargetLatitude() { + return measureTargetLatitude; + } + + public DockDronePayload setMeasureTargetLatitude(Float measureTargetLatitude) { + this.measureTargetLatitude = measureTargetLatitude; + return this; + } + + public Float getMeasureTargetLongitude() { + return measureTargetLongitude; + } + + public DockDronePayload setMeasureTargetLongitude(Float measureTargetLongitude) { + this.measureTargetLongitude = measureTargetLongitude; + return this; + } + + public MeasureTargetStateEnum getMeasureTargetErrorState() { + return measureTargetErrorState; + } + + public DockDronePayload setMeasureTargetErrorState(MeasureTargetStateEnum measureTargetErrorState) { + this.measureTargetErrorState = measureTargetErrorState; + return this; + } + + public Integer getVersion() { + return version; + } + + public DockDronePayload setVersion(Integer version) { + this.version = version; + return this; + } + + public ThermalPaletteStyleEnum getThermalCurrentPaletteStyle() { + return thermalCurrentPaletteStyle; + } + + public DockDronePayload setThermalCurrentPaletteStyle(ThermalPaletteStyleEnum thermalCurrentPaletteStyle) { + this.thermalCurrentPaletteStyle = thermalCurrentPaletteStyle; + return this; + } + + public ThermalGainModeEnum getThermalGainMode() { + return thermalGainMode; + } + + public DockDronePayload setThermalGainMode(ThermalGainModeEnum thermalGainMode) { + this.thermalGainMode = thermalGainMode; + return this; + } + + public Float getThermalGlobalTemperatureMax() { + return thermalGlobalTemperatureMax; + } + + public DockDronePayload setThermalGlobalTemperatureMax(Float thermalGlobalTemperatureMax) { + this.thermalGlobalTemperatureMax = thermalGlobalTemperatureMax; + return this; + } + + public Float getThermalGlobalTemperatureMin() { + return thermalGlobalTemperatureMin; + } + + public DockDronePayload setThermalGlobalTemperatureMin(Float thermalGlobalTemperatureMin) { + this.thermalGlobalTemperatureMin = thermalGlobalTemperatureMin; + return this; + } + + public Integer getThermalIsothermLowerLimit() { + return thermalIsothermLowerLimit; + } + + public DockDronePayload setThermalIsothermLowerLimit(Integer thermalIsothermLowerLimit) { + this.thermalIsothermLowerLimit = thermalIsothermLowerLimit; + return this; + } + + public SwitchActionEnum getThermalIsothermState() { + return thermalIsothermState; + } + + public DockDronePayload setThermalIsothermState(SwitchActionEnum thermalIsothermState) { + this.thermalIsothermState = thermalIsothermState; + return this; + } + + public Integer getThermalIsothermUpperLimit() { + return thermalIsothermUpperLimit; + } + + public DockDronePayload setThermalIsothermUpperLimit(Integer thermalIsothermUpperLimit) { + this.thermalIsothermUpperLimit = thermalIsothermUpperLimit; + return this; + } + + public List getSmartTrackPoint() { + return smartTrackPoint; + } + + public DockDronePayload setSmartTrackPoint(List smartTrackPoint) { + this.smartTrackPoint = smartTrackPoint; + return this; + } + + public Float getZoomFactor() { + return zoomFactor; + } + + public DockDronePayload setZoomFactor(Float zoomFactor) { + this.zoomFactor = zoomFactor; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneThermalSupportedPaletteStyle.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneThermalSupportedPaletteStyle.java new file mode 100644 index 0000000..327f325 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneThermalSupportedPaletteStyle.java @@ -0,0 +1,56 @@ +package com.dji.sdk.cloudapi.device; + +import java.util.Arrays; + +/** + * @author sean + * @version 1.7 + * @date 2023/5/23 + */ +public class DockDroneThermalSupportedPaletteStyle { + + private PayloadIndex payloadIndex; + + private ThermalPaletteStyleEnum[] thermalSupportedPaletteStyles; + + private Integer version; + + public DockDroneThermalSupportedPaletteStyle() { + } + + @Override + public String toString() { + return "DockDroneThermalSupportedPaletteStyle{" + + "payloadIndex=" + payloadIndex + + ", thermalSupportedPaletteStyles=" + Arrays.toString(thermalSupportedPaletteStyles) + + ", version=" + version + + '}'; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public DockDroneThermalSupportedPaletteStyle setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public ThermalPaletteStyleEnum[] getThermalSupportedPaletteStyles() { + return thermalSupportedPaletteStyles; + } + + public DockDroneThermalSupportedPaletteStyle setThermalSupportedPaletteStyles(ThermalPaletteStyleEnum[] thermalSupportedPaletteStyles) { + this.thermalSupportedPaletteStyles = thermalSupportedPaletteStyles; + return this; + } + + public Integer getVersion() { + return version; + } + + public DockDroneThermalSupportedPaletteStyle setVersion(Integer version) { + this.version = version; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneWpmzVersion.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneWpmzVersion.java new file mode 100644 index 0000000..1ea30f2 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockDroneWpmzVersion.java @@ -0,0 +1,30 @@ +package com.dji.sdk.cloudapi.device; + +/** + * @author sean + * @version 1.7 + * @date 2023/5/23 + */ +public class DockDroneWpmzVersion { + + private String wpmzVersion; + + public DockDroneWpmzVersion() { + } + + @Override + public String toString() { + return "DockDroneWpmzVersion{" + + "wpmzVersion='" + wpmzVersion + '\'' + + '}'; + } + + public String getWpmzVersion() { + return wpmzVersion; + } + + public DockDroneWpmzVersion setWpmzVersion(String wpmzVersion) { + this.wpmzVersion = wpmzVersion; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockFirmwareVersion.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockFirmwareVersion.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DockFirmwareVersion.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockFirmwareVersion.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockLiveErrorStatus.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockLiveErrorStatus.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DockLiveErrorStatus.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockLiveErrorStatus.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockLiveStatus.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockLiveStatus.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DockLiveStatus.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockLiveStatus.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockLiveStatusData.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockLiveStatusData.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DockLiveStatusData.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockLiveStatusData.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockMaintainStatus.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockMaintainStatus.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DockMaintainStatus.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockMaintainStatus.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockModeCodeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockModeCodeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DockModeCodeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockModeCodeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockPayloadControlSource.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockPayloadControlSource.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DockPayloadControlSource.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockPayloadControlSource.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockPositionState.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockPositionState.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DockPositionState.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockPositionState.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockSilentMode.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockSilentMode.java new file mode 100644 index 0000000..4c11e5f --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockSilentMode.java @@ -0,0 +1,38 @@ +package com.dji.sdk.cloudapi.device; + +import com.dji.sdk.cloudapi.property.SilentModeEnum; +import com.dji.sdk.common.BaseModel; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class DockSilentMode extends BaseModel { + + @NotNull + @JsonProperty("silent_mode") + private SilentModeEnum silentMode; + + public DockSilentMode() { + } + + @Override + public String toString() { + return "DockSilentMode{" + + "silentMode=" + silentMode + + '}'; + } + + public SilentModeEnum getSilentMode() { + return silentMode; + } + + public DockSilentMode setSilentMode(SilentModeEnum silentMode) { + this.silentMode = silentMode; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockSubDevice.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockSubDevice.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DockSubDevice.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DockSubDevice.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DongleInfo.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DongleInfo.java new file mode 100644 index 0000000..eae3e77 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DongleInfo.java @@ -0,0 +1,140 @@ +package com.dji.sdk.cloudapi.device; + +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/19 + */ +public class DongleInfo { + + /** + * Dongle’s unique identification mark + */ + private String imei; + + /** + * dongle type + */ + private DongleTypeEnum dongleType; + + /** + * The unique identification mark of eSIM is used for public account query packages and purchase services. + */ + private String eid; + + /** + * esim activation status + */ + private EsimActivateStateEnum esimActivateState; + + /** + * The status of the physical sim card in the dongle. + */ + private SimCardStateEnum simCardState; + + /** + * Identifies the sim card slot currently being used by the dongle. + */ + private SimSlotEnum simSlot; + + /** + * esim information + */ + private List esimInfos; + + /** + * Physical sim card information that can be inserted into the dongle. + */ + private SimInfo simInfo; + + public DongleInfo() { + } + + @Override + public String toString() { + return "DongleInfo{" + + "imei='" + imei + '\'' + + ", dongleType=" + dongleType + + ", eid='" + eid + '\'' + + ", esimActivateState=" + esimActivateState + + ", simCardState=" + simCardState + + ", simSlot=" + simSlot + + ", esimInfos=" + esimInfos + + ", simInfo=" + simInfo + + '}'; + } + + public String getImei() { + return imei; + } + + public DongleInfo setImei(String imei) { + this.imei = imei; + return this; + } + + public DongleTypeEnum getDongleType() { + return dongleType; + } + + public DongleInfo setDongleType(DongleTypeEnum dongleType) { + this.dongleType = dongleType; + return this; + } + + public String getEid() { + return eid; + } + + public DongleInfo setEid(String eid) { + this.eid = eid; + return this; + } + + public EsimActivateStateEnum getEsimActivateState() { + return esimActivateState; + } + + public DongleInfo setEsimActivateState(EsimActivateStateEnum esimActivateState) { + this.esimActivateState = esimActivateState; + return this; + } + + public SimCardStateEnum getSimCardState() { + return simCardState; + } + + public DongleInfo setSimCardState(SimCardStateEnum simCardState) { + this.simCardState = simCardState; + return this; + } + + public SimSlotEnum getSimSlot() { + return simSlot; + } + + public DongleInfo setSimSlot(SimSlotEnum simSlot) { + this.simSlot = simSlot; + return this; + } + + public List getEsimInfos() { + return esimInfos; + } + + public DongleInfo setEsimInfos(List esimInfos) { + this.esimInfos = esimInfos; + return this; + } + + public SimInfo getSimInfo() { + return simInfo; + } + + public DongleInfo setSimInfo(SimInfo simInfo) { + this.simInfo = simInfo; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DongleInfos.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DongleInfos.java new file mode 100644 index 0000000..fc5de94 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DongleInfos.java @@ -0,0 +1,32 @@ +package com.dji.sdk.cloudapi.device; + +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class DongleInfos { + + private List dongleInfos; + + public DongleInfos() { + } + + @Override + public String toString() { + return "DongleInfos{" + + "dongleInfos=" + dongleInfos + + '}'; + } + + public List getDongleInfos() { + return dongleInfos; + } + + public DongleInfos setDongleInfos(List dongleInfos) { + this.dongleInfos = dongleInfos; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DongleTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DongleTypeEnum.java new file mode 100644 index 0000000..5fdc8c7 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DongleTypeEnum.java @@ -0,0 +1,39 @@ +package com.dji.sdk.cloudapi.device; + +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 + * @date 2023/10/20 + */ +public enum DongleTypeEnum { + + OLD_DONGLE(6), + + SUPPORTED_ESIM(10), + + ; + + private final int type; + + DongleTypeEnum(int type) { + this.type = type; + } + + @JsonValue + public int getType() { + return type; + } + + @JsonCreator + public static DongleTypeEnum find(int type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny() + .orElseThrow(() -> new CloudSDKException(DongleTypeEnum.class, type)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DrcStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DrcStateEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DrcStateEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DrcStateEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DroneBattery.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneBattery.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DroneBattery.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneBattery.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenance.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenance.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenance.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenance.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenanceInfo.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenanceInfo.java new file mode 100644 index 0000000..2a8be30 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenanceInfo.java @@ -0,0 +1,76 @@ +package com.dji.sdk.cloudapi.device; + +import java.util.List; + +/** + * @author sean + * @version 1.4 + * @date 2022/11/3 + */ +public class DroneBatteryMaintenanceInfo { + + private List batteries; + + private MaintenanceStateEnum maintenanceState; + + /** + * Remaining time of battery maintenance + * Round down + * unit: hour + */ + private Integer maintenanceTimeLeft; + + /** + * When the drone is powered off in the dock, this property will report the heating and insulation information of the drone battery. + */ + private HeatStateEnum heatState; + + public DroneBatteryMaintenanceInfo() { + } + + @Override + public String toString() { + return "DroneBatteryMaintenanceInfo{" + + "batteries=" + batteries + + ", maintenanceState=" + maintenanceState + + ", maintenanceTimeLeft=" + maintenanceTimeLeft + + ", heatState=" + heatState + + '}'; + } + + public List getBatteries() { + return batteries; + } + + public DroneBatteryMaintenanceInfo setBatteries(List batteries) { + this.batteries = batteries; + return this; + } + + public MaintenanceStateEnum getMaintenanceState() { + return maintenanceState; + } + + public DroneBatteryMaintenanceInfo setMaintenanceState(MaintenanceStateEnum maintenanceState) { + this.maintenanceState = maintenanceState; + return this; + } + + public Integer getMaintenanceTimeLeft() { + return maintenanceTimeLeft; + } + + public DroneBatteryMaintenanceInfo setMaintenanceTimeLeft(Integer maintenanceTimeLeft) { + this.maintenanceTimeLeft = maintenanceTimeLeft; + return this; + } + + public HeatStateEnum getHeatState() { + return heatState; + } + + public DroneBatteryMaintenanceInfo setHeatState(HeatStateEnum heatState) { + this.heatState = heatState; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DroneChargeState.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneChargeState.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DroneChargeState.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneChargeState.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DroneMaintainStatus.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneMaintainStatus.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DroneMaintainStatus.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneMaintainStatus.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneModeCodeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneModeCodeEnum.java new file mode 100644 index 0000000..3f4e184 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DroneModeCodeEnum.java @@ -0,0 +1,76 @@ +package com.dji.sdk.cloudapi.device; + +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.4 + * @date 2023/3/9 + */ +public enum DroneModeCodeEnum { + + IDLE(0), + + TAKEOFF_PREPARE(1), + + TAKEOFF_FINISHED(2), + + MANUAL(3), + + TAKEOFF_AUTO(4), + + WAYLINE(5), + + PANORAMIC_SHOT(6), + + ACTIVE_TRACK(7), + + ADS_B_AVOIDANCE(8), + + RETURN_AUTO(9), + + LANDING_AUTO(10), + + LANDING_FORCED(11), + + LANDING_THREE_PROPELLER(12), + + UPGRADING(13), + + DISCONNECTED(14), + + APAS(15), + + VIRTUAL_JOYSTICK(16), + + LIVE_FLIGHT_CONTROLS(17), + + AERIAL_RTK_FIXED(18), + + DOCK_SITE_EVALUATION(19), + + POI(20), + + ; + + private final int code; + + DroneModeCodeEnum(int code) { + this.code = code; + } + + @JsonValue + public int getCode() { + return code; + } + + @JsonCreator + public static DroneModeCodeEnum find(int code) { + return Arrays.stream(values()).filter(modeCodeEnum -> modeCodeEnum.ordinal() == code).findAny() + .orElseThrow(() -> new CloudSDKException(DroneModeCodeEnum.class, code)); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DronePositionState.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DronePositionState.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/DronePositionState.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DronePositionState.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/EsimActivateStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/EsimActivateStateEnum.java new file mode 100644 index 0000000..64d0487 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/EsimActivateStateEnum.java @@ -0,0 +1,39 @@ +package com.dji.sdk.cloudapi.device; + +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 + * @date 2023/10/20 + */ +public enum EsimActivateStateEnum { + + INACTIVATED(0), + + ACTIVATED(1), + + ; + + private final int state; + + EsimActivateStateEnum(int state) { + this.state = state; + } + + @JsonValue + public int getState() { + return state; + } + + @JsonCreator + public static EsimActivateStateEnum find(int state) { + return Arrays.stream(values()).filter(stateEnum -> stateEnum.state == state).findAny() + .orElseThrow(() -> new CloudSDKException(EsimActivateStateEnum.class, state)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/EsimInfo.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/EsimInfo.java new file mode 100644 index 0000000..c8daaf9 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/EsimInfo.java @@ -0,0 +1,63 @@ +package com.dji.sdk.cloudapi.device; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class EsimInfo { + + /** + * esim supported operators + */ + private TelecomOperatorEnum telecomOperator; + + /** + * In esim infos, only one esim can be enabled at the same time. + */ + private Boolean enabled; + + /** + * The unique identification mark of the sim card can be used to purchase physical sim card packages. + */ + private String iccid; + + public EsimInfo() { + } + + @Override + public String toString() { + return "EsimInfo{" + + "telecomOperator=" + telecomOperator + + ", enabled=" + enabled + + ", iccid='" + iccid + '\'' + + '}'; + } + + public TelecomOperatorEnum getTelecomOperator() { + return telecomOperator; + } + + public EsimInfo setTelecomOperator(TelecomOperatorEnum telecomOperator) { + this.telecomOperator = telecomOperator; + return this; + } + + public Boolean getEnabled() { + return enabled; + } + + public EsimInfo setEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public String getIccid() { + return iccid; + } + + public EsimInfo setIccid(String iccid) { + this.iccid = iccid; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/ExitWaylineWhenRcLostEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ExitWaylineWhenRcLostEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/ExitWaylineWhenRcLostEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ExitWaylineWhenRcLostEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/FirmwareVersion.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/FirmwareVersion.java new file mode 100644 index 0000000..49d82c5 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/FirmwareVersion.java @@ -0,0 +1,31 @@ +package com.dji.sdk.cloudapi.device; + +/** + * @author sean + * @version 1.0 + * @date 2022/4/28 + */ +public class FirmwareVersion { + + private String firmwareVersion; + + public FirmwareVersion() { + } + + @Override + public String toString() { + return "FirmwareVersion{" + + "firmwareVersion='" + firmwareVersion + '\'' + + '}'; + } + + public String getFirmwareVersion() { + return firmwareVersion; + } + + public FirmwareVersion setFirmwareVersion(String firmwareVersion) { + this.firmwareVersion = firmwareVersion; + return this; + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/FlighttaskStepCodeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/FlighttaskStepCodeEnum.java new file mode 100644 index 0000000..9ceeaba --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/FlighttaskStepCodeEnum.java @@ -0,0 +1,50 @@ +package com.dji.sdk.cloudapi.device; + +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 + * @date 2023/6/30 + */ +public enum FlighttaskStepCodeEnum { + + TASK_PREPARING(0), + + TASK_OPERATING(1), + + STATE_RECOVERING(2), + + CUSTOM_FLIGHT_AREA_UPDATING(3), + + OFFLINE_MAP_UPDATING(4), + + IDLE(5), + + UNKNOWN1(255), + + UNKNOWN2(256), + ; + + private final int code; + + FlighttaskStepCodeEnum(int code) { + this.code = code; + } + + @JsonValue + public int getCode() { + return code; + } + + @JsonCreator + public static FlighttaskStepCodeEnum find(int code) { + return Arrays.stream(values()).filter(codeEnum -> codeEnum.code == code).findAny() + .orElseThrow(() -> new CloudSDKException(FlighttaskStepCodeEnum.class, code)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/FocusStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/FocusStateEnum.java new file mode 100644 index 0000000..2a6c901 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/FocusStateEnum.java @@ -0,0 +1,43 @@ +package com.dji.sdk.cloudapi.device; + +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.9 + * @date 2023/12/12 + */ +public enum FocusStateEnum { + + IDLE(0), + + FOCUSING(1), + + SUCCESS(2), + + FAILED(3), + + ; + + private final int state; + + FocusStateEnum(int state) { + this.state = state; + } + + @JsonValue + public int getState() { + return state; + } + + @JsonCreator + public static FocusStateEnum find(int state) { + return Arrays.stream(values()).filter(stateEnum -> stateEnum.state == state).findAny() + .orElseThrow(() -> new CloudSDKException(FocusStateEnum.class, state)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/GearEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/GearEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/GearEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/GearEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/HeatStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/HeatStateEnum.java new file mode 100644 index 0000000..1ba13f1 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/HeatStateEnum.java @@ -0,0 +1,41 @@ +package com.dji.sdk.cloudapi.device; + +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.4 + * @date 2022/11/3 + */ +public enum HeatStateEnum { + + DISABLED(0), + + HEATING(1), + + INSULATION(2), + + ; + + private final int state; + + HeatStateEnum(int state) { + this.state = state; + } + + @JsonValue + public int getState() { + return state; + } + + @JsonCreator + public static HeatStateEnum find(int state) { + return Arrays.stream(values()).filter(stateEnum -> stateEnum.state == state).findAny() + .orElseThrow(() -> new CloudSDKException(HeatStateEnum.class, state)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/IrMeteringArea.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/IrMeteringArea.java new file mode 100644 index 0000000..0461d19 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/IrMeteringArea.java @@ -0,0 +1,114 @@ +package com.dji.sdk.cloudapi.device; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class IrMeteringArea { + + private Float x; + + private Float y; + + private Float temperature; + + private Float width; + + private Float height; + + private Float averTemperature; + + private IrMeteringPoint minTemperaturePoint; + + private IrMeteringPoint maxTemperaturePoint; + + public IrMeteringArea() { + } + + @Override + public String toString() { + return "IrMeteringArea{" + + "x=" + x + + ", y=" + y + + ", temperature=" + temperature + + ", width=" + width + + ", height=" + height + + ", averTemperature=" + averTemperature + + ", minTemperaturePoint=" + minTemperaturePoint + + ", maxTemperaturePoint=" + maxTemperaturePoint + + '}'; + } + + public Float getX() { + return x; + } + + public IrMeteringArea setX(Float x) { + this.x = x; + return this; + } + + public Float getY() { + return y; + } + + public IrMeteringArea setY(Float y) { + this.y = y; + return this; + } + + public Float getTemperature() { + return temperature; + } + + public IrMeteringArea setTemperature(Float temperature) { + this.temperature = temperature; + return this; + } + + public Float getWidth() { + return width; + } + + public IrMeteringArea setWidth(Float width) { + this.width = width; + return this; + } + + public Float getHeight() { + return height; + } + + public IrMeteringArea setHeight(Float height) { + this.height = height; + return this; + } + + public Float getAverTemperature() { + return averTemperature; + } + + public IrMeteringArea setAverTemperature(Float averTemperature) { + this.averTemperature = averTemperature; + return this; + } + + public IrMeteringPoint getMinTemperaturePoint() { + return minTemperaturePoint; + } + + public IrMeteringArea setMinTemperaturePoint(IrMeteringPoint minTemperaturePoint) { + this.minTemperaturePoint = minTemperaturePoint; + return this; + } + + public IrMeteringPoint getMaxTemperaturePoint() { + return maxTemperaturePoint; + } + + public IrMeteringArea setMaxTemperaturePoint(IrMeteringPoint maxTemperaturePoint) { + this.maxTemperaturePoint = maxTemperaturePoint; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/IrMeteringPoint.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/IrMeteringPoint.java new file mode 100644 index 0000000..fbe99a7 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/IrMeteringPoint.java @@ -0,0 +1,54 @@ +package com.dji.sdk.cloudapi.device; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/12 + */ +public class IrMeteringPoint { + + private Float x; + + private Float y; + + private Float temperature; + + public IrMeteringPoint() { + } + + @Override + public String toString() { + return "IrMeteringPoint{" + + "x=" + x + + ", y=" + y + + ", temperature=" + temperature + + '}'; + } + + public Float getX() { + return x; + } + + public IrMeteringPoint setX(Float x) { + this.x = x; + return this; + } + + public Float getY() { + return y; + } + + public IrMeteringPoint setY(Float y) { + this.y = y; + return this; + } + + public Float getTemperature() { + return temperature; + } + + public IrMeteringPoint setTemperature(Float temperature) { + this.temperature = temperature; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/LinkWorkModeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/LinkWorkModeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/LinkWorkModeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/LinkWorkModeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/LiveviewWorldRegion.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/LiveviewWorldRegion.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/LiveviewWorldRegion.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/LiveviewWorldRegion.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/MaintainTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/MaintainTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/MaintainTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/MaintainTypeEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/MaintenanceStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/MaintenanceStateEnum.java new file mode 100644 index 0000000..d10624f --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/MaintenanceStateEnum.java @@ -0,0 +1,41 @@ +package com.dji.sdk.cloudapi.device; + +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.4 + * @date 2022/11/3 + */ +public enum MaintenanceStateEnum { + + NO_NEED_TO_MAINTENANCE(0), + + NEED_MAINTENANCE(1), + + UNDER_MAINTENANCE(2), + + ; + + private final int state; + + MaintenanceStateEnum(int state) { + this.state = state; + } + + @JsonValue + public int getState() { + return state; + } + + @JsonCreator + public static MaintenanceStateEnum find(int state) { + return Arrays.stream(values()).filter(stateEnum -> stateEnum.state == state).findAny() + .orElseThrow(() -> new CloudSDKException(MaintenanceStateEnum.class, state)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/MeasureTargetStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/MeasureTargetStateEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/MeasureTargetStateEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/MeasureTargetStateEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/MediaFileDetail.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/MediaFileDetail.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/MediaFileDetail.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/MediaFileDetail.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ModeCodeReasonEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ModeCodeReasonEnum.java new file mode 100644 index 0000000..b4389e7 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ModeCodeReasonEnum.java @@ -0,0 +1,82 @@ +package com.dji.sdk.cloudapi.device; + +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.4 + * @date 2023/2/28 + */ +public enum ModeCodeReasonEnum { + + NO_MEANING(0), + + LOW_POWER(1), + + LOW_VOLTAGE(2), + + SERIOUS_LOW_VOLTAGE(3), + + RC_CONTROL(4), + + APP_CONTROL(5), + + RC_SIGNAL_LOST(6), + + EXTERNAL_DEVICE_TRIGGERED(7), + + GEO_ZONE(8), + + HOME_POINT_TOO_CLOSED(9), + + HOME_POINT_TOO_FAR(10), + + EXECUTING_WAYPOINT_MISSION(11), + + ARRIVE_HOME_POINT(12), + + SECOND_LIMIT_LANDING(13), + + APP_FORCIBLY_BREAK_PROTECTION(14), + + PLANES_PASSING_NEARBY(15), + + HEIGHT_CONTROL_FAILED(16), + + LOW_POWER_RTH(17), + + AP_CONTROL(18), + + HARDWARE_ABNORMAL(19), + + TOUCHDOWN_AVOIDANCE_PROTECTION(20), + + CANCEL_RTH(21), + + RTH_OBSTACLE_AVOIDANCE(22), + + RTH_STRONG_GALE(23), + + ; + + private final int reason; + + ModeCodeReasonEnum(int reason) { + this.reason = reason; + } + + @JsonValue + public int getReason() { + return reason; + } + + @JsonCreator + public static ModeCodeReasonEnum find(int reason) { + return Arrays.stream(values()).filter(reasonEnum -> reasonEnum.reason == reason).findAny() + .orElseThrow(() -> new CloudSDKException(ModeCodeReasonEnum.class, reason)); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/NetworkState.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/NetworkState.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/NetworkState.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/NetworkState.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/NetworkStateQualityEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/NetworkStateQualityEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/NetworkStateQualityEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/NetworkStateQualityEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/NetworkStateTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/NetworkStateTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/NetworkStateTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/NetworkStateTypeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/ObstacleAvoidance.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ObstacleAvoidance.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/ObstacleAvoidance.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ObstacleAvoidance.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdCamera.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdCamera.java new file mode 100644 index 0000000..4319295 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdCamera.java @@ -0,0 +1,417 @@ +package com.dji.sdk.cloudapi.device; + +import com.dji.sdk.annotations.CloudSDKVersion; +import com.dji.sdk.cloudapi.control.*; +import com.dji.sdk.config.version.CloudSDKVersionEnum; + +import java.util.List; + +/** + * @author sean + * @version 1.4 + * @date 2023/3/8 + */ +public class OsdCamera { + + private CameraModeEnum cameraMode; + + private LiveviewWorldRegion liveviewWorldRegion; + + private PayloadIndex payloadIndex; + + private CameraStateEnum photoState; + + private Integer recordTime; + + private CameraStateEnum recordingState; + + private Long remainPhotoNum; + + private Integer remainRecordDuration; + + private Float zoomFactor; + + private Float irZoomFactor; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + private Boolean screenSplitEnable; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + private List photoStorageSettings; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + private List videoStorageSettings; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private ExposureModeEnum wideExposureMode; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private CameraIsoEnum wideIso; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private ShutterSpeedEnum wideShutterSpeed; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private ExposureValueEnum wideExposureValue; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private ExposureModeEnum zoomExposureMode; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private CameraIsoEnum zoomIso; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private ShutterSpeedEnum zoomShutterSpeed; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private ExposureValueEnum zoomExposureValue; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private FocusModeEnum zoomFocusMode; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private Integer zoomFocusValue; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private Integer zoomMaxFocusValue; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private Integer zoomMinFocusValue; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private MeteringModeEnum irMeteringMode; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private IrMeteringPoint irMeteringPoint; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private IrMeteringArea irMeteringArea; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private Integer zoomCalibrateFarthestFocusValue; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private Integer zoomCalibrateNearestFocusValue; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2) + private FocusStateEnum zoomFocusState; + + public OsdCamera() { + } + + @Override + public String toString() { + return "OsdCamera{" + + "cameraMode=" + cameraMode + + ", liveviewWorldRegion=" + liveviewWorldRegion + + ", payloadIndex=" + payloadIndex + + ", photoState=" + photoState + + ", recordTime=" + recordTime + + ", recordingState=" + recordingState + + ", remainPhotoNum=" + remainPhotoNum + + ", remainRecordDuration=" + remainRecordDuration + + ", zoomFactor=" + zoomFactor + + ", irZoomFactor=" + irZoomFactor + + ", screenSplitEnable=" + screenSplitEnable + + ", photoStorageSettings=" + photoStorageSettings + + ", videoStorageSettings=" + videoStorageSettings + + ", wideExposureMode=" + wideExposureMode + + ", wideIso=" + wideIso + + ", wideShutterSpeed=" + wideShutterSpeed + + ", wideExposureValue=" + wideExposureValue + + ", zoomExposureMode=" + zoomExposureMode + + ", zoomIso=" + zoomIso + + ", zoomShutterSpeed=" + zoomShutterSpeed + + ", zoomExposureValue=" + zoomExposureValue + + ", zoomFocusMode=" + zoomFocusMode + + ", zoomFocusValue=" + zoomFocusValue + + ", zoomMaxFocusValue=" + zoomMaxFocusValue + + ", zoomMinFocusValue=" + zoomMinFocusValue + + ", irMeteringMode=" + irMeteringMode + + ", irMeteringPoint=" + irMeteringPoint + + ", irMeteringArea=" + irMeteringArea + + ", zoomCalibrateFarthestFocusValue=" + zoomCalibrateFarthestFocusValue + + ", zoomCalibrateNearestFocusValue=" + zoomCalibrateNearestFocusValue + + ", zoomFocusState=" + zoomFocusState + + '}'; + } + + public CameraModeEnum getCameraMode() { + return cameraMode; + } + + public OsdCamera setCameraMode(CameraModeEnum cameraMode) { + this.cameraMode = cameraMode; + return this; + } + + public LiveviewWorldRegion getLiveviewWorldRegion() { + return liveviewWorldRegion; + } + + public OsdCamera setLiveviewWorldRegion(LiveviewWorldRegion liveviewWorldRegion) { + this.liveviewWorldRegion = liveviewWorldRegion; + return this; + } + + public PayloadIndex getPayloadIndex() { + return payloadIndex; + } + + public OsdCamera setPayloadIndex(PayloadIndex payloadIndex) { + this.payloadIndex = payloadIndex; + return this; + } + + public CameraStateEnum getPhotoState() { + return photoState; + } + + public OsdCamera setPhotoState(CameraStateEnum photoState) { + this.photoState = photoState; + return this; + } + + public Integer getRecordTime() { + return recordTime; + } + + public OsdCamera setRecordTime(Integer recordTime) { + this.recordTime = recordTime; + return this; + } + + public CameraStateEnum getRecordingState() { + return recordingState; + } + + public OsdCamera setRecordingState(CameraStateEnum recordingState) { + this.recordingState = recordingState; + return this; + } + + public Long getRemainPhotoNum() { + return remainPhotoNum; + } + + public OsdCamera setRemainPhotoNum(Long remainPhotoNum) { + this.remainPhotoNum = remainPhotoNum; + return this; + } + + public Integer getRemainRecordDuration() { + return remainRecordDuration; + } + + public OsdCamera setRemainRecordDuration(Integer remainRecordDuration) { + this.remainRecordDuration = remainRecordDuration; + return this; + } + + public Float getZoomFactor() { + return zoomFactor; + } + + public OsdCamera setZoomFactor(Float zoomFactor) { + this.zoomFactor = zoomFactor; + return this; + } + + public Float getIrZoomFactor() { + return irZoomFactor; + } + + public OsdCamera setIrZoomFactor(Float irZoomFactor) { + this.irZoomFactor = irZoomFactor; + return this; + } + + public Boolean getScreenSplitEnable() { + return screenSplitEnable; + } + + public OsdCamera setScreenSplitEnable(Boolean screenSplitEnable) { + this.screenSplitEnable = screenSplitEnable; + return this; + } + + public List getPhotoStorageSettings() { + return photoStorageSettings; + } + + public OsdCamera setPhotoStorageSettings(List photoStorageSettings) { + this.photoStorageSettings = photoStorageSettings; + return this; + } + + public List getVideoStorageSettings() { + return videoStorageSettings; + } + + public OsdCamera setVideoStorageSettings(List videoStorageSettings) { + this.videoStorageSettings = videoStorageSettings; + return this; + } + + public ExposureModeEnum getWideExposureMode() { + return wideExposureMode; + } + + public OsdCamera setWideExposureMode(ExposureModeEnum wideExposureMode) { + this.wideExposureMode = wideExposureMode; + return this; + } + + public CameraIsoEnum getWideIso() { + return wideIso; + } + + public OsdCamera setWideIso(CameraIsoEnum wideIso) { + this.wideIso = wideIso; + return this; + } + + public ShutterSpeedEnum getWideShutterSpeed() { + return wideShutterSpeed; + } + + public OsdCamera setWideShutterSpeed(ShutterSpeedEnum wideShutterSpeed) { + this.wideShutterSpeed = wideShutterSpeed; + return this; + } + + public ExposureValueEnum getWideExposureValue() { + return wideExposureValue; + } + + public OsdCamera setWideExposureValue(ExposureValueEnum wideExposureValue) { + this.wideExposureValue = wideExposureValue; + return this; + } + + public ExposureModeEnum getZoomExposureMode() { + return zoomExposureMode; + } + + public OsdCamera setZoomExposureMode(ExposureModeEnum zoomExposureMode) { + this.zoomExposureMode = zoomExposureMode; + return this; + } + + public CameraIsoEnum getZoomIso() { + return zoomIso; + } + + public OsdCamera setZoomIso(CameraIsoEnum zoomIso) { + this.zoomIso = zoomIso; + return this; + } + + public ShutterSpeedEnum getZoomShutterSpeed() { + return zoomShutterSpeed; + } + + public OsdCamera setZoomShutterSpeed(ShutterSpeedEnum zoomShutterSpeed) { + this.zoomShutterSpeed = zoomShutterSpeed; + return this; + } + + public ExposureValueEnum getZoomExposureValue() { + return zoomExposureValue; + } + + public OsdCamera setZoomExposureValue(ExposureValueEnum zoomExposureValue) { + this.zoomExposureValue = zoomExposureValue; + return this; + } + + public FocusModeEnum getZoomFocusMode() { + return zoomFocusMode; + } + + public OsdCamera setZoomFocusMode(FocusModeEnum zoomFocusMode) { + this.zoomFocusMode = zoomFocusMode; + return this; + } + + public Integer getZoomFocusValue() { + return zoomFocusValue; + } + + public OsdCamera setZoomFocusValue(Integer zoomFocusValue) { + this.zoomFocusValue = zoomFocusValue; + return this; + } + + public Integer getZoomMaxFocusValue() { + return zoomMaxFocusValue; + } + + public OsdCamera setZoomMaxFocusValue(Integer zoomMaxFocusValue) { + this.zoomMaxFocusValue = zoomMaxFocusValue; + return this; + } + + public Integer getZoomMinFocusValue() { + return zoomMinFocusValue; + } + + public OsdCamera setZoomMinFocusValue(Integer zoomMinFocusValue) { + this.zoomMinFocusValue = zoomMinFocusValue; + return this; + } + + public MeteringModeEnum getIrMeteringMode() { + return irMeteringMode; + } + + public OsdCamera setIrMeteringMode(MeteringModeEnum irMeteringMode) { + this.irMeteringMode = irMeteringMode; + return this; + } + + public IrMeteringPoint getIrMeteringPoint() { + return irMeteringPoint; + } + + public OsdCamera setIrMeteringPoint(IrMeteringPoint irMeteringPoint) { + this.irMeteringPoint = irMeteringPoint; + return this; + } + + public IrMeteringArea getIrMeteringArea() { + return irMeteringArea; + } + + public OsdCamera setIrMeteringArea(IrMeteringArea irMeteringArea) { + this.irMeteringArea = irMeteringArea; + return this; + } + + public Integer getZoomCalibrateFarthestFocusValue() { + return zoomCalibrateFarthestFocusValue; + } + + public OsdCamera setZoomCalibrateFarthestFocusValue(Integer zoomCalibrateFarthestFocusValue) { + this.zoomCalibrateFarthestFocusValue = zoomCalibrateFarthestFocusValue; + return this; + } + + public Integer getZoomCalibrateNearestFocusValue() { + return zoomCalibrateNearestFocusValue; + } + + public OsdCamera setZoomCalibrateNearestFocusValue(Integer zoomCalibrateNearestFocusValue) { + this.zoomCalibrateNearestFocusValue = zoomCalibrateNearestFocusValue; + return this; + } + + public FocusStateEnum getZoomFocusState() { + return zoomFocusState; + } + + public OsdCamera setZoomFocusState(FocusStateEnum zoomFocusState) { + this.zoomFocusState = zoomFocusState; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdDock.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdDock.java new file mode 100644 index 0000000..113d2c3 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdDock.java @@ -0,0 +1,493 @@ +package com.dji.sdk.cloudapi.device; + +import com.dji.sdk.annotations.CloudSDKVersion; +import com.dji.sdk.config.version.CloudSDKVersionEnum; + +/** + * @author sean + * @version 1.3 + * @date 2022/11/3 + */ +public class OsdDock { + + private NetworkState networkState; + + private Boolean droneInDock; + + private DroneChargeState droneChargeState; + + private RainfallEnum rainfall; + + private Float windSpeed; + + private Float environmentTemperature; + + private Float temperature; + + private Integer humidity; + + private Float latitude; + + private Float longitude; + + private Float height; + + private AlternateLandPoint alternateLandPoint; + + private Long firstPowerOn; + + private DockPositionState positionState; + + private Storage storage; + + private DockModeCodeEnum modeCode; + + private CoverStateEnum coverState; + + private Boolean supplementLightState; + + private Boolean emergencyStopState; + + private AirConditioner airConditioner; + + private BatteryStoreModeEnum batteryStoreMode; + + private Boolean alarmState; + + private PutterStateEnum putterState; + + private DockSubDevice subDevice; + + private Integer jobNumber; + + private Long accTime; + + private Long activationTime; + + private OsdDockMaintainStatus maintainStatus; + + private Integer electricSupplyVoltage; + + private Integer workingVoltage; + + private Integer workingCurrent; + + private BackupBattery backupBattery; + + private DroneBatteryMaintenanceInfo droneBatteryMaintenanceInfo; + + private FlighttaskStepCodeEnum flighttaskStepCode; + + private Integer flighttaskPrepareCapacity; + + private MediaFileDetail mediaFileDetail; + + private WirelessLink wirelessLink; + + private DrcStateEnum drcState; + + /** + * User experience improvement program + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + private UserExperienceImprovementEnum userExperienceImprovement; + + public OsdDock() { + } + + @Override + public String toString() { + return "OsdDock{" + + "networkState=" + networkState + + ", droneInDock=" + droneInDock + + ", droneChargeState=" + droneChargeState + + ", rainfall=" + rainfall + + ", windSpeed=" + windSpeed + + ", environmentTemperature=" + environmentTemperature + + ", temperature=" + temperature + + ", humidity=" + humidity + + ", latitude=" + latitude + + ", longitude=" + longitude + + ", height=" + height + + ", alternateLandPoint=" + alternateLandPoint + + ", firstPowerOn=" + firstPowerOn + + ", positionState=" + positionState + + ", storage=" + storage + + ", modeCode=" + modeCode + + ", coverState=" + coverState + + ", supplementLightState=" + supplementLightState + + ", emergencyStopState=" + emergencyStopState + + ", airConditioner=" + airConditioner + + ", batteryStoreMode=" + batteryStoreMode + + ", alarmState=" + alarmState + + ", putterState=" + putterState + + ", subDevice=" + subDevice + + ", jobNumber=" + jobNumber + + ", accTime=" + accTime + + ", activationTime=" + activationTime + + ", maintainStatus=" + maintainStatus + + ", electricSupplyVoltage=" + electricSupplyVoltage + + ", workingVoltage=" + workingVoltage + + ", workingCurrent=" + workingCurrent + + ", backupBattery=" + backupBattery + + ", droneBatteryMaintenanceInfo=" + droneBatteryMaintenanceInfo + + ", flighttaskStepCode=" + flighttaskStepCode + + ", flighttaskPrepareCapacity=" + flighttaskPrepareCapacity + + ", mediaFileDetail=" + mediaFileDetail + + ", wirelessLink=" + wirelessLink + + ", drcState=" + drcState + + ", userExperienceImprovement=" + userExperienceImprovement + + '}'; + } + + public NetworkState getNetworkState() { + return networkState; + } + + public OsdDock setNetworkState(NetworkState networkState) { + this.networkState = networkState; + return this; + } + + public Boolean getDroneInDock() { + return droneInDock; + } + + public OsdDock setDroneInDock(Boolean droneInDock) { + this.droneInDock = droneInDock; + return this; + } + + public DroneChargeState getDroneChargeState() { + return droneChargeState; + } + + public OsdDock setDroneChargeState(DroneChargeState droneChargeState) { + this.droneChargeState = droneChargeState; + return this; + } + + public RainfallEnum getRainfall() { + return rainfall; + } + + public OsdDock setRainfall(RainfallEnum rainfall) { + this.rainfall = rainfall; + return this; + } + + public Float getWindSpeed() { + return windSpeed; + } + + public OsdDock setWindSpeed(Float windSpeed) { + this.windSpeed = windSpeed; + return this; + } + + public Float getEnvironmentTemperature() { + return environmentTemperature; + } + + public OsdDock setEnvironmentTemperature(Float environmentTemperature) { + this.environmentTemperature = environmentTemperature; + return this; + } + + public Float getTemperature() { + return temperature; + } + + public OsdDock setTemperature(Float temperature) { + this.temperature = temperature; + return this; + } + + public Integer getHumidity() { + return humidity; + } + + public OsdDock setHumidity(Integer humidity) { + this.humidity = humidity; + return this; + } + + public Float getLatitude() { + return latitude; + } + + public OsdDock setLatitude(Float latitude) { + this.latitude = latitude; + return this; + } + + public Float getLongitude() { + return longitude; + } + + public OsdDock setLongitude(Float longitude) { + this.longitude = longitude; + return this; + } + + public Float getHeight() { + return height; + } + + public OsdDock setHeight(Float height) { + this.height = height; + return this; + } + + public AlternateLandPoint getAlternateLandPoint() { + return alternateLandPoint; + } + + public OsdDock setAlternateLandPoint(AlternateLandPoint alternateLandPoint) { + this.alternateLandPoint = alternateLandPoint; + return this; + } + + public Long getFirstPowerOn() { + return firstPowerOn; + } + + public OsdDock setFirstPowerOn(Long firstPowerOn) { + this.firstPowerOn = firstPowerOn; + return this; + } + + public DockPositionState getPositionState() { + return positionState; + } + + public OsdDock setPositionState(DockPositionState positionState) { + this.positionState = positionState; + return this; + } + + public Storage getStorage() { + return storage; + } + + public OsdDock setStorage(Storage storage) { + this.storage = storage; + return this; + } + + public DockModeCodeEnum getModeCode() { + return modeCode; + } + + public OsdDock setModeCode(DockModeCodeEnum modeCode) { + this.modeCode = modeCode; + return this; + } + + public CoverStateEnum getCoverState() { + return coverState; + } + + public OsdDock setCoverState(CoverStateEnum coverState) { + this.coverState = coverState; + return this; + } + + public Boolean getSupplementLightState() { + return supplementLightState; + } + + public OsdDock setSupplementLightState(Boolean supplementLightState) { + this.supplementLightState = supplementLightState; + return this; + } + + public Boolean getEmergencyStopState() { + return emergencyStopState; + } + + public OsdDock setEmergencyStopState(Boolean emergencyStopState) { + this.emergencyStopState = emergencyStopState; + return this; + } + + public AirConditioner getAirConditioner() { + return airConditioner; + } + + public OsdDock setAirConditioner(AirConditioner airConditioner) { + this.airConditioner = airConditioner; + return this; + } + + public BatteryStoreModeEnum getBatteryStoreMode() { + return batteryStoreMode; + } + + public OsdDock setBatteryStoreMode(BatteryStoreModeEnum batteryStoreMode) { + this.batteryStoreMode = batteryStoreMode; + return this; + } + + public Boolean getAlarmState() { + return alarmState; + } + + public OsdDock setAlarmState(Boolean alarmState) { + this.alarmState = alarmState; + return this; + } + + public PutterStateEnum getPutterState() { + return putterState; + } + + public OsdDock setPutterState(PutterStateEnum putterState) { + this.putterState = putterState; + return this; + } + + public DockSubDevice getSubDevice() { + return subDevice; + } + + public OsdDock setSubDevice(DockSubDevice subDevice) { + this.subDevice = subDevice; + return this; + } + + public Integer getJobNumber() { + return jobNumber; + } + + public OsdDock setJobNumber(Integer jobNumber) { + this.jobNumber = jobNumber; + return this; + } + + public Long getAccTime() { + return accTime; + } + + public OsdDock setAccTime(Long accTime) { + this.accTime = accTime; + return this; + } + + public Long getActivationTime() { + return activationTime; + } + + public OsdDock setActivationTime(Long activationTime) { + this.activationTime = activationTime; + return this; + } + + public OsdDockMaintainStatus getMaintainStatus() { + return maintainStatus; + } + + public OsdDock setMaintainStatus(OsdDockMaintainStatus maintainStatus) { + this.maintainStatus = maintainStatus; + return this; + } + + public Integer getElectricSupplyVoltage() { + return electricSupplyVoltage; + } + + public OsdDock setElectricSupplyVoltage(Integer electricSupplyVoltage) { + this.electricSupplyVoltage = electricSupplyVoltage; + return this; + } + + public Integer getWorkingVoltage() { + return workingVoltage; + } + + public OsdDock setWorkingVoltage(Integer workingVoltage) { + this.workingVoltage = workingVoltage; + return this; + } + + public Integer getWorkingCurrent() { + return workingCurrent; + } + + public OsdDock setWorkingCurrent(Integer workingCurrent) { + this.workingCurrent = workingCurrent; + return this; + } + + public BackupBattery getBackupBattery() { + return backupBattery; + } + + public OsdDock setBackupBattery(BackupBattery backupBattery) { + this.backupBattery = backupBattery; + return this; + } + + public DroneBatteryMaintenanceInfo getDroneBatteryMaintenanceInfo() { + return droneBatteryMaintenanceInfo; + } + + public OsdDock setDroneBatteryMaintenanceInfo(DroneBatteryMaintenanceInfo droneBatteryMaintenanceInfo) { + this.droneBatteryMaintenanceInfo = droneBatteryMaintenanceInfo; + return this; + } + + public FlighttaskStepCodeEnum getFlighttaskStepCode() { + return flighttaskStepCode; + } + + public OsdDock setFlighttaskStepCode(FlighttaskStepCodeEnum flighttaskStepCode) { + this.flighttaskStepCode = flighttaskStepCode; + return this; + } + + public Integer getFlighttaskPrepareCapacity() { + return flighttaskPrepareCapacity; + } + + public OsdDock setFlighttaskPrepareCapacity(Integer flighttaskPrepareCapacity) { + this.flighttaskPrepareCapacity = flighttaskPrepareCapacity; + return this; + } + + public MediaFileDetail getMediaFileDetail() { + return mediaFileDetail; + } + + public OsdDock setMediaFileDetail(MediaFileDetail mediaFileDetail) { + this.mediaFileDetail = mediaFileDetail; + return this; + } + + public WirelessLink getWirelessLink() { + return wirelessLink; + } + + public OsdDock setWirelessLink(WirelessLink wirelessLink) { + this.wirelessLink = wirelessLink; + return this; + } + + public DrcStateEnum getDrcState() { + return drcState; + } + + public OsdDock setDrcState(DrcStateEnum drcState) { + this.drcState = drcState; + return this; + } + + public UserExperienceImprovementEnum getUserExperienceImprovement() { + return userExperienceImprovement; + } + + public OsdDock setUserExperienceImprovement(UserExperienceImprovementEnum userExperienceImprovement) { + this.userExperienceImprovement = userExperienceImprovement; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdDockDrone.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdDockDrone.java new file mode 100644 index 0000000..2d2cbc5 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdDockDrone.java @@ -0,0 +1,472 @@ +package com.dji.sdk.cloudapi.device; + +import com.dji.sdk.annotations.CloudSDKVersion; +import com.dji.sdk.config.version.CloudSDKVersionEnum; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +/** + * @author sean.zhou + * @version 0.1 + * @date 2021/11/23 + */ +public class OsdDockDrone { + + private Float attitudeHead; + + private Double attitudePitch; + + private Double attitudeRoll; + + private Float elevation; + + private DroneBattery battery; + + private String firmwareVersion; + + private GearEnum gear; + + private Float height; + + private Float homeDistance; + + private Float horizontalSpeed; + + private Float latitude; + + private Float longitude; + + private DroneModeCodeEnum modeCode; + + private Double totalFlightDistance; + + private Float totalFlightTime; + + private Float verticalSpeed; + + private WindDirectionEnum windDirection; + + private Float windSpeed; + + private DronePositionState positionState; + + @JsonProperty(PayloadModelConst.PAYLOAD_KEY) + private List payloads; + + private Storage storage; + + private SwitchActionEnum nightLightsState; + + private Integer heightLimit; + + private DockDistanceLimitStatus distanceLimitStatus; + + private ObstacleAvoidance obstacleAvoidance; + + private Long activationTime; + + private List cameras; + + private RcLostActionEnum rcLostAction; + + private Integer rthAltitude; + + private Integer totalFlightSorties; + + @CloudSDKVersion(deprecated = CloudSDKVersionEnum.V1_0_0) + private ExitWaylineWhenRcLostEnum exitWaylineWhenRcLost; + + private String country; + + private Boolean ridState; + + @JsonProperty("is_near_area_limit") + private Boolean nearAreaLimit; + + @JsonProperty("is_near_height_limit") + private Boolean nearHeightLimit; + + private OsdDroneMaintainStatus maintainStatus; + + private String trackId; + + public OsdDockDrone() { + } + + @Override + public String toString() { + return "OsdDockDrone{" + + "attitudeHead=" + attitudeHead + + ", attitudePitch=" + attitudePitch + + ", attitudeRoll=" + attitudeRoll + + ", elevation=" + elevation + + ", battery=" + battery + + ", firmwareVersion='" + firmwareVersion + '\'' + + ", gear=" + gear + + ", height=" + height + + ", homeDistance=" + homeDistance + + ", horizontalSpeed=" + horizontalSpeed + + ", latitude=" + latitude + + ", longitude=" + longitude + + ", modeCode=" + modeCode + + ", totalFlightDistance=" + totalFlightDistance + + ", totalFlightTime=" + totalFlightTime + + ", verticalSpeed=" + verticalSpeed + + ", windDirection=" + windDirection + + ", windSpeed=" + windSpeed + + ", positionState=" + positionState + + ", payloads=" + payloads + + ", storage=" + storage + + ", nightLightsState=" + nightLightsState + + ", heightLimit=" + heightLimit + + ", distanceLimitStatus=" + distanceLimitStatus + + ", obstacleAvoidance=" + obstacleAvoidance + + ", activationTime=" + activationTime + + ", cameras=" + cameras + + ", rcLostAction=" + rcLostAction + + ", rthAltitude=" + rthAltitude + + ", totalFlightSorties=" + totalFlightSorties + + ", exitWaylineWhenRcLost=" + exitWaylineWhenRcLost + + ", country='" + country + '\'' + + ", ridState=" + ridState + + ", nearAreaLimit=" + nearAreaLimit + + ", nearHeightLimit=" + nearHeightLimit + + ", maintainStatus=" + maintainStatus + + ", trackId='" + trackId + '\'' + + '}'; + } + + public Float getAttitudeHead() { + return attitudeHead; + } + + public OsdDockDrone setAttitudeHead(Float attitudeHead) { + this.attitudeHead = attitudeHead; + return this; + } + + public Double getAttitudePitch() { + return attitudePitch; + } + + public OsdDockDrone setAttitudePitch(Double attitudePitch) { + this.attitudePitch = attitudePitch; + return this; + } + + public Double getAttitudeRoll() { + return attitudeRoll; + } + + public OsdDockDrone setAttitudeRoll(Double attitudeRoll) { + this.attitudeRoll = attitudeRoll; + return this; + } + + public Float getElevation() { + return elevation; + } + + public OsdDockDrone setElevation(Float elevation) { + this.elevation = elevation; + return this; + } + + public DroneBattery getBattery() { + return battery; + } + + public OsdDockDrone setBattery(DroneBattery battery) { + this.battery = battery; + return this; + } + + public String getFirmwareVersion() { + return firmwareVersion; + } + + public OsdDockDrone setFirmwareVersion(String firmwareVersion) { + this.firmwareVersion = firmwareVersion; + return this; + } + + public GearEnum getGear() { + return gear; + } + + public OsdDockDrone setGear(GearEnum gear) { + this.gear = gear; + return this; + } + + public Float getHeight() { + return height; + } + + public OsdDockDrone setHeight(Float height) { + this.height = height; + return this; + } + + public Float getHomeDistance() { + return homeDistance; + } + + public OsdDockDrone setHomeDistance(Float homeDistance) { + this.homeDistance = homeDistance; + return this; + } + + public Float getHorizontalSpeed() { + return horizontalSpeed; + } + + public OsdDockDrone setHorizontalSpeed(Float horizontalSpeed) { + this.horizontalSpeed = horizontalSpeed; + return this; + } + + public Float getLatitude() { + return latitude; + } + + public OsdDockDrone setLatitude(Float latitude) { + this.latitude = latitude; + return this; + } + + public Float getLongitude() { + return longitude; + } + + public OsdDockDrone setLongitude(Float longitude) { + this.longitude = longitude; + return this; + } + + public DroneModeCodeEnum getModeCode() { + return modeCode; + } + + public OsdDockDrone setModeCode(DroneModeCodeEnum modeCode) { + this.modeCode = modeCode; + return this; + } + + public Double getTotalFlightDistance() { + return totalFlightDistance; + } + + public OsdDockDrone setTotalFlightDistance(Double totalFlightDistance) { + this.totalFlightDistance = totalFlightDistance; + return this; + } + + public Float getTotalFlightTime() { + return totalFlightTime; + } + + public OsdDockDrone setTotalFlightTime(Float totalFlightTime) { + this.totalFlightTime = totalFlightTime; + return this; + } + + public Float getVerticalSpeed() { + return verticalSpeed; + } + + public OsdDockDrone setVerticalSpeed(Float verticalSpeed) { + this.verticalSpeed = verticalSpeed; + return this; + } + + public WindDirectionEnum getWindDirection() { + return windDirection; + } + + public OsdDockDrone setWindDirection(WindDirectionEnum windDirection) { + this.windDirection = windDirection; + return this; + } + + public Float getWindSpeed() { + return windSpeed; + } + + public OsdDockDrone setWindSpeed(Float windSpeed) { + this.windSpeed = windSpeed; + return this; + } + + public DronePositionState getPositionState() { + return positionState; + } + + public OsdDockDrone setPositionState(DronePositionState positionState) { + this.positionState = positionState; + return this; + } + + public List getPayloads() { + return payloads; + } + + public OsdDockDrone setPayloads(List payloads) { + this.payloads = payloads; + return this; + } + + public Storage getStorage() { + return storage; + } + + public OsdDockDrone setStorage(Storage storage) { + this.storage = storage; + return this; + } + + public SwitchActionEnum getNightLightsState() { + return nightLightsState; + } + + public OsdDockDrone setNightLightsState(SwitchActionEnum nightLightsState) { + this.nightLightsState = nightLightsState; + return this; + } + + public Integer getHeightLimit() { + return heightLimit; + } + + public OsdDockDrone setHeightLimit(Integer heightLimit) { + this.heightLimit = heightLimit; + return this; + } + + public DockDistanceLimitStatus getDistanceLimitStatus() { + return distanceLimitStatus; + } + + public OsdDockDrone setDistanceLimitStatus(DockDistanceLimitStatus distanceLimitStatus) { + this.distanceLimitStatus = distanceLimitStatus; + return this; + } + + public ObstacleAvoidance getObstacleAvoidance() { + return obstacleAvoidance; + } + + public OsdDockDrone setObstacleAvoidance(ObstacleAvoidance obstacleAvoidance) { + this.obstacleAvoidance = obstacleAvoidance; + return this; + } + + public Long getActivationTime() { + return activationTime; + } + + public OsdDockDrone setActivationTime(Long activationTime) { + this.activationTime = activationTime; + return this; + } + + public List getCameras() { + return cameras; + } + + public OsdDockDrone setCameras(List cameras) { + this.cameras = cameras; + return this; + } + + public RcLostActionEnum getRcLostAction() { + return rcLostAction; + } + + public OsdDockDrone setRcLostAction(RcLostActionEnum rcLostAction) { + this.rcLostAction = rcLostAction; + return this; + } + + public Integer getRthAltitude() { + return rthAltitude; + } + + public OsdDockDrone setRthAltitude(Integer rthAltitude) { + this.rthAltitude = rthAltitude; + return this; + } + + public Integer getTotalFlightSorties() { + return totalFlightSorties; + } + + public OsdDockDrone setTotalFlightSorties(Integer totalFlightSorties) { + this.totalFlightSorties = totalFlightSorties; + return this; + } + + public ExitWaylineWhenRcLostEnum getExitWaylineWhenRcLost() { + return exitWaylineWhenRcLost; + } + + public OsdDockDrone setExitWaylineWhenRcLost(ExitWaylineWhenRcLostEnum exitWaylineWhenRcLost) { + this.exitWaylineWhenRcLost = exitWaylineWhenRcLost; + return this; + } + + public String getCountry() { + return country; + } + + public OsdDockDrone setCountry(String country) { + this.country = country; + return this; + } + + public Boolean getRidState() { + return ridState; + } + + public OsdDockDrone setRidState(Boolean ridState) { + this.ridState = ridState; + return this; + } + + public Boolean getNearAreaLimit() { + return nearAreaLimit; + } + + public OsdDockDrone setNearAreaLimit(Boolean nearAreaLimit) { + this.nearAreaLimit = nearAreaLimit; + return this; + } + + public Boolean getNearHeightLimit() { + return nearHeightLimit; + } + + public OsdDockDrone setNearHeightLimit(Boolean nearHeightLimit) { + this.nearHeightLimit = nearHeightLimit; + return this; + } + + public OsdDroneMaintainStatus getMaintainStatus() { + return maintainStatus; + } + + public OsdDockDrone setMaintainStatus(OsdDroneMaintainStatus maintainStatus) { + this.maintainStatus = maintainStatus; + return this; + } + + public String getTrackId() { + return trackId; + } + + public OsdDockDrone setTrackId(String trackId) { + this.trackId = trackId; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/cloudapi/device/OsdDockMaintainStatus.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdDockMaintainStatus.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/OsdDockMaintainStatus.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdDockMaintainStatus.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/OsdDroneMaintainStatus.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdDroneMaintainStatus.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/OsdDroneMaintainStatus.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdDroneMaintainStatus.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/OsdRcDrone.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdRcDrone.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/OsdRcDrone.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdRcDrone.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/OsdRemoteControl.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdRemoteControl.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/OsdRemoteControl.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/OsdRemoteControl.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/PayloadFirmwareVersion.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PayloadFirmwareVersion.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/PayloadFirmwareVersion.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PayloadFirmwareVersion.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/PayloadIndex.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PayloadIndex.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/PayloadIndex.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PayloadIndex.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PayloadModelConst.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PayloadModelConst.java new file mode 100644 index 0000000..b09d106 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PayloadModelConst.java @@ -0,0 +1,35 @@ +package com.dji.sdk.cloudapi.device; + +import java.util.Arrays; +import java.util.Set; +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 getAllModelWithPosition() { + Set 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", "")) + .flatMap(m -> position.stream().map(p -> m.concat("-").concat(p))).collect(Collectors.toSet()); + } + + public static Set getAllIndexWithPosition() { + Set 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())) + .flatMap(m -> position.stream().map(p -> m.concat("-").concat(p))).collect(Collectors.toSet()); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/PayloadPositionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PayloadPositionEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/PayloadPositionEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PayloadPositionEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/PositionFixedEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PositionFixedEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/PositionFixedEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PositionFixedEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/PutterStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PutterStateEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/PutterStateEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/PutterStateEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/RainfallEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RainfallEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/RainfallEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RainfallEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/RcDistanceLimitStatus.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcDistanceLimitStatus.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/RcDistanceLimitStatus.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcDistanceLimitStatus.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/RcDroneControlSource.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcDroneControlSource.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/RcDroneControlSource.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcDroneControlSource.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/RcDronePayload.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcDronePayload.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/RcDronePayload.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcDronePayload.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/RcLiveStatus.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcLiveStatus.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/RcLiveStatus.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcLiveStatus.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/RcLiveStatusData.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcLiveStatusData.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/RcLiveStatusData.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcLiveStatusData.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/RcLostActionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcLostActionEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/RcLostActionEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcLostActionEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/RcPayloadControlSource.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcPayloadControlSource.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/RcPayloadControlSource.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/RcPayloadControlSource.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ShutterSpeedEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ShutterSpeedEnum.java new file mode 100644 index 0000000..3a8c69c --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ShutterSpeedEnum.java @@ -0,0 +1,169 @@ +package com.dji.sdk.cloudapi.device; + +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.9 + * @date 2023/12/12 + */ +public enum ShutterSpeedEnum { + + /** + * 1/8000 s + */ + _1_8000TH_S(0), + + _1_6400TH_S(1), + + _1_6000TH_S(2), + + _1_5000TH_S(3), + + _1_4000TH_S(4), + + _1_3200TH_S(5), + + _1_3000TH_S(6), + + _1_2500TH_S(7), + + _1_2000TH_S(8), + + _1_1600TH_S(9), + + _1_1500TH_S(10), + + _1_1250TH_S(11), + + _1_1000TH_S(12), + + _1_800TH_S(13), + + _1_725TH_S(14), + + _1_640TH_S(15), + + _1_500TH_S(16), + + _1_400TH_S(17), + + _1_350TH_S(18), + + _1_320TH_S(19), + + _1_250TH_S(20), + + _1_240TH_S(21), + + _1_200TH_S(22), + + _1_180TH_S(23), + + _1_160TH_S(24), + + _1_125TH_S(25), + + _1_120TH_S(26), + + _1_100TH_S(27), + + _1_90TH_S(28), + + _1_80TH_S(29), + + _1_60TH_S(30), + + _1_50TH_S(31), + + _1_40TH_S(32), + + _1_30TH_S(33), + + _1_25TH_S(34), + + _1_20TH_S(35), + + _1_15TH_S(36), + + _2_25THS_S(37), + + _1_10TH_S(38), + + _1_8TH_S(39), + + _4_25THS_S(40), + + _1_5TH_S(41), + + _1_4TH_S(42), + + _1_3TH_S(43), + + _2_5THS_S(44), + + _1_2TH_S(45), + + /** + * 3/5 s + */ + _3_5THS_S(46), + + _4_5TH_S(47), + + /** + * 1 s + */ + _1S(48), + + /** + * 1.3 s + */ + _1_DOT_3S(49), + + _1_DOT_6_S(50), + + _2_S(51), + + _2_DOT_5_S(52), + + _3_DOT_S(53), + + _3_DOT_2_S(54), + + _4_DOT_S(55), + + _5_DOT_S(56), + + _6_DOT_S(57), + + _7_DOT_S(58), + + _8_DOT_S(59), + + AUTO(65534), + + ; + + private final int speed; + + ShutterSpeedEnum(int speed) { + this.speed = speed; + } + + @JsonValue + public int getSpeed() { + return speed; + } + + @JsonCreator + public static ShutterSpeedEnum find(int speed) { + return Arrays.stream(values()).filter(speedEnum -> speedEnum.speed == speed).findAny() + .orElseThrow(() -> new CloudSDKException(ShutterSpeedEnum.class, speed)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimCardStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimCardStateEnum.java new file mode 100644 index 0000000..9ca6623 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimCardStateEnum.java @@ -0,0 +1,39 @@ +package com.dji.sdk.cloudapi.device; + +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 + * @date 2023/10/20 + */ +public enum SimCardStateEnum { + + NO_CARD(0), + + INSERTED(1), + + ; + + private final int state; + + SimCardStateEnum(int state) { + this.state = state; + } + + @JsonValue + public int getState() { + return state; + } + + @JsonCreator + public static SimCardStateEnum find(int state) { + return Arrays.stream(values()).filter(stateEnum -> stateEnum.state == state).findAny() + .orElseThrow(() -> new CloudSDKException(SimCardStateEnum.class, state)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimInfo.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimInfo.java new file mode 100644 index 0000000..ab9d390 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimInfo.java @@ -0,0 +1,63 @@ +package com.dji.sdk.cloudapi.device; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class SimInfo { + + /** + * sim supported operators + */ + private TelecomOperatorEnum telecomOperator; + + /** + * Type of physical sim card + */ + private SimTypeEnum simType; + + /** + * The unique identification mark of the sim card can be used to purchase physical sim card packages. + */ + private String iccid; + + public SimInfo() { + } + + @Override + public String toString() { + return "SimInfo{" + + "telecomOperator=" + telecomOperator + + ", simType=" + simType + + ", iccid='" + iccid + '\'' + + '}'; + } + + public TelecomOperatorEnum getTelecomOperator() { + return telecomOperator; + } + + public SimInfo setTelecomOperator(TelecomOperatorEnum telecomOperator) { + this.telecomOperator = telecomOperator; + return this; + } + + public SimTypeEnum getSimType() { + return simType; + } + + public SimInfo setSimType(SimTypeEnum simType) { + this.simType = simType; + return this; + } + + public String getIccid() { + return iccid; + } + + public SimInfo setIccid(String iccid) { + this.iccid = iccid; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimSlotEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimSlotEnum.java new file mode 100644 index 0000000..4576e64 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimSlotEnum.java @@ -0,0 +1,41 @@ +package com.dji.sdk.cloudapi.device; + +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 + * @date 2023/10/20 + */ +public enum SimSlotEnum { + + UNKNOWN(0), + + SIM(1), + + ESIM(2), + + ; + + private final int slot; + + SimSlotEnum(int slot) { + this.slot = slot; + } + + @JsonValue + public int getSlot() { + return slot; + } + + @JsonCreator + public static SimSlotEnum find(int slot) { + return Arrays.stream(values()).filter(slotEnum -> slotEnum.slot == slot).findAny() + .orElseThrow(() -> new CloudSDKException(SimSlotEnum.class, slot)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimTypeEnum.java new file mode 100644 index 0000000..f23e2bd --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SimTypeEnum.java @@ -0,0 +1,41 @@ +package com.dji.sdk.cloudapi.device; + +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 + * @date 2023/10/20 + */ +public enum SimTypeEnum { + + UNKNOWN(0), + + ORDINARY(1), + + THREE_NETWORK_MODES(2), + + ; + + private final int type; + + SimTypeEnum(int type) { + this.type = type; + } + + @JsonValue + public int getType() { + return type; + } + + @JsonCreator + public static SimTypeEnum find(int type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny() + .orElseThrow(() -> new CloudSDKException(SimTypeEnum.class, type)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/SmartTrackPoint.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SmartTrackPoint.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/SmartTrackPoint.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SmartTrackPoint.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/Storage.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/Storage.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/Storage.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/Storage.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/SwitchActionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SwitchActionEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/SwitchActionEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/SwitchActionEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/TelecomOperatorEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/TelecomOperatorEnum.java new file mode 100644 index 0000000..a98554e --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/TelecomOperatorEnum.java @@ -0,0 +1,43 @@ +package com.dji.sdk.cloudapi.device; + +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 + * @date 2023/10/20 + */ +public enum TelecomOperatorEnum { + + UNKNOWN(0), + + CHINA_MOBILE(1), + + CHINA_UNICOM(2), + + CHINA_TELECOM(3), + + ; + + private final int operator; + + TelecomOperatorEnum(int operator) { + this.operator = operator; + } + + @JsonValue + public int getOperator() { + return operator; + } + + @JsonCreator + public static TelecomOperatorEnum find(int operator) { + return Arrays.stream(values()).filter(operatorEnum -> operatorEnum.operator == operator).findAny() + .orElseThrow(() -> new CloudSDKException(TelecomOperatorEnum.class, operator)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/ThermalGainModeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ThermalGainModeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/ThermalGainModeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ThermalGainModeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/ThermalPaletteStyleEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ThermalPaletteStyleEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/ThermalPaletteStyleEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/ThermalPaletteStyleEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/TrackTargetModeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/TrackTargetModeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/TrackTargetModeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/TrackTargetModeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/UpdateTopo.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/UpdateTopo.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/UpdateTopo.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/UpdateTopo.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/UpdateTopoSubDevice.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/UpdateTopoSubDevice.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/UpdateTopoSubDevice.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/UpdateTopoSubDevice.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/UserExperienceImprovementEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/UserExperienceImprovementEnum.java new file mode 100644 index 0000000..c970c57 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/UserExperienceImprovementEnum.java @@ -0,0 +1,40 @@ +package com.dji.sdk.cloudapi.device; + +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 + * @date 2023/10/13 + */ +public enum UserExperienceImprovementEnum { + + INITIAL(0), + + REFUSE(1), + + AGREE(2), + ; + + private final int state; + + UserExperienceImprovementEnum(int state) { + this.state = state; + } + + @JsonValue + public int getState() { + return state; + } + + @JsonCreator + public static UserExperienceImprovementEnum find(int state) { + return Arrays.stream(values()).filter(stateEnum -> stateEnum.state == state).findAny() + .orElseThrow(() -> new CloudSDKException(UserExperienceImprovementEnum.class, state)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/VideoId.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/VideoId.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/VideoId.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/VideoId.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/WindDirectionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/WindDirectionEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/WindDirectionEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/WindDirectionEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/device/WirelessLink.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/WirelessLink.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/device/WirelessLink.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/WirelessLink.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/api/AbstractDeviceService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/api/AbstractDeviceService.java new file mode 100644 index 0000000..08626e2 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/api/AbstractDeviceService.java @@ -0,0 +1,274 @@ +package com.dji.sdk.cloudapi.device.api; + +import com.dji.sdk.annotations.CloudSDKVersion; +import com.dji.sdk.cloudapi.device.*; +import com.dji.sdk.cloudapi.property.DockDroneCommanderFlightHeight; +import com.dji.sdk.cloudapi.property.DockDroneCommanderModeLostAction; +import com.dji.sdk.cloudapi.property.DockDroneRthMode; +import com.dji.sdk.config.version.CloudSDKVersionEnum; +import com.dji.sdk.config.version.GatewayTypeEnum; +import com.dji.sdk.mqtt.ChannelName; +import com.dji.sdk.mqtt.MqttReply; +import com.dji.sdk.mqtt.osd.TopicOsdRequest; +import com.dji.sdk.mqtt.state.TopicStateRequest; +import com.dji.sdk.mqtt.state.TopicStateResponse; +import com.dji.sdk.mqtt.status.TopicStatusRequest; +import com.dji.sdk.mqtt.status.TopicStatusResponse; +import org.springframework.integration.annotation.ServiceActivator; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageHeaders; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/30 + */ +public class AbstractDeviceService { + + /** + * osd dock + * @param request data + * @param headers The headers for a {@link Message}. + * @return status_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_OSD_DOCK) + public void osdDock(TopicOsdRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("osdDock not implemented"); + } + + /** + * osd dock drone + * @param request data + * @param headers The headers for a {@link Message}. + * @return status_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_OSD_DOCK_DRONE) + public void osdDockDrone(TopicOsdRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("osdDockDrone not implemented"); + } + + /** + * osd remote control + * @param request data + * @param headers The headers for a {@link Message}. + * @return status_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_OSD_RC) + public void osdRemoteControl(TopicOsdRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("osdRemoteControl not implemented"); + } + + /** + * osd remote control drone + * @param request data + * @param headers The headers for a {@link Message}. + * @return status_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_OSD_RC_DRONE) + public void osdRcDrone(TopicOsdRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("osdRcDrone not implemented"); + } + + /** + * Gateway device + sub device online + * @param request data + * @param headers The headers for a {@link Message}. + * @return status_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATUS_ONLINE, outputChannel = ChannelName.OUTBOUND_STATUS) + public TopicStatusResponse updateTopoOnline(TopicStatusRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("updateTopoOnline not implemented"); + } + + /** + * Sub device offline + * @param request data + * @param headers The headers for a {@link Message}. + * @return status_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATUS_OFFLINE, outputChannel = ChannelName.OUTBOUND_STATUS) + public TopicStatusResponse updateTopoOffline(TopicStatusRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("updateTopoOffline not implemented"); + } + + /** + * Firmware version update for dock and drone + * @param request data + * @param headers The headers for a {@link Message}. + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_FIRMWARE_VERSION) + public void dockFirmwareVersionUpdate(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockFirmwareVersionUpdate not implemented"); + } + + /** + * Firmware version update for remote control and drone + * @param request data + * @param headers The headers for a {@link Message}. + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_RC_AND_DRONE_FIRMWARE_VERSION) + public void rcAndDroneFirmwareVersionUpdate(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("rcAndDroneFirmwareVersionUpdate not implemented"); + } + + /** + * Drone control source update for dock and drone + * @param request data + * @param headers The headers for a {@link Message}. + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_DRONE_CONTROL_SOURCE) + public void dockControlSourceUpdate(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockControlSourceUpdate not implemented"); + } + + /** + * Drone control source update for remote control and drone + * @param request data + * @param headers The headers for a {@link Message}. + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_RC_CONTROL_SOURCE) + public void rcControlSourceUpdate(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("rcControlSourceUpdate not implemented"); + } + + /** + * Live status update for dock and drone + * @param request data + * @param headers The headers for a {@link Message}. + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_LIVE_STATUS) + public void dockLiveStatusUpdate(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockLiveStatusUpdate not implemented"); + } + + /** + * Live status source update for remote control and drone + * @param request data + * @param headers The headers for a {@link Message}. + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_RC_LIVE_STATUS) + public void rcLiveStatusUpdate(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("rcLiveStatusUpdate not implemented"); + } + + /** + * Payload firmware version update for remote control and drone + * @param request data + * @param headers The headers for a {@link Message}. + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_RC_PAYLOAD_FIRMWARE) + public void rcPayloadFirmwareVersionUpdate(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("rcPayloadFirmwareVersionUpdate not implemented"); + } + + /** + * Wpmz firmware version update for drone + * @param request data + * @param headers The headers for a {@link Message}. + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_DRONE_WPMZ_VERSION) + public void dockWpmzVersionUpdate(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockWpmzVersionUpdate not implemented"); + } + + /** + * Styles supported by the IR palette + * @param request data + * @param headers The headers for a {@link Message}. + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_DRONE_THERMAL_SUPPORTED_PALETTE_STYLE) + public void dockThermalSupportedPaletteStyle(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockThermalSupportedPaletteStyle not implemented"); + } + + /** + * Under optimal RTH mode, aircraft will automatically plan the optimal return altitude. + * When the environment and lighting do not meet the requirements of the visual system (such as direct sunlight in the evening or no light at night), the aircraft will perform a straight-line return at the altitude you have set. + * @param request data + * @param headers The headers for a {@link Message}. + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_DRONE_RTH_MODE, outputChannel = ChannelName.OUTBOUND_STATE) + public TopicStateResponse dockDroneRthMode(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockRthMode not implemented"); + } + + /** + * Current RTH height mode + * @param request data + * @param headers The headers for a {@link Message}. + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_DRONE_CURRENT_RTH_MODE, outputChannel = ChannelName.OUTBOUND_STATE) + public TopicStateResponse dockDroneCurrentRthMode(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockCurrentRthMode not implemented"); + } + + /** + * To-point flight mission out of control action + * @param request data + * @param headers The headers for a {@link Message}. + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_DRONE_COMMANDER_MODE_LOST_ACTION, outputChannel = ChannelName.OUTBOUND_STATE) + public TopicStateResponse dockDroneCommanderModeLostAction(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockDroneCommanderModeLostAction not implemented"); + } + + /** + * Current mode of to-point flight mission + * @param request data + * @param headers The headers for a {@link Message}. + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_DRONE_CURRENT_COMMANDER_FLIGHT_MODE, outputChannel = ChannelName.OUTBOUND_STATE) + public TopicStateResponse dockDroneCurrentCommanderFlightMode(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockDroneCurrentCommanderFlightMode not implemented"); + } + + /** + * Relative to (airport) takeoff point altitude. + * ALT. + * @param request data + * @param headers The headers for a {@link Message}. + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_DRONE_COMMANDER_FLIGHT_HEIGHT, outputChannel = ChannelName.OUTBOUND_STATE) + public TopicStateResponse dockDroneCommanderFlightHeight(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockDroneCommanderFlightHeight not implemented"); + } + + /** + * The reason why the drone enters current state + * @param request data + * @param headers The headers for a {@link Message}. + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_DRONE_MODE_CODE_REASON, outputChannel = ChannelName.OUTBOUND_STATE) + public TopicStateResponse dockDroneModeCodeReason(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockDroneModeCodeReason not implemented"); + } + + /** + * 4g dongle information + * @param request data + * @param headers The headers for a {@link Message}. + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_1, include = GatewayTypeEnum.DOCK2) + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_AND_DRONE_DONGLE_INFOS, outputChannel = ChannelName.OUTBOUND_STATE) + public TopicStateResponse dongleInfos(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dongleInfos not implemented"); + } + + /** + * silent mode + * @param request data + * @param headers The headers for a {@link Message}. + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_2, include = GatewayTypeEnum.DOCK) + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_SILENT_MODE, outputChannel = ChannelName.OUTBOUND_STATE) + public TopicStateResponse dockSilentMode(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockSilentMode not implemented"); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/firmware/FirmwareErrorCodeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/FirmwareErrorCodeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/firmware/FirmwareErrorCodeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/FirmwareErrorCodeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/firmware/FirmwareMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/FirmwareMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/firmware/FirmwareMethodEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/FirmwareMethodEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/firmware/FirmwareUpgradeTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/FirmwareUpgradeTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/firmware/FirmwareUpgradeTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/FirmwareUpgradeTypeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateDevice.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateDevice.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateDevice.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateDevice.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateRequest.java new file mode 100644 index 0000000..9c00762 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateRequest.java @@ -0,0 +1,39 @@ +package com.dji.sdk.cloudapi.firmware; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/28 + */ +public class OtaCreateRequest extends BaseModel { + + @Size(min = 1, max = 2) + @NotNull + private List<@Valid OtaCreateDevice> devices; + + public OtaCreateRequest() { + } + + @Override + public String toString() { + return "OtaCreateRequest{" + + "devices=" + devices + + '}'; + } + + public List getDevices() { + return devices; + } + + public OtaCreateRequest setDevices(List devices) { + this.devices = devices; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateResponse.java diff --git a/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgress.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgress.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgress.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgress.java diff --git a/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressData.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressData.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressData.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressData.java diff --git a/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressExt.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressExt.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressExt.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressExt.java diff --git a/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressStatusEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressStatusEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressStatusEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressStatusEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressStepEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressStepEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressStepEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/OtaProgressStepEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/firmware/api/AbstractFirmwareService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/api/AbstractFirmwareService.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/firmware/api/AbstractFirmwareService.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/firmware/api/AbstractFirmwareService.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/DroneLocation.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/DroneLocation.java new file mode 100644 index 0000000..07a5cd8 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/DroneLocation.java @@ -0,0 +1,54 @@ +package com.dji.sdk.cloudapi.flightarea; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/17 + */ +public class DroneLocation { + + /** + * Region unique ID + */ + private String areaId; + + /** + * Distance to the custom flight area boundary + */ + private Float areaDistance; + + /** + * Whether in custom flight area + */ + @JsonProperty("is_in_area") + private Boolean inArea; + + public String getAreaId() { + return areaId; + } + + public DroneLocation setAreaId(String areaId) { + this.areaId = areaId; + return this; + } + + public Float getAreaDistance() { + return areaDistance; + } + + public DroneLocation setAreaDistance(Float areaDistance) { + this.areaDistance = areaDistance; + return this; + } + + public Boolean getInArea() { + return inArea; + } + + public DroneLocation setInArea(Boolean inArea) { + this.inArea = inArea; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FeatureProperty.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FeatureProperty.java new file mode 100644 index 0000000..0fcbc73 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FeatureProperty.java @@ -0,0 +1,60 @@ +package com.dji.sdk.cloudapi.flightarea; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.validation.constraints.Min; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/21 + */ +public class FeatureProperty { + + @JsonProperty("subType") + private GeometrySubTypeEnum subType; + + @Min(10) + private Float radius = 0f; + + private Boolean enable; + + public FeatureProperty() { + } + + @Override + public String toString() { + return "FeatureProperty{" + + "subType=" + subType + + ", radius=" + radius + + ", enable=" + enable + + '}'; + } + + public GeometrySubTypeEnum getSubType() { + return subType; + } + + public FeatureProperty setSubType(GeometrySubTypeEnum subType) { + this.subType = subType; + return this; + } + + public Float getRadius() { + return radius; + } + + public FeatureProperty setRadius(Float radius) { + this.radius = radius; + return this; + } + + public Boolean getEnable() { + return enable; + } + + public FeatureProperty setEnable(Boolean enable) { + this.enable = enable; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaFeature.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaFeature.java new file mode 100644 index 0000000..41ece85 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaFeature.java @@ -0,0 +1,83 @@ +package com.dji.sdk.cloudapi.flightarea; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/21 + */ +public class FlightAreaFeature { + + @Pattern(regexp = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") + @NotNull + private String id; + + private final String type = "Feature"; + + @NotNull + private GeofenceTypeEnum geofenceType; + + @NotNull + @Valid + private FlightAreaGeometry geometry; + + @NotNull + private FeatureProperty properties; + + public FlightAreaFeature() { + } + + @Override + public String toString() { + return "FlightAreaFeature{" + + "id='" + id + '\'' + + ", type='" + type + '\'' + + ", geofenceType=" + geofenceType + + ", geometry=" + geometry + + ", properties=" + properties + + '}'; + } + + public String getId() { + return id; + } + + public FlightAreaFeature setId(String id) { + this.id = id; + return this; + } + + public String getType() { + return type; + } + + public GeofenceTypeEnum getGeofenceType() { + return geofenceType; + } + + public FlightAreaFeature setGeofenceType(GeofenceTypeEnum geofenceType) { + this.geofenceType = geofenceType; + return this; + } + + public FlightAreaGeometry getGeometry() { + return geometry; + } + + public FlightAreaFeature setGeometry(FlightAreaGeometry geometry) { + this.geometry = geometry; + return this; + } + + public FeatureProperty getProperties() { + return properties; + } + + public FlightAreaFeature setProperties(FeatureProperty properties) { + this.properties = properties; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaFile.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaFile.java new file mode 100644 index 0000000..6709269 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaFile.java @@ -0,0 +1,48 @@ +package com.dji.sdk.cloudapi.flightarea; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/17 + */ +public class FlightAreaFile { + + /** + * Custom flight area file name + */ + private String name; + + /** + * File SHA256 signature + */ + private String checksum; + + public FlightAreaFile() { + } + + @Override + public String toString() { + return "FlightAreaFile{" + + "name='" + name + '\'' + + ", checksum='" + checksum + '\'' + + '}'; + } + + public String getName() { + return name; + } + + public FlightAreaFile setName(String name) { + this.name = name; + return this; + } + + public String getChecksum() { + return checksum; + } + + public FlightAreaFile setChecksum(String checksum) { + this.checksum = checksum; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaGeometry.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaGeometry.java new file mode 100644 index 0000000..ca855ad --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaGeometry.java @@ -0,0 +1,21 @@ +package com.dji.sdk.cloudapi.flightarea; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/21 + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", + include = JsonTypeInfo.As.EXISTING_PROPERTY, defaultImpl = FlightAreaGeometry.class) +@JsonSubTypes({ + @JsonSubTypes.Type(value = FlightAreaPointGeometry.class, name = "Point"), + @JsonSubTypes.Type(value = FlightAreaPolygonGeometry.class, name = "Polygon") +}) +public abstract class FlightAreaGeometry { + + private GeometryTypeEnum type; + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaGetFile.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaGetFile.java new file mode 100644 index 0000000..174e44d --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaGetFile.java @@ -0,0 +1,86 @@ +package com.dji.sdk.cloudapi.flightarea; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/17 + */ +public class FlightAreaGetFile { + + /** + * File name + */ + @NotNull + @Pattern(regexp = "^geofence_[A-Za-z0-9]{32}.json$") + private String name; + + /** + * File URL + */ + @NotNull + private String url; + + /** + * File SHA256 signature + */ + @NotNull + private String checksum; + + /** + * File size + */ + @NotNull + private Integer size; + + public FlightAreaGetFile() { + } + + @Override + public String toString() { + return "FlightAreaGetFile{" + + "name='" + name + '\'' + + ", url='" + url + '\'' + + ", checksum='" + checksum + '\'' + + ", size=" + size + + '}'; + } + + public String getName() { + return name; + } + + public FlightAreaGetFile setName(String name) { + this.name = name; + return this; + } + + public String getUrl() { + return url; + } + + public FlightAreaGetFile setUrl(String url) { + this.url = url; + return this; + } + + public String getChecksum() { + return checksum; + } + + public FlightAreaGetFile setChecksum(String checksum) { + this.checksum = checksum; + return this; + } + + public Integer getSize() { + return size; + } + + public FlightAreaGetFile setSize(Integer size) { + this.size = size; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaJson.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaJson.java new file mode 100644 index 0000000..e976949 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaJson.java @@ -0,0 +1,41 @@ +package com.dji.sdk.cloudapi.flightarea; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/21 + */ +public class FlightAreaJson { + + private final String type = "FeatureCollection"; + + @NotNull + private List features; + + public FlightAreaJson() { + } + + @Override + public String toString() { + return "FlightAreaJson{" + + "type='" + type + '\'' + + ", features=" + features + + '}'; + } + + public String getType() { + return type; + } + + public List getFeatures() { + return features; + } + + public FlightAreaJson setFeatures(List features) { + this.features = features; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaMethodEnum.java new file mode 100644 index 0000000..48327a0 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaMethodEnum.java @@ -0,0 +1,27 @@ +package com.dji.sdk.cloudapi.flightarea; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/17 + */ +public enum FlightAreaMethodEnum { + + FLIGHT_AREAS_UPDATE("flight_areas_update"), + + FLIGHT_AREAS_DELETE("flight_areas_delete"), + ; + + private final String method; + + FlightAreaMethodEnum(String method) { + this.method = method; + } + + @JsonValue + public String getMethod() { + return method; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaPointGeometry.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaPointGeometry.java new file mode 100644 index 0000000..1f2393b --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaPointGeometry.java @@ -0,0 +1,39 @@ +package com.dji.sdk.cloudapi.flightarea; + +import java.util.Arrays; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/21 + */ +public class FlightAreaPointGeometry extends FlightAreaGeometry { + + private final GeometryTypeEnum type = GeometryTypeEnum.POINT; + + private Double[] coordinates; + + public FlightAreaPointGeometry() { + } + + @Override + public String toString() { + return "FlightAreaPointGeometry{" + + "type=" + type + + ", coordinates=" + Arrays.toString(coordinates) + + '}'; + } + + public GeometryTypeEnum getType() { + return type; + } + + public Double[] getCoordinates() { + return coordinates; + } + + public FlightAreaPointGeometry setCoordinates(Double[] coordinates) { + this.coordinates = coordinates; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaPolygonGeometry.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaPolygonGeometry.java new file mode 100644 index 0000000..69748ae --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaPolygonGeometry.java @@ -0,0 +1,39 @@ +package com.dji.sdk.cloudapi.flightarea; + +import java.util.Arrays; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/21 + */ +public class FlightAreaPolygonGeometry extends FlightAreaGeometry { + + private final GeometryTypeEnum type = GeometryTypeEnum.POLYGON; + + private Double[][][] coordinates; + + public FlightAreaPolygonGeometry() { + } + + @Override + public String toString() { + return "FlightAreaPointGeometry{" + + "type=" + type + + ", coordinates=" + Arrays.toString(coordinates) + + '}'; + } + + public GeometryTypeEnum getType() { + return type; + } + + public Double[][][] getCoordinates() { + return coordinates; + } + + public FlightAreaPolygonGeometry setCoordinates(Double[][][] coordinates) { + this.coordinates = coordinates; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaSyncReasonEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaSyncReasonEnum.java new file mode 100644 index 0000000..a2aa727 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaSyncReasonEnum.java @@ -0,0 +1,70 @@ +package com.dji.sdk.cloudapi.flightarea; + +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 + * @date 2023/10/17 + */ +public enum FlightAreaSyncReasonEnum { + + SUCCESS(0, "success"), + + PARSE_FILE_FAILED(1, "Failed to parse file information returned from the cloud."), + + RETRIEVE_FILE_FAILED(2, "Failed to retrieve file information from the aircraft's end."), + + DOWNLOAD_FILE_FAILED(3, "Failed to download the file from the cloud."), + + LINK_FLIPPING_FAILED(4, "Link flipping failed."), + + FILE_TRANSMISSION_FAILED(5, "File transmission failed."), + + DISABLE_FAILED(6, "Filed to disable."), + + FILE_DELETION_FAILED(7, "File deletion failed."), + + FILE_LOADING_FAILED(8, "Failed to load file on drone."), + + ENABLE_FAILED(9, "Filed to enable."), + + TURN_OFF_ENHANCED_FAILED(10, "Failed to turn off enhanced image transmission."), + + POWER_ON_FAILED(11, "Failed to power on the drone."), + + CHECK_FAILED(12, "The checksum check failed."), + + SYNCHRONIZATION_TIMED_OUT(13, "Synchronization exception timed out."), + + ; + + private final int reason; + + private final String msg; + + FlightAreaSyncReasonEnum(int reason, String msg) { + this.reason = reason; + this.msg = msg; + } + + @JsonValue + public int getReason() { + return reason; + } + + public String getMsg() { + return msg; + } + + @JsonCreator + public static FlightAreaSyncReasonEnum find(int reason) { + return Arrays.stream(values()).filter(reasonEnum -> reasonEnum.reason == reason).findAny() + .orElseThrow(() -> new CloudSDKException(FlightAreaSyncReasonEnum.class, reason)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaSyncStatusEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaSyncStatusEnum.java new file mode 100644 index 0000000..6c35687 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreaSyncStatusEnum.java @@ -0,0 +1,51 @@ +package com.dji.sdk.cloudapi.flightarea; + +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 + * @date 2023/10/17 + */ +public enum FlightAreaSyncStatusEnum { + + WAIT_SYNC("wait_sync", false), + + SWITCH_FAIL("switch_fail", false), + + SYNCHRONIZING("synchronizing", false), + + SYNCHRONIZED("synchronized", true), + + FAIL("fail", true), + + ; + + private final String status; + + private final boolean end; + + FlightAreaSyncStatusEnum(String status, boolean end) { + this.status = status; + this.end = end; + } + + @JsonValue + public String getStatus() { + return status; + } + + public boolean isEnd() { + return end; + } + + @JsonCreator + public static FlightAreaSyncStatusEnum find(String status) { + return Arrays.stream(values()).filter(statusEnum -> statusEnum.status.equals(status)).findAny() + .orElseThrow(() -> new CloudSDKException(FlightAreaSyncStatusEnum.class, status)); + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasDroneLocation.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasDroneLocation.java new file mode 100644 index 0000000..235bc77 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasDroneLocation.java @@ -0,0 +1,35 @@ +package com.dji.sdk.cloudapi.flightarea; + +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/17 + */ +public class FlightAreasDroneLocation { + + /** + * Flight area distance to aircraft + */ + private List droneLocations; + + public FlightAreasDroneLocation() { + } + + @Override + public String toString() { + return "FlightAreasDroneLocation{" + + "droneLocations=" + droneLocations + + '}'; + } + + public List getDroneLocations() { + return droneLocations; + } + + public FlightAreasDroneLocation setDroneLocations(List droneLocations) { + this.droneLocations = droneLocations; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasGetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasGetRequest.java new file mode 100644 index 0000000..df4b635 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasGetRequest.java @@ -0,0 +1,9 @@ +package com.dji.sdk.cloudapi.flightarea; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/17 + */ +public class FlightAreasGetRequest { +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasGetResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasGetResponse.java new file mode 100644 index 0000000..f0199a0 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasGetResponse.java @@ -0,0 +1,40 @@ +package com.dji.sdk.cloudapi.flightarea; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/17 + */ +public class FlightAreasGetResponse extends BaseModel { + + /** + * File list + */ + @NotNull + private List<@Valid FlightAreaGetFile> files; + + public FlightAreasGetResponse() { + } + + @Override + public String toString() { + return "FlightAreasGetResponse{" + + "files=" + files + + '}'; + } + + public List getFiles() { + return files; + } + + public FlightAreasGetResponse setFiles(List files) { + this.files = files; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasSyncProgress.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasSyncProgress.java new file mode 100644 index 0000000..de02310 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/FlightAreasSyncProgress.java @@ -0,0 +1,63 @@ +package com.dji.sdk.cloudapi.flightarea; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/17 + */ +public class FlightAreasSyncProgress { + + /** + * Synchronize state + */ + private FlightAreaSyncStatusEnum status; + + /** + * Return Code + */ + private FlightAreaSyncReasonEnum reason; + + /** + * Custom flight area file + */ + private FlightAreaFile file; + + public FlightAreasSyncProgress() { + } + + @Override + public String toString() { + return "FlightAreasSyncProgress{" + + "status=" + status + + ", reason=" + reason + + ", file=" + file + + '}'; + } + + public FlightAreaSyncStatusEnum getStatus() { + return status; + } + + public FlightAreasSyncProgress setStatus(FlightAreaSyncStatusEnum status) { + this.status = status; + return this; + } + + public FlightAreaSyncReasonEnum getReason() { + return reason; + } + + public FlightAreasSyncProgress setReason(FlightAreaSyncReasonEnum reason) { + this.reason = reason; + return this; + } + + public FlightAreaFile getFile() { + return file; + } + + public FlightAreasSyncProgress setFile(FlightAreaFile file) { + this.file = file; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/GeofenceTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/GeofenceTypeEnum.java new file mode 100644 index 0000000..50819fb --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/GeofenceTypeEnum.java @@ -0,0 +1,38 @@ +package com.dji.sdk.cloudapi.flightarea; + +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.9 + * @date 2023/11/21 + */ +public enum GeofenceTypeEnum { + + DFENCE("dfence"), + + NFZ("nfz"), + + ; + + private final String type; + + GeofenceTypeEnum(String type) { + this.type = type; + } + + @JsonValue + public String getType() { + return type; + } + + @JsonCreator + public static GeofenceTypeEnum find(String type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type.equals(type)).findAny() + .orElseThrow(() -> new CloudSDKException(GeofenceTypeEnum.class, type)); + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/GeometrySubTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/GeometrySubTypeEnum.java new file mode 100644 index 0000000..7c9812e --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/GeometrySubTypeEnum.java @@ -0,0 +1,36 @@ +package com.dji.sdk.cloudapi.flightarea; + +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.9 + * @date 2023/11/21 + */ +public enum GeometrySubTypeEnum { + + CIRCLE("Circle"), + + ; + + private final String subType; + + GeometrySubTypeEnum(String subType) { + this.subType = subType; + } + + @JsonValue + public String getSubType() { + return subType; + } + + @JsonCreator + public static GeometrySubTypeEnum find(String subType) { + return Arrays.stream(values()).filter(subTypeEnum -> subTypeEnum.subType.equals(subType)).findAny() + .orElseThrow(() -> new CloudSDKException(GeometrySubTypeEnum.class, subType)); + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/GeometryTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/GeometryTypeEnum.java new file mode 100644 index 0000000..0c0bca0 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/GeometryTypeEnum.java @@ -0,0 +1,38 @@ +package com.dji.sdk.cloudapi.flightarea; + +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.9 + * @date 2023/11/21 + */ +public enum GeometryTypeEnum { + + POINT("Point"), + + POLYGON("Polygon"), + + ; + + private final String type; + + GeometryTypeEnum(String type) { + this.type = type; + } + + @JsonValue + public String getType() { + return type; + } + + @JsonCreator + public static GeometryTypeEnum find(String type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type.equals(type)).findAny() + .orElseThrow(() -> new CloudSDKException(GeometryTypeEnum.class, type)); + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/api/AbstractFlightAreaService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/api/AbstractFlightAreaService.java new file mode 100644 index 0000000..c0bc9bc --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/flightarea/api/AbstractFlightAreaService.java @@ -0,0 +1,80 @@ +package com.dji.sdk.cloudapi.flightarea.api; + +import com.dji.sdk.annotations.CloudSDKVersion; +import com.dji.sdk.cloudapi.flightarea.*; +import com.dji.sdk.config.version.CloudSDKVersionEnum; +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; +import com.dji.sdk.mqtt.events.TopicEventsResponse; +import com.dji.sdk.mqtt.requests.TopicRequestsRequest; +import com.dji.sdk.mqtt.requests.TopicRequestsResponse; +import com.dji.sdk.mqtt.services.ServicesPublish; +import com.dji.sdk.mqtt.services.ServicesReplyData; +import com.dji.sdk.mqtt.services.TopicServicesResponse; +import org.springframework.integration.annotation.ServiceActivator; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageHeaders; + +import javax.annotation.Resource; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/16 + */ +public abstract class AbstractFlightAreaService { + + @Resource + private ServicesPublish servicesPublish; + + /** + * Update command + * @param gateway gateway device + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0, exclude = GatewayTypeEnum.RC, include = GatewayTypeEnum.DOCK) + public TopicServicesResponse flightAreasUpdate(GatewayManager gateway) { + return servicesPublish.publish( + gateway.getGatewaySn(), + FlightAreaMethodEnum.FLIGHT_AREAS_UPDATE.getMethod()); + } + + /** + * Progress of custom flight area file synchronize from the Cloud to the Device. Used for further defining flight area. + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_FLIGHT_AREAS_SYNC_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS) + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + public TopicEventsResponse flightAreasSyncProgress(TopicEventsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("flightAreasSyncProgress not implemented"); + } + + /** + * Push warning information + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_FLIGHT_AREAS_DRONE_LOCATION, outputChannel = ChannelName.OUTBOUND_EVENTS) + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + public TopicEventsResponse flightAreasDroneLocation(TopicEventsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("flightAreasDroneLocation not implemented"); + } + + /** + * Get custom flight area file + * @param request data + * @param headers The headers for a {@link Message}. + * @return requests_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_REQUESTS_FLIGHT_AREAS_GET, outputChannel = ChannelName.OUTBOUND_REQUESTS) + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + public TopicRequestsResponse> flightAreasGet(TopicRequestsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("flightAreasGet not implemented"); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/DeviceHms.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/DeviceHms.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/DeviceHms.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/DeviceHms.java diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/DeviceHmsArgs.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/DeviceHmsArgs.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/DeviceHmsArgs.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/DeviceHmsArgs.java diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/Hms.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/Hms.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/Hms.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/Hms.java diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/HmsBatteryIndexEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsBatteryIndexEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/HmsBatteryIndexEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsBatteryIndexEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/HmsChargingRodIndexEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsChargingRodIndexEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/HmsChargingRodIndexEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsChargingRodIndexEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/HmsDockCoverIndexEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsDockCoverIndexEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/HmsDockCoverIndexEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsDockCoverIndexEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/HmsFaqIdEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsFaqIdEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/HmsFaqIdEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsFaqIdEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/HmsFormatKeyEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsFormatKeyEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/HmsFormatKeyEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsFormatKeyEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/HmsInTheSkyEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsInTheSkyEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/HmsInTheSkyEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsInTheSkyEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/HmsLevelEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsLevelEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/HmsLevelEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsLevelEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/HmsMessageLanguageEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsMessageLanguageEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/HmsMessageLanguageEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsMessageLanguageEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/HmsModuleEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsModuleEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/HmsModuleEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/HmsModuleEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/hms/api/AbstractHmsService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/api/AbstractHmsService.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/hms/api/AbstractHmsService.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/hms/api/AbstractHmsService.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionFromEsdk.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionFromEsdk.java new file mode 100644 index 0000000..b53626c --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionFromEsdk.java @@ -0,0 +1,34 @@ +package com.dji.sdk.cloudapi.interconnection; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/16 + */ +public class CustomDataTransmissionFromEsdk { + + /** + * Data content + * length: Less than 256 + */ + private String value; + + public CustomDataTransmissionFromEsdk() { + } + + @Override + public String toString() { + return "CustomDataTransmissionFromEsdk{" + + "value='" + value + '\'' + + '}'; + } + + public String getValue() { + return value; + } + + public CustomDataTransmissionFromEsdk setValue(String value) { + this.value = value; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionFromPsdk.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionFromPsdk.java new file mode 100644 index 0000000..39d4a40 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionFromPsdk.java @@ -0,0 +1,34 @@ +package com.dji.sdk.cloudapi.interconnection; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/16 + */ +public class CustomDataTransmissionFromPsdk { + + /** + * Data content + * length: Less than 256 + */ + private String value; + + public CustomDataTransmissionFromPsdk() { + } + + @Override + public String toString() { + return "CustomDataTransmissionFromPsdk{" + + "value='" + value + '\'' + + '}'; + } + + public String getValue() { + return value; + } + + public CustomDataTransmissionFromPsdk setValue(String value) { + this.value = value; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionToEsdkRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionToEsdkRequest.java new file mode 100644 index 0000000..2611233 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionToEsdkRequest.java @@ -0,0 +1,41 @@ +package com.dji.sdk.cloudapi.interconnection; + +import com.dji.sdk.common.BaseModel; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/16 + */ +public class CustomDataTransmissionToEsdkRequest extends BaseModel { + + /** + * Data content + * length: Less than 256 + */ + @NotNull + @Length(max = 256) + private String value; + + public CustomDataTransmissionToEsdkRequest() { + } + + @Override + public String toString() { + return "CustomDataTransmissionToEsdkRequest{" + + "value='" + value + '\'' + + '}'; + } + + public String getValue() { + return value; + } + + public CustomDataTransmissionToEsdkRequest setValue(String value) { + this.value = value; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionToPsdkRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionToPsdkRequest.java new file mode 100644 index 0000000..35dc96f --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/CustomDataTransmissionToPsdkRequest.java @@ -0,0 +1,41 @@ +package com.dji.sdk.cloudapi.interconnection; + +import com.dji.sdk.common.BaseModel; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/16 + */ +public class CustomDataTransmissionToPsdkRequest extends BaseModel { + + /** + * Data content + * length: Less than 256 + */ + @NotNull + @Length(max = 256) + private String value; + + public CustomDataTransmissionToPsdkRequest() { + } + + @Override + public String toString() { + return "CustomDataTransmissionToPsdkRequest{" + + "value='" + value + '\'' + + '}'; + } + + public String getValue() { + return value; + } + + public CustomDataTransmissionToPsdkRequest setValue(String value) { + this.value = value; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/InterconnectionMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/InterconnectionMethodEnum.java new file mode 100644 index 0000000..e15a565 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/InterconnectionMethodEnum.java @@ -0,0 +1,29 @@ +package com.dji.sdk.cloudapi.interconnection; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/16 + */ +public enum InterconnectionMethodEnum { + + CUSTOM_DATA_TRANSMISSION_TO_ESDK("custom_data_transmission_to_esdk"), + + CUSTOM_DATA_TRANSMISSION_TO_PSDK("custom_data_transmission_to_psdk"), + + ; + + private final String method; + + InterconnectionMethodEnum(String method) { + this.method = method; + } + + @JsonValue + public String getMethod() { + return method; + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/api/AbstractInterconnectionService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/api/AbstractInterconnectionService.java new file mode 100644 index 0000000..eccc52d --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/interconnection/api/AbstractInterconnectionService.java @@ -0,0 +1,83 @@ +package com.dji.sdk.cloudapi.interconnection.api; + +import com.dji.sdk.annotations.CloudSDKVersion; +import com.dji.sdk.cloudapi.interconnection.CustomDataTransmissionFromEsdk; +import com.dji.sdk.cloudapi.interconnection.CustomDataTransmissionToEsdkRequest; +import com.dji.sdk.cloudapi.interconnection.CustomDataTransmissionToPsdkRequest; +import com.dji.sdk.cloudapi.interconnection.InterconnectionMethodEnum; +import com.dji.sdk.config.version.CloudSDKVersionEnum; +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; +import com.dji.sdk.mqtt.events.TopicEventsResponse; +import com.dji.sdk.mqtt.services.ServicesPublish; +import com.dji.sdk.mqtt.services.ServicesReplyData; +import com.dji.sdk.mqtt.services.TopicServicesResponse; +import org.springframework.integration.annotation.ServiceActivator; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageHeaders; + +import javax.annotation.Resource; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/16 + */ +public abstract class AbstractInterconnectionService { + + @Resource + private ServicesPublish servicesPublish; + + /** + * cloud-custom data transmit from esdk + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_CUSTOM_DATA_TRANSMISSION_FROM_ESDK, outputChannel = ChannelName.OUTBOUND_EVENTS) + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + public TopicEventsResponse customDataTransmissionFromEsdk(TopicEventsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("customDataTransmissionFromEsdk not implemented"); + } + + /** + * cloud-custom data transmit to esdk + * @param gateway gateway device + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0, exclude = GatewayTypeEnum.RC) + public TopicServicesResponse customDataTransmissionToEsdk(GatewayManager gateway, CustomDataTransmissionToEsdkRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + InterconnectionMethodEnum.CUSTOM_DATA_TRANSMISSION_TO_ESDK.getMethod(), + request); + } + + /** + * cloud-custom data transmit from psdk + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_CUSTOM_DATA_TRANSMISSION_FROM_PSDK, outputChannel = ChannelName.OUTBOUND_EVENTS) + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + public TopicEventsResponse customDataTransmissionFromPsdk(TopicEventsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("customDataTransmissionFromPsdk not implemented"); + } + + /** + * cloud-custom data transmit to psdk + * @param gateway gateway device + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0, exclude = GatewayTypeEnum.RC) + public TopicServicesResponse customDataTransmissionToPsdk(GatewayManager gateway, CustomDataTransmissionToPsdkRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + InterconnectionMethodEnum.CUSTOM_DATA_TRANSMISSION_TO_PSDK.getMethod(), + request); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacity.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacity.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacity.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacity.java diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityCamera.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityCamera.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityCamera.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityCamera.java diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityDevice.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityDevice.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityDevice.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityDevice.java diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityVideo.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityVideo.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityVideo.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/DockLiveCapacityVideo.java diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/DockLivestreamAbilityUpdate.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/DockLivestreamAbilityUpdate.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/DockLivestreamAbilityUpdate.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/DockLivestreamAbilityUpdate.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/ILivestreamUrl.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/ILivestreamUrl.java new file mode 100644 index 0000000..318c064 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/ILivestreamUrl.java @@ -0,0 +1,16 @@ +package com.dji.sdk.cloudapi.livestream; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/13 + */ +public interface ILivestreamUrl { + + @JsonValue + String toString(); + + ILivestreamUrl clone(); +} diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/LensChangeVideoTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LensChangeVideoTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/LensChangeVideoTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LensChangeVideoTypeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/LiveErrorCodeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveErrorCodeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/LiveErrorCodeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveErrorCodeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/LiveLensChangeRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveLensChangeRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/LiveLensChangeRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveLensChangeRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/LiveSetQualityRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveSetQualityRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/LiveSetQualityRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveSetQualityRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStartPushRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStartPushRequest.java new file mode 100644 index 0000000..e99507b --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStartPushRequest.java @@ -0,0 +1,94 @@ +package com.dji.sdk.cloudapi.livestream; + +import com.dji.sdk.cloudapi.device.VideoId; +import com.dji.sdk.common.BaseModel; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/5/23 + */ +public class LiveStartPushRequest extends BaseModel { + + @NotNull + private UrlTypeEnum urlType; + + /** + * RTMP: (rtmp://xxxxxxx) Example: rtmp://192.168.1.1:8080/live + * RTSP:(uerName&password&port) Example: userName=dji-cloud-api&password=123456&port=8080 + * GB28181:(serverIP&serverPort&serverID&agentID&agentPassword&localPort&channel) + * Example: serverIP=192.168.1.1&serverPort=8080&serverID=34000000000000000000&agentID= + * 300000000010000000000&agentPassword=0000000&localPort=7060&channel=340000000000000000000 + * AGORA:(channel&sn&token&uid) + * Example: channel=1ZNDH360010162_39-0-7&sn=1ZNDH360010162&token=006dca67721582a48768ec4d8 + * 17b7b25a86IAB4cw2JgN6iX8BpTPdc3e4S1Iendz94IFJ56aSXKvzAJei27MqF2zyCIgCLIIoBt41+YAQAAQC3jX + * 5gAgC3jX5gAwC3jX5gBAC3jX5g&uid=50000 + * Notice: The token generated by Shengwang may have special characters such as '+' ' ', + * and need to do url encode, otherwise there will be a parsing error on the PILOT side + */ + @NotNull + @Valid + private ILivestreamUrl url; + + /** + * The format is #{uav_sn}/#{camera_id}/#{video_index}, + * drone serial number/payload and mounted location enumeration value/payload lens numbering + */ + @NotNull + private VideoId videoId; + + @NotNull + private VideoQualityEnum videoQuality; + + public LiveStartPushRequest() { + } + + @Override + public String toString() { + return "LiveStartPushRequest{" + + "urlType=" + urlType + + ", url=" + url + + ", videoId=" + videoId + + ", videoQuality=" + videoQuality + + '}'; + } + + public UrlTypeEnum getUrlType() { + return urlType; + } + + public LiveStartPushRequest setUrlType(UrlTypeEnum urlType) { + this.urlType = urlType; + return this; + } + + public ILivestreamUrl getUrl() { + return url; + } + + public LiveStartPushRequest setUrl(ILivestreamUrl url) { + this.url = url; + return this; + } + + public VideoId getVideoId() { + return videoId; + } + + public LiveStartPushRequest setVideoId(VideoId videoId) { + this.videoId = videoId; + return this; + } + + public VideoQualityEnum getVideoQuality() { + return videoQuality; + } + + public LiveStartPushRequest setVideoQuality(VideoQualityEnum videoQuality) { + this.videoQuality = videoQuality; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStopPushRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStopPushRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/LiveStopPushRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStopPushRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStreamMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStreamMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/LiveStreamMethodEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStreamMethodEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamAgoraUrl.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamAgoraUrl.java new file mode 100644 index 0000000..f86c211 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamAgoraUrl.java @@ -0,0 +1,83 @@ +package com.dji.sdk.cloudapi.livestream; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; +import java.net.URLEncoder; +import java.nio.charset.Charset; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/13 + */ +public class LivestreamAgoraUrl extends BaseModel implements ILivestreamUrl { + + @NotNull + private String channel; + + @NotNull + private String sn; + + @NotNull + private String token; + + @NotNull + private Integer uid; + + public LivestreamAgoraUrl() { + } + + @Override + public String toString() { + return "channel=" + channel + + "&sn=" + sn + + "&token=" + URLEncoder.encode(token, Charset.defaultCharset()) + + "&uid=" + uid; + } + + @Override + public LivestreamAgoraUrl clone() { + try { + return (LivestreamAgoraUrl) super.clone(); + } catch (CloneNotSupportedException e) { + return new LivestreamAgoraUrl().setSn(sn).setToken(token).setChannel(channel).setUid(uid); + } + } + + public String getChannel() { + return channel; + } + + public LivestreamAgoraUrl setChannel(String channel) { + this.channel = channel; + return this; + } + + public String getSn() { + return sn; + } + + public LivestreamAgoraUrl setSn(String sn) { + this.sn = sn; + return this; + } + + public String getToken() { + return token; + } + + public LivestreamAgoraUrl setToken(String token) { + this.token = token; + return this; + } + + public Integer getUid() { + return uid; + } + + public LivestreamAgoraUrl setUid(Integer uid) { + this.uid = uid; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamGb28181Url.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamGb28181Url.java new file mode 100644 index 0000000..99622db --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamGb28181Url.java @@ -0,0 +1,127 @@ +package com.dji.sdk.cloudapi.livestream; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/13 + */ +public class LivestreamGb28181Url extends BaseModel implements ILivestreamUrl { + + @NotNull + private String serverIP; + + @NotNull + private Integer serverPort; + + @NotNull + private String serverID; + + @NotNull + private String agentID; + + @NotNull + private String agentPassword; + + @NotNull + private Integer localPort; + + @NotNull + private String channel; + + public LivestreamGb28181Url() { + } + + @Override + public String toString() { + return "serverIP=" + serverIP + + "&serverPort=" + serverPort + + "&serverID=" + serverID + + "&agentID=" + agentID + + "&agentPassword=" + agentPassword + + "&localPort=" + localPort + + "&channel=" + channel; + } + + @Override + public LivestreamGb28181Url clone() { + try { + return (LivestreamGb28181Url) super.clone(); + } catch (CloneNotSupportedException e) { + return new LivestreamGb28181Url() + .setServerIP(serverIP) + .setServerPort(serverPort) + .setServerID(serverID) + .setAgentID(agentID) + .setAgentPassword(agentPassword) + .setLocalPort(localPort) + .setChannel(channel); + } + } + + public String getServerIP() { + return serverIP; + } + + public LivestreamGb28181Url setServerIP(String serverIP) { + this.serverIP = serverIP; + return this; + } + + public Integer getServerPort() { + return serverPort; + } + + public LivestreamGb28181Url setServerPort(Integer serverPort) { + this.serverPort = serverPort; + return this; + } + + public String getServerID() { + return serverID; + } + + public LivestreamGb28181Url setServerID(String serverID) { + this.serverID = serverID; + return this; + } + + public String getAgentID() { + return agentID; + } + + public LivestreamGb28181Url setAgentID(String agentID) { + this.agentID = agentID; + return this; + } + + public String getAgentPassword() { + return agentPassword; + } + + public LivestreamGb28181Url setAgentPassword(String agentPassword) { + this.agentPassword = agentPassword; + return this; + } + + public Integer getLocalPort() { + return localPort; + } + + public LivestreamGb28181Url setLocalPort(Integer localPort) { + this.localPort = localPort; + return this; + } + + public String getChannel() { + return channel; + } + + public LivestreamGb28181Url setChannel(String channel) { + this.channel = channel; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamRtmpUrl.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamRtmpUrl.java new file mode 100644 index 0000000..d3d4850 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamRtmpUrl.java @@ -0,0 +1,42 @@ +package com.dji.sdk.cloudapi.livestream; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/13 + */ +public class LivestreamRtmpUrl extends BaseModel implements ILivestreamUrl { + + @NotNull + private String url; + + public LivestreamRtmpUrl() { + } + + @Override + public String toString() { + return url; + } + + @Override + public LivestreamRtmpUrl clone() { + try { + return (LivestreamRtmpUrl) super.clone(); + } catch (CloneNotSupportedException e) { + return new LivestreamRtmpUrl().setUrl(url); + } + } + + public LivestreamRtmpUrl setUrl(String url) { + this.url = url; + return this; + } + + public String getUrl() { + return url; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamRtspUrl.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamRtspUrl.java new file mode 100644 index 0000000..5fda187 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamRtspUrl.java @@ -0,0 +1,68 @@ +package com.dji.sdk.cloudapi.livestream; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/13 + */ +public class LivestreamRtspUrl extends BaseModel implements ILivestreamUrl { + + @NotNull + private String username; + + @NotNull + private String password; + + @NotNull + private Integer port; + + public LivestreamRtspUrl() { + } + + @Override + public String toString() { + return "userName=" + username + + "&password=" + password + + "&port=" + port; + } + + @Override + public LivestreamRtspUrl clone() { + try { + return (LivestreamRtspUrl) super.clone(); + } catch (CloneNotSupportedException e) { + return new LivestreamRtspUrl().setUsername(username).setPassword(password).setPort(port); + } + } + + public String getUsername() { + return username; + } + + public LivestreamRtspUrl setUsername(String username) { + this.username = username; + return this; + } + + public String getPassword() { + return password; + } + + public LivestreamRtspUrl setPassword(String password) { + this.password = password; + return this; + } + + public Integer getPort() { + return port; + } + + public LivestreamRtspUrl setPort(Integer port) { + this.port = port; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamWhipUrl.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamWhipUrl.java new file mode 100644 index 0000000..32745da --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/LivestreamWhipUrl.java @@ -0,0 +1,42 @@ +package com.dji.sdk.cloudapi.livestream; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/13 + */ +public class LivestreamWhipUrl extends BaseModel implements ILivestreamUrl { + + @NotNull + private String url; + + public LivestreamWhipUrl() { + } + + @Override + public String toString() { + return url; + } + + @Override + public LivestreamWhipUrl clone() { + try { + return (LivestreamWhipUrl) super.clone(); + } catch (CloneNotSupportedException e) { + return new LivestreamWhipUrl().setUrl(url); + } + } + + public String getUrl() { + return url; + } + + public LivestreamWhipUrl setUrl(String url) { + this.url = url; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacity.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacity.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacity.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacity.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityCamera.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityCamera.java new file mode 100644 index 0000000..3091406 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityCamera.java @@ -0,0 +1,80 @@ +package com.dji.sdk.cloudapi.livestream; + +import com.dji.sdk.cloudapi.device.PayloadIndex; + +import java.util.List; + +/** + * @author sean.zhou + * @date 2021/11/18 + * @version 0.1 + */ +public class RcLiveCapacityCamera { + + /** + * Total number of video streams that can be used for livestreaming + * Total number of video streams that the camera can live stream + */ + private Integer availableVideoNumber; + + /** + * Maximum number of video streams that the camera can live stream at the same time. + */ + private Integer coexistVideoNumberMax; + + /** + * Camera index, composed of product type enumeration and gimbal index. + */ + private PayloadIndex cameraIndex; + + private List videoList; + + public RcLiveCapacityCamera() { + } + + @Override + public String toString() { + return "RcLiveCapacityCamera{" + + "availableVideoNumber=" + availableVideoNumber + + ", coexistVideoNumberMax=" + coexistVideoNumberMax + + ", cameraIndex=" + cameraIndex + + ", videoList=" + videoList + + '}'; + } + + public Integer getAvailableVideoNumber() { + return availableVideoNumber; + } + + public RcLiveCapacityCamera setAvailableVideoNumber(Integer availableVideoNumber) { + this.availableVideoNumber = availableVideoNumber; + return this; + } + + public Integer getCoexistVideoNumberMax() { + return coexistVideoNumberMax; + } + + public RcLiveCapacityCamera setCoexistVideoNumberMax(Integer coexistVideoNumberMax) { + this.coexistVideoNumberMax = coexistVideoNumberMax; + return this; + } + + public PayloadIndex getCameraIndex() { + return cameraIndex; + } + + public RcLiveCapacityCamera setCameraIndex(PayloadIndex cameraIndex) { + this.cameraIndex = cameraIndex; + return this; + } + + public List getVideoList() { + return videoList; + } + + public RcLiveCapacityCamera setVideoList(List videoList) { + this.videoList = videoList; + return this; + } +} \ No newline at end of file diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityDevice.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityDevice.java new file mode 100644 index 0000000..d961535 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityDevice.java @@ -0,0 +1,81 @@ +package com.dji.sdk.cloudapi.livestream; + +import java.util.List; + +/** + * @author sean.zhou + * @date 2021/11/18 + * @version 0.1 + */ +public class RcLiveCapacityDevice { + + /** + * Device serial number + */ + private String sn; + + /** + * Total number of video streams that can be used for livestreaming + * Total number of video streams used for livestreaming that belongs to devices. + */ + private Integer availableVideoNumber; + + /** + * Maximum number of video streams that can be used for livestreaming at the same time + */ + private Integer coexistVideoNumberMax; + + /** + * Camera list on the device + */ + private List cameraList; + + public RcLiveCapacityDevice() { + } + + @Override + public String toString() { + return "RcLiveCapacityDevice{" + + "sn='" + sn + '\'' + + ", availableVideoNumber=" + availableVideoNumber + + ", coexistVideoNumberMax=" + coexistVideoNumberMax + + ", cameraList=" + cameraList + + '}'; + } + + public String getSn() { + return sn; + } + + public RcLiveCapacityDevice setSn(String sn) { + this.sn = sn; + return this; + } + + public Integer getAvailableVideoNumber() { + return availableVideoNumber; + } + + public RcLiveCapacityDevice setAvailableVideoNumber(Integer availableVideoNumber) { + this.availableVideoNumber = availableVideoNumber; + return this; + } + + public Integer getCoexistVideoNumberMax() { + return coexistVideoNumberMax; + } + + public RcLiveCapacityDevice setCoexistVideoNumberMax(Integer coexistVideoNumberMax) { + this.coexistVideoNumberMax = coexistVideoNumberMax; + return this; + } + + public List getCameraList() { + return cameraList; + } + + public RcLiveCapacityDevice setCameraList(List cameraList) { + this.cameraList = cameraList; + return this; + } +} \ No newline at end of file diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityVideo.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityVideo.java new file mode 100644 index 0000000..191d573 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityVideo.java @@ -0,0 +1,42 @@ +package com.dji.sdk.cloudapi.livestream; + +/** + * @author sean.zhou + * @date 2021/11/18 + * @version 0.1 + */ +public class RcLiveCapacityVideo { + + private String videoIndex; + + private VideoTypeEnum videoType; + + public RcLiveCapacityVideo() { + } + + @Override + public String toString() { + return "RcLiveCapacityVideo{" + + "videoIndex='" + videoIndex + '\'' + + ", videoType=" + videoType + + '}'; + } + + public String getVideoIndex() { + return videoIndex; + } + + public RcLiveCapacityVideo setVideoIndex(String videoIndex) { + this.videoIndex = videoIndex; + return this; + } + + public VideoTypeEnum getVideoType() { + return videoType; + } + + public RcLiveCapacityVideo setVideoType(VideoTypeEnum videoType) { + this.videoType = videoType; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/RcLivestreamAbilityUpdate.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLivestreamAbilityUpdate.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/RcLivestreamAbilityUpdate.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/RcLivestreamAbilityUpdate.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/UrlTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/UrlTypeEnum.java new file mode 100644 index 0000000..3c78adc --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/UrlTypeEnum.java @@ -0,0 +1,43 @@ +package com.dji.sdk.cloudapi.livestream; + +import com.dji.sdk.exception.CloudSDKException; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +import java.util.Arrays; + +/** + * @author sean.zhou + * @version 0.1 + * @date 2021/11/22 + */ +public enum UrlTypeEnum { + + AGORA(0), + + RTMP(1), + + RTSP(2), + + GB28181(3), + + WHIP(4), + ; + + private final int type; + + UrlTypeEnum(int type) { + this.type = type; + } + + @JsonValue + public int getType() { + return type; + } + + @JsonCreator + public static UrlTypeEnum find(int type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny() + .orElseThrow(() -> new CloudSDKException(UrlTypeEnum.class, type)); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/VideoQualityEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/VideoQualityEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/VideoQualityEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/VideoQualityEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/VideoTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/VideoTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/VideoTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/VideoTypeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/api/AbstractLivestreamService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/api/AbstractLivestreamService.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/livestream/api/AbstractLivestreamService.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/livestream/api/AbstractLivestreamService.java diff --git a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListFile.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListFile.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/FileUploadListFile.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListFile.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListRequest.java new file mode 100644 index 0000000..e1f52d1 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListRequest.java @@ -0,0 +1,42 @@ +package com.dji.sdk.cloudapi.log; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/5/23 + */ +public class FileUploadListRequest extends BaseModel { + + /** + * Filter list of file + **/ + @NotNull + @Size(min = 1, max = 2) + private List moduleList; + + public FileUploadListRequest() { + } + + @Override + public String toString() { + return "FileUploadListRequest{" + + "moduleList=" + moduleList + + '}'; + } + + public List getModuleList() { + return moduleList; + } + + public FileUploadListRequest setModuleList(List moduleList) { + this.moduleList = moduleList; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/FileUploadListResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListResponse.java diff --git a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadProgress.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadProgress.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/FileUploadProgress.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadProgress.java diff --git a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadProgressExt.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadProgressExt.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/FileUploadProgressExt.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadProgressExt.java diff --git a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadProgressFile.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadProgressFile.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/FileUploadProgressFile.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadProgressFile.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartFile.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartFile.java new file mode 100644 index 0000000..cd905ab --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartFile.java @@ -0,0 +1,74 @@ +package com.dji.sdk.cloudapi.log; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author sean + * @version 1.2 + * @date 2022/9/7 + */ +public class FileUploadStartFile { + + @NotNull + private String deviceSn; + + @NotNull + private List<@Valid LogFileIndex> list; + + @NotNull + private LogModuleEnum module; + + @NotNull + private String objectKey; + + public FileUploadStartFile() { + } + + @Override + public String toString() { + return "FileUploadStartFile{" + + "deviceSn='" + deviceSn + '\'' + + ", list=" + list + + ", module=" + module + + ", objectKey='" + objectKey + '\'' + + '}'; + } + + public String getDeviceSn() { + return deviceSn; + } + + public FileUploadStartFile setDeviceSn(String deviceSn) { + this.deviceSn = deviceSn; + return this; + } + + public List getList() { + return list; + } + + public FileUploadStartFile setList(List list) { + this.list = list; + return this; + } + + public LogModuleEnum getModule() { + return module; + } + + public FileUploadStartFile setModule(LogModuleEnum module) { + this.module = module; + return this; + } + + public String getObjectKey() { + return objectKey; + } + + public FileUploadStartFile setObjectKey(String objectKey) { + this.objectKey = objectKey; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartParam.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartParam.java new file mode 100644 index 0000000..4bb8423 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartParam.java @@ -0,0 +1,37 @@ +package com.dji.sdk.cloudapi.log; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 1.2 + * @date 2022/9/7 + */ +public class FileUploadStartParam { + + @NotNull + @Size(min = 1, max = 2) + private List<@Valid FileUploadStartFile> files; + + public FileUploadStartParam() { + } + + @Override + public String toString() { + return "FileUploadStartParam{" + + "files=" + files + + '}'; + } + + public List getFiles() { + return files; + } + + public FileUploadStartParam setFiles(List files) { + this.files = files; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStatusEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStatusEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/FileUploadStatusEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStatusEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateRequest.java new file mode 100644 index 0000000..e909ab6 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateRequest.java @@ -0,0 +1,55 @@ +package com.dji.sdk.cloudapi.log; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/5/23 + */ +public class FileUploadUpdateRequest extends BaseModel { + + /** + * Filter list of file + **/ + @NotNull + @Size(min = 1, max = 2) + private List moduleList; + + @NotNull + private FileUploadUpdateStatusEnum status; + + public FileUploadUpdateRequest() { + } + + @Override + public String toString() { + return "FileUploadUpdateRequest{" + + "moduleList=" + moduleList + + ", status=" + status + + '}'; + } + + public List getModuleList() { + return moduleList; + } + + public FileUploadUpdateRequest setModuleList(List moduleList) { + this.moduleList = moduleList; + return this; + } + + public FileUploadUpdateStatusEnum getStatus() { + return status; + } + + public FileUploadUpdateRequest setStatus(FileUploadUpdateStatusEnum status) { + this.status = status; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateStatusEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateStatusEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateStatusEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateStatusEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/log/LogErrorCodeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/LogErrorCodeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/LogErrorCodeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/LogErrorCodeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/log/LogFileIndex.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/LogFileIndex.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/LogFileIndex.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/LogFileIndex.java diff --git a/src/main/java/com/dji/sdk/cloudapi/log/LogFileProgress.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/LogFileProgress.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/LogFileProgress.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/LogFileProgress.java diff --git a/src/main/java/com/dji/sdk/cloudapi/log/LogMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/LogMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/LogMethodEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/LogMethodEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/log/LogModuleEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/LogModuleEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/LogModuleEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/LogModuleEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/log/api/AbstractLogService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/api/AbstractLogService.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/log/api/AbstractLogService.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/log/api/AbstractLogService.java diff --git a/src/main/java/com/dji/sdk/cloudapi/map/CreateMapElementRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/CreateMapElementRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/map/CreateMapElementRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/CreateMapElementRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/map/CreateMapElementResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/CreateMapElementResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/map/CreateMapElementResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/CreateMapElementResponse.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/DockDroneDongleInfos.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/DockDroneDongleInfos.java new file mode 100644 index 0000000..ef23447 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/DockDroneDongleInfos.java @@ -0,0 +1,9 @@ +package com.dji.sdk.cloudapi.map; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/19 + */ +public class DockDroneDongleInfos { +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementCircleGeometry.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementCircleGeometry.java new file mode 100644 index 0000000..64dabb1 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementCircleGeometry.java @@ -0,0 +1,64 @@ +package com.dji.sdk.cloudapi.map; + +import com.dji.sdk.cloudapi.flightarea.GeometrySubTypeEnum; + +import java.util.List; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +public class ElementCircleGeometry extends ElementPointGeometry { + + private final String type = GeometrySubTypeEnum.CIRCLE.getSubType(); + + private Float radius; + + public ElementCircleGeometry() { + } + + @Override + public String toString() { + return "ElementCircleGeometry{" + + "type='" + type + '\'' + + ", radius=" + radius + + '}'; + } + + @Override + public List convertToList() { + return super.convertToList(); + } + + @Override + public void adapterCoordinateType(List coordinateList) { + super.adapterCoordinateType(coordinateList); + Double[] coordinates = this.getCoordinates(); + this.setCoordinates(new Double[]{coordinates[0], coordinates[1]}); + } + + @Override + public Double[] getCoordinates() { + return super.getCoordinates(); + } + + @Override + public ElementPointGeometry setCoordinates(Double[] coordinates) { + return super.setCoordinates(coordinates); + } + + @Override + public String getType() { + return type; + } + + public Float getRadius() { + return radius; + } + + public ElementCircleGeometry setRadius(Float radius) { + this.radius = radius; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementContent.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementContent.java new file mode 100644 index 0000000..9890891 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementContent.java @@ -0,0 +1,61 @@ +package com.dji.sdk.cloudapi.map; + +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/30 + */ +@Schema(description = "element content") +public class ElementContent { + + @Schema(defaultValue = "Feature", allowableValues = "Feature") + @NotNull + private final String type = "Feature"; + + @NotNull + @Valid + private ElementProperty properties; + + @Valid + @NotNull + private ElementGeometryType geometry; + + public ElementContent() { + } + + @Override + public String toString() { + return "ElementContent{" + + "type='" + type + '\'' + + ", properties=" + properties + + ", geometry=" + geometry + + '}'; + } + + public String getType() { + return type; + } + + public ElementProperty getProperties() { + return properties; + } + + public ElementContent setProperties(ElementProperty properties) { + this.properties = properties; + return this; + } + + public ElementGeometryType getGeometry() { + return geometry; + } + + public ElementContent setGeometry(ElementGeometryType geometry) { + this.geometry = geometry; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementCoordinate.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementCoordinate.java new file mode 100644 index 0000000..332f492 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementCoordinate.java @@ -0,0 +1,66 @@ +package com.dji.sdk.cloudapi.map; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/30 + */ +@Schema(description = "The coordinates of the element, the coordinate system is WGS84") +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ElementCoordinate { + + @Schema(description = "longitude") + @NotNull + private Double longitude; + + @Schema(description = "latitude") + @NotNull + private Double latitude; + + @Schema(description = "altitude") + private Double altitude; + + public ElementCoordinate() { + } + + @Override + public String toString() { + return "ElementCoordinate{" + + "longitude=" + longitude + + ", latitude=" + latitude + + ", altitude=" + altitude + + '}'; + } + + public Double getLongitude() { + return longitude; + } + + public ElementCoordinate setLongitude(Double longitude) { + this.longitude = longitude; + return this; + } + + public Double getLatitude() { + return latitude; + } + + public ElementCoordinate setLatitude(Double latitude) { + this.latitude = latitude; + return this; + } + + public Double getAltitude() { + return altitude; + } + + public ElementCoordinate setAltitude(Double altitude) { + this.altitude = altitude; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementGeometryType.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementGeometryType.java new file mode 100644 index 0000000..a6f7ea1 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementGeometryType.java @@ -0,0 +1,49 @@ +package com.dji.sdk.cloudapi.map; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import io.swagger.v3.oas.annotations.media.Schema; + +import java.util.List; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/30 + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", + include = JsonTypeInfo.As.EXISTING_PROPERTY, defaultImpl = ElementGeometryType.class) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ElementCircleGeometry.class, name = "Circle"), + @JsonSubTypes.Type(value = ElementPointGeometry.class, name = "Point"), + @JsonSubTypes.Type(value = ElementLineStringGeometry.class, name = "LineString"), + @JsonSubTypes.Type(value = ElementPolygonGeometry.class, name = "Polygon") +}) +@Schema(oneOf = {ElementPointGeometry.class, ElementLineStringGeometry.class, ElementPolygonGeometry.class}) +public abstract class ElementGeometryType { + + private String type; + + ElementGeometryType(String type) { + this.type = type; + } + + public ElementGeometryType() { + } + + public String getType() { + return type; + } + + /** + * Convert coordinate data into objects and then add them to the collection. + * @return + */ + public abstract List convertToList(); + + /** + * Converts coordinates in a collection of objects to a specific type. + * @param coordinateList + */ + public abstract void adapterCoordinateType(List coordinateList); +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementLineStringGeometry.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementLineStringGeometry.java new file mode 100644 index 0000000..a24eeb4 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementLineStringGeometry.java @@ -0,0 +1,81 @@ +package com.dji.sdk.cloudapi.map; + +import com.dji.sdk.exception.CloudSDKErrorEnum; +import com.dji.sdk.exception.CloudSDKException; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.util.CollectionUtils; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/30 + */ +@Schema(description = "line geometry") +public class ElementLineStringGeometry extends ElementGeometryType { + + @Schema(example = "LineString") + @NotNull + private final String type = ElementResourceTypeEnum.LINE_STRING.getTypeName(); + + @Schema(example = "[[113.943109, 22.577378]]") + @NotNull + @Size(min = 2) + private Double[][] coordinates; + + public ElementLineStringGeometry() { + super(); + } + + @Override + public List convertToList() { + if (this.coordinates.length < 2) { + throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER); + } + List coordinateList = new ArrayList<>(); + for (Double[] coordinate : this.coordinates) { + coordinateList.add(new ElementCoordinate() + .setLongitude(coordinate[0]) + .setLatitude(coordinate[1])); + } + return coordinateList; + } + + @Override + public void adapterCoordinateType(List coordinateList) { + if (CollectionUtils.isEmpty(coordinateList) || coordinateList.size() < 2) { + throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER); + } + this.coordinates = new Double[coordinateList.size()][2]; + for (int i = 0; i < this.coordinates.length; i++) { + this.coordinates[i][0] = coordinateList.get(i).getLongitude(); + this.coordinates[i][1] = coordinateList.get(i).getLatitude(); + } + } + + @Override + public String toString() { + return "ElementLineStringGeometry{" + + "coordinates=" + Arrays.toString(coordinates) + + '}'; + } + + public Double[][] getCoordinates() { + return coordinates; + } + + public ElementLineStringGeometry setCoordinates(Double[][] coordinates) { + this.coordinates = coordinates; + return this; + } + + @Override + public String getType() { + return type; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementPointGeometry.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementPointGeometry.java new file mode 100644 index 0000000..8fe6d8b --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementPointGeometry.java @@ -0,0 +1,77 @@ +package com.dji.sdk.cloudapi.map; + +import com.dji.sdk.exception.CloudSDKErrorEnum; +import com.dji.sdk.exception.CloudSDKException; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.util.CollectionUtils; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/30 + */ +@Schema(description = "point geometry") +public class ElementPointGeometry extends ElementGeometryType { + + @Schema(example = "Point") + @NotNull + private final String type = ElementResourceTypeEnum.POINT.getTypeName(); + + @Schema(example = "[113.943109, 22.577378]") + @NotNull + @Size(min = 2, max = 3) + private Double[] coordinates; + + public ElementPointGeometry() { + super(); + } + + @Override + public List convertToList() { + List coordinateList = new ArrayList<>(); + coordinateList.add(new ElementCoordinate() + .setLongitude(this.coordinates[0]) + .setLatitude(this.coordinates[1]) + .setAltitude(this.coordinates.length == 3 ? this.coordinates[2] : null)); + return coordinateList; + } + + @Override + public void adapterCoordinateType(List coordinateList) { + if (CollectionUtils.isEmpty(coordinateList)) { + throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER); + } + this.coordinates = new Double[]{ + coordinateList.get(0).getLongitude(), + coordinateList.get(0).getLatitude(), + coordinateList.get(0).getAltitude() + }; + } + + @Override + public String toString() { + return "ElementPointGeometry{" + + "coordinates=" + Arrays.toString(coordinates) + + '}'; + } + + public Double[] getCoordinates() { + return coordinates; + } + + public ElementPointGeometry setCoordinates(Double[] coordinates) { + this.coordinates = coordinates; + return this; + } + + @Override + public String getType() { + return type; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementPolygonGeometry.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementPolygonGeometry.java new file mode 100644 index 0000000..e7d2670 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementPolygonGeometry.java @@ -0,0 +1,81 @@ +package com.dji.sdk.cloudapi.map; + +import com.dji.sdk.exception.CloudSDKErrorEnum; +import com.dji.sdk.exception.CloudSDKException; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.util.CollectionUtils; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/30 + */ +@Schema(description = "polygon geometry") +public class ElementPolygonGeometry extends ElementGeometryType { + + @Schema(example = "Polygon") + @NotNull + private final String type = ElementTypeEnum.POLYGON.getDesc(); + + @Schema(example = "[[[113.943109, 22.577378]]]") + @NotNull + @Size(min = 1, max = 1) + private Double[][][] coordinates; + + public ElementPolygonGeometry() { + super(); + } + + @Override + public List convertToList() { + if (this.coordinates[0].length < 3) { + throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER); + } + List coordinateList = new ArrayList<>(); + for (Double[] coordinate : this.coordinates[0]) { + coordinateList.add(new ElementCoordinate() + .setLongitude(coordinate[0]) + .setLatitude(coordinate[1])); + } + return coordinateList; + } + + @Override + public void adapterCoordinateType(List coordinateList) { + if (CollectionUtils.isEmpty(coordinateList) || coordinateList.size() < 3) { + throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER); + } + this.coordinates = new Double[1][coordinateList.size()][2]; + for (int i = 0; i < this.coordinates[0].length; i++) { + this.coordinates[0][i][0] = coordinateList.get(i).getLongitude(); + this.coordinates[0][i][1] = coordinateList.get(i).getLatitude(); + } + } + + @Override + public String toString() { + return "ElementPolygonGeometry{" + + "coordinates=" + Arrays.toString(coordinates) + + '}'; + } + + public Double[][][] getCoordinates() { + return coordinates; + } + + public ElementPolygonGeometry setCoordinates(Double[][][] coordinates) { + this.coordinates = coordinates; + return this; + } + + @Override + public String getType() { + return type; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/ElementProperty.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementProperty.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/map/ElementProperty.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementProperty.java diff --git a/src/main/java/com/dji/sdk/cloudapi/map/ElementResource.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementResource.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/map/ElementResource.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementResource.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementResourceTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementResourceTypeEnum.java new file mode 100644 index 0000000..8d2a42e --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementResourceTypeEnum.java @@ -0,0 +1,53 @@ +package com.dji.sdk.cloudapi.map; + +import com.dji.sdk.exception.CloudSDKException; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +import java.util.Arrays; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/30 + */ +@Schema(enumAsRef = true, description = "

0: Point

1: LineString

2: Polygon

", allowableValues = {"0", "1", "2"}) +public enum ElementResourceTypeEnum { + + POINT(0, "Point"), + + LINE_STRING(1, "LineString"), + + POLYGON(2, "Polygon"); + + private final int type; + + private final String typeName; + + ElementResourceTypeEnum(int type, String typeName) { + this.type = type; + this.typeName = typeName; + } + + public String getTypeName() { + return typeName; + } + + @JsonValue + public int getType() { + return type; + } + + @JsonCreator + public static ElementResourceTypeEnum find(int type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny() + .orElseThrow(() -> new CloudSDKException(ElementResourceTypeEnum.class, type)); + } + + public static ElementResourceTypeEnum find(String typeName) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.typeName.equals(typeName)).findAny() + .orElseThrow(() -> new CloudSDKException(ElementResourceTypeEnum.class, typeName)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementTypeEnum.java new file mode 100644 index 0000000..eb18450 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/ElementTypeEnum.java @@ -0,0 +1,61 @@ +package com.dji.sdk.cloudapi.map; + +import com.dji.sdk.exception.CloudSDKException; + +import java.util.Optional; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/30 + */ +public enum ElementTypeEnum { + + POINT(ElementResourceTypeEnum.POINT), + + LINE_STRING(ElementResourceTypeEnum.LINE_STRING), + + POLYGON(ElementResourceTypeEnum.POLYGON); + + private ElementResourceTypeEnum typeEnum; + + ElementTypeEnum(ElementResourceTypeEnum typeEnum) { + this.typeEnum = typeEnum; + } + + public static Optional findType(int val) { + if (POINT.typeEnum.getType() == val) { + return Optional.of(new ElementPointGeometry()); + } + + if (LINE_STRING.typeEnum.getType() == val) { + return Optional.of(new ElementLineStringGeometry()); + } + + if (POLYGON.typeEnum.getType() == val) { + return Optional.of(new ElementPolygonGeometry()); + } + + return Optional.empty(); + } + + public String getDesc() { + return typeEnum.getTypeName(); + } + + public static int findVal(String desc) { + if (POINT.typeEnum.getTypeName().equals(desc)) { + return POINT.typeEnum.getType(); + } + + if (LINE_STRING.typeEnum.getTypeName().equals(desc)) { + return LINE_STRING.typeEnum.getType(); + } + + if (POLYGON.typeEnum.getTypeName().equals(desc)) { + return POLYGON.typeEnum.getType(); + } + + throw new CloudSDKException("unknown type:" + desc); + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/GetMapElementsResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/GetMapElementsResponse.java new file mode 100644 index 0000000..f2c41e1 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/GetMapElementsResponse.java @@ -0,0 +1,99 @@ +package com.dji.sdk.cloudapi.map; + +import com.dji.sdk.common.BaseModel; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.util.List; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/29 + */ +@Schema(description = "element group data") +public class GetMapElementsResponse extends BaseModel { + + @NotNull + @Pattern(regexp = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") + @Schema(description = "group id", format = "uuid") + private String id; + + @NotNull + @Schema(description = "group name", example = "Pilot Share Layer") + private String name; + + @NotNull + private GroupTypeEnum type; + + @NotNull + @Schema(description = "data collection of elements") + private List<@Valid MapGroupElement> elements; + + @JsonProperty(value = "is_lock") + @NotNull + @Schema(description = "Whether the element group is locked.") + private Boolean lock; + + public GetMapElementsResponse() { + } + + @Override + public String toString() { + return "GetMapElementsResponse{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", type=" + type + + ", elements=" + elements + + ", lock=" + lock + + '}'; + } + + public String getId() { + return id; + } + + public GetMapElementsResponse setId(String id) { + this.id = id; + return this; + } + + public String getName() { + return name; + } + + public GetMapElementsResponse setName(String name) { + this.name = name; + return this; + } + + public GroupTypeEnum getType() { + return type; + } + + public GetMapElementsResponse setType(GroupTypeEnum type) { + this.type = type; + return this; + } + + public List getElements() { + return elements; + } + + public GetMapElementsResponse setElements(List elements) { + this.elements = elements; + return this; + } + + public Boolean getLock() { + return lock; + } + + public GetMapElementsResponse setLock(Boolean lock) { + this.lock = lock; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/GroupTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/GroupTypeEnum.java new file mode 100644 index 0000000..748db7a --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/GroupTypeEnum.java @@ -0,0 +1,44 @@ +package com.dji.sdk.cloudapi.map; + +import com.dji.sdk.exception.CloudSDKException; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +import java.util.Arrays; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/15 + */ +@Schema(description = "

0: custom element group

1: default element group

2: APP shared element group " + + "(type=2 is an APP element group, PILOT will add map elements to this element group by default, " + + "and there must be an APP shared element group. " + + "It is recommended that in the same workspace, there are And there is only one APP shared element group)

", + enumAsRef = true, type = "int", allowableValues = {"0", "1", "2"}) +public enum GroupTypeEnum { + + CUSTOM(0), + + DEFAULT(1), + + SHARED(2); + + private final int type; + + GroupTypeEnum(int type) { + this.type = type; + } + + @JsonValue + public int getType() { + return type; + } + + @JsonCreator + public static GroupTypeEnum find(int type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny() + .orElseThrow(() -> new CloudSDKException(GroupTypeEnum.class, type)); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/MapElementCreateWsResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapElementCreateWsResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/map/MapElementCreateWsResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapElementCreateWsResponse.java diff --git a/src/main/java/com/dji/sdk/cloudapi/map/MapElementDeleteWsResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapElementDeleteWsResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/map/MapElementDeleteWsResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapElementDeleteWsResponse.java diff --git a/src/main/java/com/dji/sdk/cloudapi/map/MapElementUpdateWsResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapElementUpdateWsResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/map/MapElementUpdateWsResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapElementUpdateWsResponse.java diff --git a/src/main/java/com/dji/sdk/cloudapi/map/MapGroupElement.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapGroupElement.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/map/MapGroupElement.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapGroupElement.java diff --git a/src/main/java/com/dji/sdk/cloudapi/map/MapGroupRefreshWsResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapGroupRefreshWsResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/map/MapGroupRefreshWsResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapGroupRefreshWsResponse.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapMethodEnum.java new file mode 100644 index 0000000..14846ca --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/MapMethodEnum.java @@ -0,0 +1,26 @@ +package com.dji.sdk.cloudapi.map; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public enum MapMethodEnum { + + OFFLINE_MAP_UPDATE("offline_map_update"), + + ; + + private final String method; + + MapMethodEnum(String method) { + this.method = method; + } + + @JsonValue + public String getMethod() { + return method; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapFile.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapFile.java new file mode 100644 index 0000000..db8b364 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapFile.java @@ -0,0 +1,84 @@ +package com.dji.sdk.cloudapi.map; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class OfflineMapFile { + + /** + * The offline map file name will be used as a way to determine the version, and the format is: offline_map_{sync_method}_{version}. + * offline_map: is a fixed prefix, sync_method: data synchronization method - full (full), version: version number + */ + @NotNull + @Pattern(regexp = "^offline_map_full_\\w+\\.rocksdb\\.zip$") + private String name; + + @NotNull + private String url; + + /** + * Calculated using SHA256, this value can be used to confirm whether the file is complete. + */ + @NotNull + private String checksum; + + /** + * The size of this file in bytes. + */ + @NotNull + private Long size; + + public OfflineMapFile() { + } + + @Override + public String toString() { + return "OfflineMapFile{" + + "name='" + name + '\'' + + ", url='" + url + '\'' + + ", checksum='" + checksum + '\'' + + ", size=" + size + + '}'; + } + + public String getName() { + return name; + } + + public OfflineMapFile setName(String name) { + this.name = name; + return this; + } + + public String getUrl() { + return url; + } + + public OfflineMapFile setUrl(String url) { + this.url = url; + return this; + } + + public String getChecksum() { + return checksum; + } + + public OfflineMapFile setChecksum(String checksum) { + this.checksum = checksum; + return this; + } + + public Long getSize() { + return size; + } + + public OfflineMapFile setSize(Long size) { + this.size = size; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapGetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapGetRequest.java new file mode 100644 index 0000000..0a29f0d --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapGetRequest.java @@ -0,0 +1,9 @@ +package com.dji.sdk.cloudapi.map; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class OfflineMapGetRequest { +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapGetResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapGetResponse.java new file mode 100644 index 0000000..43ebc83 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapGetResponse.java @@ -0,0 +1,56 @@ +package com.dji.sdk.cloudapi.map; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class OfflineMapGetResponse extends BaseModel { + + /** + * This parameter allows the dock to turn off the offline map capability of the aircraft. + */ + @NotNull + private Boolean offlineMapEnable; + + /** + * Offline map file object list. + */ + @NotNull + private List<@Valid OfflineMapFile> files; + + public OfflineMapGetResponse() { + } + + @Override + public String toString() { + return "OfflineMapGetResponse{" + + "offlineMapEnable=" + offlineMapEnable + + ", files=" + files + + '}'; + } + + public Boolean getOfflineMapEnable() { + return offlineMapEnable; + } + + public OfflineMapGetResponse setOfflineMapEnable(Boolean offlineMapEnable) { + this.offlineMapEnable = offlineMapEnable; + return this; + } + + public List getFiles() { + return files; + } + + public OfflineMapGetResponse setFiles(List files) { + this.files = files; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncFile.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncFile.java new file mode 100644 index 0000000..85e1660 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncFile.java @@ -0,0 +1,49 @@ +package com.dji.sdk.cloudapi.map; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class OfflineMapSyncFile { + + /** + * The offline map file name will be used as a way to determine the version, and the format is: offline_map_{sync_method}_{version}. + * offline_map: is a fixed prefix, sync_method: data synchronization method - full (full), version: version number + */ + private String name; + + /** + * Calculated using SHA256, this value can be used to confirm whether the file is complete. + */ + private String checksum; + + public OfflineMapSyncFile() { + } + + @Override + public String toString() { + return "OfflineMapSyncFile{" + + "name='" + name + '\'' + + ", checksum='" + checksum + '\'' + + '}'; + } + + public String getName() { + return name; + } + + public OfflineMapSyncFile setName(String name) { + this.name = name; + return this; + } + + public String getChecksum() { + return checksum; + } + + public OfflineMapSyncFile setChecksum(String checksum) { + this.checksum = checksum; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncProgress.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncProgress.java new file mode 100644 index 0000000..8ef5705 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncProgress.java @@ -0,0 +1,63 @@ +package com.dji.sdk.cloudapi.map; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class OfflineMapSyncProgress { + + /** + * Sync status + */ + private OfflineMapSyncStatusEnum status; + + /** + * Result code + */ + private OfflineMapSyncReasonEnum reason; + + /** + * Offline map file information + */ + private OfflineMapSyncFile file; + + public OfflineMapSyncProgress() { + } + + @Override + public String toString() { + return "OfflineMapSyncProgress{" + + "status=" + status + + ", reason=" + reason + + ", file=" + file + + '}'; + } + + public OfflineMapSyncStatusEnum getStatus() { + return status; + } + + public OfflineMapSyncProgress setStatus(OfflineMapSyncStatusEnum status) { + this.status = status; + return this; + } + + public OfflineMapSyncReasonEnum getReason() { + return reason; + } + + public OfflineMapSyncProgress setReason(OfflineMapSyncReasonEnum reason) { + this.reason = reason; + return this; + } + + public OfflineMapSyncFile getFile() { + return file; + } + + public OfflineMapSyncProgress setFile(OfflineMapSyncFile file) { + this.file = file; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncReasonEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncReasonEnum.java new file mode 100644 index 0000000..9b1114f --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncReasonEnum.java @@ -0,0 +1,62 @@ +package com.dji.sdk.cloudapi.map; + +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 + * @date 2023/10/20 + */ +public enum OfflineMapSyncReasonEnum { + + SUCCESS(0, "success"), + + PARSE_FILE_FAILED(1, "Failed to parse the file information returned by the cloud."), + + OBTAIN_DRONE_FILE_FAILED(2, "Failed to obtain aircraft file information."), + + DOWNLOAD_FILE_FAILED(3, "Failed to download file from cloud."), + + LINK_ROLLOVER_FAILED(4, "Failed to rollover the link."), + + FILE_TRANSFER_FAILED(5, "Failed to transfer file."), + + DISABLE_OFFLINE_MAP_FAILED(6, "Failed to disable offline map."), + + DELETE_FILE_FAILED(7, "Failed to delete file."), + + LOAD_FILE_FAILED(8, "Failed to load the file on the device side."), + + ENABLE_OFFLINE_MAP_FAILED(9, "Failed to enable offline map."), + + ; + + private final int reason; + + private final String msg; + + OfflineMapSyncReasonEnum(int reason, String msg) { + this.reason = reason; + this.msg = msg; + } + + @JsonValue + public int getReason() { + return reason; + } + + public String getMsg() { + return msg; + } + + @JsonCreator + public static OfflineMapSyncReasonEnum find(int reason) { + return Arrays.stream(values()).filter(reasonEnum -> reasonEnum.reason == reason).findAny() + .orElseThrow(() -> new CloudSDKException(OfflineMapSyncReasonEnum.class, reason)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncStatusEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncStatusEnum.java new file mode 100644 index 0000000..fae0dc3 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/OfflineMapSyncStatusEnum.java @@ -0,0 +1,45 @@ +package com.dji.sdk.cloudapi.map; + +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 + * @date 2023/10/20 + */ +public enum OfflineMapSyncStatusEnum { + + WAIT_SYNC("wait_sync"), + + SYNCHRONIZING("synchronizing"), + + SYNCHRONIZED("synchronized"), + + FAIL("fail"), + + SWITCH_FAIL("switch_fail"), + + ; + + + private final String status; + + OfflineMapSyncStatusEnum(String status) { + this.status = status; + } + + @JsonValue + public String getStatus() { + return status; + } + + @JsonCreator + public static OfflineMapSyncStatusEnum find(String status) { + return Arrays.stream(values()).filter(statusEnum -> statusEnum.status.equals(status)).findAny() + .orElseThrow(() -> new CloudSDKException(OfflineMapSyncStatusEnum.class, status)); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/UpdateMapElementRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/UpdateMapElementRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/map/UpdateMapElementRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/UpdateMapElementRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/api/AbstractOfflineMapService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/api/AbstractOfflineMapService.java new file mode 100644 index 0000000..af47a44 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/api/AbstractOfflineMapService.java @@ -0,0 +1,87 @@ +package com.dji.sdk.cloudapi.map.api; + +import com.dji.sdk.annotations.CloudSDKVersion; +import com.dji.sdk.cloudapi.map.MapMethodEnum; +import com.dji.sdk.cloudapi.map.OfflineMapGetRequest; +import com.dji.sdk.cloudapi.map.OfflineMapGetResponse; +import com.dji.sdk.cloudapi.map.OfflineMapSyncProgress; +import com.dji.sdk.cloudapi.property.DockDroneOfflineMapEnable; +import com.dji.sdk.config.version.CloudSDKVersionEnum; +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.requests.TopicRequestsRequest; +import com.dji.sdk.mqtt.requests.TopicRequestsResponse; +import com.dji.sdk.mqtt.services.ServicesPublish; +import com.dji.sdk.mqtt.services.ServicesReplyData; +import com.dji.sdk.mqtt.services.TopicServicesResponse; +import com.dji.sdk.mqtt.state.TopicStateRequest; +import com.dji.sdk.mqtt.state.TopicStateResponse; +import org.springframework.integration.annotation.ServiceActivator; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageHeaders; + +import javax.annotation.Resource; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/19 + */ +public abstract class AbstractOfflineMapService { + + @Resource + private ServicesPublish servicesPublish; + + /** + * When the offline map is closed, offline map synchronization will no longer automatically synchronize. + * @param request data + * @param headers The headers for a {@link Message}. + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_1, include = GatewayTypeEnum.DOCK2) + @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_DRONE_OFFLINE_MAP_ENABLE, outputChannel = ChannelName.OUTBOUND_STATE) + public TopicStateResponse dockDroneOfflineMapEnable(TopicStateRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("dockDroneOfflineMapEnable not implemented"); + } + + /** + * Actively trigger offline map updates. + * After receiving the message, the airport will actively pull offline map information at the appropriate time and trigger the offline map synchronization mechanism. + * @param gateway gateway device + * @return services_reply + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_1, include = GatewayTypeEnum.DOCK2) + public TopicServicesResponse offlineMapUpdate(GatewayManager gateway) { + return servicesPublish.publish( + gateway.getGatewaySn(), + MapMethodEnum.OFFLINE_MAP_UPDATE.getMethod()); + } + + /** + * Offline map file synchronization status + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_OFFLINE_MAP_SYNC_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS) + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_1, include = GatewayTypeEnum.DOCK2) + public TopicRequestsResponse offlineMapSyncProgress(TopicRequestsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("offlineMapSyncProgress not implemented"); + } + + /** + * The dock will actively pull the latest offline map file information. + * From this information, it will check whether the aircraft's offline map file name or checksum has changed. + * Once a change is found, offline map synchronization will be triggered. + * Otherwise, synchronization will not be triggered. + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_REQUESTS_OFFLINE_MAP_GET, outputChannel = ChannelName.OUTBOUND_REQUESTS) + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_1, include = GatewayTypeEnum.DOCK2) + public TopicRequestsResponse> offlineMapGet(TopicRequestsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("offlineMapGet not implemented"); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/api/IHttpMapService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/api/IHttpMapService.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/map/api/IHttpMapService.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/map/api/IHttpMapService.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/FastUploadExtension.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/FastUploadExtension.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/FastUploadExtension.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/FastUploadExtension.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/FileUploadCallback.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/FileUploadCallback.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/FileUploadCallback.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/FileUploadCallback.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/FileUploadCallbackFile.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/FileUploadCallbackFile.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/FileUploadCallbackFile.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/FileUploadCallbackFile.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/FolderUploadCallbackRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/FolderUploadCallbackRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/FolderUploadCallbackRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/FolderUploadCallbackRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/GetFileFingerprintRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/GetFileFingerprintRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/GetFileFingerprintRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/GetFileFingerprintRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/GetFileFingerprintResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/GetFileFingerprintResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/GetFileFingerprintResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/GetFileFingerprintResponse.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/HighestPriorityUploadFlightTaskMedia.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/HighestPriorityUploadFlightTaskMedia.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/HighestPriorityUploadFlightTaskMedia.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/HighestPriorityUploadFlightTaskMedia.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/MediaFastUploadRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/MediaFastUploadRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/MediaFastUploadRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/MediaFastUploadRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/MediaFileExtension.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/MediaFileExtension.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/MediaFileExtension.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/MediaFileExtension.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/MediaFileMetadata.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/MediaFileMetadata.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/MediaFileMetadata.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/MediaFileMetadata.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/MediaMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/MediaMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/MediaMethodEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/MediaMethodEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/MediaSubFileTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/MediaSubFileTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/MediaSubFileTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/MediaSubFileTypeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/MediaUploadCallbackRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/MediaUploadCallbackRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/MediaUploadCallbackRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/MediaUploadCallbackRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/Position.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/Position.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/Position.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/Position.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/StorageConfigGet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/StorageConfigGet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/StorageConfigGet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/StorageConfigGet.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/StorageConfigGetModuleEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/StorageConfigGetModuleEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/StorageConfigGetModuleEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/StorageConfigGetModuleEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/UploadCallbackFileExtension.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/UploadCallbackFileExtension.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/UploadCallbackFileExtension.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/UploadCallbackFileExtension.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/UploadCallbackFileMetadata.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/UploadCallbackFileMetadata.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/UploadCallbackFileMetadata.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/UploadCallbackFileMetadata.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/UploadFlighttaskMediaPrioritize.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/UploadFlighttaskMediaPrioritize.java new file mode 100644 index 0000000..b93fad3 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/UploadFlighttaskMediaPrioritize.java @@ -0,0 +1,37 @@ +package com.dji.sdk.cloudapi.media; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/27 + */ +public class UploadFlighttaskMediaPrioritize extends BaseModel { + + @NotNull + @Pattern(regexp = "^[^<>:\"/|?*._\\\\]+$") + private String flightId; + + public UploadFlighttaskMediaPrioritize() { + } + + @Override + public String toString() { + return "UploadFlighttaskMediaPrioritize{" + + "flightId='" + flightId + '\'' + + '}'; + } + + public String getFlightId() { + return flightId; + } + + public UploadFlighttaskMediaPrioritize setFlightId(String flightId) { + this.flightId = flightId; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/media/api/AbstractMediaService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/api/AbstractMediaService.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/api/AbstractMediaService.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/api/AbstractMediaService.java diff --git a/src/main/java/com/dji/sdk/cloudapi/media/api/IHttpMediaService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/api/IHttpMediaService.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/media/api/IHttpMediaService.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/media/api/IHttpMediaService.java diff --git a/src/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusResponse.java new file mode 100644 index 0000000..2bff608 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusResponse.java @@ -0,0 +1,39 @@ +package com.dji.sdk.cloudapi.organization; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/30 + */ +public class AirportBindStatusResponse extends BaseModel { + + @NotNull + @Size(min = 1, max = 2) + private List<@Valid BindStatusRequestDevice> bindStatus; + + public AirportBindStatusResponse() { + } + + @Override + public String toString() { + return "AirportBindStatusResponse{" + + "bindStatus=" + bindStatus + + '}'; + } + + public List getBindStatus() { + return bindStatus; + } + + public AirportBindStatusResponse setBindStatus(List bindStatus) { + this.bindStatus = bindStatus; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindResponse.java new file mode 100644 index 0000000..296fcb6 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindResponse.java @@ -0,0 +1,39 @@ +package com.dji.sdk.cloudapi.organization; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/30 + */ +public class AirportOrganizationBindResponse extends BaseModel { + + @NotNull + @Size(min = 1, max = 2) + private List<@Valid OrganizationBindInfo> errInfos; + + public AirportOrganizationBindResponse() { + } + + @Override + public String toString() { + return "AirportOrganizationBindResponse{" + + "errInfos=" + errInfos + + '}'; + } + + public List getErrInfos() { + return errInfos; + } + + public AirportOrganizationBindResponse setErrInfos(List errInfos) { + this.errInfos = errInfos; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationGetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationGetRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationGetRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationGetRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationGetResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationGetResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationGetResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationGetResponse.java diff --git a/src/main/java/com/dji/sdk/cloudapi/organization/BindStatusRequestDevice.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/BindStatusRequestDevice.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/organization/BindStatusRequestDevice.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/BindStatusRequestDevice.java diff --git a/src/main/java/com/dji/sdk/cloudapi/organization/BindStatusResponseDevice.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/BindStatusResponseDevice.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/organization/BindStatusResponseDevice.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/BindStatusResponseDevice.java diff --git a/src/main/java/com/dji/sdk/cloudapi/organization/OrganizationBindDevice.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/OrganizationBindDevice.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/organization/OrganizationBindDevice.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/OrganizationBindDevice.java diff --git a/src/main/java/com/dji/sdk/cloudapi/organization/OrganizationBindInfo.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/OrganizationBindInfo.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/organization/OrganizationBindInfo.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/OrganizationBindInfo.java diff --git a/src/main/java/com/dji/sdk/cloudapi/organization/api/AbstractOrganizationService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/api/AbstractOrganizationService.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/organization/api/AbstractOrganizationService.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/organization/api/AbstractOrganizationService.java diff --git a/src/main/java/com/dji/sdk/cloudapi/property/DistanceLimitStatusData.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DistanceLimitStatusData.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/DistanceLimitStatusData.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DistanceLimitStatusData.java diff --git a/src/main/java/com/dji/sdk/cloudapi/property/DistanceLimitStatusSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DistanceLimitStatusSet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/DistanceLimitStatusSet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DistanceLimitStatusSet.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneCommanderFlightHeight.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneCommanderFlightHeight.java new file mode 100644 index 0000000..5178d1c --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneCommanderFlightHeight.java @@ -0,0 +1,41 @@ +package com.dji.sdk.cloudapi.property; + +import com.dji.sdk.common.BaseModel; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class DockDroneCommanderFlightHeight extends BaseModel { + + @JsonProperty("commander_flight_height") + @NotNull + @Min(2) + @Max(3000) + private Float commanderFlightHeight; + + public DockDroneCommanderFlightHeight() { + } + + @Override + public String toString() { + return "DockDroneCommanderFlightHeight{" + + "commanderFlightHeight=" + commanderFlightHeight + + '}'; + } + + public Float getCommanderFlightHeight() { + return commanderFlightHeight; + } + + public DockDroneCommanderFlightHeight setCommanderFlightHeight(Float commanderFlightHeight) { + this.commanderFlightHeight = commanderFlightHeight; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneCommanderModeLostAction.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneCommanderModeLostAction.java new file mode 100644 index 0000000..014a4b6 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneCommanderModeLostAction.java @@ -0,0 +1,38 @@ +package com.dji.sdk.cloudapi.property; + +import com.dji.sdk.cloudapi.control.CommanderModeLostActionEnum; +import com.dji.sdk.common.BaseModel; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/19 + */ +public class DockDroneCommanderModeLostAction extends BaseModel { + + @JsonProperty("commander_mode_lost_action") + @NotNull + private CommanderModeLostActionEnum commanderModeLostAction; + + public DockDroneCommanderModeLostAction() { + } + + @Override + public String toString() { + return "DockDroneCommanderModeLostAction{" + + "commanderModeLostAction=" + commanderModeLostAction + + '}'; + } + + public CommanderModeLostActionEnum getCommanderModeLostAction() { + return commanderModeLostAction; + } + + public DockDroneCommanderModeLostAction setCommanderModeLostAction(CommanderModeLostActionEnum commanderModeLostAction) { + this.commanderModeLostAction = commanderModeLostAction; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneOfflineMapEnable.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneOfflineMapEnable.java new file mode 100644 index 0000000..c329212 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneOfflineMapEnable.java @@ -0,0 +1,37 @@ +package com.dji.sdk.cloudapi.property; + +import com.dji.sdk.common.BaseModel; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/20 + */ +public class DockDroneOfflineMapEnable extends BaseModel { + + @JsonProperty("offline_map_enable") + @NotNull + private Boolean offlineMapEnable; + + public DockDroneOfflineMapEnable() { + } + + @Override + public String toString() { + return "DockDroneOfflineMapEnable{" + + "offlineMapEnable=" + offlineMapEnable + + '}'; + } + + public Boolean getOfflineMapEnable() { + return offlineMapEnable; + } + + public DockDroneOfflineMapEnable setOfflineMapEnable(Boolean offlineMapEnable) { + this.offlineMapEnable = offlineMapEnable; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneRthMode.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneRthMode.java new file mode 100644 index 0000000..f900076 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/DockDroneRthMode.java @@ -0,0 +1,38 @@ +package com.dji.sdk.cloudapi.property; + +import com.dji.sdk.cloudapi.wayline.RthModeEnum; +import com.dji.sdk.common.BaseModel; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/11 + */ +public class DockDroneRthMode extends BaseModel { + + @JsonProperty("rth_mode") + @NotNull + private RthModeEnum rthMode; + + public DockDroneRthMode() { + } + + @Override + public String toString() { + return "DockDroneRthMode{" + + "rthMode=" + rthMode + + '}'; + } + + public RthModeEnum getRthMode() { + return rthMode; + } + + public DockDroneRthMode setRthMode(RthModeEnum rthMode) { + this.rthMode = rthMode; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/property/ExitWaylineWhenRcLostSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ExitWaylineWhenRcLostSet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/ExitWaylineWhenRcLostSet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ExitWaylineWhenRcLostSet.java diff --git a/src/main/java/com/dji/sdk/cloudapi/property/HeightLimitSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/HeightLimitSet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/HeightLimitSet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/HeightLimitSet.java diff --git a/src/main/java/com/dji/sdk/cloudapi/property/NightLightsStateSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/NightLightsStateSet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/NightLightsStateSet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/NightLightsStateSet.java diff --git a/src/main/java/com/dji/sdk/cloudapi/property/ObstacleAvoidanceSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ObstacleAvoidanceSet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/ObstacleAvoidanceSet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ObstacleAvoidanceSet.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/PropertySetEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/PropertySetEnum.java new file mode 100644 index 0000000..9679e95 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/PropertySetEnum.java @@ -0,0 +1,106 @@ +package com.dji.sdk.cloudapi.property; + +import com.dji.sdk.cloudapi.device.DockSilentMode; +import com.dji.sdk.common.BaseModel; +import com.dji.sdk.config.version.CloudSDKVersionEnum; +import com.dji.sdk.config.version.GatewayTypeEnum; +import com.dji.sdk.exception.CloudSDKException; + +import java.util.Arrays; +import java.util.Set; + +/** + * @author sean + * @version 1.3 + * @date 2022/10/27 + */ +public enum PropertySetEnum { + + NIGHT_LIGHTS_STATE("night_lights_state", NightLightsStateSet.class, CloudSDKVersionEnum.V0_0_1, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + HEIGHT_LIMIT("height_limit", HeightLimitSet.class, CloudSDKVersionEnum.V0_0_1, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + DISTANCE_LIMIT_STATUS("distance_limit_status", DistanceLimitStatusSet.class, CloudSDKVersionEnum.V0_0_1, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + OBSTACLE_AVOIDANCE("obstacle_avoidance", ObstacleAvoidanceSet.class, CloudSDKVersionEnum.V0_0_1, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + RTH_ALTITUDE("rth_altitude", RthAltitudeSet.class, CloudSDKVersionEnum.V0_0_1, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + OUT_OF_CONTROL_ACTION("rc_lost_action", RcLostActionSet.class, CloudSDKVersionEnum.V0_0_1, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + EXIT_WAYLINE_WHEN_RC_LOST("exit_wayline_when_rc_lost", ExitWaylineWhenRcLostSet.class, CloudSDKVersionEnum.V0_0_1, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2), true), + + THERMAL_CURRENT_PALETTE_STYLE("thermal_current_palette_style", ThermalCurrentPaletteStyleSet.class, CloudSDKVersionEnum.V0_0_1, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + THERMAL_GAIN_MODE("thermal_gain_mode", ThermalGainModeSet.class, CloudSDKVersionEnum.V0_0_1, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + THERMAL_ISOTHERM_STATE("thermal_isotherm_state", ThermalIsothermStateSet.class, CloudSDKVersionEnum.V0_0_1, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + THERMAL_ISOTHERM_UPPER_LIMIT("thermal_isotherm_upper_limit", ThermalIsothermUpperLimitSet.class, CloudSDKVersionEnum.V0_0_1, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + THERMAL_ISOTHERM_LOWER_LIMIT("thermal_isotherm_lower_limit", ThermalIsothermLowerLimitSet.class, CloudSDKVersionEnum.V0_0_1, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + RTH_MODE("rth_mode", DockDroneRthMode.class, CloudSDKVersionEnum.V1_0_0, Set.of(GatewayTypeEnum.DOCK2)), + + USER_EXPERIENCE_IMPROVEMENT("user_experience_improvement", UserExperienceImprovementSet.class, CloudSDKVersionEnum.V1_0_0, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + COMMANDER_MODE_LOST_ACTION("commander_mode_lost_action", DockDroneCommanderModeLostAction.class, CloudSDKVersionEnum.V1_0_0, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + COMMANDER_FLIGHT_HEIGHT("commander_flight_height", DockDroneCommanderFlightHeight.class, CloudSDKVersionEnum.V1_0_0, Set.of(GatewayTypeEnum.DOCK, GatewayTypeEnum.DOCK2)), + + OFFLINE_MAP_ENABLE("offline_map_enable", DockDroneOfflineMapEnable.class, CloudSDKVersionEnum.V1_0_1, Set.of(GatewayTypeEnum.DOCK2)), + + SILENT_MODE("silent_mode", DockSilentMode.class, CloudSDKVersionEnum.V1_0_2, Set.of(GatewayTypeEnum.DOCK)), + + ; + + private final String property; + + private final Class clazz; + + private final CloudSDKVersionEnum since; + + private final Set supportedDevices; + + private boolean deprecated; + + PropertySetEnum(String property, Class clazz, CloudSDKVersionEnum since, Set supportedDevices) { + this.property = property; + this.clazz = clazz; + this.since = since; + this.supportedDevices = supportedDevices; + } + + PropertySetEnum(String property, Class clazz, CloudSDKVersionEnum since, Set supportedDevices, boolean deprecated) { + this.property = property; + this.clazz = clazz; + this.since = since; + this.supportedDevices = supportedDevices; + this.deprecated = deprecated; + } + + public String getProperty() { + return property; + } + + public Class getClazz() { + return clazz; + } + + public CloudSDKVersionEnum getSince() { + return since; + } + + public Set getSupportedDevices() { + return supportedDevices; + } + + public boolean isDeprecated() { + return deprecated; + } + + public static PropertySetEnum find(String property) { + return Arrays.stream(values()).filter(propertyEnum -> propertyEnum.property.equals(property)).findAny() + .orElseThrow(() -> new CloudSDKException(PropertySetEnum.class, property)); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/property/RcLostActionSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/RcLostActionSet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/RcLostActionSet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/RcLostActionSet.java diff --git a/src/main/java/com/dji/sdk/cloudapi/property/RthAltitudeSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/RthAltitudeSet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/RthAltitudeSet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/RthAltitudeSet.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/SilentModeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/SilentModeEnum.java new file mode 100644 index 0000000..369b6e0 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/SilentModeEnum.java @@ -0,0 +1,39 @@ +package com.dji.sdk.cloudapi.property; + +import com.dji.sdk.exception.CloudSDKException; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +import java.util.Arrays; + +/** + * @author sean + * @date 2023/12/12 + * @version 1.9 + */ +public enum SilentModeEnum { + + RING(0), + + SILENT(1), + + ; + + private final int mode; + + SilentModeEnum(int mode) { + this.mode = mode; + } + + @JsonValue + public int getMode() { + return mode; + } + + @JsonCreator + public static SilentModeEnum find(int mode) { + return Arrays.stream(values()).filter(modeEnum -> modeEnum.mode == mode).findAny() + .orElseThrow(() -> new CloudSDKException(SilentModeEnum.class, mode)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/property/ThermalCurrentPaletteStyleSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ThermalCurrentPaletteStyleSet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/ThermalCurrentPaletteStyleSet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ThermalCurrentPaletteStyleSet.java diff --git a/src/main/java/com/dji/sdk/cloudapi/property/ThermalGainModeSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ThermalGainModeSet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/ThermalGainModeSet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ThermalGainModeSet.java diff --git a/src/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermLowerLimitSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermLowerLimitSet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermLowerLimitSet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermLowerLimitSet.java diff --git a/src/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermStateSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermStateSet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermStateSet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermStateSet.java diff --git a/src/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermUpperLimitSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermUpperLimitSet.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermUpperLimitSet.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/ThermalIsothermUpperLimitSet.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/UserExperienceImprovementSet.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/UserExperienceImprovementSet.java new file mode 100644 index 0000000..eda802d --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/UserExperienceImprovementSet.java @@ -0,0 +1,38 @@ +package com.dji.sdk.cloudapi.property; + +import com.dji.sdk.cloudapi.device.UserExperienceImprovementEnum; +import com.dji.sdk.common.BaseModel; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/13 + */ +public class UserExperienceImprovementSet extends BaseModel { + + @NotNull + @JsonProperty("user_experience_improvement") + private UserExperienceImprovementEnum userExperienceImprovement; + + public UserExperienceImprovementSet() { + } + + @Override + public String toString() { + return "UserExperienceImprovementSet{" + + "userExperienceImprovement=" + userExperienceImprovement + + '}'; + } + + public UserExperienceImprovementEnum getUserExperienceImprovement() { + return userExperienceImprovement; + } + + public UserExperienceImprovementSet setUserExperienceImprovement(UserExperienceImprovementEnum userExperienceImprovement) { + this.userExperienceImprovement = userExperienceImprovement; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/api/AbstractPropertyService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/api/AbstractPropertyService.java new file mode 100644 index 0000000..56a9ab7 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/property/api/AbstractPropertyService.java @@ -0,0 +1,89 @@ +package com.dji.sdk.cloudapi.property.api; + +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.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; +import com.dji.sdk.mqtt.property.PropertySetReplyResultEnum; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/30 + */ +public abstract class AbstractPropertyService { + + @Resource + private PropertySetPublish propertySetPublish; + + /** + * Device property set + * @param gateway + * @param propertyEnum + * @param request + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public PropertySetReplyResultEnum propertySet(GatewayManager gateway, PropertySetEnum propertyEnum, BaseModel request) { + checkCondition(gateway, propertyEnum, request); + + Common.validateModel(request); + Field[] fields = request.getClass().getDeclaredFields(); + if (fields.length > 1 || null == fields[0].getDeclaredAnnotation(Valid.class)) { + return propertySetPublish.publish(gateway.getGatewaySn(), request); + } + + try { + Map map = new HashMap<>(); + fields[0].setAccessible(true); + Object child = fields[0].get(request); + for (Field field : ((Class) fields[0].getGenericType()).getDeclaredFields()) { + field.setAccessible(true); + Object value = field.get(child); + if (Objects.isNull(value)) { + continue; + } + map.put(Optional.ofNullable(field.getDeclaredAnnotation(JsonProperty.class)) + .map(JsonProperty::value).orElse(field.getName()), value); + field.setAccessible(false); + PropertySetReplyResultEnum result = propertySetPublish.publish( + gateway.getGatewaySn(), Map.of(propertyEnum.getProperty(), map)); + if (PropertySetReplyResultEnum.SUCCESS != result) { + return result; + } + map.clear(); + } + fields[0].setAccessible(false); + + } catch (IllegalAccessException e) { + throw new CloudSDKException(e); + } + return PropertySetReplyResultEnum.SUCCESS; + } + + private void checkCondition(GatewayManager gateway, PropertySetEnum propertyEnum, BaseModel request) { + if (Objects.isNull(request) || propertyEnum.getClazz() != request.getClass()) { + throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER); + } + if (!propertyEnum.getSupportedDevices().contains(gateway.getType())) { + throw new CloudSDKException(CloudSDKErrorEnum.DEVICE_TYPE_NOT_SUPPORT); + } + if (propertyEnum.isDeprecated() || !gateway.getSdkVersion().isSupported(propertyEnum.getSince())) { + throw new CloudSDKException(CloudSDKErrorEnum.DEVICE_VERSION_NOT_SUPPORT); + } + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/storage/CredentialsToken.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/storage/CredentialsToken.java new file mode 100644 index 0000000..c8ffc0e --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/storage/CredentialsToken.java @@ -0,0 +1,95 @@ +package com.dji.sdk.cloudapi.storage; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + + +/** + * @author sean + * @version 0.2 + * @date 2021/12/7 + */ +@Schema(description = "The token data of the temporary credential") +public class CredentialsToken { + + private static final int DELAY = 300; + + @NotNull + @Schema(description = "access key id", example = "3POX6W77L1EF4C86L2RE") + @JsonProperty("access_key_id") + private String accessKeyId; + + @NotNull + @Schema(description = "access key secret", example = "9NG2P2yJaUrck576CkdRoRbchKssJiZygi5D93CBsduY") + @JsonProperty("access_key_secret") + private String accessKeySecret; + + @NotNull + @Min(1) + @Schema(description = "The valid time of the token, in seconds.", example = "3600") + private Long expire; + + @NotNull + @JsonProperty("security_token") + @Schema(description = "security token", example = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiIzUE9YNlc3N0wxRUY0Qzg2TDJSRSIsImV4cCI6MTY4NjgxOTgyOSwicGFyZW50IjoibWluaW8ifQ.cWJXI90UidrBOTD0gWxKt8PT5Qp_6dEK5wNfJuE6lR9dH6Us7jtSB8vcttRDwPhpCNrAGsv91ydw6NLMyjqAOw") + private String securityToken; + + public CredentialsToken(@NotNull String accessKeyId, @NotNull String accessKeySecret, @NotNull String securityToken, @NotNull @Min(1) Long expire) { + this.accessKeyId = accessKeyId; + this.accessKeySecret = accessKeySecret; + this.securityToken = securityToken; + this.expire = expire - DELAY; + } + + public CredentialsToken() { + } + + @Override + public String toString() { + return "CredentialsToken{" + + "accessKeyId='" + accessKeyId + '\'' + + ", accessKeySecret='" + accessKeySecret + '\'' + + ", expire=" + expire + + ", securityToken='" + securityToken + '\'' + + '}'; + } + + public String getAccessKeyId() { + return accessKeyId; + } + + public CredentialsToken setAccessKeyId(String accessKeyId) { + this.accessKeyId = accessKeyId; + return this; + } + + public String getAccessKeySecret() { + return accessKeySecret; + } + + public CredentialsToken setAccessKeySecret(String accessKeySecret) { + this.accessKeySecret = accessKeySecret; + return this; + } + + public Long getExpire() { + return expire; + } + + public CredentialsToken setExpire(Long expire) { + this.expire = expire; + return this; + } + + public String getSecurityToken() { + return securityToken; + } + + public CredentialsToken setSecurityToken(String securityToken) { + this.securityToken = securityToken; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/storage/OssTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/storage/OssTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/storage/OssTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/storage/OssTypeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/storage/StsCredentialsResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/storage/StsCredentialsResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/storage/StsCredentialsResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/storage/StsCredentialsResponse.java diff --git a/src/main/java/com/dji/sdk/cloudapi/storage/api/IHttpStorageService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/storage/api/IHttpStorageService.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/storage/api/IHttpStorageService.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/storage/api/IHttpStorageService.java diff --git a/src/main/java/com/dji/sdk/cloudapi/tsa/DeviceIconUrl.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/DeviceIconUrl.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/tsa/DeviceIconUrl.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/DeviceIconUrl.java diff --git a/src/main/java/com/dji/sdk/cloudapi/tsa/DeviceTopology.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/DeviceTopology.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/tsa/DeviceTopology.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/DeviceTopology.java diff --git a/src/main/java/com/dji/sdk/cloudapi/tsa/IconUrlEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/IconUrlEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/tsa/IconUrlEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/IconUrlEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyDeviceModel.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyDeviceModel.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/tsa/TopologyDeviceModel.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyDeviceModel.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyList.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyList.java new file mode 100644 index 0000000..acdf7b2 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyList.java @@ -0,0 +1,53 @@ +package com.dji.sdk.cloudapi.tsa; + +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author sean + * @version 0.2 + * @date 2021/12/8 + */ +@Schema(description = "device topology list") +public class TopologyList { + + @Schema(description = "drone device topology collection") + @NotNull + private List<@Valid DeviceTopology> hosts; + + @Schema(description = "gateway device topology collection") + @NotNull + private List<@Valid DeviceTopology> parents; + + public TopologyList() { + } + + @Override + public String toString() { + return "TopologyList{" + + "hosts=" + hosts + + ", parents=" + parents + + '}'; + } + + public List getHosts() { + return hosts; + } + + public TopologyList setHosts(List hosts) { + this.hosts = hosts; + return this; + } + + public List getParents() { + return parents; + } + + public TopologyList setParents(List parents) { + this.parents = parents; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyResponse.java new file mode 100644 index 0000000..352b947 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyResponse.java @@ -0,0 +1,39 @@ +package com.dji.sdk.cloudapi.tsa; + +import com.dji.sdk.common.BaseModel; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/16 + */ +@Schema(description = "topology response data") +public class TopologyResponse extends BaseModel { + + @NotNull + private List<@Valid TopologyList> list; + + public TopologyResponse() { + } + + @Override + public String toString() { + return "TopologyResponse{" + + "list=" + list + + '}'; + } + + public List getList() { + return list; + } + + public TopologyResponse setList(List list) { + this.list = list; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/tsa/api/IHttpTsaService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/api/IHttpTsaService.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/tsa/api/IHttpTsaService.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/tsa/api/IHttpTsaService.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ActionTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ActionTypeEnum.java new file mode 100644 index 0000000..fe5b998 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ActionTypeEnum.java @@ -0,0 +1,37 @@ +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 + * @date 2023/10/23 + */ +public enum ActionTypeEnum { + + SPOT_CHECK(1), + + ; + + private final int type; + + ActionTypeEnum(int type) { + this.type = type; + } + + @JsonValue + public int getType() { + return type; + } + + @JsonCreator + public static ActionTypeEnum find(int type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny() + .orElseThrow(() -> new CloudSDKException(ActionTypeEnum.class, type)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/BreakpointStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/BreakpointStateEnum.java new file mode 100644 index 0000000..263917e --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/BreakpointStateEnum.java @@ -0,0 +1,43 @@ +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 + * @date 2023/6/6 + */ +public enum BreakpointStateEnum { + + WAYLINE_SEGMENT(0, "On the wayline segment"), + + WAYPOINT(1, "On the waypoint"); + + private final int state; + + private final String msg; + + BreakpointStateEnum(int state, String msg) { + this.state = state; + this.msg = msg; + } + + @JsonValue + public int getState() { + return state; + } + + public String getMsg() { + return msg; + } + + @JsonCreator + public static BreakpointStateEnum find(int state) { + return Arrays.stream(values()).filter(stateEnum -> stateEnum.state == state).findAny() + .orElseThrow(() -> new CloudSDKException(BreakpointStateEnum.class, state)); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/DeviceExitHomingNotify.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/DeviceExitHomingNotify.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/DeviceExitHomingNotify.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/DeviceExitHomingNotify.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/ExecutableConditions.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExecutableConditions.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/ExecutableConditions.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExecutableConditions.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExecutionStepEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExecutionStepEnum.java new file mode 100644 index 0000000..0a13a86 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExecutionStepEnum.java @@ -0,0 +1,131 @@ +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 + * @date 2023/6/6 + */ +public enum ExecutionStepEnum { + + INITIAL(0, "Initial state"), + + PRE_CHECK(1, "Pre-launch check: Is the spacecraft executing the route?"), + + CHECK_WORK_MODE(2, "Pre-launch check: Is the airport exiting work mode?"), + + CHECK_EXECUTION(3, "Pre-launch check: Route execution in progress"), + + CHECK_RETURN(4, "Pre-launch check: Return in progress"), + + PREPARATION(5, "Route execution entering preparation state, waiting for task issuance to begin"), + + OPERATIONAL(6, "Airport entering operational state"), + + OPEN_COVER_PREPARATION(7, "Entering startup check preparation and hatch opening preparation"), + + WAITING_FOR_FLIGHT_SYSTEM_READINESS(8, "Waiting for flight system readiness, push connection establishment"), + + WAITING_FOR_RTK(9, "Waiting for RTK source monitoring with reported values"), + + CHECK_RTK_SOURCE(10, "Check if RTK source is from the airport; if not, reset"), + + WAITING_FOR_FLIGHT_CONTROL(11, "Waiting for flight control notification"), + + WRESTING_FLIGHT_CONTROL(12, "Airport has no control; wresting control from the aircraft"), + + GET_KMZ(13, "Get the latest KMZ URL"), + + DOWNLOAD_KMZ(14, "Download KMZ"), + + KMZ_UPLOADING(15, "KMZ uploading"), + + DYE_CONFIGURATION(16, "Dye configuration"), + + SET_DRONE_PARAMETER(17, "Aircraft takeoff parameter settings, alternate landing point settings, takeoff altitude settings, dye settings"), + + SET_TAKEOFF_PARAMETER(18, "Aircraft 'flyto' takeoff parameter settings"), + + SET_HOME_POINT(19, "Home point settings"), + + WAYLINE_EXECUTION(20, "Trigger route execution"), + + IN_PROGRESS(21, "Route execution in progress"), + + RETURN_CHECK_PREPARATION(22, "Entering return check preparation"), + + LADING(23, "Aircraft landing at the airport"), + + CLOSE_COVER(24, "Hatch closure after landing"), + + EXIT_WORK_MODE(25, "Airport exiting work mode"), + + DRONE_ABNORMAL_RECOVERY(26, "Airport abnormal recovery"), + + UPLOADING_FLIGHT_SYSTEM_LOGS(27, "Airport uploading flight system logs"), + + CHECK_RECORDING_STATUS(28, "Camera recording status check"), + + GET_MEDIA_FILES(29, "Get the number of media files"), + + DOCK_ABNORMAL_RECOVERY(30, "Abnormal recovery of airport takeoff hatch opening"), + + NOTIFY_TASK_RESULTS(31, "Notify task results"), + + TASK_COMPLETED(32, "Task execution completed; whether to initiate log retrieval based on configuration file"), + + RETRIEVAL_DRONE_LOG_LIST(33, "Log list retrieval - Aircraft list"), + + RETRIEVAL_DOCK_LOG_LIST(34, "Log list retrieval - Airport list retrieval"), + + UPLOAD_LOG_LIST_RESULTS(35, "Log list retrieval - Upload log list results"), + + RETRIEVAL_DRONE_LOG(36, "Log retrieval - Retrieve aircraft logs"), + + RETRIEVAL_DOCK_LOG(37, "Log retrieval - Retrieve airport logs"), + + COMPRESS_DRONE_LOG(38, "Log retrieval - Compress aircraft logs"), + + COMPRESS_DOCK_LOG(39, "Log retrieval - Compress airport logs"), + + UPLOAD_DRONE_LOG(40, "Log retrieval - Upload aircraft logs"), + + UPLOAD_DOCK_LOG(41, "Log retrieval - Upload airport logs"), + + NOTIFY_LOG_RESULTS(42, "Log retrieval - Notify results"), + + WAITING_FOR_SERVICE_RESPONSE(65533, "Waiting for service response after completion"), + + NO_SPECIFIC_STATUS(65534, "No specific status"), + + UNKNOWN(65535, "UNKNOWN"); + + private final int step; + + private final String msg; + + ExecutionStepEnum(int step, String msg) { + this.step = step; + this.msg = msg; + } + + @JsonValue + public int getStep() { + return step; + } + + public String getMsg() { + return msg; + } + + @JsonCreator + public static ExecutionStepEnum find(int step) { + return Arrays.stream(values()).filter(stepEnum -> stepEnum.step == step).findAny() + .orElseThrow(() -> new CloudSDKException(ExecutionStepEnum.class, step)); + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHActionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHActionEnum.java new file mode 100644 index 0000000..8c4498f --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHActionEnum.java @@ -0,0 +1,44 @@ +package com.dji.sdk.cloudapi.wayline; + +import com.dji.sdk.cloudapi.device.ExitWaylineWhenRcLostEnum; +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 + * @date 2023/6/6 + */ +public enum ExitingRTHActionEnum { + + EXIT(0, "Exit exiting RTH state"), + + Enter(1, "Enter exiting RTH state"); + + private final int action; + + private final String msg; + + ExitingRTHActionEnum(int action, String msg) { + this.action = action; + this.msg = msg; + } + + @JsonValue + public int getAction() { + return action; + } + + public String getMsg() { + return msg; + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ExitingRTHActionEnum find(int action) { + return Arrays.stream(values()).filter(actionEnum -> actionEnum.action == action).findAny() + .orElseThrow(() -> new CloudSDKException(ExitWaylineWhenRcLostEnum.class, action)); + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHReasonEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHReasonEnum.java new file mode 100644 index 0000000..0190d4e --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHReasonEnum.java @@ -0,0 +1,61 @@ +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 + * @date 2023/6/6 + */ +public enum ExitingRTHReasonEnum { + + ADD_JOYSTICK_THROTTLE(0, "Add joystick throttle"), + + ADD_JOYSTICK_PITCH(1, "Add joystick pitch"), + + INITIALIZATION_FAILED(2, "The initialization of behavior tree is failed"), + + SURROUNDED_BY_OBSTACLES(3, "Surrounded by obstacles"), + + FLIGHT_RESTRICTION(4, "Flight restriction is triggered"), + + OBSTACLE_IS_TOO_CLOSED(5, "Obstacle is too closed"), + + NO_GPS(6, "No GPS signal"), + + GPS_AND_VIO_ARE_FALSE(7, "The output flag of GPS and VIO location is false"), + + ERROR_OF_GPS_AND_VIO(8, "The error of GPS and VIO fusion position is too large"), + + SHORT_DISTANCE_BACKTRACKING(9, "Backtrack in a short distance"), + + TRIGGER_RTH(10, "Trigger the RTH in a short distanc"); + + private final int reason; + + private final String msg; + + ExitingRTHReasonEnum(int reason, String msg) { + this.reason = reason; + this.msg = msg; + } + + @JsonValue + public int getReason() { + return reason; + } + + public String getMsg() { + return msg; + } + + @JsonCreator + public static ExitingRTHReasonEnum find(int reason) { + return Arrays.stream(values()).filter(reasonEnum -> reasonEnum.reason == reason).findAny() + .orElseThrow(() -> new CloudSDKException(ExitingRTHReasonEnum.class, reason)); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakPoint.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakPoint.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakPoint.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakPoint.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakReasonEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakReasonEnum.java new file mode 100644 index 0000000..a57a1e7 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakReasonEnum.java @@ -0,0 +1,201 @@ +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 + * @date 2023/6/6 + */ +public enum FlighttaskBreakReasonEnum { + + 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; + } + + @JsonValue + public int getReason() { + return reason; + } + + 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)); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskCreateFile.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskCreateFile.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskCreateFile.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskCreateFile.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskCreateRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskCreateRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskCreateRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskCreateRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskExecuteRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskExecuteRequest.java new file mode 100644 index 0000000..5ef50d5 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskExecuteRequest.java @@ -0,0 +1,37 @@ +package com.dji.sdk.cloudapi.wayline; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +/** + * @author sean + * @version 1.1 + * @date 2022/6/1 + */ +public class FlighttaskExecuteRequest extends BaseModel { + + @NotNull + @Pattern(regexp = "^[^<>:\"/|?*._\\\\]+$") + private String flightId; + + public FlighttaskExecuteRequest() { + } + + @Override + public String toString() { + return "FlighttaskExecuteRequest{" + + "flightId='" + flightId + '\'' + + '}'; + } + + public String getFlightId() { + return flightId; + } + + public FlighttaskExecuteRequest setFlightId(String flightId) { + this.flightId = flightId; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskFile.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskFile.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskFile.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskFile.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskPrepareRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskPrepareRequest.java new file mode 100755 index 0000000..c1777f8 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskPrepareRequest.java @@ -0,0 +1,260 @@ +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.config.version.CloudSDKVersionEnum; +import com.dji.sdk.config.version.GatewayTypeEnum; + +import javax.validation.Valid; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/6 + */ +public class FlighttaskPrepareRequest extends BaseModel { + + /** + * Task ID + */ + @NotNull + @Pattern(regexp = "^[^<>:\"/|?*._\\\\]+$") + private String flightId; + + /** + * Time to execute + * Millisecond timestamp of task execution time. Optional field. + * When the `task_type` is 0 or 1, it is required. When the `task_type` is 2, it is not required. + */ + @Min(123456789012L) + private Long executeTime; + + /** + * Task type + * The execution time of immediate task and timed task are defined by `execute_time`. + * The conditional task supports the task readiness condition defined by `ready_conditions`. + * The task can be executed if conditions are satisfied within a specified period. + * Immediate task has the highest priority. Timed task and conditional task have the same priority. + */ + @NotNull + private TaskTypeEnum taskType; + + /** + * Wayline type + */ + @NotNull + private WaylineTypeEnum waylineType; + + /** + * Wayline file object + */ + @NotNull + @Valid + private FlighttaskFile file; + + /** + * Task readiness condition + */ + @Valid + private ReadyConditions readyConditions; + + /** + * Task executable condition + */ + @Valid + private ExecutableConditions executableConditions; + + /** + * Wayline breakpoint information + */ + @Valid + private FlighttaskBreakPoint breakPoint; + + /** + * Height for RTH + */ + @NotNull + @Min(20) + @Max(1500) + private Integer rthAltitude; + + /** + * Remote controller out of control action + * Out of control action: the current fixed transmitted value is 0, meaning Return-to-Home (RTH). + * Note that this enumeration value definition is inconsistent with the flight control and dock definitions, + * and a conversion exists at the dock end. + */ + @NotNull + private OutOfControlActionEnum outOfControlAction; + + /** + * wayline out of control action + * consistent with the KMZ file + */ + @NotNull + private ExitWaylineWhenRcLostEnum exitWaylineWhenRcLost; + + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + private RthModeEnum rthMode = RthModeEnum.PRESET_HEIGHT; + + @Valid + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + private SimulateMission simulateMission; + + @NotNull + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_1, include = GatewayTypeEnum.DOCK2) + private WaylinePrecisionTypeEnum waylinePrecisionType; + + public FlighttaskPrepareRequest() {} + + @Override + public String toString() { + return "FlighttaskPrepareRequest{" + + "flightId='" + flightId + '\'' + + ", executeTime=" + executeTime + + ", taskType=" + taskType + + ", waylineType=" + waylineType + + ", file=" + file + + ", readyConditions=" + readyConditions + + ", executableConditions=" + executableConditions + + ", breakPoint=" + breakPoint + + ", rthAltitude=" + rthAltitude + + ", outOfControlAction=" + outOfControlAction + + ", exitWaylineWhenRcLost=" + exitWaylineWhenRcLost + + ", rthMode=" + rthMode + + ", simulateMission=" + simulateMission + + ", waylinePrecisionType=" + waylinePrecisionType + + '}'; + } + + public String getFlightId() { + return flightId; + } + + public FlighttaskPrepareRequest setFlightId(String flightId) { + this.flightId = flightId; + return this; + } + + public Long getExecuteTime() { + return executeTime; + } + + public FlighttaskPrepareRequest setExecuteTime(Long executeTime) { + this.executeTime = executeTime; + return this; + } + + public TaskTypeEnum getTaskType() { + return taskType; + } + + public FlighttaskPrepareRequest setTaskType(TaskTypeEnum taskType) { + this.taskType = taskType; + return this; + } + + public WaylineTypeEnum getWaylineType() { + return waylineType; + } + + public FlighttaskPrepareRequest setWaylineType(WaylineTypeEnum waylineType) { + this.waylineType = waylineType; + return this; + } + + public FlighttaskFile getFile() { + return file; + } + + public FlighttaskPrepareRequest setFile(FlighttaskFile file) { + this.file = file; + return this; + } + + public ReadyConditions getReadyConditions() { + return readyConditions; + } + + public FlighttaskPrepareRequest setReadyConditions(ReadyConditions readyConditions) { + this.readyConditions = readyConditions; + return this; + } + + public ExecutableConditions getExecutableConditions() { + return executableConditions; + } + + public FlighttaskPrepareRequest setExecutableConditions(ExecutableConditions executableConditions) { + this.executableConditions = executableConditions; + return this; + } + + public FlighttaskBreakPoint getBreakPoint() { + return breakPoint; + } + + public FlighttaskPrepareRequest setBreakPoint(FlighttaskBreakPoint breakPoint) { + this.breakPoint = breakPoint; + return this; + } + + public Integer getRthAltitude() { + return rthAltitude; + } + + public FlighttaskPrepareRequest setRthAltitude(Integer rthAltitude) { + this.rthAltitude = rthAltitude; + return this; + } + + public OutOfControlActionEnum getOutOfControlAction() { + return outOfControlAction; + } + + public FlighttaskPrepareRequest setOutOfControlAction(OutOfControlActionEnum outOfControlAction) { + this.outOfControlAction = outOfControlAction; + return this; + } + + public ExitWaylineWhenRcLostEnum getExitWaylineWhenRcLost() { + return exitWaylineWhenRcLost; + } + + public FlighttaskPrepareRequest setExitWaylineWhenRcLost(ExitWaylineWhenRcLostEnum exitWaylineWhenRcLost) { + this.exitWaylineWhenRcLost = exitWaylineWhenRcLost; + return this; + } + + public RthModeEnum getRthMode() { + return rthMode; + } + + public FlighttaskPrepareRequest setRthMode(RthModeEnum rthMode) { + this.rthMode = rthMode; + return this; + } + + public SimulateMission getSimulateMission() { + return simulateMission; + } + + public FlighttaskPrepareRequest setSimulateMission(SimulateMission simulateMission) { + this.simulateMission = simulateMission; + return this; + } + + public WaylinePrecisionTypeEnum getWaylinePrecisionType() { + return waylinePrecisionType; + } + + public FlighttaskPrepareRequest setWaylinePrecisionType(WaylinePrecisionTypeEnum waylinePrecisionType) { + this.waylinePrecisionType = waylinePrecisionType; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgress.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgress.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgress.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgress.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressData.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressData.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressData.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressData.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressExt.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressExt.java new file mode 100644 index 0000000..fc2d8d0 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressExt.java @@ -0,0 +1,116 @@ +package com.dji.sdk.cloudapi.wayline; + +import com.dji.sdk.annotations.CloudSDKVersion; +import com.dji.sdk.config.version.CloudSDKVersionEnum; + +/** + * @author sean + * @version 1.1 + * @date 2022/6/9 + */ +public class FlighttaskProgressExt { + + private Integer currentWaypointIndex; + + private Integer mediaCount; + + private String flightId; + + private String trackId; + + private ProgressExtBreakPoint breakPoint; + + /** + * Wayline mission state + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + private WaylineMissionStateEnum waylineMissionState; + + /** + * This includes the transitional phase of entering the flight path. + * For example, 0 indicates that the spacecraft is entering or already executing the first route. + */ + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + private Integer waylineId; + + public FlighttaskProgressExt() { + } + + @Override + public String toString() { + return "FlighttaskProgressExt{" + + "currentWaypointIndex=" + currentWaypointIndex + + ", mediaCount=" + mediaCount + + ", flightId='" + flightId + '\'' + + ", trackId='" + trackId + '\'' + + ", breakPoint=" + breakPoint + + ", waylineMissionState=" + waylineMissionState + + ", waylineId=" + waylineId + + '}'; + } + + public Integer getCurrentWaypointIndex() { + return currentWaypointIndex; + } + + public FlighttaskProgressExt setCurrentWaypointIndex(Integer currentWaypointIndex) { + this.currentWaypointIndex = currentWaypointIndex; + return this; + } + + public Integer getMediaCount() { + return mediaCount; + } + + public FlighttaskProgressExt setMediaCount(Integer mediaCount) { + this.mediaCount = mediaCount; + return this; + } + + public String getFlightId() { + return flightId; + } + + public FlighttaskProgressExt setFlightId(String flightId) { + this.flightId = flightId; + return this; + } + + public String getTrackId() { + return trackId; + } + + public FlighttaskProgressExt setTrackId(String trackId) { + this.trackId = trackId; + return this; + } + + public ProgressExtBreakPoint getBreakPoint() { + return breakPoint; + } + + public FlighttaskProgressExt setBreakPoint(ProgressExtBreakPoint breakPoint) { + this.breakPoint = breakPoint; + return this; + } + + public WaylineMissionStateEnum getWaylineMissionState() { + return waylineMissionState; + } + + public FlighttaskProgressExt setWaylineMissionState(WaylineMissionStateEnum waylineMissionState) { + this.waylineMissionState = waylineMissionState; + return this; + } + + public Integer getWaylineId() { + return waylineId; + } + + public FlighttaskProgressExt setWaylineId(Integer waylineId) { + this.waylineId = waylineId; + return this; + } +} + + diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskReady.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskReady.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskReady.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskReady.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskResourceGetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskResourceGetRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskResourceGetRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskResourceGetRequest.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskResourceGetResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskResourceGetResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskResourceGetResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskResourceGetResponse.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskStatusEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskStatusEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskStatusEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskStatusEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskUndoRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskUndoRequest.java new file mode 100644 index 0000000..10b9a48 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskUndoRequest.java @@ -0,0 +1,39 @@ +package com.dji.sdk.cloudapi.wayline; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/7 + */ +public class FlighttaskUndoRequest extends BaseModel { + + @NotNull + @Size(min = 1) + private List<@Pattern(regexp = "^[^<>:\"/|?*._\\\\]+$") String> flightIds; + + public FlighttaskUndoRequest() { + } + + @Override + public String toString() { + return "FlighttaskUndoRequest{" + + "flightIds=" + flightIds + + '}'; + } + + public List getFlightIds() { + return flightIds; + } + + public FlighttaskUndoRequest setFlightIds(List flightIds) { + this.flightIds = flightIds; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListOrderBy.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListOrderBy.java new file mode 100644 index 0000000..e81d175 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListOrderBy.java @@ -0,0 +1,50 @@ +package com.dji.sdk.cloudapi.wayline; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/25 + */ +public class GetWaylineListOrderBy { + + @NotNull + private OrderByColumnEnum column; + + private boolean desc; + + @JsonCreator + public GetWaylineListOrderBy(String orderBy) { + String[] arr = orderBy.split(" "); + this.column = OrderByColumnEnum.find(arr[0]); + this.desc = arr.length > 1 && arr[1].contains("desc"); + } + + @Override + @JsonValue + public String toString() { + return column.getColumn() + (desc ? " desc" : " asc"); + } + + public OrderByColumnEnum getColumn() { + return column; + } + + public GetWaylineListOrderBy setColumn(OrderByColumnEnum column) { + this.column = column; + return this; + } + + public boolean isDesc() { + return desc; + } + + public GetWaylineListOrderBy setDesc(boolean desc) { + this.desc = desc; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListRequest.java new file mode 100644 index 0000000..5b28c32 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListRequest.java @@ -0,0 +1,188 @@ +package com.dji.sdk.cloudapi.wayline; + +import com.dji.sdk.cloudapi.device.DeviceEnum; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.Valid; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/6/8 + */ +@Schema(description = "Query parameter to get list of wayline files") +public class GetWaylineListRequest { + + /** + * Is the wayline file favorited? + */ + @Parameter(name = "favorited", description = "Is the wayline file favorited?") + private Boolean favorited; + + /** + * order(xxx_column desc or xxx_column asc) + * Pilot2 optional value: nameupdate_timecreate_time + */ + @NotNull + @JsonProperty("order_by") + @Parameter(name = "order_by", description = "sort field name", example = "update_time desc", + schema = @Schema(allowableValues = {"name desc", "name asc", "update_time desc", "update_time asc", "create_time desc", "create_time asc"})) + @Valid + private GetWaylineListOrderBy orderBy; + + /** + * current page + */ + @Min(1) + @Parameter(name = "page", description = "current page", schema = @Schema(defaultValue = "1", type = "int")) + private int page = 1; + + /** + * page size + */ + @Min(1) + @JsonProperty("page_size") + @Parameter(name = "page_size", description = "page size", schema = @Schema(defaultValue = "10", type = "int")) + private int pageSize = 10; + + /** + * wayline template type collection + */ + @Size(min = 1) + @JsonProperty("template_type") + @Parameter(name = "template_type", description = "wayline template type collection", example = "[0]") + private List templateType; + + /** + * 1: Enable AI Spot-Check wayline. Without this field means all waylines. + */ + @JsonProperty("action_type") + @Parameter(name = "action_type", description = "wayline template type collection", example = "1") + private ActionTypeEnum actionType; + + /** + * Selected aircraft models + */ + @JsonProperty("drone_model_keys") + @Schema(name = "drone_model_keys", description = "drone device product enum", example = "[\"0-67-0\"]") + private List droneModelKeys; + + /** + * Selected payload models + */ + @JsonProperty("payload_model_key") + @Schema(name = "payload_model_key", description = "payload device product enum", example = "[\"1-53-0\"]") + private List payloadModelKey; + + /** + * Filter by wayline name + */ + @JsonProperty("key") + @Schema(name = "key", description = "wayline file name", example = "waypoint") + private String key; + + public GetWaylineListRequest() { + } + + @Override + public String toString() { + return "GetWaylineListRequest{" + + "favorited=" + favorited + + ", orderBy='" + orderBy + '\'' + + ", page=" + page + + ", pageSize=" + pageSize + + ", templateType=" + templateType + + ", actionType=" + actionType + + ", droneModelKeys=" + droneModelKeys + + ", payloadModelKey=" + payloadModelKey + + ", key='" + key + '\'' + + '}'; + } + + public Boolean getFavorited() { + return favorited; + } + + public GetWaylineListRequest setFavorited(Boolean favorited) { + this.favorited = favorited; + return this; + } + + public GetWaylineListOrderBy getOrderBy() { + return orderBy; + } + + public GetWaylineListRequest setOrderBy(GetWaylineListOrderBy orderBy) { + this.orderBy = orderBy; + return this; + } + + public int getPage() { + return page; + } + + public GetWaylineListRequest setPage(int page) { + this.page = page; + return this; + } + + public int getPageSize() { + return pageSize; + } + + public GetWaylineListRequest setPageSize(int pageSize) { + this.pageSize = pageSize; + return this; + } + + public List getTemplateType() { + return templateType; + } + + public GetWaylineListRequest setTemplateType(List templateType) { + this.templateType = templateType; + return this; + } + + public ActionTypeEnum getActionType() { + return actionType; + } + + public GetWaylineListRequest setActionType(ActionTypeEnum actionType) { + this.actionType = actionType; + return this; + } + + public List getDroneModelKeys() { + return droneModelKeys; + } + + public GetWaylineListRequest setDroneModelKeys(List droneModelKeys) { + this.droneModelKeys = droneModelKeys; + return this; + } + + public List getPayloadModelKey() { + return payloadModelKey; + } + + public GetWaylineListRequest setPayloadModelKey(List payloadModelKey) { + this.payloadModelKey = payloadModelKey; + return this; + } + + public String getKey() { + return key; + } + + public GetWaylineListRequest setKey(String key) { + this.key = key; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListResponse.java new file mode 100644 index 0000000..69b7400 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListResponse.java @@ -0,0 +1,237 @@ +package com.dji.sdk.cloudapi.wayline; + +import com.dji.sdk.cloudapi.device.DeviceEnum; +import com.dji.sdk.common.BaseModel; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 0.3 + * @date 2021/12/22 + */ +@Schema(description = "The data of the wayline file.") +public class GetWaylineListResponse extends BaseModel { + + /** + * wayline file name + */ + @NotNull + @Schema(description = "wayline file name", example = "waylineFile") + @Pattern(regexp = "^[^<>:\"/|?*._\\\\]+$") + private String name; + + /** + * wayline file id + */ + @NotNull + @Pattern(regexp = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") + @Schema(description = "wayline file id", format = "uuid") + private String id; + + /** + * drone device product enum + */ + @NotNull + @JsonProperty("drone_model_key") + @Schema(description = "drone device product enum", example = "0-67-0") + private DeviceEnum droneModelKey; + + private String sign; + + /** + * payload device product enum + */ + @NotNull + @Size(min = 1) + @JsonProperty("payload_model_keys") + @Schema(description = "payload device product enum", example = "[\"1-53-0\"]") + private List payloadModelKeys; + + /** + * Is the wayline file favorited? + */ + @NotNull + @Schema(description = "Is the wayline file favorited?") + private Boolean favorited; + + /** + * wayline template collection + */ + @NotNull + @Size(min = 1) + @Schema(description = "wayline template collection", example = "[0]") + @JsonProperty("template_types") + private List templateTypes; + + @NotNull + @Schema(description = "The key of the object in the bucket", example = "wayline/waylineFile.kmz") + @JsonProperty("object_key") + private String objectKey; + + /** + * uploader + */ + @NotNull + @JsonProperty("user_name") + @Schema(description = "uploader's username", example = "admin") + private String username; + + /** + * update time (millisecond) + */ + @NotNull + @Min(123456789012L) + @Schema(description = "update time (millisecond). The field named `update time` must exist in the table.", example = "123456789012") + @JsonProperty("update_time") + private Long updateTime; + + /** + * create time (millisecond) + */ + @NotNull + @Min(123456789012L) + @Schema(description = "create time (millisecond). The field named `create time` must exist in the table.", example = "123456789012") + @JsonProperty("create_time") + private Long createTime; + + @JsonProperty("action_type") + @Parameter(name = "action_type", description = "wayline template type collection", example = "1") + private ActionTypeEnum actionType; + + public GetWaylineListResponse() { + } + + @Override + public String toString() { + return "GetWaylineListResponse{" + + "name='" + name + '\'' + + ", id='" + id + '\'' + + ", droneModelKey=" + droneModelKey + + ", sign='" + sign + '\'' + + ", payloadModelKeys=" + payloadModelKeys + + ", favorited=" + favorited + + ", templateTypes=" + templateTypes + + ", objectKey='" + objectKey + '\'' + + ", username='" + username + '\'' + + ", updateTime=" + updateTime + + ", createTime=" + createTime + + ", actionType=" + actionType + + '}'; + } + + public String getName() { + return name; + } + + public GetWaylineListResponse setName(String name) { + this.name = name; + return this; + } + + public String getId() { + return id; + } + + public GetWaylineListResponse setId(String id) { + this.id = id; + return this; + } + + public DeviceEnum getDroneModelKey() { + return droneModelKey; + } + + public GetWaylineListResponse setDroneModelKey(DeviceEnum droneModelKey) { + this.droneModelKey = droneModelKey; + return this; + } + + public String getSign() { + return sign; + } + + public GetWaylineListResponse setSign(String sign) { + this.sign = sign; + return this; + } + + public List getPayloadModelKeys() { + return payloadModelKeys; + } + + public GetWaylineListResponse setPayloadModelKeys(List payloadModelKeys) { + this.payloadModelKeys = payloadModelKeys; + return this; + } + + public Boolean getFavorited() { + return favorited; + } + + public GetWaylineListResponse setFavorited(Boolean favorited) { + this.favorited = favorited; + return this; + } + + public List getTemplateTypes() { + return templateTypes; + } + + public GetWaylineListResponse setTemplateTypes(List templateTypes) { + this.templateTypes = templateTypes; + return this; + } + + public String getObjectKey() { + return objectKey; + } + + public GetWaylineListResponse setObjectKey(String objectKey) { + this.objectKey = objectKey; + return this; + } + + public String getUsername() { + return username; + } + + public GetWaylineListResponse setUsername(String username) { + this.username = username; + return this; + } + + public Long getUpdateTime() { + return updateTime; + } + + public GetWaylineListResponse setUpdateTime(Long updateTime) { + this.updateTime = updateTime; + return this; + } + + public Long getCreateTime() { + return createTime; + } + + public GetWaylineListResponse setCreateTime(Long createTime) { + this.createTime = createTime; + return this; + } + + public ActionTypeEnum getActionType() { + return actionType; + } + + public GetWaylineListResponse setActionType(ActionTypeEnum actionType) { + this.actionType = actionType; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/LastPointTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/LastPointTypeEnum.java new file mode 100644 index 0000000..5adff91 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/LastPointTypeEnum.java @@ -0,0 +1,39 @@ +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 + * @date 2023/10/11 + */ +public enum LastPointTypeEnum { + + OVER_THE_HOME_POINT(0), + + NOT_OVER_THE_HOME_POINT(1), + + ; + + private final int type; + + LastPointTypeEnum(int type) { + this.type = type; + } + + @JsonValue + public int getType() { + return type; + } + + @JsonCreator + public static LastPointTypeEnum find(int type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny() + .orElseThrow(() -> new CloudSDKException(LastPointTypeEnum.class, type)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/OrderByColumnEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/OrderByColumnEnum.java new file mode 100644 index 0000000..befbd88 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/OrderByColumnEnum.java @@ -0,0 +1,40 @@ +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 + * @date 2023/10/25 + */ +public enum OrderByColumnEnum { + + NAME("name"), + + UPDATE_TIME("update_time"), + + CREATE_TIME("create_time"), + + ; + + private final String column; + + OrderByColumnEnum(String column) { + this.column = column; + } + + @JsonValue + public String getColumn() { + return column; + } + + @JsonCreator + public static OrderByColumnEnum find(String column) { + return Arrays.stream(values()).filter(columnEnum -> columnEnum.column.equals(column)).findAny() + .orElseThrow(() -> new CloudSDKException(OrderByColumnEnum.class, column)); + } +} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/OutOfControlActionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/OutOfControlActionEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/OutOfControlActionEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/OutOfControlActionEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/ProgressExtBreakPoint.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ProgressExtBreakPoint.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/ProgressExtBreakPoint.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ProgressExtBreakPoint.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ReadyConditions.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ReadyConditions.java new file mode 100755 index 0000000..ea0288e --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ReadyConditions.java @@ -0,0 +1,77 @@ +package com.dji.sdk.cloudapi.wayline; + +import com.dji.sdk.common.BaseModel; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.7 + * @date 2023/5/23 + */ +public class ReadyConditions extends BaseModel { + + /** + * Battery capacity + * The aircraft battery percentage threshold of the executable task. + * The aircraft battery must be greater than the `battery_capacity` when the task starts. + */ + @NotNull + @Min(0) + @Max(100) + private Integer batteryCapacity; + + /** + * Start time of the task executable period + * Start millisecond timestamp of the task executable period. The task execution time should be later than the `begin_time`. + */ + @NotNull + private Long beginTime; + + /** + * End time of the task executable period + * End millisecond timestamp of the task executable period. The task execution time should be earlier than the `end_time`. + */ + @NotNull + private Long endTime; + + public ReadyConditions() {} + + @Override + public String toString() { + return "ReadyConditions{" + + "batteryCapacity=" + batteryCapacity + + ", beginTime=" + beginTime + + ", endTime=" + endTime + + '}'; + } + + public Integer getBatteryCapacity() { + return batteryCapacity; + } + + public ReadyConditions setBatteryCapacity(Integer batteryCapacity) { + this.batteryCapacity = batteryCapacity; + return this; + } + + public Long getBeginTime() { + return beginTime; + } + + public ReadyConditions setBeginTime(Long beginTime) { + this.beginTime = beginTime; + return this; + } + + public Long getEndTime() { + return endTime; + } + + public ReadyConditions setEndTime(Long endTime) { + this.endTime = endTime; + return this; + } +} \ No newline at end of file diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ReturnHomeInfo.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ReturnHomeInfo.java new file mode 100644 index 0000000..8b908a5 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/ReturnHomeInfo.java @@ -0,0 +1,74 @@ +package com.dji.sdk.cloudapi.wayline; + +import com.dji.sdk.cloudapi.control.Point; + +import java.util.List; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/11 + */ +public class ReturnHomeInfo { + + /** + * The real-time planned return route for the aircraft. + * Each push is a complete update of the route. + * There is an complete return path in the array. + */ + private List plannedPathPoints; + + /** + * You can use this field to determine the display mode of the last point in the trajectory. + * 0 means the last point of the trajectory is located above the return point on the ground. + * The terminal can display a line connecting the last point of the trajectory to the return point. + * 1 means the last point of the trajectory is not the return point. + * The terminal should not display a line connecting the last point of the trajectory to the return point. + * The reason for not being able to reach the return point could be that the return point is in a restricted zones or inside an obstacle. + */ + private LastPointTypeEnum lastPointType; + + /** + * Currently working wayline mission ID + */ + private String flightId; + + public ReturnHomeInfo() { + } + + @Override + public String toString() { + return "ReturnHomeInfo{" + + "plannedPathPoints=" + plannedPathPoints + + ", lastPointType=" + lastPointType + + ", flightId='" + flightId + '\'' + + '}'; + } + + public List getPlannedPathPoints() { + return plannedPathPoints; + } + + public ReturnHomeInfo setPlannedPathPoints(List plannedPathPoints) { + this.plannedPathPoints = plannedPathPoints; + return this; + } + + public LastPointTypeEnum getLastPointType() { + return lastPointType; + } + + public ReturnHomeInfo setLastPointType(LastPointTypeEnum lastPointType) { + this.lastPointType = lastPointType; + return this; + } + + public String getFlightId() { + return flightId; + } + + public ReturnHomeInfo setFlightId(String flightId) { + this.flightId = flightId; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/RthModeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/RthModeEnum.java new file mode 100644 index 0000000..55bf935 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/RthModeEnum.java @@ -0,0 +1,37 @@ +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 + * @date 2023/8/4 + */ +public enum RthModeEnum { + + OPTIMAL_HEIGHT(0), + + PRESET_HEIGHT(1); + + private final int rthMode; + + RthModeEnum(int rthMode) { + this.rthMode = rthMode; + } + + @JsonValue + public int getRthMode() { + return rthMode; + } + + @JsonCreator + public static RthModeEnum find(int rthMode) { + return Arrays.stream(values()).filter(rthModeEnum -> rthModeEnum.rthMode == rthMode).findAny() + .orElseThrow(() -> new CloudSDKException(RthModeEnum.class, rthMode)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/SimulateMission.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/SimulateMission.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/SimulateMission.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/SimulateMission.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/SimulateSwitchEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/SimulateSwitchEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/SimulateSwitchEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/SimulateSwitchEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/TaskTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/TaskTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/TaskTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/TaskTypeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineErrorCodeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineErrorCodeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/WaylineErrorCodeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineErrorCodeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/WaylineMethodEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineMethodEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineMissionStateEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineMissionStateEnum.java new file mode 100644 index 0000000..dd06b34 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineMissionStateEnum.java @@ -0,0 +1,62 @@ +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 + * @date 2023/10/11 + */ +public enum WaylineMissionStateEnum { + + DISCONNECT(0, "Disconnect"), + + NOT_SUPPORTED_WAYPOINT(1, "Do not support this waypoint"), + + WAYLINE_PREPARING(2, "Wayline is ready. File can be uploaded and uploaded file can be executed."), + + WAYLINE_UPLOADING(3, "Wayline file is uploading"), + + DRONE_PREPARING(4, "Trigger start command. Trgger aircraft reading wayline. Not start. Under preparation."), + + ARRIVE_FIRST_WAYPOINT(5, "Enter wayline and arrive first waypoint"), + + WAYLINE_EXECUTING(6, "Execute wayline"), + + WAYLINE_BROKEN(7, "Wayline is broken. Trigger reason: 1. User pauses the wayline. 2. Flight control is abnormal."), + + WAYLINE_RECOVER(8, "Wayline recover"), + + WAYLINE_END(9, "Wayline stop"), + + ; + + private final int state; + + private final String msg; + + WaylineMissionStateEnum(int state, String msg) { + this.state = state; + this.msg = msg; + } + + @JsonValue + public int getState() { + return state; + } + + public String getMsg() { + return msg; + } + + @JsonCreator + public static WaylineMissionStateEnum find(int state) { + return Arrays.stream(values()).filter(stateEnum -> stateEnum.state == state).findAny() + .orElseThrow(() -> new CloudSDKException(WaylineMissionStateEnum.class, state)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylinePrecisionTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylinePrecisionTypeEnum.java new file mode 100644 index 0000000..62aca23 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylinePrecisionTypeEnum.java @@ -0,0 +1,38 @@ +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 + * @date 2023/10/19 + */ +public enum WaylinePrecisionTypeEnum { + + GPS(0), + + RTK(1), + ; + + private final int type; + + WaylinePrecisionTypeEnum(int type) { + this.type = type; + } + + @JsonValue + public int getType() { + return type; + } + + @JsonCreator + public static WaylinePrecisionTypeEnum find(int type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny() + .orElseThrow(() -> new CloudSDKException(WaylinePrecisionTypeEnum.class, type)); + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/WaylineTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineTypeEnum.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineUploadCallbackMetadata.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineUploadCallbackMetadata.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/WaylineUploadCallbackMetadata.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineUploadCallbackMetadata.java diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineUploadCallbackRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineUploadCallbackRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/WaylineUploadCallbackRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/WaylineUploadCallbackRequest.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/api/AbstractWaylineService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/api/AbstractWaylineService.java new file mode 100644 index 0000000..783ef39 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/api/AbstractWaylineService.java @@ -0,0 +1,206 @@ +package com.dji.sdk.cloudapi.wayline.api; + +import com.dji.sdk.annotations.CloudSDKVersion; +import com.dji.sdk.cloudapi.wayline.*; +import com.dji.sdk.config.version.CloudSDKVersionEnum; +import com.dji.sdk.common.Common; +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; +import com.dji.sdk.mqtt.MqttReply; +import com.dji.sdk.mqtt.events.EventsDataRequest; +import com.dji.sdk.mqtt.events.TopicEventsRequest; +import com.dji.sdk.mqtt.events.TopicEventsResponse; +import com.dji.sdk.mqtt.requests.TopicRequestsRequest; +import com.dji.sdk.mqtt.requests.TopicRequestsResponse; +import com.dji.sdk.mqtt.services.ServicesPublish; +import com.dji.sdk.mqtt.services.ServicesReplyData; +import com.dji.sdk.mqtt.services.TopicServicesResponse; +import org.springframework.integration.annotation.ServiceActivator; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageHeaders; + +import javax.annotation.Resource; + +/** + * @author sean + * @version 1.7 + * @date 2023/5/19 + */ +public abstract class AbstractWaylineService { + + @Resource + private ServicesPublish servicesPublish; + + /** + * Notification of device exits the Return to Home (RTH) state + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_DEVICE_EXIT_HOMING_NOTIFY, outputChannel = ChannelName.OUTBOUND_EVENTS) + public TopicEventsResponse deviceExitHomingNotify(TopicEventsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("deviceExitHomingNotify not implemented"); + } + + /** + * Report wayline task progress + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_FLIGHTTASK_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS) + public TopicEventsResponse flighttaskProgress(TopicEventsRequest> request, MessageHeaders headers) { + throw new UnsupportedOperationException("flighttaskProgress not implemented"); + } + + /** + * Notification of task readiness + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_FLIGHTTASK_READY, outputChannel = ChannelName.OUTBOUND_EVENTS) + public TopicEventsResponse flighttaskReady(TopicEventsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("flighttaskReady not implemented"); + } + + /** + * Create wayline task (Deprecated) + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(deprecated = CloudSDKVersionEnum.V0_0_1, exclude = GatewayTypeEnum.RC) + public TopicServicesResponse flighttaskCreate(GatewayManager gateway, FlighttaskCreateRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + WaylineMethodEnum.FLIGHTTASK_CREATE.getMethod(), + request); + } + + /** + * Issue wayline task + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse flighttaskPrepare(GatewayManager gateway, FlighttaskPrepareRequest request) { + validPrepareParam(request); + return servicesPublish.publish( + gateway.getGatewaySn(), + WaylineMethodEnum.FLIGHTTASK_PREPARE.getMethod(), + request, + request.getFlightId()); + } + + /** + * Execute wayline task + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse flighttaskExecute(GatewayManager gateway, FlighttaskExecuteRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + WaylineMethodEnum.FLIGHTTASK_EXECUTE.getMethod(), + request, + request.getFlightId()); + } + + /** + * Cancel wayline task + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse flighttaskUndo(GatewayManager gateway, FlighttaskUndoRequest request) { + return servicesPublish.publish( + gateway.getGatewaySn(), + WaylineMethodEnum.FLIGHTTASK_UNDO.getMethod(), + request); + } + + /** + * Pause wayline task + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse flighttaskPause(GatewayManager gateway) { + return servicesPublish.publish( + gateway.getGatewaySn(), + WaylineMethodEnum.FLIGHTTASK_PAUSE.getMethod()); + } + + /** + * Resume wayline task + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse flighttaskRecovery(GatewayManager gateway) { + return servicesPublish.publish( + gateway.getGatewaySn(), + WaylineMethodEnum.FLIGHTTASK_RECOVERY.getMethod()); + } + + /** + * Return to Home (RTH) + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse returnHome(GatewayManager gateway) { + return servicesPublish.publish( + gateway.getGatewaySn(), + WaylineMethodEnum.RETURN_HOME.getMethod()); + } + + /** + * Cancel return to home + * @param gateway + * @return services_reply + */ + @CloudSDKVersion(exclude = GatewayTypeEnum.RC) + public TopicServicesResponse returnHomeCancel(GatewayManager gateway) { + return servicesPublish.publish( + gateway.getGatewaySn(), + WaylineMethodEnum.RETURN_HOME_CANCEL.getMethod()); + } + + /** + * Get the wayline task resource + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_REQUESTS_FLIGHTTASK_RESOURCE_GET, outputChannel = ChannelName.OUTBOUND_REQUESTS) + public TopicRequestsResponse> flighttaskResourceGet(TopicRequestsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("flighttaskResourceGet not implemented"); + } + + /** + * Return-to-home information + * @param request data + * @param headers The headers for a {@link Message}. + * @return events_reply + */ + @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_RETURN_HOME_INFO, outputChannel = ChannelName.OUTBOUND_EVENTS) + @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) + public TopicRequestsResponse returnHomeInfo(TopicRequestsRequest request, MessageHeaders headers) { + throw new UnsupportedOperationException("returnHomeInfo not implemented"); + } + + private void validPrepareParam(FlighttaskPrepareRequest request) { + if (null == request.getExecuteTime() + && (TaskTypeEnum.IMMEDIATE == request.getTaskType() || TaskTypeEnum.TIMED == request.getTaskType())) { + throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER, "Execute time must not be null."); + } + if (TaskTypeEnum.CONDITIONAL == request.getTaskType()) { + Common.validateModel(request.getReadyConditions()); + } + } + +} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/api/IHttpWaylineService.java b/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/api/IHttpWaylineService.java similarity index 100% rename from src/main/java/com/dji/sdk/cloudapi/wayline/api/IHttpWaylineService.java rename to cloud-sdk/src/main/java/com/dji/sdk/cloudapi/wayline/api/IHttpWaylineService.java diff --git a/src/main/java/com/dji/sdk/common/BaseModel.java b/cloud-sdk/src/main/java/com/dji/sdk/common/BaseModel.java similarity index 100% rename from src/main/java/com/dji/sdk/common/BaseModel.java rename to cloud-sdk/src/main/java/com/dji/sdk/common/BaseModel.java diff --git a/src/main/java/com/dji/sdk/common/Common.java b/cloud-sdk/src/main/java/com/dji/sdk/common/Common.java similarity index 100% rename from src/main/java/com/dji/sdk/common/Common.java rename to cloud-sdk/src/main/java/com/dji/sdk/common/Common.java diff --git a/src/main/java/com/dji/sdk/common/CommonErrorEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/common/CommonErrorEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/common/CommonErrorEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/common/CommonErrorEnum.java diff --git a/src/main/java/com/dji/sdk/common/ErrorCodeSourceEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/common/ErrorCodeSourceEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/common/ErrorCodeSourceEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/common/ErrorCodeSourceEnum.java diff --git a/src/main/java/com/dji/sdk/common/HttpResultResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/common/HttpResultResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/common/HttpResultResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/common/HttpResultResponse.java diff --git a/src/main/java/com/dji/sdk/common/IErrorInfo.java b/cloud-sdk/src/main/java/com/dji/sdk/common/IErrorInfo.java similarity index 100% rename from src/main/java/com/dji/sdk/common/IErrorInfo.java rename to cloud-sdk/src/main/java/com/dji/sdk/common/IErrorInfo.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/common/Pagination.java b/cloud-sdk/src/main/java/com/dji/sdk/common/Pagination.java new file mode 100644 index 0000000..9ee142e --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/common/Pagination.java @@ -0,0 +1,79 @@ +package com.dji.sdk.common; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Used for paging display. These field names cannot be changed. + * Because they need to be the same as the pilot. + * @author sean + * @version 0.3 + * @date 2021/12/22 + */ +@Schema(description = "Used for paging display") +public class Pagination { + + /** + * The current page number. + */ + @Schema(description = "The current page number.", example = "1") + private long page; + + /** + * The amount of data displayed per page. + */ + @Schema(description = "The amount of data displayed per page.", example = "10") + @JsonProperty("page_size") + private long pageSize; + + /** + * The total amount of all data. + */ + @Schema(description = "The total amount of all data.", example = "10") + private long total; + + public Pagination() { + } + + public Pagination(long page, long pageSize, long total) { + this.page = page; + this.pageSize = pageSize; + this.total = total; + } + + @Override + public String toString() { + return "Pagination{" + + "page=" + page + + ", pageSize=" + pageSize + + ", total=" + total + + '}'; + } + + public long getPage() { + return page; + } + + public Pagination setPage(long page) { + this.page = page; + return this; + } + + public long getPageSize() { + return pageSize; + } + + public Pagination setPageSize(long pageSize) { + this.pageSize = pageSize; + return this; + } + + public long getTotal() { + return total; + } + + public Pagination setTotal(long total) { + this.total = total; + return this; + } +} diff --git a/src/main/java/com/dji/sdk/common/PaginationData.java b/cloud-sdk/src/main/java/com/dji/sdk/common/PaginationData.java similarity index 100% rename from src/main/java/com/dji/sdk/common/PaginationData.java rename to cloud-sdk/src/main/java/com/dji/sdk/common/PaginationData.java diff --git a/src/main/java/com/dji/sdk/common/SDKManager.java b/cloud-sdk/src/main/java/com/dji/sdk/common/SDKManager.java similarity index 100% rename from src/main/java/com/dji/sdk/common/SDKManager.java rename to cloud-sdk/src/main/java/com/dji/sdk/common/SDKManager.java diff --git a/src/main/java/com/dji/sdk/common/SpringBeanUtils.java b/cloud-sdk/src/main/java/com/dji/sdk/common/SpringBeanUtils.java similarity index 100% rename from src/main/java/com/dji/sdk/common/SpringBeanUtils.java rename to cloud-sdk/src/main/java/com/dji/sdk/common/SpringBeanUtils.java diff --git a/src/main/java/com/dji/sdk/config/CloudSDKHandler.java b/cloud-sdk/src/main/java/com/dji/sdk/config/CloudSDKHandler.java similarity index 100% rename from src/main/java/com/dji/sdk/config/CloudSDKHandler.java rename to cloud-sdk/src/main/java/com/dji/sdk/config/CloudSDKHandler.java diff --git a/src/main/java/com/dji/sdk/config/CloudSDKMvcConfigurer.java b/cloud-sdk/src/main/java/com/dji/sdk/config/CloudSDKMvcConfigurer.java similarity index 100% rename from src/main/java/com/dji/sdk/config/CloudSDKMvcConfigurer.java rename to cloud-sdk/src/main/java/com/dji/sdk/config/CloudSDKMvcConfigurer.java diff --git a/src/main/java/com/dji/sdk/config/GetSnakeArgumentProcessor.java b/cloud-sdk/src/main/java/com/dji/sdk/config/GetSnakeArgumentProcessor.java similarity index 100% rename from src/main/java/com/dji/sdk/config/GetSnakeArgumentProcessor.java rename to cloud-sdk/src/main/java/com/dji/sdk/config/GetSnakeArgumentProcessor.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/config/GetSnakeDataBinder.java b/cloud-sdk/src/main/java/com/dji/sdk/config/GetSnakeDataBinder.java new file mode 100644 index 0000000..6f08395 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/config/GetSnakeDataBinder.java @@ -0,0 +1,109 @@ +package com.dji.sdk.config; + +import com.dji.sdk.common.Common; +import com.dji.sdk.exception.CloudSDKException; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.springframework.beans.MutablePropertyValues; +import org.springframework.beans.PropertyValue; +import org.springframework.web.servlet.mvc.method.annotation.ExtendedServletRequestDataBinder; + +import javax.servlet.ServletRequest; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author sean + * @version 1.2 + * @date 2022/9/9 + */ +public class GetSnakeDataBinder extends ExtendedServletRequestDataBinder { + + public GetSnakeDataBinder(Object target, String objectName) { + super(target, objectName); + } + + @Override + protected void addBindValues(MutablePropertyValues mpvs, ServletRequest request) { + List propertyValueList = mpvs.getPropertyValueList(); + List values = new ArrayList<>(propertyValueList); + Field[] fields = this.getTarget().getClass().getDeclaredFields(); + Map fieldMap = Arrays.stream(fields).collect(Collectors.toMap(Field::getName, field -> field)); + fieldMap.putAll(Arrays.stream(fields).filter(field -> null != field.getAnnotation(JsonProperty.class)) + .collect(Collectors.toMap(field -> field.getAnnotation(JsonProperty.class).value(), field -> field))); + + for (PropertyValue property : values) { + if (!fieldMap.containsKey(property.getName())) { + continue; + } + + Field field = fieldMap.get(property.getName()); + List list = (List) Objects.requireNonNullElse(property.getConvertedValue(), new ArrayList<>()); + list.addAll((List) convertValue(field, this.getTarget(), property.getValue())); + property.setConvertedValue(list); + + String fieldName = field.getName(); + if (mpvs.contains(fieldName)) { + PropertyValue propertyValue = mpvs.getPropertyValue(fieldName); + if (propertyValue != property && null != propertyValue.getConvertedValue()) { + ((List) propertyValue.getConvertedValue()).addAll((List) property.getConvertedValue()); + property = propertyValue; + } + } + Object data = Collection.class.isAssignableFrom(field.getType()) ? property.getConvertedValue() : ((List) property.getConvertedValue()).get(0); + mpvs.addPropertyValue(new PropertyValue(fieldName, Objects.requireNonNullElse(data, property.getValue()))); + } + + super.addBindValues(mpvs, request); + } + + private Object convertValue(Field field, Object object, Object value) { + List convertedValue = new ArrayList(); + if (Enum.class.isAssignableFrom(field.getType())) { + convertedValue.add(getRealEnumValue(field.getType(), object, value)); + return convertedValue; + } + if (field.getType() == field.getGenericType()) { + convertedValue.add(value); + return convertedValue; + } + if (Collection.class.isAssignableFrom(field.getType())) { + if (!value.getClass().isArray()) { + value = String.valueOf(value).split(","); + } + for (String v : (String[]) value) { + if ("".equals(v)) { + continue; + } + convertedValue.add(getRealEnumValue((Class) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0], object, v)); + } + } + + return convertedValue; + } + + private Object getRealEnumValue(Class type, Object object, Object... value) { + if (!type.isEnum()) { + return value; + } + Set methods = Arrays.stream(type.getDeclaredMethods()) + .filter(m -> null != m.getAnnotation(JsonCreator.class)) + .filter(m -> m.getParameterTypes().length == value.length).collect(Collectors.toSet()); + for (Method m : methods) { + try { + Class[] parameterTypes = m.getParameterTypes(); + for (int i = 0; i < value.length; i++) { + value[i] = Common.getObjectMapper().convertValue(value[i], parameterTypes[i]); + } + return m.invoke(object, value); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new CloudSDKException(e); + } + } + return value; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/config/version/CloudSDKVersionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/config/version/CloudSDKVersionEnum.java new file mode 100644 index 0000000..52a20b0 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/config/version/CloudSDKVersionEnum.java @@ -0,0 +1,39 @@ +package com.dji.sdk.config.version; + +/** + * @author sean + * @version 1.7 + * @date 2023/5/22 + */ +public enum CloudSDKVersionEnum { + + V0_0_1("0.0.1"), + + V1_0_0("1.0.0"), + + V1_0_1("1.0.1"), + + V1_0_2("1.0.2"), + + DEFAULT("1.0.2"), + + V99("99"); + + private final String version; + + CloudSDKVersionEnum(String version) { + this.version = version; + } + + public String getVersion() { + return version; + } + + public boolean isSupported(CloudSDKVersionEnum version) { + return this.version.compareTo(version.getVersion()) >= 0; + } + + public boolean isDeprecated(CloudSDKVersionEnum version) { + return this.version.compareTo(version.getVersion()) >= 0; + } +} diff --git a/src/main/java/com/dji/sdk/config/version/Dock2ThingVersionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/config/version/Dock2ThingVersionEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/config/version/Dock2ThingVersionEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/config/version/Dock2ThingVersionEnum.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/config/version/DockThingVersionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/config/version/DockThingVersionEnum.java new file mode 100644 index 0000000..47ee21a --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/config/version/DockThingVersionEnum.java @@ -0,0 +1,47 @@ +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/5/19 + */ +public enum DockThingVersionEnum implements IThingVersion { + + V1_0_0("1.0.0", CloudSDKVersionEnum.V0_0_1), + + V1_1_0("1.1.0", CloudSDKVersionEnum.V0_0_1), + + V1_1_2("1.1.2", CloudSDKVersionEnum.V1_0_0), + + V1_1_3("1.1.3", CloudSDKVersionEnum.V1_0_2), + + ; + + private final String thingVersion; + + private final CloudSDKVersionEnum cloudSDKVersion; + + DockThingVersionEnum(String thingVersion, CloudSDKVersionEnum cloudSDKVersion) { + this.thingVersion = thingVersion; + this.cloudSDKVersion = cloudSDKVersion; + } + + @JsonValue + public String getThingVersion() { + return thingVersion; + } + + public CloudSDKVersionEnum getCloudSDKVersion() { + return cloudSDKVersion; + } + + public static DockThingVersionEnum find(String thingVersion) { + return Arrays.stream(values()).filter(thingVersionEnum -> thingVersionEnum.thingVersion.equals(thingVersion)) + .findAny().orElseThrow(() -> new CloudSDKVersionException(thingVersion)); + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/config/version/DroneThingVersionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/config/version/DroneThingVersionEnum.java new file mode 100644 index 0000000..3d3ca79 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/config/version/DroneThingVersionEnum.java @@ -0,0 +1,56 @@ +package com.dji.sdk.config.version; + +import com.dji.sdk.exception.CloudSDKVersionException; +import com.fasterxml.jackson.annotation.JsonValue; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.Optional; + +/** + * @author sean + * @version 1.7 + * @date 2023/5/19 + */ +public enum DroneThingVersionEnum implements IThingVersion { + + V1_0_0("1.0.0", CloudSDKVersionEnum.V0_0_1), + + V1_1_0("1.1.0", CloudSDKVersionEnum.V1_0_0), + + V1_1_2("1.1.2", CloudSDKVersionEnum.V1_0_0), + + V1_1_3("1.1.3", CloudSDKVersionEnum.V1_0_2), + + ; + + private static final Logger log = LoggerFactory.getLogger(DroneThingVersionEnum.class); + + private final String thingVersion; + + private final CloudSDKVersionEnum cloudSDKVersion; + + DroneThingVersionEnum(String thingVersion, CloudSDKVersionEnum cloudSDKVersion) { + this.thingVersion = thingVersion; + this.cloudSDKVersion = cloudSDKVersion; + } + + @JsonValue + public String getThingVersion() { + return thingVersion; + } + + public CloudSDKVersionEnum getCloudSDKVersion() { + return cloudSDKVersion; + } + + public static DroneThingVersionEnum find(String thingVersion) { + Optional opt = Arrays.stream(values()) + .filter(thingVersionEnum -> thingVersionEnum.thingVersion.equals(thingVersion)).findAny(); + if (opt.isPresent()) { + return opt.get(); + } + throw new CloudSDKVersionException(thingVersion); + } +} diff --git a/src/main/java/com/dji/sdk/config/version/GatewayManager.java b/cloud-sdk/src/main/java/com/dji/sdk/config/version/GatewayManager.java similarity index 100% rename from src/main/java/com/dji/sdk/config/version/GatewayManager.java rename to cloud-sdk/src/main/java/com/dji/sdk/config/version/GatewayManager.java diff --git a/src/main/java/com/dji/sdk/config/version/GatewayThingVersion.java b/cloud-sdk/src/main/java/com/dji/sdk/config/version/GatewayThingVersion.java similarity index 100% rename from src/main/java/com/dji/sdk/config/version/GatewayThingVersion.java rename to cloud-sdk/src/main/java/com/dji/sdk/config/version/GatewayThingVersion.java diff --git a/src/main/java/com/dji/sdk/config/version/GatewayTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/config/version/GatewayTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/config/version/GatewayTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/config/version/GatewayTypeEnum.java diff --git a/src/main/java/com/dji/sdk/config/version/IThingVersion.java b/cloud-sdk/src/main/java/com/dji/sdk/config/version/IThingVersion.java similarity index 100% rename from src/main/java/com/dji/sdk/config/version/IThingVersion.java rename to cloud-sdk/src/main/java/com/dji/sdk/config/version/IThingVersion.java diff --git a/src/main/java/com/dji/sdk/config/version/RcThingVersionEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/config/version/RcThingVersionEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/config/version/RcThingVersionEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/config/version/RcThingVersionEnum.java diff --git a/src/main/java/com/dji/sdk/exception/CloudSDKErrorEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/exception/CloudSDKErrorEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/exception/CloudSDKErrorEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/exception/CloudSDKErrorEnum.java diff --git a/src/main/java/com/dji/sdk/exception/CloudSDKException.java b/cloud-sdk/src/main/java/com/dji/sdk/exception/CloudSDKException.java similarity index 100% rename from src/main/java/com/dji/sdk/exception/CloudSDKException.java rename to cloud-sdk/src/main/java/com/dji/sdk/exception/CloudSDKException.java diff --git a/src/main/java/com/dji/sdk/exception/CloudSDKVersionException.java b/cloud-sdk/src/main/java/com/dji/sdk/exception/CloudSDKVersionException.java similarity index 100% rename from src/main/java/com/dji/sdk/exception/CloudSDKVersionException.java rename to cloud-sdk/src/main/java/com/dji/sdk/exception/CloudSDKVersionException.java diff --git a/src/main/java/com/dji/sdk/mqtt/Chan.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/Chan.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/Chan.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/Chan.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/mqtt/ChannelName.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/ChannelName.java new file mode 100644 index 0000000..876e1e3 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/ChannelName.java @@ -0,0 +1,181 @@ +package com.dji.sdk.mqtt; + +/** + * The name of all channels. + * + * @author sean.zhou + * @date 2021/11/10 + * @version 0.1 + */ +public class ChannelName { + + public static final String INBOUND = "inbound"; + public static final String DEFAULT = "default"; + public static final String OUTBOUND = "outbound"; + + // status + public static final String INBOUND_STATUS = "inboundStatus"; + + public static final String OUTBOUND_STATUS = "outboundStatus"; + + public static final String INBOUND_STATUS_ONLINE = "inboundStatusOnline"; + + public static final String INBOUND_STATUS_OFFLINE = "inboundStatusOffline"; + + + // state + public static final String INBOUND_STATE = "inboundState"; + + public static final String INBOUND_STATE_RC_CONTROL_SOURCE = "inboundStateRcControlSource"; + + public static final String INBOUND_STATE_DOCK_DRONE_CONTROL_SOURCE = "inboundStateDockControlSource"; + + public static final String INBOUND_STATE_RC_LIVESTREAM_ABILITY_UPDATE = "inboundStateRcLiveCapacity"; + + public static final String INBOUND_STATE_DOCK_LIVESTREAM_ABILITY_UPDATE = "inboundStateDockLiveCapacity"; + + public static final String INBOUND_STATE_RC_LIVE_STATUS = "inboundStateRcLiveStatus"; + + public static final String INBOUND_STATE_DOCK_LIVE_STATUS = "inboundStateDockLiveStatus"; + + public static final String INBOUND_STATE_RC_AND_DRONE_FIRMWARE_VERSION = "inboundStateRcAndDroneFirmwareVersion"; + + public static final String INBOUND_STATE_DOCK_FIRMWARE_VERSION = "inboundStateDockFirmwareVersion"; + + public static final String INBOUND_STATE_RC_PAYLOAD_FIRMWARE = "inboundStateRcPayloadFirmware"; + + public static final String INBOUND_STATE_DOCK_DRONE_WPMZ_VERSION = "inboundStateDockDroneWpmzVersion"; + + public static final String INBOUND_STATE_DOCK_DRONE_THERMAL_SUPPORTED_PALETTE_STYLE = "inboundStateDockDronePayload"; + + public static final String INBOUND_STATE_DOCK_DRONE_RTH_MODE = "inboundStateDockDroneRthMode"; + + public static final String INBOUND_STATE_DOCK_DRONE_CURRENT_RTH_MODE = "inboundStateDockDroneCurrentRthMode"; + + public static final String INBOUND_STATE_DOCK_DRONE_COMMANDER_MODE_LOST_ACTION = "inboundStateDockDroneCommanderModeLostAction"; + + public static final String INBOUND_STATE_DOCK_DRONE_CURRENT_COMMANDER_FLIGHT_MODE = "inboundStateDockDroneCurrentCommanderFlightMode"; + + public static final String INBOUND_STATE_DOCK_DRONE_COMMANDER_FLIGHT_HEIGHT = "inboundStateDockDroneCommanderFlightHeight"; + + public static final String INBOUND_STATE_DOCK_DRONE_MODE_CODE_REASON = "inboundStateDockDroneModeCodeReason"; + + public static final String INBOUND_STATE_DOCK_DRONE_OFFLINE_MAP_ENABLE = "inboundStateDockDroneOfflineMapEnable"; + + public static final String INBOUND_STATE_DOCK_AND_DRONE_DONGLE_INFOS = "inboundStateDockAndDroneDongleInfos"; + + public static final String INBOUND_STATE_DOCK_SILENT_MODE = "inboundStateDockSilentMode"; + + + public static final String OUTBOUND_STATE = "outboundState"; + + + // services_reply + public static final String INBOUND_SERVICES_REPLY = "inboundServicesReply"; + + + // osd + public static final String INBOUND_OSD = "inboundOsd"; + + public static final String INBOUND_OSD_RC = "inboundOsdRc"; + + public static final String INBOUND_OSD_DOCK = "inboundOsdDock"; + + public static final String INBOUND_OSD_RC_DRONE = "inboundOsdRcDrone"; + + public static final String INBOUND_OSD_DOCK_DRONE = "inboundOsdDockDrone"; + + + // requests + public static final String INBOUND_REQUESTS = "inboundRequests"; + + public static final String INBOUND_REQUESTS_STORAGE_CONFIG_GET = "inboundRequestsStorageConfigGet"; + + public static final String INBOUND_REQUESTS_AIRPORT_BIND_STATUS = "inboundRequestsAirportBindStatus"; + + public static final String INBOUND_REQUESTS_AIRPORT_ORGANIZATION_GET = "inboundRequestsAirportOrganizationGet"; + + public static final String INBOUND_REQUESTS_AIRPORT_ORGANIZATION_BIND = "inboundRequestsAirportOrganizationBind"; + + public static final String INBOUND_REQUESTS_CONFIG = "inboundRequestsConfig"; + + public static final String INBOUND_REQUESTS_FLIGHTTASK_RESOURCE_GET = "inboundRequestsFlightTaskResourceGet"; + + public static final String INBOUND_REQUESTS_FLIGHT_AREAS_GET = "inboundRequestsFlightAreasGet"; + + public static final String INBOUND_REQUESTS_OFFLINE_MAP_GET = "inboundRequestsOfflineMapGet"; + + + public static final String OUTBOUND_REQUESTS = "outboundRequests"; + + + // events + public static final String INBOUND_EVENTS = "inboundEvents"; + + public static final String OUTBOUND_EVENTS = "outboundEvents"; + + public static final String INBOUND_EVENTS_DEVICE_EXIT_HOMING_NOTIFY = "inboundEventsDeviceExitHomingNotify"; + + public static final String INBOUND_EVENTS_FLIGHTTASK_PROGRESS = "inboundEventsFlighttaskProgress"; + + public static final String INBOUND_EVENTS_FLIGHTTASK_READY = "inboundEventsFlighttaskReady"; + + public static final String INBOUND_EVENTS_FILE_UPLOAD_CALLBACK = "inboundEventsFileUploadCallback"; + + public static final String INBOUND_EVENTS_HMS = "inboundEventsHms"; + + public static final String INBOUND_EVENTS_CONTROL_PROGRESS = "inboundEventsControlProgress"; + + public static final String INBOUND_EVENTS_OTA_PROGRESS = "inboundEventsOtaProgress"; + + public static final String INBOUND_EVENTS_FILEUPLOAD_PROGRESS = "inboundEventsFileUploadProgress"; + + public static final String INBOUND_EVENTS_FLY_TO_POINT_PROGRESS = "inboundEventsFlyToPointProgress"; + + public static final String INBOUND_EVENTS_TAKEOFF_TO_POINT_PROGRESS = "inboundEventsTakeoffToPointProgress"; + + public static final String INBOUND_EVENTS_DRC_STATUS_NOTIFY = "inboundEventsDrcStatusNotify"; + + public static final String INBOUND_EVENTS_JOYSTICK_INVALID_NOTIFY = "inboundEventsJoystickInvalidNotify"; + + public static final String INBOUND_EVENTS_HIGHEST_PRIORITY_UPLOAD_FLIGHT_TASK_MEDIA = "inboundEventsHighestPriorityUploadFlightTaskMedia"; + + public static final String INBOUND_EVENTS_RETURN_HOME_INFO = "inboundEventsReturnHomeInfo"; + + public static final String INBOUND_EVENTS_CUSTOM_DATA_TRANSMISSION_FROM_ESDK = "inboundEventsCustomDataTransmissionFromEsdk"; + + public static final String INBOUND_EVENTS_CUSTOM_DATA_TRANSMISSION_FROM_PSDK = "inboundEventsCustomDataTransmissionFromPsdk"; + + public static final String INBOUND_EVENTS_AIRSENSE_WARNING = "inboundEventsAirsenseWarning"; + + public static final String INBOUND_EVENTS_FLIGHT_AREAS_SYNC_PROGRESS = "inboundEventsFlightAreasSyncProgress"; + + public static final String INBOUND_EVENTS_FLIGHT_AREAS_DRONE_LOCATION = "inboundEventsFlightAreasDroneLocation"; + + public static final String INBOUND_EVENTS_OFFLINE_MAP_SYNC_PROGRESS = "inboundEventsOfflineMapSyncProgress"; + + public static final String INBOUND_EVENTS_POI_STATUS_NOTIFY = "inboundEventsPoiStatusNotify"; + + public static final String INBOUND_EVENTS_CAMERA_PHOTO_TAKE_PROGRESS = "inboundEventsCameraPhotoTakeProgress"; + + + // property + public static final String INBOUND_PROPERTY_SET_REPLY = "inboundPropertySetReply"; + + + // drc/up + public static final String INBOUND_DRC_UP = "inboundDrcUp"; + + public static final String INBOUND_DRC_UP_DRONE_CONTROL = "inboundDrcUpDroneControl"; + + public static final String INBOUND_DRC_UP_DRONE_EMERGENCY_STOP = "inboundDrcUpDroneEmergencyStop"; + + public static final String INBOUND_DRC_UP_HEART_BEAT = "inboundDrcUpHeartBeat"; + + public static final String INBOUND_DRC_UP_HSI_INFO_PUSH = "inboundDrcUpHsiInfoPush"; + + public static final String INBOUND_DRC_UP_DELAY_INFO_PUSH = "inboundDrcUpDelayInfoPush"; + + public static final String INBOUND_DRC_UP_OSD_INFO_PUSH = "inboundDrcUpOsdInfoPush"; + +} diff --git a/src/main/java/com/dji/sdk/mqtt/CloudApiTopicEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/CloudApiTopicEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/CloudApiTopicEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/CloudApiTopicEnum.java diff --git a/src/main/java/com/dji/sdk/mqtt/CommonTopicRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/CommonTopicRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/CommonTopicRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/CommonTopicRequest.java diff --git a/src/main/java/com/dji/sdk/mqtt/CommonTopicResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/CommonTopicResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/CommonTopicResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/CommonTopicResponse.java diff --git a/src/main/java/com/dji/sdk/mqtt/IMqttMessageGateway.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/IMqttMessageGateway.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/IMqttMessageGateway.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/IMqttMessageGateway.java diff --git a/src/main/java/com/dji/sdk/mqtt/IMqttTopicService.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/IMqttTopicService.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/IMqttTopicService.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/IMqttTopicService.java diff --git a/src/main/java/com/dji/sdk/mqtt/InboundMessageRouter.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/InboundMessageRouter.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/InboundMessageRouter.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/InboundMessageRouter.java diff --git a/src/main/java/com/dji/sdk/mqtt/MqttConfiguration.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttConfiguration.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/MqttConfiguration.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttConfiguration.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttGatewayPublish.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttGatewayPublish.java new file mode 100644 index 0000000..272651c --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttGatewayPublish.java @@ -0,0 +1,104 @@ +package com.dji.sdk.mqtt; + +import com.dji.sdk.common.Common; +import com.dji.sdk.exception.CloudSDKErrorEnum; +import com.dji.sdk.exception.CloudSDKException; +import com.dji.sdk.websocket.api.WebSocketMessageSend; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.TypeMismatchException; +import org.springframework.integration.mqtt.support.MqttHeaders; +import org.springframework.messaging.MessageHeaders; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import javax.annotation.Resource; +import java.util.Objects; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * @author sean.zhou + * @date 2021/11/16 + * @version 0.1 + */ +@Component +public class MqttGatewayPublish { + + private static final Logger log = LoggerFactory.getLogger(WebSocketMessageSend.class); + + private static final int DEFAULT_QOS = 0; + public static final int DEFAULT_RETRY_COUNT = 2; + public static final int DEFAULT_RETRY_TIMEOUT = 3000; + + @Resource + private IMqttMessageGateway messageGateway; + + public void publish(String topic, int qos, CommonTopicRequest request) { + try { + log.debug("send topic: {}, payload: {}", topic, request.toString()); + byte[] payload = Common.getObjectMapper().writeValueAsBytes(request); + messageGateway.publish(topic, payload, qos); + } catch (JsonProcessingException e) { + log.error("Failed to publish the message. {}", request.toString()); + e.printStackTrace(); + } + } + + public void publish(String topic, int qos, CommonTopicResponse response) { + try { + log.debug("send topic: {}, payload: {}", topic, response.toString()); + byte[] payload = Common.getObjectMapper().writeValueAsBytes(response); + messageGateway.publish(topic, payload, qos); + } catch (JsonProcessingException e) { + log.error("Failed to publish the message. {}", response.toString()); + e.printStackTrace(); + } + } + + public void publish(String topic, CommonTopicRequest request, int publishCount) { + AtomicInteger time = new AtomicInteger(0); + while (time.getAndIncrement() < publishCount) { + this.publish(topic, DEFAULT_QOS, request); + } + } + + public void publish(String topic, CommonTopicRequest request) { + this.publish(topic, DEFAULT_QOS, request); + } + + public void publishReply(CommonTopicResponse response, MessageHeaders headers) { + this.publish(headers.get(MqttHeaders.RECEIVED_TOPIC) + TopicConst._REPLY_SUF, 2, response); + } + + public CommonTopicResponse publishWithReply(Class clazz, String topic, CommonTopicRequest request, int retryCount, long timeout) { + AtomicInteger time = new AtomicInteger(0); + boolean hasBid = StringUtils.hasText(request.getBid()); + request.setBid(hasBid ? request.getBid() : UUID.randomUUID().toString()); + // Retry + while (time.getAndIncrement() <= retryCount) { + this.publish(topic, request); + + // If the message is not received in 3 seconds then resend it again. + CommonTopicResponse receiver = Chan.getInstance(request.getTid(), true).get(request.getTid(), timeout); + // Need to match tid and bid. + if (Objects.nonNull(receiver) + && receiver.getTid().equals(request.getTid()) + && receiver.getBid().equals(request.getBid())) { + if (clazz.isAssignableFrom(receiver.getData().getClass())) { + return receiver; + } + throw new TypeMismatchException(receiver.getData(), clazz); + } + // It must be guaranteed that the tid and bid of each message are different. + if (!hasBid) { + request.setBid(UUID.randomUUID().toString()); + } + request.setTid(UUID.randomUUID().toString()); + } + throw new CloudSDKException(CloudSDKErrorEnum.MQTT_PUBLISH_ABNORMAL, "No message reply received."); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/mqtt/MqttReply.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttReply.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/MqttReply.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttReply.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttReplyHandler.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttReplyHandler.java new file mode 100644 index 0000000..45256d4 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttReplyHandler.java @@ -0,0 +1,68 @@ +package com.dji.sdk.mqtt; + +import com.dji.sdk.common.BaseModel; +import com.dji.sdk.common.Common; +import com.dji.sdk.mqtt.events.TopicEventsRequest; +import com.dji.sdk.mqtt.events.TopicEventsResponse; +import com.dji.sdk.mqtt.requests.TopicRequestsRequest; +import com.dji.sdk.mqtt.requests.TopicRequestsResponse; +import com.dji.sdk.mqtt.state.TopicStateRequest; +import com.dji.sdk.mqtt.state.TopicStateResponse; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; + +import java.util.Objects; + +/** + * @author sean + * @version 1.7 + * @date 2023/5/22 + */ +@Aspect +@Component +public class MqttReplyHandler { + + @AfterReturning(value = "execution(public com.dji.sdk.mqtt.CommonTopicResponse+ com.dji.sdk.cloudapi.*.api.*.*(com.dji.sdk.mqtt.CommonTopicRequest+, org.springframework.messaging.MessageHeaders))", returning = "result") + public Object validateReturnValue(JoinPoint point, CommonTopicResponse result) { + if (Objects.isNull(result)) { + return null; + } + CommonTopicRequest request = (CommonTopicRequest) point.getArgs()[0]; + result.setBid(request.getBid()).setTid(request.getTid()).setTimestamp(System.currentTimeMillis()); + if (result instanceof TopicEventsResponse) { + fillEvents((TopicEventsResponse) result, (TopicEventsRequest) request); + } else if (result instanceof TopicRequestsResponse) { + validateRequests((TopicRequestsResponse) result, (TopicRequestsRequest) request); + } else if (result instanceof TopicStateResponse) { + fillState((TopicStateResponse) result, (TopicStateRequest) request); + } + return result; + } + + private void fillEvents(TopicEventsResponse response, TopicEventsRequest request) { + if (!request.isNeedReply()) { + response.setData(null); + return; + } + response.setMethod(request.getMethod()).setData(MqttReply.success()); + } + + private void validateRequests(TopicRequestsResponse response, TopicRequestsRequest request) { + response.setMethod(request.getMethod()); + Object data = response.getData(); + if (data instanceof MqttReply) { + MqttReply mqttData = (MqttReply) data; + if (MqttReply.CODE_SUCCESS != mqttData.getResult()) { + return; + } + data = mqttData.getOutput(); + } + Common.validateModel((BaseModel) data); + } + + private void fillState(TopicStateResponse response, TopicStateRequest request) { + response.setData(request.isNeedReply() ? MqttReply.success() : null); + } +} diff --git a/src/main/java/com/dji/sdk/mqtt/MqttTopicServiceImpl.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttTopicServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/MqttTopicServiceImpl.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/MqttTopicServiceImpl.java diff --git a/src/main/java/com/dji/sdk/mqtt/TopicConst.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/TopicConst.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/TopicConst.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/TopicConst.java diff --git a/src/main/java/com/dji/sdk/mqtt/drc/DrcDownPublish.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/DrcDownPublish.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/drc/DrcDownPublish.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/DrcDownPublish.java diff --git a/src/main/java/com/dji/sdk/mqtt/drc/DrcUpData.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/DrcUpData.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/drc/DrcUpData.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/DrcUpData.java diff --git a/src/main/java/com/dji/sdk/mqtt/drc/DrcUpMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/DrcUpMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/drc/DrcUpMethodEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/DrcUpMethodEnum.java diff --git a/src/main/java/com/dji/sdk/mqtt/drc/DrcUpRouter.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/DrcUpRouter.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/drc/DrcUpRouter.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/DrcUpRouter.java diff --git a/src/main/java/com/dji/sdk/mqtt/drc/DrcUpSubscribe.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/DrcUpSubscribe.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/drc/DrcUpSubscribe.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/DrcUpSubscribe.java diff --git a/src/main/java/com/dji/sdk/mqtt/drc/TopicDrcRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/TopicDrcRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/drc/TopicDrcRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/TopicDrcRequest.java diff --git a/src/main/java/com/dji/sdk/mqtt/drc/TopicDrcResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/TopicDrcResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/drc/TopicDrcResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/drc/TopicDrcResponse.java diff --git a/src/main/java/com/dji/sdk/mqtt/events/EventsDataRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsDataRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/events/EventsDataRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsDataRequest.java diff --git a/src/main/java/com/dji/sdk/mqtt/events/EventsErrorCode.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsErrorCode.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/events/EventsErrorCode.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsErrorCode.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsMethodEnum.java new file mode 100644 index 0000000..4ab564b --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsMethodEnum.java @@ -0,0 +1,132 @@ +package com.dji.sdk.mqtt.events; + +import com.dji.sdk.cloudapi.airsense.AirsenseWarning; +import com.dji.sdk.cloudapi.control.*; +import com.dji.sdk.cloudapi.debug.RemoteDebugProgress; +import com.dji.sdk.cloudapi.firmware.OtaProgress; +import com.dji.sdk.cloudapi.flightarea.FlightAreasDroneLocation; +import com.dji.sdk.cloudapi.flightarea.FlightAreasSyncProgress; +import com.dji.sdk.cloudapi.hms.Hms; +import com.dji.sdk.cloudapi.interconnection.CustomDataTransmissionFromEsdk; +import com.dji.sdk.cloudapi.interconnection.CustomDataTransmissionFromPsdk; +import com.dji.sdk.cloudapi.log.FileUploadProgress; +import com.dji.sdk.cloudapi.map.OfflineMapSyncProgress; +import com.dji.sdk.cloudapi.media.FileUploadCallback; +import com.dji.sdk.cloudapi.media.HighestPriorityUploadFlightTaskMedia; +import com.dji.sdk.cloudapi.wayline.DeviceExitHomingNotify; +import com.dji.sdk.cloudapi.wayline.FlighttaskProgress; +import com.dji.sdk.cloudapi.wayline.FlighttaskReady; +import com.dji.sdk.cloudapi.wayline.ReturnHomeInfo; +import com.dji.sdk.mqtt.ChannelName; +import com.fasterxml.jackson.core.type.TypeReference; + +import java.util.Arrays; +import java.util.List; + +/** + * @author sean + * @version 1.1 + * @date 2022/6/1 + */ +public enum EventsMethodEnum { + + FLIGHTTASK_PROGRESS("flighttask_progress", ChannelName.INBOUND_EVENTS_FLIGHTTASK_PROGRESS, new TypeReference>() {}), + + DEVICE_EXIT_HOMING_NOTIFY("device_exit_homing_notify", ChannelName.INBOUND_EVENTS_DEVICE_EXIT_HOMING_NOTIFY, new TypeReference() {}), + + FILE_UPLOAD_CALLBACK("file_upload_callback", ChannelName.INBOUND_EVENTS_FILE_UPLOAD_CALLBACK, new TypeReference() {}), + + HMS("hms", ChannelName.INBOUND_EVENTS_HMS, new TypeReference() {}), + + DEVICE_REBOOT("device_reboot", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + DRONE_OPEN("drone_open", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + DRONE_CLOSE("drone_close", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + DRONE_FORMAT("drone_format", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + DEVICE_FORMAT("device_format", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + COVER_OPEN("cover_open", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + COVER_CLOSE("cover_close", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + PUTTER_OPEN("putter_open", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + PUTTER_CLOSE("putter_close", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + CHARGE_OPEN("charge_open", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + CHARGE_CLOSE("charge_close", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + ESIM_ACTIVATE("esim_activate", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + ESIM_OPERATOR_SWITCH("esim_operator_switch", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), + + OTA_PROGRESS("ota_progress", ChannelName.INBOUND_EVENTS_OTA_PROGRESS, new TypeReference>() {}), + + FILE_UPLOAD_PROGRESS("fileupload_progress", ChannelName.INBOUND_EVENTS_FILEUPLOAD_PROGRESS, new TypeReference>() {}), + + HIGHEST_PRIORITY_UPLOAD_FLIGHT_TASK_MEDIA("highest_priority_upload_flighttask_media", ChannelName.INBOUND_EVENTS_HIGHEST_PRIORITY_UPLOAD_FLIGHT_TASK_MEDIA, new TypeReference() {}), + + FLIGHT_TASK_READY("flighttask_ready", ChannelName.INBOUND_EVENTS_FLIGHTTASK_READY, new TypeReference() {}), + + FLY_TO_POINT_PROGRESS("fly_to_point_progress", ChannelName.INBOUND_EVENTS_FLY_TO_POINT_PROGRESS, new TypeReference() {}), + + TAKE_OFF_TO_POINT_PROGRESS("takeoff_to_point_progress", ChannelName.INBOUND_EVENTS_TAKEOFF_TO_POINT_PROGRESS, new TypeReference() {}), + + DRC_STATUS_NOTIFY("drc_status_notify", ChannelName.INBOUND_EVENTS_DRC_STATUS_NOTIFY, new TypeReference() {}), + + JOYSTICK_INVALID_NOTIFY("joystick_invalid_notify", ChannelName.INBOUND_EVENTS_JOYSTICK_INVALID_NOTIFY, new TypeReference() {}), + + RETURN_HOME_INFO("return_home_info", ChannelName.INBOUND_EVENTS_RETURN_HOME_INFO, new TypeReference() {}), + + CUSTOM_DATA_TRANSMISSION_FROM_ESDK("custom_data_transmission_from_esdk", ChannelName.INBOUND_EVENTS_CUSTOM_DATA_TRANSMISSION_FROM_ESDK, new TypeReference() {}), + + CUSTOM_DATA_TRANSMISSION_FROM_PSDK("custom_data_transmission_from_psdk", ChannelName.INBOUND_EVENTS_CUSTOM_DATA_TRANSMISSION_FROM_PSDK, new TypeReference() {}), + + AIRSENSE_WARNING("airsense_warning", ChannelName.INBOUND_EVENTS_AIRSENSE_WARNING, new TypeReference>() {}), + + FLIGHT_AREAS_SYNC_PROGRESS("flight_areas_sync_progress", ChannelName.INBOUND_EVENTS_FLIGHT_AREAS_SYNC_PROGRESS, new TypeReference() {}), + + FLIGHT_AREAS_DRONE_LOCATION("flight_areas_drone_location", ChannelName.INBOUND_EVENTS_FLIGHT_AREAS_DRONE_LOCATION, new TypeReference() {}), + + OFFLINE_MAP_SYNC_PROGRESS("offline_map_sync_progress", ChannelName.INBOUND_EVENTS_OFFLINE_MAP_SYNC_PROGRESS, new TypeReference() {}), + + POI_STATUS_NOTIFY("poi_status_notify", ChannelName.INBOUND_EVENTS_POI_STATUS_NOTIFY, new TypeReference() {}), + + CAMERA_PHOTO_TAKE_PROGRESS("camera_photo_take_progress", ChannelName.INBOUND_EVENTS_CAMERA_PHOTO_TAKE_PROGRESS, new TypeReference>() {}), + + UNKNOWN("", ChannelName.DEFAULT, new TypeReference<>() {}); + + private final String method; + + private final String channelName; + + private final TypeReference classType; + + EventsMethodEnum(String method, String channelName, TypeReference classType) { + this.method = method; + this.channelName = channelName; + this.classType = classType; + } + + public String getMethod() { + return method; + } + + public String getChannelName() { + return channelName; + } + + public TypeReference getClassType() { + return classType; + } + + public static EventsMethodEnum find(String method) { + return Arrays.stream(EventsMethodEnum.values()) + .filter(methodEnum -> methodEnum.method.equals(method)) + .findAny().orElse(UNKNOWN); + } +} diff --git a/src/main/java/com/dji/sdk/mqtt/events/EventsRouter.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsRouter.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/events/EventsRouter.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsRouter.java diff --git a/src/main/java/com/dji/sdk/mqtt/events/EventsSubscribe.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsSubscribe.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/events/EventsSubscribe.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsSubscribe.java diff --git a/src/main/java/com/dji/sdk/mqtt/events/IEventsErrorCode.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/IEventsErrorCode.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/events/IEventsErrorCode.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/IEventsErrorCode.java diff --git a/src/main/java/com/dji/sdk/mqtt/events/TopicEventsRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/TopicEventsRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/events/TopicEventsRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/TopicEventsRequest.java diff --git a/src/main/java/com/dji/sdk/mqtt/events/TopicEventsResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/TopicEventsResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/events/TopicEventsResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/TopicEventsResponse.java diff --git a/src/main/java/com/dji/sdk/mqtt/osd/OsdDeviceTypeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/osd/OsdDeviceTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/osd/OsdDeviceTypeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/osd/OsdDeviceTypeEnum.java diff --git a/src/main/java/com/dji/sdk/mqtt/osd/OsdRouter.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/osd/OsdRouter.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/osd/OsdRouter.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/osd/OsdRouter.java diff --git a/src/main/java/com/dji/sdk/mqtt/osd/OsdSubscribe.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/osd/OsdSubscribe.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/osd/OsdSubscribe.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/osd/OsdSubscribe.java diff --git a/src/main/java/com/dji/sdk/mqtt/osd/TopicOsdRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/osd/TopicOsdRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/osd/TopicOsdRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/osd/TopicOsdRequest.java diff --git a/src/main/java/com/dji/sdk/mqtt/property/PropertySetPublish.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/property/PropertySetPublish.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/property/PropertySetPublish.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/property/PropertySetPublish.java diff --git a/src/main/java/com/dji/sdk/mqtt/property/PropertySetReplyHandler.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/property/PropertySetReplyHandler.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/property/PropertySetReplyHandler.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/property/PropertySetReplyHandler.java diff --git a/src/main/java/com/dji/sdk/mqtt/property/PropertySetReplyResultEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/property/PropertySetReplyResultEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/property/PropertySetReplyResultEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/property/PropertySetReplyResultEnum.java diff --git a/src/main/java/com/dji/sdk/mqtt/property/PropertySetSubscribe.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/property/PropertySetSubscribe.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/property/PropertySetSubscribe.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/property/PropertySetSubscribe.java diff --git a/src/main/java/com/dji/sdk/mqtt/property/TopicPropertySetRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/property/TopicPropertySetRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/property/TopicPropertySetRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/property/TopicPropertySetRequest.java diff --git a/src/main/java/com/dji/sdk/mqtt/property/TopicPropertySetResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/property/TopicPropertySetResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/property/TopicPropertySetResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/property/TopicPropertySetResponse.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/mqtt/requests/RequestsMethodEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/requests/RequestsMethodEnum.java new file mode 100644 index 0000000..5304a7a --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/requests/RequestsMethodEnum.java @@ -0,0 +1,69 @@ +package com.dji.sdk.mqtt.requests; + +import com.dji.sdk.cloudapi.config.RequestsConfigRequest; +import com.dji.sdk.cloudapi.flightarea.FlightAreasGetRequest; +import com.dji.sdk.cloudapi.map.OfflineMapGetRequest; +import com.dji.sdk.cloudapi.media.StorageConfigGet; +import com.dji.sdk.cloudapi.organization.AirportBindStatusRequest; +import com.dji.sdk.cloudapi.organization.AirportOrganizationBindRequest; +import com.dji.sdk.cloudapi.organization.AirportOrganizationGetRequest; +import com.dji.sdk.cloudapi.wayline.FlighttaskResourceGetRequest; +import com.dji.sdk.mqtt.ChannelName; + +import java.util.Arrays; + +/** + * @author sean + * @version 1.0 + * @date 2022/5/25 + */ +public enum RequestsMethodEnum { + + STORAGE_CONFIG_GET("storage_config_get", ChannelName.INBOUND_REQUESTS_STORAGE_CONFIG_GET, StorageConfigGet.class), + + AIRPORT_BIND_STATUS("airport_bind_status", ChannelName.INBOUND_REQUESTS_AIRPORT_BIND_STATUS, AirportBindStatusRequest.class), + + AIRPORT_ORGANIZATION_BIND("airport_organization_bind", ChannelName.INBOUND_REQUESTS_AIRPORT_ORGANIZATION_BIND, AirportOrganizationBindRequest.class), + + AIRPORT_ORGANIZATION_GET("airport_organization_get", ChannelName.INBOUND_REQUESTS_AIRPORT_ORGANIZATION_GET, AirportOrganizationGetRequest.class), + + FLIGHT_TASK_RESOURCE_GET("flighttask_resource_get", ChannelName.INBOUND_REQUESTS_FLIGHTTASK_RESOURCE_GET, FlighttaskResourceGetRequest.class), + + CONFIG("config", ChannelName.INBOUND_REQUESTS_CONFIG, RequestsConfigRequest.class), + + FLIGHT_AREAS_GET("flight_areas_get", ChannelName.INBOUND_REQUESTS_FLIGHT_AREAS_GET, FlightAreasGetRequest.class), + + OFFLINE_MAP_GET("offline_map_get", ChannelName.INBOUND_REQUESTS_OFFLINE_MAP_GET, OfflineMapGetRequest.class), + + UNKNOWN("", ChannelName.DEFAULT, Object.class); + + private final String method; + + private final String channelName; + + private final Class classType; + + RequestsMethodEnum(String method, String channelName, Class classType) { + this.method = method; + this.channelName = channelName; + this.classType = classType; + } + + public String getMethod() { + return method; + } + + public String getChannelName() { + return channelName; + } + + public Class getClassType() { + return classType; + } + + public static RequestsMethodEnum find(String method) { + return Arrays.stream(RequestsMethodEnum.values()) + .filter(methodEnum -> methodEnum.method.equals(method)) + .findAny().orElse(UNKNOWN); + } +} diff --git a/src/main/java/com/dji/sdk/mqtt/requests/RequestsRouter.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/requests/RequestsRouter.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/requests/RequestsRouter.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/requests/RequestsRouter.java diff --git a/src/main/java/com/dji/sdk/mqtt/requests/RequestsSubscribe.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/requests/RequestsSubscribe.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/requests/RequestsSubscribe.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/requests/RequestsSubscribe.java diff --git a/src/main/java/com/dji/sdk/mqtt/requests/TopicRequestsRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/requests/TopicRequestsRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/requests/TopicRequestsRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/requests/TopicRequestsRequest.java diff --git a/src/main/java/com/dji/sdk/mqtt/requests/TopicRequestsResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/requests/TopicRequestsResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/requests/TopicRequestsResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/requests/TopicRequestsResponse.java diff --git a/src/main/java/com/dji/sdk/mqtt/services/IServicesErrorCode.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/IServicesErrorCode.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/services/IServicesErrorCode.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/IServicesErrorCode.java diff --git a/src/main/java/com/dji/sdk/mqtt/services/ServicesErrorCode.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/ServicesErrorCode.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/services/ServicesErrorCode.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/ServicesErrorCode.java diff --git a/src/main/java/com/dji/sdk/mqtt/services/ServicesPublish.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/ServicesPublish.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/services/ServicesPublish.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/ServicesPublish.java diff --git a/src/main/java/com/dji/sdk/mqtt/services/ServicesReplyData.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/ServicesReplyData.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/services/ServicesReplyData.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/ServicesReplyData.java diff --git a/src/main/java/com/dji/sdk/mqtt/services/ServicesReplyHandler.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/ServicesReplyHandler.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/services/ServicesReplyHandler.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/ServicesReplyHandler.java diff --git a/src/main/java/com/dji/sdk/mqtt/services/ServicesReplyReceiver.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/ServicesReplyReceiver.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/services/ServicesReplyReceiver.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/ServicesReplyReceiver.java diff --git a/src/main/java/com/dji/sdk/mqtt/services/ServicesSubscribe.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/ServicesSubscribe.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/services/ServicesSubscribe.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/ServicesSubscribe.java diff --git a/src/main/java/com/dji/sdk/mqtt/services/TopicServicesRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/TopicServicesRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/services/TopicServicesRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/TopicServicesRequest.java diff --git a/src/main/java/com/dji/sdk/mqtt/services/TopicServicesResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/TopicServicesResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/services/TopicServicesResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/services/TopicServicesResponse.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/DockStateDataKeyEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/DockStateDataKeyEnum.java new file mode 100644 index 0000000..9a00e0b --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/DockStateDataKeyEnum.java @@ -0,0 +1,78 @@ +package com.dji.sdk.mqtt.state; + +import com.dji.sdk.cloudapi.device.*; +import com.dji.sdk.cloudapi.livestream.DockLivestreamAbilityUpdate; +import com.dji.sdk.cloudapi.property.DockDroneCommanderFlightHeight; +import com.dji.sdk.cloudapi.property.DockDroneCommanderModeLostAction; +import com.dji.sdk.cloudapi.property.DockDroneOfflineMapEnable; +import com.dji.sdk.cloudapi.property.DockDroneRthMode; +import com.dji.sdk.exception.CloudSDKException; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Set; + +/** + * + * @author sean.zhou + * @date 2021/11/18 + * @version 0.1 + */ +public enum DockStateDataKeyEnum { + + FIRMWARE_VERSION(Set.of("firmware_version"), DockFirmwareVersion.class), + + LIVE_CAPACITY(Set.of("live_capacity"), DockLivestreamAbilityUpdate.class), + + CONTROL_SOURCE(Set.of("control_source"), DockDroneControlSource.class), + + LIVE_STATUS(Set.of("live_status"), DockLiveStatus.class), + + WPMZ_VERSION(Set.of("wpmz_version"), DockDroneWpmzVersion.class), + + THERMAL_SUPPORTED_PALETTE_STYLE(PayloadModelConst.getAllIndexWithPosition(), DockDroneThermalSupportedPaletteStyle.class), + + RTH_MODE(Set.of("rth_mode"), DockDroneRthMode.class), + + CURRENT_RTH_MODE(Set.of("current_rth_mode"), DockDroneCurrentRthMode.class), + + COMMANDER_MODE_LOST_ACTION(Set.of("commander_mode_lost_action"), DockDroneCommanderModeLostAction.class), + + CURRENT_COMMANDER_FLIGHT_MODE(Set.of("current_commander_flight_mode"), DockDroneCurrentCommanderFlightMode.class), + + COMMANDER_FLIGHT_HEIGHT(Set.of("commander_flight_height"), DockDroneCommanderFlightHeight.class), + + MODE_CODE_REASON(Set.of("mode_code_reason"), DockDroneModeCodeReason.class), + + OFFLINE_MAP_ENABLE(Set.of("offline_map_enable"), DockDroneOfflineMapEnable.class), + + DONGLE_INFOS(Set.of("dongle_infos"), DongleInfos.class), + + SILENT_MODE(Set.of("silent_mode"), DockSilentMode.class), + + ; + + private final Set keys; + + private final Class classType; + + + DockStateDataKeyEnum(Set keys, Class classType) { + this.keys = keys; + this.classType = classType; + } + + public Class getClassType() { + return classType; + } + + public Set getKeys() { + return keys; + } + + public static DockStateDataKeyEnum find(Set keys) { + return Arrays.stream(values()).filter(keyEnum -> !Collections.disjoint(keys, keyEnum.keys)).findAny() + .orElseThrow(() -> new CloudSDKException(DockStateDataKeyEnum.class, keys)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/RcStateDataKeyEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/RcStateDataKeyEnum.java new file mode 100644 index 0000000..bd80c68 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/RcStateDataKeyEnum.java @@ -0,0 +1,53 @@ +package com.dji.sdk.mqtt.state; + +import com.dji.sdk.cloudapi.device.*; +import com.dji.sdk.cloudapi.livestream.RcLivestreamAbilityUpdate; +import com.dji.sdk.exception.CloudSDKException; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Set; + +/** + * + * @author sean.zhou + * @date 2021/11/18 + * @version 0.1 + */ +public enum RcStateDataKeyEnum { + + FIRMWARE_VERSION(Set.of("firmware_version"), FirmwareVersion.class), + + LIVE_CAPACITY(Set.of("live_capacity"), RcLivestreamAbilityUpdate.class), + + CONTROL_SOURCE(Set.of("control_source"), RcDroneControlSource.class), + + LIVE_STATUS(Set.of("live_status"), RcLiveStatus.class), + + PAYLOAD_FIRMWARE(PayloadModelConst.getAllModelWithPosition(), PayloadFirmwareVersion.class), + ; + + private final Set keys; + + private final Class classType; + + + RcStateDataKeyEnum(Set keys, Class classType) { + this.keys = keys; + this.classType = classType; + } + + public Class getClassType() { + return classType; + } + + public Set getKeys() { + return keys; + } + + public static RcStateDataKeyEnum find(Set keys) { + return Arrays.stream(values()).filter(keyEnum -> !Collections.disjoint(keys, keyEnum.keys)).findAny() + .orElseThrow(() -> new CloudSDKException(RcStateDataKeyEnum.class, keys)); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/StateDataKeyEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/StateDataKeyEnum.java new file mode 100644 index 0000000..257569c --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/StateDataKeyEnum.java @@ -0,0 +1,86 @@ +package com.dji.sdk.mqtt.state; + +import com.dji.sdk.cloudapi.device.*; +import com.dji.sdk.cloudapi.livestream.DockLivestreamAbilityUpdate; +import com.dji.sdk.cloudapi.livestream.RcLivestreamAbilityUpdate; +import com.dji.sdk.cloudapi.property.DockDroneCommanderFlightHeight; +import com.dji.sdk.cloudapi.property.DockDroneCommanderModeLostAction; +import com.dji.sdk.cloudapi.property.DockDroneOfflineMapEnable; +import com.dji.sdk.cloudapi.property.DockDroneRthMode; +import com.dji.sdk.mqtt.ChannelName; + +import java.util.Arrays; + +/** + * + * @author sean.zhou + * @date 2021/11/18 + * @version 0.1 + */ +public enum StateDataKeyEnum { + + RC_AND_DRONE_FIRMWARE_VERSION(ChannelName.INBOUND_STATE_RC_AND_DRONE_FIRMWARE_VERSION, FirmwareVersion.class), + + RC_LIVE_CAPACITY(ChannelName.INBOUND_STATE_RC_LIVESTREAM_ABILITY_UPDATE, RcLivestreamAbilityUpdate.class), + + RC_DRONE_CONTROL_SOURCE(ChannelName.INBOUND_STATE_RC_CONTROL_SOURCE, RcDroneControlSource.class), + + RC_LIVE_STATUS(ChannelName.INBOUND_STATE_RC_LIVE_STATUS, RcLiveStatus.class), + + RC_PAYLOAD_FIRMWARE(ChannelName.INBOUND_STATE_RC_PAYLOAD_FIRMWARE, PayloadFirmwareVersion.class), + + DOCK_FIRMWARE_VERSION(ChannelName.INBOUND_STATE_DOCK_FIRMWARE_VERSION, DockFirmwareVersion.class), + + DOCK_LIVE_CAPACITY(ChannelName.INBOUND_STATE_DOCK_LIVESTREAM_ABILITY_UPDATE, DockLivestreamAbilityUpdate.class), + + DOCK_DRONE_CONTROL_SOURCE(ChannelName.INBOUND_STATE_DOCK_DRONE_CONTROL_SOURCE, DockDroneControlSource.class), + + DOCK_LIVE_STATUS(ChannelName.INBOUND_STATE_DOCK_LIVE_STATUS, DockLiveStatus.class), + + DOCK_DRONE_WPMZ_VERSION(ChannelName.INBOUND_STATE_DOCK_DRONE_WPMZ_VERSION, DockDroneWpmzVersion.class), + + DOCK_DRONE_THERMAL_SUPPORTED_PALETTE_STYLE(ChannelName.INBOUND_STATE_DOCK_DRONE_THERMAL_SUPPORTED_PALETTE_STYLE, DockDroneThermalSupportedPaletteStyle.class), + + DOCK_DRONE_RTH_MODE(ChannelName.INBOUND_STATE_DOCK_DRONE_RTH_MODE, DockDroneRthMode.class), + + DOCK_DRONE_CURRENT_RTH_MODE(ChannelName.INBOUND_STATE_DOCK_DRONE_CURRENT_RTH_MODE, DockDroneCurrentRthMode.class), + + DOCK_DRONE_COMMANDER_MODE_LOST_ACTION(ChannelName.INBOUND_STATE_DOCK_DRONE_COMMANDER_MODE_LOST_ACTION, DockDroneCommanderModeLostAction.class), + + DOCK_DRONE_CURRENT_COMMANDER_FLIGHT_MODE(ChannelName.INBOUND_STATE_DOCK_DRONE_CURRENT_COMMANDER_FLIGHT_MODE, DockDroneCurrentCommanderFlightMode.class), + + DOCK_DRONE_COMMANDER_FLIGHT_HEIGHT(ChannelName.INBOUND_STATE_DOCK_DRONE_COMMANDER_FLIGHT_HEIGHT, DockDroneCommanderFlightHeight.class), + + DOCK_DRONE_MODE_CODE_REASON(ChannelName.INBOUND_STATE_DOCK_DRONE_MODE_CODE_REASON, DockDroneModeCodeReason.class), + + DOCK_DRONE_OFFLINE_MAP_ENABLE(ChannelName.INBOUND_STATE_DOCK_DRONE_OFFLINE_MAP_ENABLE, DockDroneOfflineMapEnable.class), + + DOCK_AND_DRONE_DONGLE_INFOS(ChannelName.INBOUND_STATE_DOCK_AND_DRONE_DONGLE_INFOS, DongleInfos.class), + + DOCK_SILENT_MODE(ChannelName.INBOUND_STATE_DOCK_SILENT_MODE, DockSilentMode.class), + + UNKNOWN(ChannelName.DEFAULT, Object.class); + + private final String channelName; + + private final Class classType; + + StateDataKeyEnum(String channelName, Class classType) { + this.channelName = channelName; + this.classType = classType; + } + + public Class getClassType() { + return classType; + } + + public String getChannelName() { + return channelName; + } + + public static StateDataKeyEnum find(Class clazz) { + return Arrays.stream(values()).filter(keyEnum -> keyEnum.classType == clazz).findAny() + .orElse(UNKNOWN); + } + +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/StateRouter.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/StateRouter.java new file mode 100644 index 0000000..f431fe7 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/StateRouter.java @@ -0,0 +1,90 @@ +package com.dji.sdk.mqtt.state; + +import com.dji.sdk.common.Common; +import com.dji.sdk.common.SDKManager; +import com.dji.sdk.exception.CloudSDKErrorEnum; +import com.dji.sdk.exception.CloudSDKException; +import com.dji.sdk.mqtt.ChannelName; +import com.dji.sdk.mqtt.MqttGatewayPublish; +import com.fasterxml.jackson.core.type.TypeReference; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.integration.dsl.IntegrationFlow; +import org.springframework.integration.dsl.IntegrationFlows; +import org.springframework.integration.mqtt.support.MqttHeaders; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageHeaders; + +import javax.annotation.Resource; +import java.io.IOException; +import java.util.Arrays; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import static com.dji.sdk.mqtt.TopicConst.*; + +/** + * + * @author sean.zhou + * @date 2021/11/17 + * @version 0.1 + */ +@Configuration +public class StateRouter { + + @Resource + private MqttGatewayPublish gatewayPublish; + + @Bean + public IntegrationFlow stateDataRouterFlow() { + return IntegrationFlows + .from(ChannelName.INBOUND_STATE) + .transform(Message.class, source -> { + try { + TopicStateRequest response = Common.getObjectMapper().readValue((byte[]) source.getPayload(), new TypeReference() {}); + String topic = String.valueOf(source.getHeaders().get(MqttHeaders.RECEIVED_TOPIC)); + String from = topic.substring((THING_MODEL_PRE + PRODUCT).length(), topic.indexOf(STATE_SUF)); + return response.setFrom(from) + .setData(Common.getObjectMapper().convertValue(response.getData(), getTypeReference(response.getGateway(), response.getData()))); + } catch (IOException e) { + throw new CloudSDKException(e); + } + }, null) + .route(response -> StateDataKeyEnum.find(response.getData().getClass()), + mapping -> Arrays.stream(StateDataKeyEnum.values()).forEach(key -> mapping.channelMapping(key, key.getChannelName()))) + .get(); + } + + + @Bean + public IntegrationFlow replySuccessState() { + return IntegrationFlows + .from(ChannelName.OUTBOUND_STATE) + .handle(this::publish) + .nullChannel(); + + } + + private TopicStateResponse publish(TopicStateResponse request, MessageHeaders headers) { + if (Objects.isNull(request) || Objects.isNull(request.getData())) { + return null; + } + gatewayPublish.publishReply(request, headers); + return request; + } + + + private Class getTypeReference(String gatewaySn, Object data) { + Set keys = ((Map) data).keySet(); + switch (SDKManager.getDeviceSDK(gatewaySn).getType()) { + 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()); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/mqtt/state/StateSubscribe.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/StateSubscribe.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/state/StateSubscribe.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/StateSubscribe.java diff --git a/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/TopicStateRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/TopicStateRequest.java new file mode 100644 index 0000000..a10d5a6 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/TopicStateRequest.java @@ -0,0 +1,96 @@ +package com.dji.sdk.mqtt.state; + +import com.dji.sdk.mqtt.CommonTopicRequest; + +/** + * @author sean + * @version 1.7 + * @date 2023/5/24 + */ +public class TopicStateRequest extends CommonTopicRequest { + + private String gateway; + + private String from; + + private boolean needReply; + + public TopicStateRequest() { + } + + @Override + public String toString() { + return "TopicStateRequest{" + + "gateway='" + gateway + '\'' + + ", from='" + from + '\'' + + ", needReply=" + needReply + + ", tid='" + tid + '\'' + + ", bid='" + bid + '\'' + + ", timestamp=" + timestamp + + ", data=" + data + + '}'; + } + + public String getTid() { + return tid; + } + + public TopicStateRequest setTid(String tid) { + this.tid = tid; + return this; + } + + public String getBid() { + return bid; + } + + public TopicStateRequest setBid(String bid) { + this.bid = bid; + return this; + } + + public Long getTimestamp() { + return timestamp; + } + + public TopicStateRequest setTimestamp(Long timestamp) { + this.timestamp = timestamp; + return this; + } + + public T getData() { + return data; + } + + public TopicStateRequest setData(T data) { + this.data = data; + return this; + } + + public String getGateway() { + return gateway; + } + + public TopicStateRequest setGateway(String gateway) { + this.gateway = gateway; + return this; + } + + public String getFrom() { + return from; + } + + public TopicStateRequest setFrom(String from) { + this.from = from; + return this; + } + + public boolean isNeedReply() { + return needReply; + } + + public TopicStateRequest setNeedReply(boolean needReply) { + this.needReply = needReply; + return this; + } +} diff --git a/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/TopicStateResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/TopicStateResponse.java new file mode 100644 index 0000000..8ab4106 --- /dev/null +++ b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/TopicStateResponse.java @@ -0,0 +1,68 @@ +package com.dji.sdk.mqtt.state; + +import com.dji.sdk.mqtt.CommonTopicResponse; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/11 + */ +public class TopicStateResponse extends CommonTopicResponse { + + public TopicStateResponse() { + } + + @Override + public String toString() { + return "TopicStateResponse{" + + "tid='" + tid + '\'' + + ", bid='" + bid + '\'' + + ", data=" + data + + ", timestamp=" + timestamp + + '}'; + } + + @Override + public String getTid() { + return super.getTid(); + } + + @Override + public TopicStateResponse setTid(String tid) { + super.setTid(tid); + return this; + } + + @Override + public String getBid() { + return super.getBid(); + } + + @Override + public TopicStateResponse setBid(String bid) { + super.setBid(bid); + return this; + } + + @Override + public T getData() { + return super.getData(); + } + + @Override + public TopicStateResponse setData(T data) { + super.setData(data); + return this; + } + + @Override + public Long getTimestamp() { + return super.getTimestamp(); + } + + @Override + public TopicStateResponse setTimestamp(Long timestamp) { + super.setTimestamp(timestamp); + return this; + } +} diff --git a/src/main/java/com/dji/sdk/mqtt/status/StatusRouter.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/status/StatusRouter.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/status/StatusRouter.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/status/StatusRouter.java diff --git a/src/main/java/com/dji/sdk/mqtt/status/StatusSubscribe.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/status/StatusSubscribe.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/status/StatusSubscribe.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/status/StatusSubscribe.java diff --git a/src/main/java/com/dji/sdk/mqtt/status/TopicStatusRequest.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/status/TopicStatusRequest.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/status/TopicStatusRequest.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/status/TopicStatusRequest.java diff --git a/src/main/java/com/dji/sdk/mqtt/status/TopicStatusResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/mqtt/status/TopicStatusResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/mqtt/status/TopicStatusResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/mqtt/status/TopicStatusResponse.java diff --git a/src/main/java/com/dji/sdk/swagger/SwaggerConfig.java b/cloud-sdk/src/main/java/com/dji/sdk/swagger/SwaggerConfig.java similarity index 100% rename from src/main/java/com/dji/sdk/swagger/SwaggerConfig.java rename to cloud-sdk/src/main/java/com/dji/sdk/swagger/SwaggerConfig.java diff --git a/src/main/java/com/dji/sdk/websocket/BizCodeEnum.java b/cloud-sdk/src/main/java/com/dji/sdk/websocket/BizCodeEnum.java similarity index 100% rename from src/main/java/com/dji/sdk/websocket/BizCodeEnum.java rename to cloud-sdk/src/main/java/com/dji/sdk/websocket/BizCodeEnum.java diff --git a/src/main/java/com/dji/sdk/websocket/ConcurrentWebSocketSession.java b/cloud-sdk/src/main/java/com/dji/sdk/websocket/ConcurrentWebSocketSession.java similarity index 100% rename from src/main/java/com/dji/sdk/websocket/ConcurrentWebSocketSession.java rename to cloud-sdk/src/main/java/com/dji/sdk/websocket/ConcurrentWebSocketSession.java diff --git a/src/main/java/com/dji/sdk/websocket/WebSocketConfiguration.java b/cloud-sdk/src/main/java/com/dji/sdk/websocket/WebSocketConfiguration.java similarity index 100% rename from src/main/java/com/dji/sdk/websocket/WebSocketConfiguration.java rename to cloud-sdk/src/main/java/com/dji/sdk/websocket/WebSocketConfiguration.java diff --git a/src/main/java/com/dji/sdk/websocket/WebSocketDefaultFactory.java b/cloud-sdk/src/main/java/com/dji/sdk/websocket/WebSocketDefaultFactory.java similarity index 100% rename from src/main/java/com/dji/sdk/websocket/WebSocketDefaultFactory.java rename to cloud-sdk/src/main/java/com/dji/sdk/websocket/WebSocketDefaultFactory.java diff --git a/src/main/java/com/dji/sdk/websocket/WebSocketDefaultHandler.java b/cloud-sdk/src/main/java/com/dji/sdk/websocket/WebSocketDefaultHandler.java similarity index 100% rename from src/main/java/com/dji/sdk/websocket/WebSocketDefaultHandler.java rename to cloud-sdk/src/main/java/com/dji/sdk/websocket/WebSocketDefaultHandler.java diff --git a/src/main/java/com/dji/sdk/websocket/WebSocketMessageResponse.java b/cloud-sdk/src/main/java/com/dji/sdk/websocket/WebSocketMessageResponse.java similarity index 100% rename from src/main/java/com/dji/sdk/websocket/WebSocketMessageResponse.java rename to cloud-sdk/src/main/java/com/dji/sdk/websocket/WebSocketMessageResponse.java diff --git a/src/main/java/com/dji/sdk/websocket/api/WebSocketMessageSend.java b/cloud-sdk/src/main/java/com/dji/sdk/websocket/api/WebSocketMessageSend.java similarity index 100% rename from src/main/java/com/dji/sdk/websocket/api/WebSocketMessageSend.java rename to cloud-sdk/src/main/java/com/dji/sdk/websocket/api/WebSocketMessageSend.java diff --git a/pom.xml b/pom.xml index 65db1ed..fd51c25 100644 --- a/pom.xml +++ b/pom.xml @@ -2,85 +2,41 @@ 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.7.12 - - + pom + + cloud-sdk + sample + com.dji cloud-api-sample - 1.8.0 + ${revision} cloud-api-sample + 1.9.0 + 1.0.2 11 - 3.4.2 - 1.2.6 - 3.12.1 - 5.5.5 - 8.3.7 - 4.9.1 - 3.1.0 - 3.12.0 + 11 + 11 1.1.1 - 2.3.3 - 2.15.0 - 2.3.0 + 5.5.5 - - - org.springframework.boot - spring-boot-starter-web - - - - mysql - mysql-connector-java - 8.0.31 - - - - org.projectlombok - lombok - true - - - org.springframework.boot - spring-boot-starter-test - test - - - - com.baomidou - mybatis-plus-boot-starter - ${mybatis-plus.version} - - - - com.alibaba - druid-spring-boot-starter - ${druid.version} - - - - com.auth0 - java-jwt - ${jwt.version} - + + + + org.springframework.boot + spring-boot-starter-parent + 2.7.12 + pom + import + - - org.springframework.integration - spring-integration-mqtt - ${mqtt.version} - + + - - org.springframework.boot - spring-boot-starter-websocket - + org.jetbrains annotations @@ -89,63 +45,20 @@ - io.minio - minio - ${minio.version} - - - - com.squareup.okhttp3 - okhttp - ${okhttp3.version} - - - - com.aliyun - aliyun-java-sdk-sts - ${aliyun-sdk-sts.version} - - - - com.aliyun.oss - aliyun-sdk-oss - ${aliyun-oss.version} + org.springframework.integration + spring-integration-mqtt + ${mqtt.version} - - javax.xml.bind - jaxb-api - javax.activation activation ${javax-activation.version} - - - org.glassfish.jaxb - jaxb-runtime - ${glassfish-jaxb.version} - org.springframework.boot - spring-boot-starter-data-redis - - - org.apache.commons - commons-pool2 - - - - com.amazonaws - aws-java-sdk-s3 - 1.12.261 - - - com.amazonaws - aws-java-sdk-sts - 1.12.261 + spring-boot-starter-validation @@ -153,45 +66,6 @@ jackson-datatype-jsr310 - - org.springframework.boot - spring-boot-starter-aop - - - - org.dom4j - dom4j - 2.1.3 - - - - jaxen - jaxen - - - - org.bouncycastle - bcpkix-jdk15on - 1.69 - - - - org.springframework.boot - spring-boot-starter-validation - - - - - - - - - - org.springdoc - springdoc-openapi-ui - 1.7.0 - - diff --git a/sample/pom.xml b/sample/pom.xml new file mode 100644 index 0000000..575608d --- /dev/null +++ b/sample/pom.xml @@ -0,0 +1,148 @@ + + + + cloud-api-sample + com.dji + ${revision} + + 4.0.0 + + sample + ${revision} + + + 8.0.31 + 3.4.2 + 1.2.6 + 3.12.1 + 8.3.7 + 4.9.1 + 3.1.0 + 3.12.0 + 2.3.3 + 2.15.0 + 2.3.0 + + + + + com.dji + cloud-sdk + ${cloud-sdk.revision} + + + org.springframework.boot + spring-boot-starter-web + + + + mysql + mysql-connector-java + ${mysql.version} + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + + com.auth0 + java-jwt + ${jwt.version} + + + + io.minio + minio + ${minio.version} + + + + com.squareup.okhttp3 + okhttp + ${okhttp3.version} + + + + com.aliyun + aliyun-java-sdk-sts + ${aliyun-sdk-sts.version} + + + + com.aliyun.oss + aliyun-sdk-oss + ${aliyun-oss.version} + + + + javax.xml.bind + jaxb-api + + + + + org.glassfish.jaxb + jaxb-runtime + ${glassfish-jaxb.version} + + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.apache.commons + commons-pool2 + + + + com.amazonaws + aws-java-sdk-s3 + 1.12.261 + + + com.amazonaws + aws-java-sdk-sts + 1.12.261 + + + + org.dom4j + dom4j + 2.1.3 + + + + jaxen + jaxen + + + + org.bouncycastle + bcpkix-jdk15on + 1.69 + + + + \ No newline at end of file diff --git a/src/main/java/com/dji/sample/CloudApiSampleApplication.java b/sample/src/main/java/com/dji/sample/CloudApiSampleApplication.java similarity index 100% rename from src/main/java/com/dji/sample/CloudApiSampleApplication.java rename to sample/src/main/java/com/dji/sample/CloudApiSampleApplication.java diff --git a/src/main/java/com/dji/sample/common/error/CommonErrorEnum.java b/sample/src/main/java/com/dji/sample/common/error/CommonErrorEnum.java similarity index 100% rename from src/main/java/com/dji/sample/common/error/CommonErrorEnum.java rename to sample/src/main/java/com/dji/sample/common/error/CommonErrorEnum.java diff --git a/src/main/java/com/dji/sample/common/model/CustomClaim.java b/sample/src/main/java/com/dji/sample/common/model/CustomClaim.java similarity index 100% rename from src/main/java/com/dji/sample/common/model/CustomClaim.java rename to sample/src/main/java/com/dji/sample/common/model/CustomClaim.java diff --git a/src/main/java/com/dji/sample/common/util/JwtUtil.java b/sample/src/main/java/com/dji/sample/common/util/JwtUtil.java similarity index 100% rename from src/main/java/com/dji/sample/common/util/JwtUtil.java rename to sample/src/main/java/com/dji/sample/common/util/JwtUtil.java diff --git a/src/main/java/com/dji/sample/common/util/SpringBeanUtilsTest.java b/sample/src/main/java/com/dji/sample/common/util/SpringBeanUtilsTest.java similarity index 100% rename from src/main/java/com/dji/sample/common/util/SpringBeanUtilsTest.java rename to sample/src/main/java/com/dji/sample/common/util/SpringBeanUtilsTest.java diff --git a/src/main/java/com/dji/sample/component/ApplicationBootInitial.java b/sample/src/main/java/com/dji/sample/component/ApplicationBootInitial.java similarity index 100% rename from src/main/java/com/dji/sample/component/ApplicationBootInitial.java rename to sample/src/main/java/com/dji/sample/component/ApplicationBootInitial.java diff --git a/src/main/java/com/dji/sample/component/AuthInterceptor.java b/sample/src/main/java/com/dji/sample/component/AuthInterceptor.java similarity index 100% rename from src/main/java/com/dji/sample/component/AuthInterceptor.java rename to sample/src/main/java/com/dji/sample/component/AuthInterceptor.java diff --git a/src/main/java/com/dji/sample/component/CorsFilter.java b/sample/src/main/java/com/dji/sample/component/CorsFilter.java similarity index 100% rename from src/main/java/com/dji/sample/component/CorsFilter.java rename to sample/src/main/java/com/dji/sample/component/CorsFilter.java diff --git a/src/main/java/com/dji/sample/component/GlobalExceptionHandler.java b/sample/src/main/java/com/dji/sample/component/GlobalExceptionHandler.java similarity index 100% rename from src/main/java/com/dji/sample/component/GlobalExceptionHandler.java rename to sample/src/main/java/com/dji/sample/component/GlobalExceptionHandler.java diff --git a/src/main/java/com/dji/sample/component/GlobalScheduleService.java b/sample/src/main/java/com/dji/sample/component/GlobalScheduleService.java similarity index 100% rename from src/main/java/com/dji/sample/component/GlobalScheduleService.java rename to sample/src/main/java/com/dji/sample/component/GlobalScheduleService.java diff --git a/src/main/java/com/dji/sample/component/mqtt/config/MqttMessageChannel.java b/sample/src/main/java/com/dji/sample/component/mqtt/config/MqttMessageChannel.java similarity index 100% rename from src/main/java/com/dji/sample/component/mqtt/config/MqttMessageChannel.java rename to sample/src/main/java/com/dji/sample/component/mqtt/config/MqttMessageChannel.java diff --git a/src/main/java/com/dji/sample/component/mqtt/config/MqttPropertyConfiguration.java b/sample/src/main/java/com/dji/sample/component/mqtt/config/MqttPropertyConfiguration.java similarity index 100% rename from src/main/java/com/dji/sample/component/mqtt/config/MqttPropertyConfiguration.java rename to sample/src/main/java/com/dji/sample/component/mqtt/config/MqttPropertyConfiguration.java diff --git a/src/main/java/com/dji/sample/component/mqtt/model/EventsReceiver.java b/sample/src/main/java/com/dji/sample/component/mqtt/model/EventsReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/component/mqtt/model/EventsReceiver.java rename to sample/src/main/java/com/dji/sample/component/mqtt/model/EventsReceiver.java diff --git a/src/main/java/com/dji/sample/component/mqtt/model/MapKeyConst.java b/sample/src/main/java/com/dji/sample/component/mqtt/model/MapKeyConst.java similarity index 100% rename from src/main/java/com/dji/sample/component/mqtt/model/MapKeyConst.java rename to sample/src/main/java/com/dji/sample/component/mqtt/model/MapKeyConst.java diff --git a/src/main/java/com/dji/sample/component/mqtt/model/MqttClientOptions.java b/sample/src/main/java/com/dji/sample/component/mqtt/model/MqttClientOptions.java similarity index 100% rename from src/main/java/com/dji/sample/component/mqtt/model/MqttClientOptions.java rename to sample/src/main/java/com/dji/sample/component/mqtt/model/MqttClientOptions.java diff --git a/src/main/java/com/dji/sample/component/mqtt/model/MqttProtocolEnum.java b/sample/src/main/java/com/dji/sample/component/mqtt/model/MqttProtocolEnum.java similarity index 100% rename from src/main/java/com/dji/sample/component/mqtt/model/MqttProtocolEnum.java rename to sample/src/main/java/com/dji/sample/component/mqtt/model/MqttProtocolEnum.java diff --git a/src/main/java/com/dji/sample/component/mqtt/model/MqttUseEnum.java b/sample/src/main/java/com/dji/sample/component/mqtt/model/MqttUseEnum.java similarity index 100% rename from src/main/java/com/dji/sample/component/mqtt/model/MqttUseEnum.java rename to sample/src/main/java/com/dji/sample/component/mqtt/model/MqttUseEnum.java diff --git a/src/main/java/com/dji/sample/component/mybatis/MybatisPlusConfiguration.java b/sample/src/main/java/com/dji/sample/component/mybatis/MybatisPlusConfiguration.java similarity index 100% rename from src/main/java/com/dji/sample/component/mybatis/MybatisPlusConfiguration.java rename to sample/src/main/java/com/dji/sample/component/mybatis/MybatisPlusConfiguration.java diff --git a/src/main/java/com/dji/sample/component/mybatis/MybatisPlusMetaObjectHandler.java b/sample/src/main/java/com/dji/sample/component/mybatis/MybatisPlusMetaObjectHandler.java similarity index 100% rename from src/main/java/com/dji/sample/component/mybatis/MybatisPlusMetaObjectHandler.java rename to sample/src/main/java/com/dji/sample/component/mybatis/MybatisPlusMetaObjectHandler.java diff --git a/src/main/java/com/dji/sample/component/oss/model/OssConfiguration.java b/sample/src/main/java/com/dji/sample/component/oss/model/OssConfiguration.java similarity index 100% rename from src/main/java/com/dji/sample/component/oss/model/OssConfiguration.java rename to sample/src/main/java/com/dji/sample/component/oss/model/OssConfiguration.java diff --git a/src/main/java/com/dji/sample/component/oss/service/IOssService.java b/sample/src/main/java/com/dji/sample/component/oss/service/IOssService.java similarity index 100% rename from src/main/java/com/dji/sample/component/oss/service/IOssService.java rename to sample/src/main/java/com/dji/sample/component/oss/service/IOssService.java diff --git a/sample/src/main/java/com/dji/sample/component/oss/service/impl/AliyunOssServiceImpl.java b/sample/src/main/java/com/dji/sample/component/oss/service/impl/AliyunOssServiceImpl.java new file mode 100644 index 0000000..03d65a6 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/component/oss/service/impl/AliyunOssServiceImpl.java @@ -0,0 +1,108 @@ +package com.dji.sample.component.oss.service.impl; + +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; +import com.aliyun.oss.OSSException; +import com.aliyun.oss.model.ObjectMetadata; +import com.aliyun.oss.model.PutObjectRequest; +import com.aliyun.oss.model.PutObjectResult; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.exceptions.ClientException; +import com.aliyuncs.profile.DefaultProfile; +import com.aliyuncs.sts.model.v20150401.AssumeRoleRequest; +import com.aliyuncs.sts.model.v20150401.AssumeRoleResponse; +import com.dji.sample.component.oss.model.OssConfiguration; +import com.dji.sample.component.oss.service.IOssService; +import com.dji.sdk.cloudapi.storage.CredentialsToken; +import com.dji.sdk.cloudapi.storage.OssTypeEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.io.InputStream; +import java.net.URL; +import java.util.Date; +import java.util.Objects; + +/** + * @author sean + * @version 0.3 + * @date 2021/12/23 + */ +@Service +@Slf4j +public class AliyunOssServiceImpl implements IOssService { + + private OSS ossClient; + + @Override + public OssTypeEnum getOssType() { + return OssTypeEnum.ALIYUN; + } + + @Override + public CredentialsToken getCredentials() { + + try { + DefaultProfile profile = DefaultProfile.getProfile( + OssConfiguration.region, OssConfiguration.accessKey, OssConfiguration.secretKey); + IAcsClient client = new DefaultAcsClient(profile); + + AssumeRoleRequest request = new AssumeRoleRequest(); + request.setDurationSeconds(OssConfiguration.expire); + request.setRoleArn(OssConfiguration.roleArn); + request.setRoleSessionName(OssConfiguration.roleSessionName); + + AssumeRoleResponse.Credentials response = client.getAcsResponse(request).getCredentials(); + return new CredentialsToken(response.getAccessKeyId(), response.getAccessKeySecret(), response.getSecurityToken(), OssConfiguration.expire); + + } catch (ClientException e) { + log.debug("Failed to obtain sts."); + e.printStackTrace(); + } + return null; + } + + @Override + public URL getObjectUrl(String bucket, String objectKey) { + // First check if the object can be fetched. + boolean isExist = ossClient.doesObjectExist(bucket, objectKey); + if (!isExist) { + throw new OSSException("The object does not exist."); + } + + return ossClient.generatePresignedUrl(bucket, objectKey, + new Date(System.currentTimeMillis() + OssConfiguration.expire * 1000)); + } + + @Override + public Boolean deleteObject(String bucket, String objectKey) { + if (!ossClient.doesObjectExist(bucket, objectKey)) { + return true; + } + ossClient.deleteObject(bucket, objectKey); + return true; + } + + @Override + public InputStream getObject(String bucket, String objectKey) { + return ossClient.getObject(bucket, objectKey).getObjectContent(); + } + + @Override + public void putObject(String bucket, String objectKey, InputStream input) { + if (ossClient.doesObjectExist(bucket, objectKey)) { + throw new RuntimeException("The filename already exists."); + } + PutObjectResult objectResult = ossClient.putObject(new PutObjectRequest(bucket, objectKey, input, new ObjectMetadata())); + log.info("Upload FlighttaskCreateFile: {}", objectResult.getETag()); + } + + public void createClient() { + if (Objects.nonNull(this.ossClient)) { + return; + } + this.ossClient = new OSSClientBuilder() + .build(OssConfiguration.endpoint, OssConfiguration.accessKey, OssConfiguration.secretKey); + } +} diff --git a/sample/src/main/java/com/dji/sample/component/oss/service/impl/AmazonS3ServiceImpl.java b/sample/src/main/java/com/dji/sample/component/oss/service/impl/AmazonS3ServiceImpl.java new file mode 100644 index 0000000..dabc0bd --- /dev/null +++ b/sample/src/main/java/com/dji/sample/component/oss/service/impl/AmazonS3ServiceImpl.java @@ -0,0 +1,126 @@ +package com.dji.sample.component.oss.service.impl; + +import com.amazonaws.HttpMethod; +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.AmazonS3ClientBuilder; +import com.amazonaws.services.s3.model.*; +import com.amazonaws.services.securitytoken.AWSSecurityTokenService; +import com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClientBuilder; +import com.amazonaws.services.securitytoken.model.AssumeRoleRequest; +import com.amazonaws.services.securitytoken.model.AssumeRoleResult; +import com.amazonaws.services.securitytoken.model.Credentials; +import com.dji.sample.component.AuthInterceptor; +import com.dji.sample.component.oss.model.OssConfiguration; +import com.dji.sample.component.oss.service.IOssService; +import com.dji.sdk.cloudapi.storage.CredentialsToken; +import com.dji.sdk.cloudapi.storage.OssTypeEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +/** + * @author sean + * @version 1.0 + * @date 2022/4/27 + */ +@Slf4j +@Service +public class AmazonS3ServiceImpl implements IOssService { + + private AmazonS3 client; + + @Override + public OssTypeEnum getOssType() { + return OssTypeEnum.AWS; + } + + @Override + public CredentialsToken getCredentials() { + AWSSecurityTokenService stsClient = AWSSecurityTokenServiceClientBuilder.standard() + .withCredentials(new AWSStaticCredentialsProvider( + new BasicAWSCredentials(OssConfiguration.accessKey, OssConfiguration.secretKey))) + .withRegion(OssConfiguration.region).build(); + + AssumeRoleRequest request = new AssumeRoleRequest() + .withRoleArn(OssConfiguration.roleArn) + .withRoleSessionName(OssConfiguration.roleSessionName) + .withDurationSeconds(Math.toIntExact(OssConfiguration.expire)); + AssumeRoleResult result = stsClient.assumeRole(request); + Credentials credentials = result.getCredentials(); + return new CredentialsToken(credentials.getAccessKeyId(), credentials.getSecretAccessKey(), + credentials.getSessionToken(), (credentials.getExpiration().getTime() - System.currentTimeMillis()) / 1000); + } + + @Override + public URL getObjectUrl(String bucket, String objectKey) { + return client.generatePresignedUrl(bucket, objectKey, + new Date(System.currentTimeMillis() + OssConfiguration.expire * 1000), HttpMethod.GET); + } + + @Override + public Boolean deleteObject(String bucket, String objectKey) { + if (!client.doesObjectExist(bucket, objectKey)) { + return true; + } + client.deleteObject(bucket, objectKey); + return true; + } + + public InputStream getObject(String bucket, String objectKey) { + return client.getObject(bucket, objectKey).getObjectContent().getDelegateStream(); + } + + @Override + public void putObject(String bucket, String objectKey, InputStream input) { + if (client.doesObjectExist(bucket, objectKey)) { + throw new RuntimeException("The filename already exists."); + } + PutObjectResult objectResult = client.putObject(new PutObjectRequest(bucket, objectKey, input, new ObjectMetadata())); + log.info("Upload FlighttaskCreateFile: {}", objectResult.toString()); + } + + public void createClient() { + if (Objects.nonNull(this.client)) { + return; + } + this.client = AmazonS3ClientBuilder.standard() + .withCredentials( + new AWSStaticCredentialsProvider( + new BasicAWSCredentials(OssConfiguration.accessKey, OssConfiguration.secretKey))) + .withRegion(OssConfiguration.region) + .build(); + } + + /** + * Configuring cross-origin resource sharing + */ + @PostConstruct + private void configCORS() { + if (!OssConfiguration.enable || !OssTypeEnum.AWS.getType().equals(OssConfiguration.provider)) { + return; + } + List allowedMethods = new ArrayList<>(); + allowedMethods.add(CORSRule.AllowedMethods.GET); + allowedMethods.add(CORSRule.AllowedMethods.POST); + allowedMethods.add(CORSRule.AllowedMethods.DELETE); + + CORSRule rule = new CORSRule() + .withId("CORSAccessRule") + .withAllowedOrigins(List.of("*")) + .withAllowedHeaders(List.of(AuthInterceptor.PARAM_TOKEN)) + .withAllowedMethods(allowedMethods); + + client.setBucketCrossOriginConfiguration(OssConfiguration.bucket, + new BucketCrossOriginConfiguration().withRules(rule)); + + } +} diff --git a/sample/src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java b/sample/src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java new file mode 100644 index 0000000..af21aa6 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java @@ -0,0 +1,123 @@ +package com.dji.sample.component.oss.service.impl; + +import com.dji.sample.component.oss.model.OssConfiguration; +import com.dji.sample.component.oss.service.IOssService; +import com.dji.sdk.cloudapi.storage.CredentialsToken; +import com.dji.sdk.cloudapi.storage.OssTypeEnum; +import io.minio.*; +import io.minio.credentials.AssumeRoleProvider; +import io.minio.credentials.Credentials; +import io.minio.errors.*; +import io.minio.http.Method; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.Objects; + +/** + * @author sean + * @version 0.3 + * @date 2021/12/23 + */ +@Service +@Slf4j +public class MinIOServiceImpl implements IOssService { + + private MinioClient client; + + @Override + public OssTypeEnum getOssType() { + return OssTypeEnum.MINIO; + } + + @Override + public CredentialsToken getCredentials() { + try { + AssumeRoleProvider provider = new AssumeRoleProvider(OssConfiguration.endpoint, OssConfiguration.accessKey, + OssConfiguration.secretKey, Math.toIntExact(OssConfiguration.expire), + null, OssConfiguration.region, null, null, null, null); + Credentials credential = provider.fetch(); + return new CredentialsToken(credential.accessKey(), credential.secretKey(), credential.sessionToken(), OssConfiguration.expire); + } catch (NoSuchAlgorithmException e) { + log.debug("Failed to obtain sts."); + e.printStackTrace(); + } + return null; + } + + @Override + public URL getObjectUrl(String bucket, String objectKey) { + try { + return new URL( + client.getPresignedObjectUrl( + GetPresignedObjectUrlArgs.builder() + .method(Method.GET) + .bucket(bucket) + .object(objectKey) + .expiry(Math.toIntExact(OssConfiguration.expire)) + .build())); + } catch (ErrorResponseException | InsufficientDataException | InternalException | + InvalidKeyException | InvalidResponseException | IOException | + NoSuchAlgorithmException | XmlParserException | ServerException e) { + throw new RuntimeException("The file does not exist on the OssConfiguration."); + } + } + + @Override + public Boolean deleteObject(String bucket, String objectKey) { + try { + client.removeObject(RemoveObjectArgs.builder().bucket(bucket).object(objectKey).build()); + } catch (MinioException | NoSuchAlgorithmException | IOException | InvalidKeyException e) { + log.error("Failed to delete file."); + e.printStackTrace(); + return false; + } + return true; + } + + @Override + public InputStream getObject(String bucket, String objectKey) { + try { + GetObjectResponse object = client.getObject(GetObjectArgs.builder().bucket(bucket).object(objectKey).build()); + return new ByteArrayInputStream(object.readAllBytes()); + } catch (ErrorResponseException | InsufficientDataException | InternalException | InvalidKeyException | InvalidResponseException | IOException | NoSuchAlgorithmException | ServerException | XmlParserException e) { + e.printStackTrace(); + } + return InputStream.nullInputStream(); + } + + @Override + public void putObject(String bucket, String objectKey, InputStream input) { + try { + client.statObject(StatObjectArgs.builder().bucket(bucket).object(objectKey).build()); + throw new RuntimeException("The filename already exists."); + } catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) { + log.info("The file does not exist, start uploading."); + try { + ObjectWriteResponse response = client.putObject( + PutObjectArgs.builder().bucket(bucket).object(objectKey).stream(input, input.available(), 0).build()); + log.info("Upload FlighttaskCreateFile: {}", response.etag()); + } catch (MinioException | IOException | InvalidKeyException | NoSuchAlgorithmException ex) { + log.error("Failed to upload FlighttaskCreateFile {}.", objectKey); + ex.printStackTrace(); + } + } + } + + public void createClient() { + if (Objects.nonNull(this.client)) { + return; + } + this.client = MinioClient.builder() + .endpoint(OssConfiguration.endpoint) + .credentials(OssConfiguration.accessKey, OssConfiguration.secretKey) + .region(OssConfiguration.region) + .build(); + } +} diff --git a/src/main/java/com/dji/sample/component/oss/service/impl/OssAspectHandler.java b/sample/src/main/java/com/dji/sample/component/oss/service/impl/OssAspectHandler.java similarity index 100% rename from src/main/java/com/dji/sample/component/oss/service/impl/OssAspectHandler.java rename to sample/src/main/java/com/dji/sample/component/oss/service/impl/OssAspectHandler.java diff --git a/src/main/java/com/dji/sample/component/oss/service/impl/OssServiceContext.java b/sample/src/main/java/com/dji/sample/component/oss/service/impl/OssServiceContext.java similarity index 100% rename from src/main/java/com/dji/sample/component/oss/service/impl/OssServiceContext.java rename to sample/src/main/java/com/dji/sample/component/oss/service/impl/OssServiceContext.java diff --git a/src/main/java/com/dji/sample/component/redis/RedisConfiguration.java b/sample/src/main/java/com/dji/sample/component/redis/RedisConfiguration.java similarity index 100% rename from src/main/java/com/dji/sample/component/redis/RedisConfiguration.java rename to sample/src/main/java/com/dji/sample/component/redis/RedisConfiguration.java diff --git a/src/main/java/com/dji/sample/component/redis/RedisConst.java b/sample/src/main/java/com/dji/sample/component/redis/RedisConst.java similarity index 100% rename from src/main/java/com/dji/sample/component/redis/RedisConst.java rename to sample/src/main/java/com/dji/sample/component/redis/RedisConst.java diff --git a/src/main/java/com/dji/sample/component/redis/RedisOpsUtils.java b/sample/src/main/java/com/dji/sample/component/redis/RedisOpsUtils.java similarity index 100% rename from src/main/java/com/dji/sample/component/redis/RedisOpsUtils.java rename to sample/src/main/java/com/dji/sample/component/redis/RedisOpsUtils.java diff --git a/src/main/java/com/dji/sample/component/websocket/config/AuthPrincipalHandler.java b/sample/src/main/java/com/dji/sample/component/websocket/config/AuthPrincipalHandler.java similarity index 100% rename from src/main/java/com/dji/sample/component/websocket/config/AuthPrincipalHandler.java rename to sample/src/main/java/com/dji/sample/component/websocket/config/AuthPrincipalHandler.java diff --git a/src/main/java/com/dji/sample/component/websocket/config/MyConcurrentWebSocketSession.java b/sample/src/main/java/com/dji/sample/component/websocket/config/MyConcurrentWebSocketSession.java similarity index 100% rename from src/main/java/com/dji/sample/component/websocket/config/MyConcurrentWebSocketSession.java rename to sample/src/main/java/com/dji/sample/component/websocket/config/MyConcurrentWebSocketSession.java diff --git a/src/main/java/com/dji/sample/component/websocket/config/MyWebSocketFactory.java b/sample/src/main/java/com/dji/sample/component/websocket/config/MyWebSocketFactory.java similarity index 100% rename from src/main/java/com/dji/sample/component/websocket/config/MyWebSocketFactory.java rename to sample/src/main/java/com/dji/sample/component/websocket/config/MyWebSocketFactory.java diff --git a/src/main/java/com/dji/sample/component/websocket/config/MyWebSocketHandler.java b/sample/src/main/java/com/dji/sample/component/websocket/config/MyWebSocketHandler.java similarity index 100% rename from src/main/java/com/dji/sample/component/websocket/config/MyWebSocketHandler.java rename to sample/src/main/java/com/dji/sample/component/websocket/config/MyWebSocketHandler.java diff --git a/sample/src/main/java/com/dji/sample/component/websocket/model/BizCodeEnum.java b/sample/src/main/java/com/dji/sample/component/websocket/model/BizCodeEnum.java new file mode 100644 index 0000000..2e5c630 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/component/websocket/model/BizCodeEnum.java @@ -0,0 +1,93 @@ +package com.dji.sample.component.websocket.model; + +/** + * @author sean + * @version 0.1 + * @date 2021/11/26 + */ +public enum BizCodeEnum { + + DEVICE_ONLINE("device_online"), + + DEVICE_OFFLINE("device_offline"), + + DEVICE_UPDATE_TOPO("device_update_topo"), + + DEVICE_OSD("device_osd"), + + RC_OSD("gateway_osd"), + + DOCK_OSD("dock_osd"), + + MAP_ELEMENT_CREATE("map_element_create"), + + MAP_ELEMENT_UPDATE("map_element_update"), + + MAP_ELEMENT_DELETE("map_element_delete"), + + MAP_GROUP_REFRESH("map_group_refresh"), + + FLIGHT_TASK_PROGRESS("flighttask_progress"), + + DEVICE_HMS("device_hms"), + + DEVICE_REBOOT("device_reboot"), + + DRONE_OPEN("drone_open"), + + DRONE_CLOSE("drone_close"), + + DEVICE_CHECK("device_check"), + + DRONE_FORMAT("drone_format"), + + DEVICE_FORMAT("device_format"), + + COVER_OPEN("cover_open"), + + COVER_CLOSE("cover_close"), + + PUTTER_OPEN("putter_open"), + + PUTTER_CLOSE("putter_close"), + + CHARGE_OPEN("charge_open"), + + CHARGE_CLOSE("charge_close"), + + FILE_UPLOAD_CALLBACK("file_upload_callback"), + + FILE_UPLOAD_PROGRESS("fileupload_progress"), + + OTA_PROGRESS("ota_progress"), + + HIGHEST_PRIORITY_UPLOAD_FLIGHT_TASK_MEDIA("highest_priority_upload_flighttask_media"), + + CONTROL_SOURCE_CHANGE("control_source_change"), + + FLY_TO_POINT_PROGRESS("fly_to_point_progress"), + + TAKE_OFF_TO_POINT_PROGRESS("takeoff_to_point_progress"), + + DRC_STATUS_NOTIFY("drc_status_notify"), + + JOYSTICK_INVALID_NOTIFY("joystick_invalid_notify"), + + FLIGHT_AREAS_SYNC_PROGRESS("flight_areas_sync_progress"), + + FLIGHT_AREAS_DRONE_LOCATION("flight_areas_drone_location"), + + FLIGHT_AREAS_UPDATE("flight_areas_update"), + + ; + + private String code; + + BizCodeEnum(String code) { + this.code = code; + } + + public String getCode() { + return code; + } +} diff --git a/src/main/java/com/dji/sample/component/websocket/service/IWebSocketManageService.java b/sample/src/main/java/com/dji/sample/component/websocket/service/IWebSocketManageService.java similarity index 100% rename from src/main/java/com/dji/sample/component/websocket/service/IWebSocketManageService.java rename to sample/src/main/java/com/dji/sample/component/websocket/service/IWebSocketManageService.java diff --git a/src/main/java/com/dji/sample/component/websocket/service/IWebSocketMessageService.java b/sample/src/main/java/com/dji/sample/component/websocket/service/IWebSocketMessageService.java similarity index 100% rename from src/main/java/com/dji/sample/component/websocket/service/IWebSocketMessageService.java rename to sample/src/main/java/com/dji/sample/component/websocket/service/IWebSocketMessageService.java diff --git a/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java b/sample/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java rename to sample/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java diff --git a/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketMessageServiceImpl.java b/sample/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketMessageServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketMessageServiceImpl.java rename to sample/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketMessageServiceImpl.java diff --git a/src/main/java/com/dji/sample/configuration/GlobalThreadPoolConfiguration.java b/sample/src/main/java/com/dji/sample/configuration/GlobalThreadPoolConfiguration.java similarity index 100% rename from src/main/java/com/dji/sample/configuration/GlobalThreadPoolConfiguration.java rename to sample/src/main/java/com/dji/sample/configuration/GlobalThreadPoolConfiguration.java diff --git a/src/main/java/com/dji/sample/configuration/SpringBeanConfiguration.java b/sample/src/main/java/com/dji/sample/configuration/SpringBeanConfiguration.java similarity index 100% rename from src/main/java/com/dji/sample/configuration/SpringBeanConfiguration.java rename to sample/src/main/java/com/dji/sample/configuration/SpringBeanConfiguration.java diff --git a/src/main/java/com/dji/sample/configuration/mvc/GlobalMVCConfigurer.java b/sample/src/main/java/com/dji/sample/configuration/mvc/GlobalMVCConfigurer.java similarity index 100% rename from src/main/java/com/dji/sample/configuration/mvc/GlobalMVCConfigurer.java rename to sample/src/main/java/com/dji/sample/configuration/mvc/GlobalMVCConfigurer.java diff --git a/src/main/java/com/dji/sample/control/controller/DockController.java b/sample/src/main/java/com/dji/sample/control/controller/DockController.java similarity index 100% rename from src/main/java/com/dji/sample/control/controller/DockController.java rename to sample/src/main/java/com/dji/sample/control/controller/DockController.java diff --git a/src/main/java/com/dji/sample/control/controller/DrcController.java b/sample/src/main/java/com/dji/sample/control/controller/DrcController.java similarity index 100% rename from src/main/java/com/dji/sample/control/controller/DrcController.java rename to sample/src/main/java/com/dji/sample/control/controller/DrcController.java diff --git a/src/main/java/com/dji/sample/control/model/dto/AirConditionerMode.java b/sample/src/main/java/com/dji/sample/control/model/dto/AirConditionerMode.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/dto/AirConditionerMode.java rename to sample/src/main/java/com/dji/sample/control/model/dto/AirConditionerMode.java diff --git a/src/main/java/com/dji/sample/control/model/dto/AlarmState.java b/sample/src/main/java/com/dji/sample/control/model/dto/AlarmState.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/dto/AlarmState.java rename to sample/src/main/java/com/dji/sample/control/model/dto/AlarmState.java diff --git a/src/main/java/com/dji/sample/control/model/dto/BatteryStoreMode.java b/sample/src/main/java/com/dji/sample/control/model/dto/BatteryStoreMode.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/dto/BatteryStoreMode.java rename to sample/src/main/java/com/dji/sample/control/model/dto/BatteryStoreMode.java diff --git a/src/main/java/com/dji/sample/control/model/dto/JwtAclDTO.java b/sample/src/main/java/com/dji/sample/control/model/dto/JwtAclDTO.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/dto/JwtAclDTO.java rename to sample/src/main/java/com/dji/sample/control/model/dto/JwtAclDTO.java diff --git a/src/main/java/com/dji/sample/control/model/dto/LinkWorkMode.java b/sample/src/main/java/com/dji/sample/control/model/dto/LinkWorkMode.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/dto/LinkWorkMode.java rename to sample/src/main/java/com/dji/sample/control/model/dto/LinkWorkMode.java diff --git a/src/main/java/com/dji/sample/control/model/dto/RemoteDebugOpenState.java b/sample/src/main/java/com/dji/sample/control/model/dto/RemoteDebugOpenState.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/dto/RemoteDebugOpenState.java rename to sample/src/main/java/com/dji/sample/control/model/dto/RemoteDebugOpenState.java diff --git a/src/main/java/com/dji/sample/control/model/dto/ResultNotifyDTO.java b/sample/src/main/java/com/dji/sample/control/model/dto/ResultNotifyDTO.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/dto/ResultNotifyDTO.java rename to sample/src/main/java/com/dji/sample/control/model/dto/ResultNotifyDTO.java diff --git a/src/main/java/com/dji/sample/control/model/dto/ReturnHomeCancelState.java b/sample/src/main/java/com/dji/sample/control/model/dto/ReturnHomeCancelState.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/dto/ReturnHomeCancelState.java rename to sample/src/main/java/com/dji/sample/control/model/dto/ReturnHomeCancelState.java diff --git a/src/main/java/com/dji/sample/control/model/dto/ReturnHomeState.java b/sample/src/main/java/com/dji/sample/control/model/dto/ReturnHomeState.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/dto/ReturnHomeState.java rename to sample/src/main/java/com/dji/sample/control/model/dto/ReturnHomeState.java diff --git a/src/main/java/com/dji/sample/control/model/enums/CameraModeEnum.java b/sample/src/main/java/com/dji/sample/control/model/enums/CameraModeEnum.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/enums/CameraModeEnum.java rename to sample/src/main/java/com/dji/sample/control/model/enums/CameraModeEnum.java diff --git a/src/main/java/com/dji/sample/control/model/enums/DrcMethodEnum.java b/sample/src/main/java/com/dji/sample/control/model/enums/DrcMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/enums/DrcMethodEnum.java rename to sample/src/main/java/com/dji/sample/control/model/enums/DrcMethodEnum.java diff --git a/src/main/java/com/dji/sample/control/model/enums/DroneAuthorityEnum.java b/sample/src/main/java/com/dji/sample/control/model/enums/DroneAuthorityEnum.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/enums/DroneAuthorityEnum.java rename to sample/src/main/java/com/dji/sample/control/model/enums/DroneAuthorityEnum.java diff --git a/src/main/java/com/dji/sample/control/model/enums/DroneControlMethodEnum.java b/sample/src/main/java/com/dji/sample/control/model/enums/DroneControlMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/enums/DroneControlMethodEnum.java rename to sample/src/main/java/com/dji/sample/control/model/enums/DroneControlMethodEnum.java diff --git a/src/main/java/com/dji/sample/control/model/enums/GimbalResetModeEnum.java b/sample/src/main/java/com/dji/sample/control/model/enums/GimbalResetModeEnum.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/enums/GimbalResetModeEnum.java rename to sample/src/main/java/com/dji/sample/control/model/enums/GimbalResetModeEnum.java diff --git a/src/main/java/com/dji/sample/control/model/enums/MqttAclAccessEnum.java b/sample/src/main/java/com/dji/sample/control/model/enums/MqttAclAccessEnum.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/enums/MqttAclAccessEnum.java rename to sample/src/main/java/com/dji/sample/control/model/enums/MqttAclAccessEnum.java diff --git a/src/main/java/com/dji/sample/control/model/enums/PayloadCommandsEnum.java b/sample/src/main/java/com/dji/sample/control/model/enums/PayloadCommandsEnum.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/enums/PayloadCommandsEnum.java rename to sample/src/main/java/com/dji/sample/control/model/enums/PayloadCommandsEnum.java diff --git a/src/main/java/com/dji/sample/control/model/enums/RemoteDebugMethodEnum.java b/sample/src/main/java/com/dji/sample/control/model/enums/RemoteDebugMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/enums/RemoteDebugMethodEnum.java rename to sample/src/main/java/com/dji/sample/control/model/enums/RemoteDebugMethodEnum.java diff --git a/src/main/java/com/dji/sample/control/model/param/DeviceDrcInfoParam.java b/sample/src/main/java/com/dji/sample/control/model/param/DeviceDrcInfoParam.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/param/DeviceDrcInfoParam.java rename to sample/src/main/java/com/dji/sample/control/model/param/DeviceDrcInfoParam.java diff --git a/src/main/java/com/dji/sample/control/model/param/DrcConnectParam.java b/sample/src/main/java/com/dji/sample/control/model/param/DrcConnectParam.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/param/DrcConnectParam.java rename to sample/src/main/java/com/dji/sample/control/model/param/DrcConnectParam.java diff --git a/src/main/java/com/dji/sample/control/model/param/DrcModeParam.java b/sample/src/main/java/com/dji/sample/control/model/param/DrcModeParam.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/param/DrcModeParam.java rename to sample/src/main/java/com/dji/sample/control/model/param/DrcModeParam.java diff --git a/src/main/java/com/dji/sample/control/model/param/DronePayloadParam.java b/sample/src/main/java/com/dji/sample/control/model/param/DronePayloadParam.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/param/DronePayloadParam.java rename to sample/src/main/java/com/dji/sample/control/model/param/DronePayloadParam.java diff --git a/sample/src/main/java/com/dji/sample/control/model/param/FlyToPointParam.java b/sample/src/main/java/com/dji/sample/control/model/param/FlyToPointParam.java new file mode 100644 index 0000000..4c96423 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/control/model/param/FlyToPointParam.java @@ -0,0 +1,36 @@ +package com.dji.sample.control.model.param; + +import com.dji.sdk.cloudapi.control.Point; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Range; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @author sean + * @version 1.3 + * @date 2023/2/14 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class FlyToPointParam { + + private String flyToId; + + @Range(min = 1, max = 15) + @NotNull + private Integer maxSpeed; + + /** + * The M30 series only support one point. + */ + @Size(min = 1) + @NotNull + private List<@Valid Point> points; +} diff --git a/src/main/java/com/dji/sample/control/model/param/PayloadCommandsParam.java b/sample/src/main/java/com/dji/sample/control/model/param/PayloadCommandsParam.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/param/PayloadCommandsParam.java rename to sample/src/main/java/com/dji/sample/control/model/param/PayloadCommandsParam.java diff --git a/src/main/java/com/dji/sample/control/model/param/RemoteDebugParam.java b/sample/src/main/java/com/dji/sample/control/model/param/RemoteDebugParam.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/param/RemoteDebugParam.java rename to sample/src/main/java/com/dji/sample/control/model/param/RemoteDebugParam.java diff --git a/src/main/java/com/dji/sample/control/model/param/TakeoffToPointParam.java b/sample/src/main/java/com/dji/sample/control/model/param/TakeoffToPointParam.java similarity index 100% rename from src/main/java/com/dji/sample/control/model/param/TakeoffToPointParam.java rename to sample/src/main/java/com/dji/sample/control/model/param/TakeoffToPointParam.java diff --git a/src/main/java/com/dji/sample/control/service/IControlService.java b/sample/src/main/java/com/dji/sample/control/service/IControlService.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/IControlService.java rename to sample/src/main/java/com/dji/sample/control/service/IControlService.java diff --git a/src/main/java/com/dji/sample/control/service/IDrcService.java b/sample/src/main/java/com/dji/sample/control/service/IDrcService.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/IDrcService.java rename to sample/src/main/java/com/dji/sample/control/service/IDrcService.java diff --git a/src/main/java/com/dji/sample/control/service/impl/CameraAimImpl.java b/sample/src/main/java/com/dji/sample/control/service/impl/CameraAimImpl.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/CameraAimImpl.java rename to sample/src/main/java/com/dji/sample/control/service/impl/CameraAimImpl.java diff --git a/src/main/java/com/dji/sample/control/service/impl/CameraFocalLengthSetImpl.java b/sample/src/main/java/com/dji/sample/control/service/impl/CameraFocalLengthSetImpl.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/CameraFocalLengthSetImpl.java rename to sample/src/main/java/com/dji/sample/control/service/impl/CameraFocalLengthSetImpl.java diff --git a/src/main/java/com/dji/sample/control/service/impl/CameraModeSwitchImpl.java b/sample/src/main/java/com/dji/sample/control/service/impl/CameraModeSwitchImpl.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/CameraModeSwitchImpl.java rename to sample/src/main/java/com/dji/sample/control/service/impl/CameraModeSwitchImpl.java diff --git a/src/main/java/com/dji/sample/control/service/impl/CameraPhotoTakeImpl.java b/sample/src/main/java/com/dji/sample/control/service/impl/CameraPhotoTakeImpl.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/CameraPhotoTakeImpl.java rename to sample/src/main/java/com/dji/sample/control/service/impl/CameraPhotoTakeImpl.java diff --git a/src/main/java/com/dji/sample/control/service/impl/CameraRecordingStartImpl.java b/sample/src/main/java/com/dji/sample/control/service/impl/CameraRecordingStartImpl.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/CameraRecordingStartImpl.java rename to sample/src/main/java/com/dji/sample/control/service/impl/CameraRecordingStartImpl.java diff --git a/src/main/java/com/dji/sample/control/service/impl/CameraRecordingStopImpl.java b/sample/src/main/java/com/dji/sample/control/service/impl/CameraRecordingStopImpl.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/CameraRecordingStopImpl.java rename to sample/src/main/java/com/dji/sample/control/service/impl/CameraRecordingStopImpl.java diff --git a/src/main/java/com/dji/sample/control/service/impl/ControlServiceImpl.java b/sample/src/main/java/com/dji/sample/control/service/impl/ControlServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/ControlServiceImpl.java rename to sample/src/main/java/com/dji/sample/control/service/impl/ControlServiceImpl.java diff --git a/src/main/java/com/dji/sample/control/service/impl/DrcServiceImpl.java b/sample/src/main/java/com/dji/sample/control/service/impl/DrcServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/DrcServiceImpl.java rename to sample/src/main/java/com/dji/sample/control/service/impl/DrcServiceImpl.java diff --git a/src/main/java/com/dji/sample/control/service/impl/GimbalResetImpl.java b/sample/src/main/java/com/dji/sample/control/service/impl/GimbalResetImpl.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/GimbalResetImpl.java rename to sample/src/main/java/com/dji/sample/control/service/impl/GimbalResetImpl.java diff --git a/src/main/java/com/dji/sample/control/service/impl/PayloadCommandsHandler.java b/sample/src/main/java/com/dji/sample/control/service/impl/PayloadCommandsHandler.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/PayloadCommandsHandler.java rename to sample/src/main/java/com/dji/sample/control/service/impl/PayloadCommandsHandler.java diff --git a/src/main/java/com/dji/sample/control/service/impl/RemoteDebugHandler.java b/sample/src/main/java/com/dji/sample/control/service/impl/RemoteDebugHandler.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/RemoteDebugHandler.java rename to sample/src/main/java/com/dji/sample/control/service/impl/RemoteDebugHandler.java diff --git a/src/main/java/com/dji/sample/control/service/impl/SDKControlService.java b/sample/src/main/java/com/dji/sample/control/service/impl/SDKControlService.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/SDKControlService.java rename to sample/src/main/java/com/dji/sample/control/service/impl/SDKControlService.java diff --git a/src/main/java/com/dji/sample/control/service/impl/SDKRemoteDebug.java b/sample/src/main/java/com/dji/sample/control/service/impl/SDKRemoteDebug.java similarity index 100% rename from src/main/java/com/dji/sample/control/service/impl/SDKRemoteDebug.java rename to sample/src/main/java/com/dji/sample/control/service/impl/SDKRemoteDebug.java diff --git a/src/main/java/com/dji/sample/manage/controller/DeviceController.java b/sample/src/main/java/com/dji/sample/manage/controller/DeviceController.java similarity index 100% rename from src/main/java/com/dji/sample/manage/controller/DeviceController.java rename to sample/src/main/java/com/dji/sample/manage/controller/DeviceController.java diff --git a/src/main/java/com/dji/sample/manage/controller/DeviceFirmwareController.java b/sample/src/main/java/com/dji/sample/manage/controller/DeviceFirmwareController.java similarity index 100% rename from src/main/java/com/dji/sample/manage/controller/DeviceFirmwareController.java rename to sample/src/main/java/com/dji/sample/manage/controller/DeviceFirmwareController.java diff --git a/src/main/java/com/dji/sample/manage/controller/DeviceHmsController.java b/sample/src/main/java/com/dji/sample/manage/controller/DeviceHmsController.java similarity index 100% rename from src/main/java/com/dji/sample/manage/controller/DeviceHmsController.java rename to sample/src/main/java/com/dji/sample/manage/controller/DeviceHmsController.java diff --git a/src/main/java/com/dji/sample/manage/controller/DeviceLogsController.java b/sample/src/main/java/com/dji/sample/manage/controller/DeviceLogsController.java similarity index 100% rename from src/main/java/com/dji/sample/manage/controller/DeviceLogsController.java rename to sample/src/main/java/com/dji/sample/manage/controller/DeviceLogsController.java diff --git a/src/main/java/com/dji/sample/manage/controller/LiveStreamController.java b/sample/src/main/java/com/dji/sample/manage/controller/LiveStreamController.java similarity index 100% rename from src/main/java/com/dji/sample/manage/controller/LiveStreamController.java rename to sample/src/main/java/com/dji/sample/manage/controller/LiveStreamController.java diff --git a/src/main/java/com/dji/sample/manage/controller/LoginController.java b/sample/src/main/java/com/dji/sample/manage/controller/LoginController.java similarity index 100% rename from src/main/java/com/dji/sample/manage/controller/LoginController.java rename to sample/src/main/java/com/dji/sample/manage/controller/LoginController.java diff --git a/src/main/java/com/dji/sample/manage/controller/TopologyController.java b/sample/src/main/java/com/dji/sample/manage/controller/TopologyController.java similarity index 100% rename from src/main/java/com/dji/sample/manage/controller/TopologyController.java rename to sample/src/main/java/com/dji/sample/manage/controller/TopologyController.java diff --git a/src/main/java/com/dji/sample/manage/controller/UserController.java b/sample/src/main/java/com/dji/sample/manage/controller/UserController.java similarity index 100% rename from src/main/java/com/dji/sample/manage/controller/UserController.java rename to sample/src/main/java/com/dji/sample/manage/controller/UserController.java diff --git a/src/main/java/com/dji/sample/manage/controller/WorkspaceController.java b/sample/src/main/java/com/dji/sample/manage/controller/WorkspaceController.java similarity index 100% rename from src/main/java/com/dji/sample/manage/controller/WorkspaceController.java rename to sample/src/main/java/com/dji/sample/manage/controller/WorkspaceController.java diff --git a/src/main/java/com/dji/sample/manage/dao/IDeviceDictionaryMapper.java b/sample/src/main/java/com/dji/sample/manage/dao/IDeviceDictionaryMapper.java similarity index 100% rename from src/main/java/com/dji/sample/manage/dao/IDeviceDictionaryMapper.java rename to sample/src/main/java/com/dji/sample/manage/dao/IDeviceDictionaryMapper.java diff --git a/src/main/java/com/dji/sample/manage/dao/IDeviceFirmwareMapper.java b/sample/src/main/java/com/dji/sample/manage/dao/IDeviceFirmwareMapper.java similarity index 100% rename from src/main/java/com/dji/sample/manage/dao/IDeviceFirmwareMapper.java rename to sample/src/main/java/com/dji/sample/manage/dao/IDeviceFirmwareMapper.java diff --git a/src/main/java/com/dji/sample/manage/dao/IDeviceHmsMapper.java b/sample/src/main/java/com/dji/sample/manage/dao/IDeviceHmsMapper.java similarity index 100% rename from src/main/java/com/dji/sample/manage/dao/IDeviceHmsMapper.java rename to sample/src/main/java/com/dji/sample/manage/dao/IDeviceHmsMapper.java diff --git a/src/main/java/com/dji/sample/manage/dao/IDeviceLogsMapper.java b/sample/src/main/java/com/dji/sample/manage/dao/IDeviceLogsMapper.java similarity index 100% rename from src/main/java/com/dji/sample/manage/dao/IDeviceLogsMapper.java rename to sample/src/main/java/com/dji/sample/manage/dao/IDeviceLogsMapper.java diff --git a/src/main/java/com/dji/sample/manage/dao/IDeviceMapper.java b/sample/src/main/java/com/dji/sample/manage/dao/IDeviceMapper.java similarity index 100% rename from src/main/java/com/dji/sample/manage/dao/IDeviceMapper.java rename to sample/src/main/java/com/dji/sample/manage/dao/IDeviceMapper.java diff --git a/src/main/java/com/dji/sample/manage/dao/IDevicePayloadMapper.java b/sample/src/main/java/com/dji/sample/manage/dao/IDevicePayloadMapper.java similarity index 100% rename from src/main/java/com/dji/sample/manage/dao/IDevicePayloadMapper.java rename to sample/src/main/java/com/dji/sample/manage/dao/IDevicePayloadMapper.java diff --git a/src/main/java/com/dji/sample/manage/dao/IFirmwareModelMapper.java b/sample/src/main/java/com/dji/sample/manage/dao/IFirmwareModelMapper.java similarity index 100% rename from src/main/java/com/dji/sample/manage/dao/IFirmwareModelMapper.java rename to sample/src/main/java/com/dji/sample/manage/dao/IFirmwareModelMapper.java diff --git a/src/main/java/com/dji/sample/manage/dao/ILogsFileIndexMapper.java b/sample/src/main/java/com/dji/sample/manage/dao/ILogsFileIndexMapper.java similarity index 100% rename from src/main/java/com/dji/sample/manage/dao/ILogsFileIndexMapper.java rename to sample/src/main/java/com/dji/sample/manage/dao/ILogsFileIndexMapper.java diff --git a/src/main/java/com/dji/sample/manage/dao/ILogsFileMapper.java b/sample/src/main/java/com/dji/sample/manage/dao/ILogsFileMapper.java similarity index 100% rename from src/main/java/com/dji/sample/manage/dao/ILogsFileMapper.java rename to sample/src/main/java/com/dji/sample/manage/dao/ILogsFileMapper.java diff --git a/src/main/java/com/dji/sample/manage/dao/IUserMapper.java b/sample/src/main/java/com/dji/sample/manage/dao/IUserMapper.java similarity index 100% rename from src/main/java/com/dji/sample/manage/dao/IUserMapper.java rename to sample/src/main/java/com/dji/sample/manage/dao/IUserMapper.java diff --git a/src/main/java/com/dji/sample/manage/dao/IWorkspaceMapper.java b/sample/src/main/java/com/dji/sample/manage/dao/IWorkspaceMapper.java similarity index 100% rename from src/main/java/com/dji/sample/manage/dao/IWorkspaceMapper.java rename to sample/src/main/java/com/dji/sample/manage/dao/IWorkspaceMapper.java diff --git a/src/main/java/com/dji/sample/manage/model/common/AppLicenseProperties.java b/sample/src/main/java/com/dji/sample/manage/model/common/AppLicenseProperties.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/common/AppLicenseProperties.java rename to sample/src/main/java/com/dji/sample/manage/model/common/AppLicenseProperties.java diff --git a/src/main/java/com/dji/sample/manage/model/common/HmsJsonUtil.java b/sample/src/main/java/com/dji/sample/manage/model/common/HmsJsonUtil.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/common/HmsJsonUtil.java rename to sample/src/main/java/com/dji/sample/manage/model/common/HmsJsonUtil.java diff --git a/src/main/java/com/dji/sample/manage/model/common/HmsMessage.java b/sample/src/main/java/com/dji/sample/manage/model/common/HmsMessage.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/common/HmsMessage.java rename to sample/src/main/java/com/dji/sample/manage/model/common/HmsMessage.java diff --git a/src/main/java/com/dji/sample/manage/model/common/NtpServerProperties.java b/sample/src/main/java/com/dji/sample/manage/model/common/NtpServerProperties.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/common/NtpServerProperties.java rename to sample/src/main/java/com/dji/sample/manage/model/common/NtpServerProperties.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/CapacityCameraDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/CapacityCameraDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/CapacityCameraDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/CapacityCameraDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/CapacityDeviceDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/CapacityDeviceDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/CapacityDeviceDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/CapacityDeviceDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/CapacityVideoDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/CapacityVideoDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/CapacityVideoDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/CapacityVideoDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/DeviceAuthorityDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/DeviceAuthorityDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/DeviceAuthorityDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/DeviceAuthorityDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/DeviceDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/DeviceDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/DeviceDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/DeviceDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/DeviceDictionaryDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/DeviceDictionaryDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/DeviceDictionaryDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/DeviceDictionaryDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareNoteDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareNoteDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareNoteDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareNoteDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareUpgradeDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareUpgradeDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareUpgradeDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/DeviceFirmwareUpgradeDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/DeviceHmsDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/DeviceHmsDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/DeviceHmsDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/DeviceHmsDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/DeviceLogsDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/DeviceLogsDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/DeviceLogsDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/DeviceLogsDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/DevicePayloadDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/DevicePayloadDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/DevicePayloadDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/DevicePayloadDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/DevicePayloadReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/dto/DevicePayloadReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/DevicePayloadReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/DevicePayloadReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/FirmwareFileProperties.java b/sample/src/main/java/com/dji/sample/manage/model/dto/FirmwareFileProperties.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/FirmwareFileProperties.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/FirmwareFileProperties.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/FirmwareModelDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/FirmwareModelDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/FirmwareModelDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/FirmwareModelDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/LiveDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/LiveDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/LiveDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/LiveDTO.java diff --git a/sample/src/main/java/com/dji/sample/manage/model/dto/LiveStreamProperty.java b/sample/src/main/java/com/dji/sample/manage/model/dto/LiveStreamProperty.java new file mode 100644 index 0000000..4f68500 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/manage/model/dto/LiveStreamProperty.java @@ -0,0 +1,65 @@ +package com.dji.sample.manage.model.dto; + +import com.dji.sample.common.error.CommonErrorEnum; +import com.dji.sdk.cloudapi.livestream.*; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * @author sean + * @version 1.7 + * @date 2023/10/13 + */ + +@Data +@ConfigurationProperties("livestream.url") +@Configuration +public class LiveStreamProperty { + + private static LivestreamAgoraUrl agora; + + private static LivestreamRtmpUrl rtmp; + + private static LivestreamRtspUrl rtsp; + + private static LivestreamGb28181Url gb28181; + + private static LivestreamWhipUrl whip; + + public void setAgora(LivestreamAgoraUrl agora) { + LiveStreamProperty.agora = agora; + } + + public void setRtmp(LivestreamRtmpUrl rtmp) { + LiveStreamProperty.rtmp = rtmp; + } + + public void setRtsp(LivestreamRtspUrl rtsp) { + LiveStreamProperty.rtsp = rtsp; + } + + public void setGb28181(LivestreamGb28181Url gb28181) { + LiveStreamProperty.gb28181 = gb28181; + } + + public void setWhip(LivestreamWhipUrl webrtc) { + LiveStreamProperty.whip = webrtc; + } + + public static ILivestreamUrl get(UrlTypeEnum type) { + switch (type) { + case AGORA: + return agora; + case RTMP: + return rtmp; + case RTSP: + return rtsp; + case GB28181: + return gb28181; + case WHIP: + return whip; + } + throw new RuntimeException(CommonErrorEnum.ILLEGAL_ARGUMENT.getMessage()); + } +} diff --git a/sample/src/main/java/com/dji/sample/manage/model/dto/LiveTypeDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/LiveTypeDTO.java new file mode 100644 index 0000000..f0a41b2 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/manage/model/dto/LiveTypeDTO.java @@ -0,0 +1,30 @@ +package com.dji.sample.manage.model.dto; + +import com.dji.sdk.cloudapi.device.VideoId; +import com.dji.sdk.cloudapi.livestream.LensChangeVideoTypeEnum; +import com.dji.sdk.cloudapi.livestream.UrlTypeEnum; +import com.dji.sdk.cloudapi.livestream.VideoQualityEnum; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * Receive live parameters. + * @author sean.zhou + * @version 0.1 + * @date 2021/11/22 + */ +@Data +public class LiveTypeDTO { + + @JsonProperty("url_type") + private UrlTypeEnum urlType; + + @JsonProperty("video_id") + private VideoId videoId; + + @JsonProperty("video_quality") + private VideoQualityEnum videoQuality; + + private LensChangeVideoTypeEnum videoType; + +} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/model/dto/LiveUrlAgoraDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/LiveUrlAgoraDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/LiveUrlAgoraDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/LiveUrlAgoraDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/LiveUrlGB28181DTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/LiveUrlGB28181DTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/LiveUrlGB28181DTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/LiveUrlGB28181DTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/LiveUrlRTSPDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/LiveUrlRTSPDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/LiveUrlRTSPDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/LiveUrlRTSPDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/LogsFileDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/LogsFileDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/LogsFileDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/LogsFileDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/LogsFileUploadDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/LogsFileUploadDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/LogsFileUploadDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/LogsFileUploadDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/LogsFileUploadListDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/LogsFileUploadListDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/LogsFileUploadListDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/LogsFileUploadListDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/LogsOutputProgressDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/LogsOutputProgressDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/LogsOutputProgressDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/LogsOutputProgressDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/LogsProgressDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/LogsProgressDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/LogsProgressDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/LogsProgressDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/LogsUploadCredentialsDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/LogsUploadCredentialsDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/LogsUploadCredentialsDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/LogsUploadCredentialsDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/ProductConfigDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/ProductConfigDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/ProductConfigDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/ProductConfigDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/TelemetryDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/TelemetryDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/TelemetryDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/TelemetryDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/TopologyDeviceDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/TopologyDeviceDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/TopologyDeviceDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/TopologyDeviceDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/UserDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/UserDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/UserDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/UserDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/dto/UserListDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/UserListDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/UserListDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/UserListDTO.java diff --git a/sample/src/main/java/com/dji/sample/manage/model/dto/UserLoginDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/UserLoginDTO.java new file mode 100644 index 0000000..1865ac9 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/manage/model/dto/UserLoginDTO.java @@ -0,0 +1,21 @@ +package com.dji.sample.manage.model.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class UserLoginDTO { + + @NonNull + private String username; + + @NonNull + private String password; + + @NonNull + private Integer flag; +} diff --git a/src/main/java/com/dji/sample/manage/model/dto/WorkspaceDTO.java b/sample/src/main/java/com/dji/sample/manage/model/dto/WorkspaceDTO.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/dto/WorkspaceDTO.java rename to sample/src/main/java/com/dji/sample/manage/model/dto/WorkspaceDTO.java diff --git a/src/main/java/com/dji/sample/manage/model/entity/DeviceDictionaryEntity.java b/sample/src/main/java/com/dji/sample/manage/model/entity/DeviceDictionaryEntity.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/entity/DeviceDictionaryEntity.java rename to sample/src/main/java/com/dji/sample/manage/model/entity/DeviceDictionaryEntity.java diff --git a/src/main/java/com/dji/sample/manage/model/entity/DeviceEntity.java b/sample/src/main/java/com/dji/sample/manage/model/entity/DeviceEntity.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/entity/DeviceEntity.java rename to sample/src/main/java/com/dji/sample/manage/model/entity/DeviceEntity.java diff --git a/src/main/java/com/dji/sample/manage/model/entity/DeviceFirmwareEntity.java b/sample/src/main/java/com/dji/sample/manage/model/entity/DeviceFirmwareEntity.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/entity/DeviceFirmwareEntity.java rename to sample/src/main/java/com/dji/sample/manage/model/entity/DeviceFirmwareEntity.java diff --git a/src/main/java/com/dji/sample/manage/model/entity/DeviceHmsEntity.java b/sample/src/main/java/com/dji/sample/manage/model/entity/DeviceHmsEntity.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/entity/DeviceHmsEntity.java rename to sample/src/main/java/com/dji/sample/manage/model/entity/DeviceHmsEntity.java diff --git a/src/main/java/com/dji/sample/manage/model/entity/DeviceLogsEntity.java b/sample/src/main/java/com/dji/sample/manage/model/entity/DeviceLogsEntity.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/entity/DeviceLogsEntity.java rename to sample/src/main/java/com/dji/sample/manage/model/entity/DeviceLogsEntity.java diff --git a/src/main/java/com/dji/sample/manage/model/entity/DevicePayloadEntity.java b/sample/src/main/java/com/dji/sample/manage/model/entity/DevicePayloadEntity.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/entity/DevicePayloadEntity.java rename to sample/src/main/java/com/dji/sample/manage/model/entity/DevicePayloadEntity.java diff --git a/src/main/java/com/dji/sample/manage/model/entity/FirmwareModelEntity.java b/sample/src/main/java/com/dji/sample/manage/model/entity/FirmwareModelEntity.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/entity/FirmwareModelEntity.java rename to sample/src/main/java/com/dji/sample/manage/model/entity/FirmwareModelEntity.java diff --git a/src/main/java/com/dji/sample/manage/model/entity/LogsFileEntity.java b/sample/src/main/java/com/dji/sample/manage/model/entity/LogsFileEntity.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/entity/LogsFileEntity.java rename to sample/src/main/java/com/dji/sample/manage/model/entity/LogsFileEntity.java diff --git a/src/main/java/com/dji/sample/manage/model/entity/LogsFileIndexEntity.java b/sample/src/main/java/com/dji/sample/manage/model/entity/LogsFileIndexEntity.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/entity/LogsFileIndexEntity.java rename to sample/src/main/java/com/dji/sample/manage/model/entity/LogsFileIndexEntity.java diff --git a/src/main/java/com/dji/sample/manage/model/entity/UserEntity.java b/sample/src/main/java/com/dji/sample/manage/model/entity/UserEntity.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/entity/UserEntity.java rename to sample/src/main/java/com/dji/sample/manage/model/entity/UserEntity.java diff --git a/src/main/java/com/dji/sample/manage/model/entity/WorkspaceEntity.java b/sample/src/main/java/com/dji/sample/manage/model/entity/WorkspaceEntity.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/entity/WorkspaceEntity.java rename to sample/src/main/java/com/dji/sample/manage/model/entity/WorkspaceEntity.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/CustomizeConfigScopeEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/CustomizeConfigScopeEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/CustomizeConfigScopeEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/CustomizeConfigScopeEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/DeviceFirmwareStatusEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/DeviceFirmwareStatusEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/DeviceFirmwareStatusEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/DeviceFirmwareStatusEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/DeviceLogsStatusEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/DeviceLogsStatusEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/DeviceLogsStatusEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/DeviceLogsStatusEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/ExitWaylineWhenRcLostActionEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/ExitWaylineWhenRcLostActionEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/ExitWaylineWhenRcLostActionEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/ExitWaylineWhenRcLostActionEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/FirmwareMethodEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/FirmwareMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/FirmwareMethodEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/FirmwareMethodEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/LiveStreamMethodEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/LiveStreamMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/LiveStreamMethodEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/LiveStreamMethodEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/LiveUrlTypeEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/LiveUrlTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/LiveUrlTypeEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/LiveUrlTypeEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/LiveVideoQualityEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/LiveVideoQualityEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/LiveVideoQualityEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/LiveVideoQualityEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/LogsFileUpdateMethodEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/LogsFileUpdateMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/LogsFileUpdateMethodEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/LogsFileUpdateMethodEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/PayloadModelEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/PayloadModelEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/PayloadModelEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/PayloadModelEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/PropertySetFieldEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/PropertySetFieldEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/PropertySetFieldEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/PropertySetFieldEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/StateSwitchEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/StateSwitchEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/StateSwitchEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/StateSwitchEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/enums/UserTypeEnum.java b/sample/src/main/java/com/dji/sample/manage/model/enums/UserTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/enums/UserTypeEnum.java rename to sample/src/main/java/com/dji/sample/manage/model/enums/UserTypeEnum.java diff --git a/src/main/java/com/dji/sample/manage/model/param/DeviceFirmwareQueryParam.java b/sample/src/main/java/com/dji/sample/manage/model/param/DeviceFirmwareQueryParam.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/param/DeviceFirmwareQueryParam.java rename to sample/src/main/java/com/dji/sample/manage/model/param/DeviceFirmwareQueryParam.java diff --git a/src/main/java/com/dji/sample/manage/model/param/DeviceFirmwareUpdateParam.java b/sample/src/main/java/com/dji/sample/manage/model/param/DeviceFirmwareUpdateParam.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/param/DeviceFirmwareUpdateParam.java rename to sample/src/main/java/com/dji/sample/manage/model/param/DeviceFirmwareUpdateParam.java diff --git a/src/main/java/com/dji/sample/manage/model/param/DeviceFirmwareUploadParam.java b/sample/src/main/java/com/dji/sample/manage/model/param/DeviceFirmwareUploadParam.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/param/DeviceFirmwareUploadParam.java rename to sample/src/main/java/com/dji/sample/manage/model/param/DeviceFirmwareUploadParam.java diff --git a/src/main/java/com/dji/sample/manage/model/param/DeviceHmsQueryParam.java b/sample/src/main/java/com/dji/sample/manage/model/param/DeviceHmsQueryParam.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/param/DeviceHmsQueryParam.java rename to sample/src/main/java/com/dji/sample/manage/model/param/DeviceHmsQueryParam.java diff --git a/src/main/java/com/dji/sample/manage/model/param/DeviceLogsCreateParam.java b/sample/src/main/java/com/dji/sample/manage/model/param/DeviceLogsCreateParam.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/param/DeviceLogsCreateParam.java rename to sample/src/main/java/com/dji/sample/manage/model/param/DeviceLogsCreateParam.java diff --git a/src/main/java/com/dji/sample/manage/model/param/DeviceLogsGetParam.java b/sample/src/main/java/com/dji/sample/manage/model/param/DeviceLogsGetParam.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/param/DeviceLogsGetParam.java rename to sample/src/main/java/com/dji/sample/manage/model/param/DeviceLogsGetParam.java diff --git a/src/main/java/com/dji/sample/manage/model/param/DeviceLogsQueryParam.java b/sample/src/main/java/com/dji/sample/manage/model/param/DeviceLogsQueryParam.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/param/DeviceLogsQueryParam.java rename to sample/src/main/java/com/dji/sample/manage/model/param/DeviceLogsQueryParam.java diff --git a/src/main/java/com/dji/sample/manage/model/param/DeviceQueryParam.java b/sample/src/main/java/com/dji/sample/manage/model/param/DeviceQueryParam.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/param/DeviceQueryParam.java rename to sample/src/main/java/com/dji/sample/manage/model/param/DeviceQueryParam.java diff --git a/src/main/java/com/dji/sample/manage/model/param/LogsFileUpdateParam.java b/sample/src/main/java/com/dji/sample/manage/model/param/LogsFileUpdateParam.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/param/LogsFileUpdateParam.java rename to sample/src/main/java/com/dji/sample/manage/model/param/LogsFileUpdateParam.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/BasicDeviceProperty.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/BasicDeviceProperty.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/BasicDeviceProperty.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/BasicDeviceProperty.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/CapacityCameraReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/CapacityCameraReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/CapacityCameraReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/CapacityCameraReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/CapacityDeviceReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/CapacityDeviceReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/CapacityDeviceReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/CapacityDeviceReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/CapacityVideoReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/CapacityVideoReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/CapacityVideoReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/CapacityVideoReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/DeviceBasicReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/DeviceBasicReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/DeviceBasicReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/DeviceBasicReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/DeviceMaintainStatusReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/DeviceMaintainStatusReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/DeviceMaintainStatusReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/DeviceMaintainStatusReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/DistanceLimitStatusReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/DistanceLimitStatusReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/DistanceLimitStatusReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/DistanceLimitStatusReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/DockSdrReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/DockSdrReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/DockSdrReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/DockSdrReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/FirmwareVersionReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/FirmwareVersionReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/FirmwareVersionReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/FirmwareVersionReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/HeightLimitReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/HeightLimitReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/HeightLimitReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/HeightLimitReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/LiveCapacityReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/LiveCapacityReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/LiveCapacityReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/LiveCapacityReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/MaintainStatusReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/MaintainStatusReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/MaintainStatusReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/MaintainStatusReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/NightLightsStateReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/NightLightsStateReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/NightLightsStateReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/NightLightsStateReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/ObstacleAvoidanceReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/ObstacleAvoidanceReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/ObstacleAvoidanceReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/ObstacleAvoidanceReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/OutOfControlActionReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/OutOfControlActionReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/OutOfControlActionReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/OutOfControlActionReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/OutputLogsProgressReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/OutputLogsProgressReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/OutputLogsProgressReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/OutputLogsProgressReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/RthAltitudeReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/RthAltitudeReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/RthAltitudeReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/RthAltitudeReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/StatusGatewayReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/StatusGatewayReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/StatusGatewayReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/StatusGatewayReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/StatusSubDeviceReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/StatusSubDeviceReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/StatusSubDeviceReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/StatusSubDeviceReceiver.java diff --git a/src/main/java/com/dji/sample/manage/model/receiver/WirelessLinkStateReceiver.java b/sample/src/main/java/com/dji/sample/manage/model/receiver/WirelessLinkStateReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/manage/model/receiver/WirelessLinkStateReceiver.java rename to sample/src/main/java/com/dji/sample/manage/model/receiver/WirelessLinkStateReceiver.java diff --git a/src/main/java/com/dji/sample/manage/service/ICameraVideoService.java b/sample/src/main/java/com/dji/sample/manage/service/ICameraVideoService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/ICameraVideoService.java rename to sample/src/main/java/com/dji/sample/manage/service/ICameraVideoService.java diff --git a/src/main/java/com/dji/sample/manage/service/ICapacityCameraService.java b/sample/src/main/java/com/dji/sample/manage/service/ICapacityCameraService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/ICapacityCameraService.java rename to sample/src/main/java/com/dji/sample/manage/service/ICapacityCameraService.java diff --git a/src/main/java/com/dji/sample/manage/service/IDeviceDictionaryService.java b/sample/src/main/java/com/dji/sample/manage/service/IDeviceDictionaryService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/IDeviceDictionaryService.java rename to sample/src/main/java/com/dji/sample/manage/service/IDeviceDictionaryService.java diff --git a/src/main/java/com/dji/sample/manage/service/IDeviceFirmwareService.java b/sample/src/main/java/com/dji/sample/manage/service/IDeviceFirmwareService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/IDeviceFirmwareService.java rename to sample/src/main/java/com/dji/sample/manage/service/IDeviceFirmwareService.java diff --git a/src/main/java/com/dji/sample/manage/service/IDeviceHmsService.java b/sample/src/main/java/com/dji/sample/manage/service/IDeviceHmsService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/IDeviceHmsService.java rename to sample/src/main/java/com/dji/sample/manage/service/IDeviceHmsService.java diff --git a/src/main/java/com/dji/sample/manage/service/IDeviceLogsService.java b/sample/src/main/java/com/dji/sample/manage/service/IDeviceLogsService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/IDeviceLogsService.java rename to sample/src/main/java/com/dji/sample/manage/service/IDeviceLogsService.java diff --git a/src/main/java/com/dji/sample/manage/service/IDevicePayloadService.java b/sample/src/main/java/com/dji/sample/manage/service/IDevicePayloadService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/IDevicePayloadService.java rename to sample/src/main/java/com/dji/sample/manage/service/IDevicePayloadService.java diff --git a/src/main/java/com/dji/sample/manage/service/IDeviceRedisService.java b/sample/src/main/java/com/dji/sample/manage/service/IDeviceRedisService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/IDeviceRedisService.java rename to sample/src/main/java/com/dji/sample/manage/service/IDeviceRedisService.java diff --git a/src/main/java/com/dji/sample/manage/service/IDeviceService.java b/sample/src/main/java/com/dji/sample/manage/service/IDeviceService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/IDeviceService.java rename to sample/src/main/java/com/dji/sample/manage/service/IDeviceService.java diff --git a/src/main/java/com/dji/sample/manage/service/IFirmwareModelService.java b/sample/src/main/java/com/dji/sample/manage/service/IFirmwareModelService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/IFirmwareModelService.java rename to sample/src/main/java/com/dji/sample/manage/service/IFirmwareModelService.java diff --git a/sample/src/main/java/com/dji/sample/manage/service/ILiveStreamService.java b/sample/src/main/java/com/dji/sample/manage/service/ILiveStreamService.java new file mode 100644 index 0000000..e18eaac --- /dev/null +++ b/sample/src/main/java/com/dji/sample/manage/service/ILiveStreamService.java @@ -0,0 +1,51 @@ +package com.dji.sample.manage.service; + +import com.dji.sample.manage.model.dto.CapacityDeviceDTO; +import com.dji.sample.manage.model.dto.LiveTypeDTO; +import com.dji.sdk.cloudapi.device.VideoId; +import com.dji.sdk.common.HttpResultResponse; + +import java.util.List; + +/** + * @author sean.zhou + * @date 2021/11/19 + * @version 0.1 + */ +public interface ILiveStreamService { + + /** + * Get all the drone data that can be broadcast live in this workspace. + * @param workspaceId + * @return + */ + List getLiveCapacity(String workspaceId); + + /** + * Initiate a live streaming by publishing mqtt message. + * @param liveParam Parameters needed for on-demand. + * @return + */ + HttpResultResponse liveStart(LiveTypeDTO liveParam); + + /** + * Stop the live streaming by publishing mqtt message. + * @param videoId + * @return + */ + HttpResultResponse liveStop(VideoId videoId); + + /** + * Readjust the clarity of the live streaming by publishing mqtt messages. + * @param liveParam + * @return + */ + HttpResultResponse liveSetQuality(LiveTypeDTO liveParam); + + /** + * Switches the lens of the device during the live streaming. + * @param liveParam + * @return + */ + HttpResultResponse liveLensChange(LiveTypeDTO liveParam); +} diff --git a/src/main/java/com/dji/sample/manage/service/ILogsFileIndexService.java b/sample/src/main/java/com/dji/sample/manage/service/ILogsFileIndexService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/ILogsFileIndexService.java rename to sample/src/main/java/com/dji/sample/manage/service/ILogsFileIndexService.java diff --git a/src/main/java/com/dji/sample/manage/service/ILogsFileService.java b/sample/src/main/java/com/dji/sample/manage/service/ILogsFileService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/ILogsFileService.java rename to sample/src/main/java/com/dji/sample/manage/service/ILogsFileService.java diff --git a/src/main/java/com/dji/sample/manage/service/IRequestsConfigService.java b/sample/src/main/java/com/dji/sample/manage/service/IRequestsConfigService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/IRequestsConfigService.java rename to sample/src/main/java/com/dji/sample/manage/service/IRequestsConfigService.java diff --git a/src/main/java/com/dji/sample/manage/service/ITopologyService.java b/sample/src/main/java/com/dji/sample/manage/service/ITopologyService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/ITopologyService.java rename to sample/src/main/java/com/dji/sample/manage/service/ITopologyService.java diff --git a/src/main/java/com/dji/sample/manage/service/IUserService.java b/sample/src/main/java/com/dji/sample/manage/service/IUserService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/IUserService.java rename to sample/src/main/java/com/dji/sample/manage/service/IUserService.java diff --git a/src/main/java/com/dji/sample/manage/service/IWorkspaceService.java b/sample/src/main/java/com/dji/sample/manage/service/IWorkspaceService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/IWorkspaceService.java rename to sample/src/main/java/com/dji/sample/manage/service/IWorkspaceService.java diff --git a/src/main/java/com/dji/sample/manage/service/impl/CameraVideoServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/CameraVideoServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/CameraVideoServiceImpl.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/CameraVideoServiceImpl.java diff --git a/src/main/java/com/dji/sample/manage/service/impl/CapacityCameraServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/CapacityCameraServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/CapacityCameraServiceImpl.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/CapacityCameraServiceImpl.java diff --git a/src/main/java/com/dji/sample/manage/service/impl/ConfigProductServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/ConfigProductServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/ConfigProductServiceImpl.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/ConfigProductServiceImpl.java diff --git a/src/main/java/com/dji/sample/manage/service/impl/DeviceDictionaryServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceDictionaryServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/DeviceDictionaryServiceImpl.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/DeviceDictionaryServiceImpl.java diff --git a/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceFirmwareServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceFirmwareServiceImpl.java new file mode 100644 index 0000000..d26e318 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceFirmwareServiceImpl.java @@ -0,0 +1,353 @@ +package com.dji.sample.manage.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dji.sample.component.mqtt.model.EventsReceiver; +import com.dji.sample.component.oss.model.OssConfiguration; +import com.dji.sample.component.oss.service.impl.OssServiceContext; +import com.dji.sample.component.redis.RedisConst; +import com.dji.sample.component.redis.RedisOpsUtils; +import com.dji.sample.component.websocket.model.BizCodeEnum; +import com.dji.sample.component.websocket.service.IWebSocketMessageService; +import com.dji.sample.manage.dao.IDeviceFirmwareMapper; +import com.dji.sample.manage.model.dto.*; +import com.dji.sample.manage.model.entity.DeviceFirmwareEntity; +import com.dji.sample.manage.model.enums.UserTypeEnum; +import com.dji.sample.manage.model.param.DeviceFirmwareQueryParam; +import com.dji.sample.manage.model.param.DeviceFirmwareUploadParam; +import com.dji.sample.manage.service.IDeviceFirmwareService; +import com.dji.sample.manage.service.IDeviceRedisService; +import com.dji.sample.manage.service.IFirmwareModelService; +import com.dji.sdk.cloudapi.firmware.FirmwareUpgradeTypeEnum; +import com.dji.sdk.cloudapi.firmware.OtaCreateDevice; +import com.dji.sdk.cloudapi.firmware.OtaProgress; +import com.dji.sdk.cloudapi.firmware.OtaProgressStatusEnum; +import com.dji.sdk.cloudapi.firmware.api.AbstractFirmwareService; +import com.dji.sdk.common.Pagination; +import com.dji.sdk.common.PaginationData; +import com.dji.sdk.mqtt.MqttReply; +import com.dji.sdk.mqtt.events.EventsDataRequest; +import com.dji.sdk.mqtt.events.TopicEventsRequest; +import com.dji.sdk.mqtt.events.TopicEventsResponse; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.messaging.MessageHeaders; +import org.springframework.stereotype.Service; +import org.springframework.util.DigestUtils; +import org.springframework.util.StringUtils; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +/** + * @author sean + * @version 1.2 + * @date 2022/8/16 + */ +@Service +@Slf4j +public class DeviceFirmwareServiceImpl extends AbstractFirmwareService implements IDeviceFirmwareService { + + @Autowired + private IDeviceFirmwareMapper mapper; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private IWebSocketMessageService webSocketMessageService; + + @Autowired + private OssServiceContext ossServiceContext; + + @Autowired + private IFirmwareModelService firmwareModelService; + + @Autowired + private IDeviceRedisService deviceRedisService; + + @Override + public Optional getFirmware(String workspaceId, String deviceName, String version) { + return Optional.ofNullable(entity2Dto(mapper.selectOne( + new LambdaQueryWrapper() + .eq(DeviceFirmwareEntity::getWorkspaceId, workspaceId) + .eq(DeviceFirmwareEntity::getFirmwareVersion, version) + .eq(DeviceFirmwareEntity::getStatus, true), + deviceName))); + } + + @Override + public Optional getLatestFirmwareReleaseNote(String deviceName) { + return Optional.ofNullable(entity2NoteDto(mapper.selectOne( + Wrappers.lambdaQuery(DeviceFirmwareEntity.class) + .eq(DeviceFirmwareEntity::getStatus, true) + .orderByDesc(DeviceFirmwareEntity::getReleaseDate, DeviceFirmwareEntity::getFirmwareVersion), + deviceName))); + } + + @Override + public List getDeviceOtaFirmware(String workspaceId, List upgradeDTOS) { + List deviceOtaList = new ArrayList<>(); + upgradeDTOS.forEach(upgradeDevice -> { + boolean exist = deviceRedisService.checkDeviceOnline(upgradeDevice.getSn()); + if (!exist) { + throw new IllegalArgumentException("Device is offline."); + } + Optional firmwareOpt = this.getFirmware( + workspaceId, upgradeDevice.getDeviceName(), upgradeDevice.getProductVersion()); + if (firmwareOpt.isEmpty()) { + throw new IllegalArgumentException("This firmware version does not exist or is not available."); + } + OtaCreateDevice ota = dto2OtaCreateDto(firmwareOpt.get()); + ota.setSn(upgradeDevice.getSn()); + ota.setFirmwareUpgradeType(FirmwareUpgradeTypeEnum.find(upgradeDevice.getFirmwareUpgradeType())); + deviceOtaList.add(ota); + }); + return deviceOtaList; + } + + @Override + public TopicEventsResponse otaProgress(TopicEventsRequest> request, MessageHeaders headers) { + String sn = request.getGateway(); + + EventsReceiver eventsReceiver = new EventsReceiver() + .setBid(request.getBid()) + .setOutput(request.getData().getOutput()) + .setResult(request.getData().getResult()); + + + log.info("SN: {}, {} ===> Upgrading progress: {}", + sn, request.getMethod(), eventsReceiver.getOutput().getProgress()); + + if (!eventsReceiver.getResult().isSuccess()) { + log.error("SN: {}, {} ===> Error: {}", sn, request.getMethod(), eventsReceiver.getResult()); + } + + Optional deviceOpt = deviceRedisService.getDeviceOnline(sn); + if (deviceOpt.isEmpty()) { + return null; + } + + OtaProgressStatusEnum statusEnum = eventsReceiver.getOutput().getStatus(); + DeviceDTO device = deviceOpt.get(); + handleProgress(device.getWorkspaceId(), sn, eventsReceiver, statusEnum.isEnd()); + handleProgress(device.getWorkspaceId(), device.getChildDeviceSn(), eventsReceiver, statusEnum.isEnd()); + + return new TopicEventsResponse().setData(MqttReply.success()); + } + + private void handleProgress(String workspaceId, String sn, EventsReceiver events, boolean isEnd) { + boolean upgrade = deviceRedisService.getFirmwareUpgradingProgress(sn).isPresent(); + if (!upgrade) { + return; + } + if (isEnd) { + // Delete the cache after the update is complete. + deviceRedisService.delFirmwareUpgrading(sn); + } else { + // Update the update progress of the dock in redis. + deviceRedisService.setFirmwareUpgrading(sn, events); + } + events.setSn(sn); + webSocketMessageService.sendBatch(workspaceId, UserTypeEnum.WEB.getVal(), BizCodeEnum.OTA_PROGRESS.getCode(), events); + } + + @Override + public Boolean checkFileExist(String workspaceId, String fileMd5) { + return RedisOpsUtils.checkExist(RedisConst.FILE_UPLOADING_PREFIX + workspaceId + fileMd5) || + mapper.selectCount(new LambdaQueryWrapper() + .eq(DeviceFirmwareEntity::getWorkspaceId, workspaceId) + .eq(DeviceFirmwareEntity::getFileMd5, fileMd5)) + > 0; + } + + @Override + public PaginationData getAllFirmwarePagination(String workspaceId, DeviceFirmwareQueryParam param) { + Page page = mapper.selectPage(new Page<>(param.getPage(), param.getPageSize()), + new LambdaQueryWrapper() + .eq(DeviceFirmwareEntity::getWorkspaceId, workspaceId) + .eq(Objects.nonNull(param.getStatus()), DeviceFirmwareEntity::getStatus, param.getStatus()) + .like(StringUtils.hasText(param.getProductVersion()), DeviceFirmwareEntity::getFirmwareVersion, param.getProductVersion()) + .orderByDesc(DeviceFirmwareEntity::getReleaseDate), param.getDeviceName()); + + List data = page.getRecords().stream().map(this::entity2Dto).collect(Collectors.toList()); + return new PaginationData(data, new Pagination(page.getCurrent(), page.getSize(), page.getTotal())); + } + + + @Override + public void importFirmwareFile(String workspaceId, String creator, DeviceFirmwareUploadParam param, MultipartFile file) { + String key = RedisConst.FILE_UPLOADING_PREFIX + workspaceId; + String existKey = key + file.getOriginalFilename(); + if (RedisOpsUtils.getExpire(existKey) > 0) { + throw new RuntimeException("Please try again later."); + } + RedisOpsUtils.setWithExpire(existKey, true, RedisConst.DEVICE_ALIVE_SECOND); + try (InputStream is = file.getInputStream()) { + long size = is.available(); + String md5 = DigestUtils.md5DigestAsHex(is); + key += md5; + boolean exist = checkFileExist(workspaceId, md5); + if (exist) { + throw new RuntimeException("The file already exists."); + } + RedisOpsUtils.set(key, System.currentTimeMillis()); + Optional firmwareOpt = verifyFirmwareFile(file); + if (firmwareOpt.isEmpty()) { + throw new RuntimeException("The file format is incorrect."); + } + + String firmwareId = UUID.randomUUID().toString(); + String objectKey = OssConfiguration.objectDirPrefix + File.separator + firmwareId + FirmwareFileProperties.FIRMWARE_FILE_SUFFIX; + + ossServiceContext.putObject(OssConfiguration.bucket, objectKey, file.getInputStream()); + log.info("upload success. {}", file.getOriginalFilename()); + DeviceFirmwareDTO firmware = DeviceFirmwareDTO.builder() + .releaseNote(param.getReleaseNote()) + .firmwareStatus(param.getStatus()) + .fileMd5(md5) + .objectKey(objectKey) + .fileName(file.getOriginalFilename()) + .workspaceId(workspaceId) + .username(creator) + .fileSize(size) + .productVersion(firmwareOpt.get().getProductVersion()) + .releasedTime(firmwareOpt.get().getReleasedTime()) + .firmwareId(firmwareId) + .build(); + + saveFirmwareInfo(firmware, param.getDeviceName()); + } catch (IOException e) { + e.printStackTrace(); + } finally { + RedisOpsUtils.del(key); + } + } + + @Override + public void saveFirmwareInfo(DeviceFirmwareDTO firmware, List deviceNames) { + DeviceFirmwareEntity entity = dto2Entity(firmware); + mapper.insert(entity); + firmwareModelService.saveFirmwareDeviceName( + FirmwareModelDTO.builder().firmwareId(entity.getFirmwareId()).deviceNames(deviceNames).build()); + } + + @Override + public void updateFirmwareInfo(DeviceFirmwareDTO firmware) { + mapper.update(dto2Entity(firmware), + new LambdaUpdateWrapper() + .eq(DeviceFirmwareEntity::getFirmwareId, firmware.getFirmwareId())); + } + + /** + * Parse firmware file information. + * @param file + * @return + */ + private Optional verifyFirmwareFile(MultipartFile file) { + try (ZipInputStream unzipFile = new ZipInputStream(file.getInputStream(), StandardCharsets.UTF_8)) { + ZipEntry nextEntry = unzipFile.getNextEntry(); + while (Objects.nonNull(nextEntry)) { + String configName = nextEntry.getName(); + if (!configName.contains(File.separator) && configName.endsWith(FirmwareFileProperties.FIRMWARE_CONFIG_FILE_SUFFIX + FirmwareFileProperties.FIRMWARE_SIG_FILE_SUFFIX)) { + String[] filenameArr = configName.split(FirmwareFileProperties.FIRMWARE_FILE_DELIMITER); + String date = filenameArr[FirmwareFileProperties.FILENAME_RELEASE_DATE_INDEX]; + int index = date.indexOf("."); + if (index != -1) { + date = date.substring(0, index); + } + return Optional.of(DeviceFirmwareDTO.builder() + .releasedTime(LocalDate.parse( + date, + DateTimeFormatter.ofPattern(FirmwareFileProperties.FILENAME_RELEASE_DATE_FORMAT))) + // delete the string v. + .productVersion(filenameArr[FirmwareFileProperties.FILENAME_VERSION_INDEX].substring(1)) + .build()); + } + nextEntry = unzipFile.getNextEntry(); + } + + } catch (IOException e) { + e.printStackTrace(); + } + return Optional.empty(); + } + + private DeviceFirmwareEntity dto2Entity(DeviceFirmwareDTO dto) { + if (dto == null) { + return null; + } + return DeviceFirmwareEntity.builder() + .fileName(dto.getFileName()) + .fileMd5(dto.getFileMd5()) + .fileSize(dto.getFileSize()) + .firmwareId(dto.getFirmwareId()) + .firmwareVersion(dto.getProductVersion()) + .objectKey(dto.getObjectKey()) + .releaseDate(Objects.nonNull(dto.getReleasedTime()) ? + dto.getReleasedTime().atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli() : null) + .releaseNote(dto.getReleaseNote()) + .status(dto.getFirmwareStatus()) + .workspaceId(dto.getWorkspaceId()) + .username(dto.getUsername()) + .build(); + } + + private DeviceFirmwareNoteDTO entity2NoteDto (DeviceFirmwareEntity entity) { + if (entity == null) { + return null; + } + return DeviceFirmwareNoteDTO.builder() + .deviceName(entity.getDeviceName()) + .productVersion(entity.getFirmwareVersion()) + .releasedTime(LocalDate.ofInstant(Instant.ofEpochMilli(entity.getReleaseDate()), ZoneId.systemDefault())) + .releaseNote(entity.getReleaseNote()) + .build(); + } + + private DeviceFirmwareDTO entity2Dto (DeviceFirmwareEntity entity) { + if (entity == null) { + return null; + } + return DeviceFirmwareDTO.builder() + .deviceName(Arrays.asList(entity.getDeviceName().split(","))) + .fileMd5(entity.getFileMd5()) + .fileSize(entity.getFileSize()) + .objectKey(entity.getObjectKey()) + .firmwareId(entity.getFirmwareId()) + .fileName(entity.getFileName()) + .productVersion(entity.getFirmwareVersion()) + .releasedTime(LocalDate.ofInstant(Instant.ofEpochMilli(entity.getReleaseDate()), ZoneId.systemDefault())) + .releaseNote(entity.getReleaseNote()) + .firmwareStatus(entity.getStatus()) + .workspaceId(entity.getWorkspaceId()) + .username(entity.getUsername()) + .build(); + } + + private OtaCreateDevice dto2OtaCreateDto(DeviceFirmwareDTO dto) { + if (dto == null) { + return null; + } + return new OtaCreateDevice() + .setFileSize(dto.getFileSize()) + .setFileUrl(ossServiceContext.getObjectUrl(OssConfiguration.bucket, dto.getObjectKey()).toString()) + .setFileName(dto.getFileName()) + .setMd5(dto.getFileMd5()) + .setProductVersion(dto.getProductVersion()); + } +} diff --git a/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceHmsServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceHmsServiceImpl.java new file mode 100644 index 0000000..3497fc4 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceHmsServiceImpl.java @@ -0,0 +1,292 @@ +package com.dji.sample.manage.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dji.sample.component.websocket.model.BizCodeEnum; +import com.dji.sample.component.websocket.service.IWebSocketMessageService; +import com.dji.sample.manage.dao.IDeviceHmsMapper; +import com.dji.sample.manage.model.common.HmsJsonUtil; +import com.dji.sample.manage.model.common.HmsMessage; +import com.dji.sample.manage.model.dto.DeviceDTO; +import com.dji.sample.manage.model.dto.DeviceHmsDTO; +import com.dji.sample.manage.model.dto.TelemetryDTO; +import com.dji.sample.manage.model.entity.DeviceHmsEntity; +import com.dji.sample.manage.model.enums.UserTypeEnum; +import com.dji.sample.manage.model.param.DeviceHmsQueryParam; +import com.dji.sample.manage.service.IDeviceHmsService; +import com.dji.sample.manage.service.IDeviceRedisService; +import com.dji.sdk.cloudapi.device.DeviceDomainEnum; +import com.dji.sdk.cloudapi.hms.*; +import com.dji.sdk.cloudapi.hms.api.AbstractHmsService; +import com.dji.sdk.common.Pagination; +import com.dji.sdk.common.PaginationData; +import com.dji.sdk.mqtt.events.TopicEventsRequest; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.messaging.MessageHeaders; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * @author sean + * @version 1.1 + * @date 2022/7/6 + */ +@Service +@Transactional +@Slf4j +public class DeviceHmsServiceImpl extends AbstractHmsService implements IDeviceHmsService { + + @Autowired + private IDeviceHmsMapper mapper; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private IWebSocketMessageService sendMessageService; + + @Autowired + private IDeviceRedisService deviceRedisService; + + private static final Pattern PATTERN_KEY = Pattern.compile( + "(" + + Arrays.stream(HmsFormatKeyEnum.values()) + .map(HmsFormatKeyEnum::getKey) + .collect(Collectors.joining("|")) + + ")"); + + @Override + public void hms(TopicEventsRequest response, MessageHeaders headers) { + String sn = response.getFrom(); + DeviceHmsEntity entity = DeviceHmsEntity.builder() + .bid(response.getBid()) + .tid(response.getTid()) + .createTime(response.getTimestamp()) + .updateTime(0L) + .sn(sn) + .build(); + // Query all unread hms messages of the device in redis. + Set hmsMap = deviceRedisService.getAllHmsKeys(sn); + + List unReadList = new ArrayList<>(); + response.getData().getList() + .forEach(hmsReceiver -> { + final DeviceHmsEntity hms = entity.clone(); + this.fillEntity(hms, hmsReceiver); + // The same unread hms are no longer incremented. + if (hmsMap.contains(hms.getHmsKey())) { + return; + } + this.fillMessage(hms, hmsReceiver.getArgs()); + unReadList.add(entity2Dto(hms)); + mapper.insert(hms); + }); + + if (unReadList.isEmpty()) { + return; + } + deviceRedisService.addEndHmsKeys(sn, unReadList.stream().map(DeviceHmsDTO::getKey).toArray(String[]::new)); + // push to the web + Optional deviceOpt = deviceRedisService.getDeviceOnline(sn); + if (deviceOpt.isEmpty()) { + return; + } + sendMessageService.sendBatch(deviceOpt.get().getWorkspaceId(), UserTypeEnum.WEB.getVal(), + BizCodeEnum.DEVICE_HMS.getCode(), TelemetryDTO.>builder().sn(sn).host(unReadList).build()); + } + + @Override + public PaginationData getDeviceHmsByParam(DeviceHmsQueryParam param) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .and(wrapper -> param.getDeviceSn().forEach(sn -> wrapper.eq(DeviceHmsEntity::getSn, sn).or())) + .between(param.getBeginTime() != null && param.getEndTime() != null, + DeviceHmsEntity::getCreateTime, param.getBeginTime(), param.getEndTime()) + .eq(param.getUpdateTime() != null, DeviceHmsEntity::getUpdateTime, param.getUpdateTime()) + .eq(param.getLevel() != null, DeviceHmsEntity::getLevel, param.getLevel()) + .like(StringUtils.hasText(param.getMessage()) && + HmsMessageLanguageEnum.ZH.getLanguage().equals(param.getLanguage()), + DeviceHmsEntity::getMessageZh, param.getMessage()) + .like(StringUtils.hasText(param.getMessage()) && + HmsMessageLanguageEnum.EN.getLanguage().equals(param.getLanguage()), + DeviceHmsEntity::getMessageEn, param.getMessage()) + .orderByDesc(DeviceHmsEntity::getCreateTime); + if (param.getPage() == null || param.getPageSize() == null) { + param.setPage(1L); + param.setPageSize(Long.valueOf(mapper.selectCount(queryWrapper))); + } + + Page pagination = mapper.selectPage(new Page<>(param.getPage(), param.getPageSize()), queryWrapper); + + List deviceHmsList = pagination.getRecords().stream().map(this::entity2Dto).collect(Collectors.toList()); + + return new PaginationData(deviceHmsList, new Pagination(pagination.getCurrent(), pagination.getSize(), pagination.getTotal())); + } + + @Override + public void updateUnreadHms(String deviceSn) { + mapper.update(DeviceHmsEntity.builder().updateTime(System.currentTimeMillis()).build(), + new LambdaUpdateWrapper() + .eq(DeviceHmsEntity::getSn, deviceSn) + .eq(DeviceHmsEntity::getUpdateTime, 0L)); + // Delete unread messages cached in redis. + deviceRedisService.delHmsKeysBySn(deviceSn); + } + + private DeviceHmsDTO entity2Dto(DeviceHmsEntity entity) { + if (entity == null) { + return null; + } + return DeviceHmsDTO.builder() + .bid(entity.getBid()) + .tid(entity.getTid()) + .createTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getCreateTime()), ZoneId.systemDefault())) + .updateTime(entity.getUpdateTime().intValue() == 0 ? + null : LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getUpdateTime()), ZoneId.systemDefault())) + .sn(entity.getSn()) + .hmsId(entity.getHmsId()) + .key(entity.getHmsKey()) + .level(entity.getLevel()) + .module(entity.getModule()) + .messageEn(entity.getMessageEn()) + .messageZh(entity.getMessageZh()) + .build(); + } + + /** + * Populate the received data into the entity. Please refer to the documentation for splicing rules. + * @param dto + * @param receiver + */ + private void fillEntity(DeviceHmsEntity dto, DeviceHms receiver) { + dto.setLevel(receiver.getLevel().getLevel()); + dto.setModule(receiver.getModule().getModule()); + dto.setHmsId(UUID.randomUUID().toString()); + DeviceDomainEnum domain = receiver.getDeviceType().getDomain(); + if (DeviceDomainEnum.DOCK == domain) { + dto.setHmsKey(HmsFaqIdEnum.DOCK_TIP.getText() + receiver.getCode()); + return; + } + StringBuilder key = new StringBuilder(HmsFaqIdEnum.FPV_TIP.getText()).append(receiver.getCode()); + + if (receiver.getInTheSky()) { + key.append(HmsInTheSkyEnum.IN_THE_SKY.getText()); + } + dto.setHmsKey(key.toString()); + } + + /** + * Replace wildcards in messages according to the relevant rules. + * Please refer to the documentation for splicing rules. + * @param dto + * @param args + */ + private void fillMessage(DeviceHmsEntity dto, DeviceHmsArgs args) { + HmsMessage hmsMessage = HmsJsonUtil.get(dto.getHmsKey()); + String zh = StringUtils.hasText(hmsMessage.getZh()) ? hmsMessage.getZh() : String.format("未知错误(%s)", dto.getHmsKey()); + String en = StringUtils.hasText(hmsMessage.getEn()) ? hmsMessage.getEn() : String.format("Unknown(%s)", dto.getHmsKey());// + + dto.setMessageZh(format(Locale.CHINESE.getLanguage(), zh, args)); + dto.setMessageEn(format(Locale.ENGLISH.getLanguage(), en, args)); + } + + /** + * Set the matching parameters for key. + * @param l language: zh or en + * @param hmsArgs + * @return + */ + private Map fillKeyArgs(String l, DeviceHmsArgs hmsArgs) { + Map args = new HashMap<>(); + args.put(HmsFormatKeyEnum.ALARM_ID.getKey(), Objects.nonNull(hmsArgs.getAlarmId()) ? Long.toHexString(hmsArgs.getAlarmId()) : null); + args.put(HmsFormatKeyEnum.COMPONENT_INDEX.getKey(), + Objects.nonNull(hmsArgs.getComponentIndex()) ? String.valueOf(hmsArgs.getComponentIndex() + 1) : null); + if (Objects.nonNull(hmsArgs.getSensorIndex())) { + args.put(HmsFormatKeyEnum.INDEX.getKey(), String.valueOf(hmsArgs.getSensorIndex() + 1)); + + HmsBatteryIndexEnum hmsBatteryIndexEnum = Optional.ofNullable(hmsArgs.getSensorIndex()) + .filter(arg -> arg <= 1).map(HmsBatteryIndexEnum::find).orElse(null); + HmsDockCoverIndexEnum hmsDockCoverIndexEnum = Optional.ofNullable(hmsArgs.getSensorIndex()) + .filter(arg -> arg <= 1).map(HmsDockCoverIndexEnum::find).orElse(null); + HmsChargingRodIndexEnum hmsChargingRodIndexEnum = Optional.ofNullable(hmsArgs.getSensorIndex()) + .filter(arg -> arg <= 3).map(HmsChargingRodIndexEnum::find).orElse(null); + + switch (l) { + case "zh": + args.put(HmsFormatKeyEnum.BATTERY_INDEX.getKey(), Optional.ofNullable(hmsBatteryIndexEnum) + .map(HmsBatteryIndexEnum::getZh).orElse(null)); + args.put(HmsFormatKeyEnum.DOCK_COVER_INDEX.getKey(), Optional.ofNullable(hmsDockCoverIndexEnum) + .map(HmsDockCoverIndexEnum::getZh).orElse(null)); + args.put(HmsFormatKeyEnum.CHARGING_ROD_INDEX.getKey(), Optional.ofNullable(hmsChargingRodIndexEnum) + .map(HmsChargingRodIndexEnum::getZh).orElse(null)); + break; + case "en": + args.put(HmsFormatKeyEnum.BATTERY_INDEX.getKey(), Optional.ofNullable(hmsBatteryIndexEnum) + .map(HmsBatteryIndexEnum::getEn).orElse(null)); + args.put(HmsFormatKeyEnum.DOCK_COVER_INDEX.getKey(), Optional.ofNullable(hmsDockCoverIndexEnum) + .map(HmsDockCoverIndexEnum::getEn).orElse(null)); + args.put(HmsFormatKeyEnum.CHARGING_ROD_INDEX.getKey(), Optional.ofNullable(hmsChargingRodIndexEnum) + .map(HmsChargingRodIndexEnum::getEn).orElse(null)); + break; + default: + break; + } + + } + return args; + } + + /** + * Returns a formatted string using the specified locale, format string, and arguments. + * @param l language: zh or en + * @param format + * @param hmsArgs + * @return + */ + private String format(String l, String format, DeviceHmsArgs hmsArgs) { + Map args = fillKeyArgs(l, hmsArgs); + List list = parse(format); + StringBuilder sb = new StringBuilder(); + for (String word : list) { + if (!StringUtils.hasText(word)) { + continue; + } + sb.append(args.getOrDefault(word, word)); + } + return sb.toString(); + } + + /** + * Finds format specifiers in the format string. + * @param s + * @return + */ + private List parse(String s) { + List list = new ArrayList<>(); + Matcher matcher = PATTERN_KEY.matcher(s); + for (int i = 0; i < s.length(); ) { + if (matcher.find(i)) { + if (matcher.start() != i) { + list.add(s.substring(i, matcher.start())); + } + list.add(matcher.group()); + i = matcher.end(); + } else { + list.add(s.substring(i)); + break; + } + } + return list; + } +} diff --git a/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceLogsServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceLogsServiceImpl.java new file mode 100644 index 0000000..3f1593f --- /dev/null +++ b/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceLogsServiceImpl.java @@ -0,0 +1,314 @@ +package com.dji.sample.manage.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dji.sample.component.mqtt.model.EventsReceiver; +import com.dji.sample.component.redis.RedisConst; +import com.dji.sample.component.redis.RedisOpsUtils; +import com.dji.sample.component.websocket.model.BizCodeEnum; +import com.dji.sample.component.websocket.service.IWebSocketMessageService; +import com.dji.sample.manage.dao.IDeviceLogsMapper; +import com.dji.sample.manage.model.dto.*; +import com.dji.sample.manage.model.entity.DeviceLogsEntity; +import com.dji.sample.manage.model.enums.DeviceLogsStatusEnum; +import com.dji.sample.manage.model.enums.UserTypeEnum; +import com.dji.sample.manage.model.param.DeviceLogsCreateParam; +import com.dji.sample.manage.model.param.DeviceLogsQueryParam; +import com.dji.sample.manage.service.IDeviceLogsService; +import com.dji.sample.manage.service.IDeviceRedisService; +import com.dji.sample.manage.service.ILogsFileService; +import com.dji.sample.manage.service.ITopologyService; +import com.dji.sample.storage.service.IStorageService; +import com.dji.sdk.cloudapi.log.*; +import com.dji.sdk.cloudapi.log.api.AbstractLogService; +import com.dji.sdk.cloudapi.storage.StsCredentialsResponse; +import com.dji.sdk.common.HttpResultResponse; +import com.dji.sdk.common.Pagination; +import com.dji.sdk.common.PaginationData; +import com.dji.sdk.common.SDKManager; +import com.dji.sdk.mqtt.MqttReply; +import com.dji.sdk.mqtt.events.EventsDataRequest; +import com.dji.sdk.mqtt.events.TopicEventsRequest; +import com.dji.sdk.mqtt.events.TopicEventsResponse; +import com.dji.sdk.mqtt.services.ServicesReplyData; +import com.dji.sdk.mqtt.services.TopicServicesResponse; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.messaging.MessageHeaders; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.net.URL; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author sean + * @version 1.2 + * @date 2022/9/7 + */ +@Service +@Transactional +@Slf4j +public class DeviceLogsServiceImpl extends AbstractLogService implements IDeviceLogsService { + + private static final String LOGS_FILE_SUFFIX = ".tar"; + + @Autowired + private IDeviceLogsMapper mapper; + + @Autowired + private ITopologyService topologyService; + + @Autowired + private ILogsFileService logsFileService; + + @Autowired + private IStorageService storageService; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private IWebSocketMessageService webSocketMessageService; + + @Autowired + private IDeviceRedisService deviceRedisService; + + @Autowired + private AbstractLogService abstractLogService; + + @Override + public PaginationData getUploadedLogs(String deviceSn, DeviceLogsQueryParam param) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(DeviceLogsEntity::getDeviceSn, deviceSn) + .between(Objects.nonNull(param.getBeginTime()) && Objects.nonNull(param.getEndTime()), + DeviceLogsEntity::getCreateTime, param.getBeginTime(), param.getEndTime()) + .eq(Objects.nonNull(param.getStatus()), DeviceLogsEntity::getStatus, param.getStatus()) + .like(StringUtils.hasText(param.getLogsInformation()), + DeviceLogsEntity::getLogsInfo, param.getLogsInformation()) + .orderByDesc(DeviceLogsEntity::getCreateTime); + + Page pagination = mapper.selectPage(new Page<>(param.getPage(), param.getPageSize()), queryWrapper); + + List deviceLogsList = pagination.getRecords().stream().map(this::entity2Dto).collect(Collectors.toList()); + + return new PaginationData(deviceLogsList, new Pagination(pagination.getCurrent(), pagination.getSize(), pagination.getTotal())); + } + + @Override + public HttpResultResponse getRealTimeLogs(String deviceSn, List domainList) { + boolean exist = deviceRedisService.checkDeviceOnline(deviceSn); + if (!exist) { + return HttpResultResponse.error("Device is offline."); + } + + TopicServicesResponse> response = abstractLogService + .fileuploadList(SDKManager.getDeviceSDK(deviceSn), new FileUploadListRequest().setModuleList(domainList)); + for (FileUploadListFile file : response.getData().getOutput().getFiles()) { + if (file.getDeviceSn().isBlank()) { + file.setDeviceSn(deviceSn); + } + } + return HttpResultResponse.success(response.getData().getOutput()); + } + + @Override + public String insertDeviceLogs(String bid, String username, String deviceSn, DeviceLogsCreateParam param) { + DeviceLogsEntity entity = DeviceLogsEntity.builder() + .deviceSn(deviceSn) + .username(username) + .happenTime(param.getHappenTime()) + .logsInfo(Objects.requireNonNullElse(param.getLogsInformation(), "")) + .logsId(bid) + .status(DeviceLogsStatusEnum.UPLOADING.getVal()) + .build(); + boolean insert = mapper.insert(entity) > 0; + if (!insert) { + return ""; + } + for (FileUploadStartFile file : param.getFiles()) { + insert = logsFileService.insertFile(file, entity.getLogsId()); + if (!insert) { + return ""; + } + } + + return bid; + } + + + @Override + public HttpResultResponse pushFileUpload(String username, String deviceSn, DeviceLogsCreateParam param) { + StsCredentialsResponse stsCredentials = storageService.getSTSCredentials(); + stsCredentials.getCredentials().setExpire(System.currentTimeMillis() + (stsCredentials.getCredentials().getExpire() - 60) * 1000); + LogsUploadCredentialsDTO credentialsDTO = new LogsUploadCredentialsDTO(stsCredentials); + // Set the storage name of the file. + List files = param.getFiles(); + files.forEach(file -> file.setObjectKey(credentialsDTO.getObjectKeyPrefix() + "/" + UUID.randomUUID().toString() + LOGS_FILE_SUFFIX)); + + credentialsDTO.setParams(new FileUploadStartParam().setFiles(files)); + + TopicServicesResponse response = abstractLogService.fileuploadStart( + SDKManager.getDeviceSDK(deviceSn), new FileUploadStartRequest() + .setCredentials(stsCredentials.getCredentials()) + .setBucket(stsCredentials.getBucket()) + .setEndpoint(stsCredentials.getEndpoint()) + .setFileStoreDir(stsCredentials.getObjectKeyPrefix()) + .setProvider(stsCredentials.getProvider()) + .setRegion(stsCredentials.getRegion()) + .setParams(new FileUploadStartParam().setFiles(files))); + + if (!response.getData().getResult().isSuccess()) { + return HttpResultResponse.error(response.getData().getResult()); + } + + String id = this.insertDeviceLogs(response.getBid(), username, deviceSn, param); + + // Save the status of the log upload. + RedisOpsUtils.hashSet(RedisConst.LOGS_FILE_PREFIX + deviceSn, id, LogsOutputProgressDTO.builder().logsId(id).build()); + return HttpResultResponse.success(); + + } + + @Override + public HttpResultResponse pushUpdateFile(String deviceSn, FileUploadUpdateRequest param) { + TopicServicesResponse response = abstractLogService.fileuploadUpdate(SDKManager.getDeviceSDK(deviceSn), param); + + if (!response.getData().getResult().isSuccess()) { + return HttpResultResponse.error(response.getData().getResult()); + } + return HttpResultResponse.success(); + } + + @Override + public void deleteLogs(String deviceSn, String logsId) { + mapper.delete(new LambdaUpdateWrapper() + .eq(DeviceLogsEntity::getLogsId, logsId).eq(DeviceLogsEntity::getDeviceSn, deviceSn)); + logsFileService.deleteFileByLogsId(logsId); + } + + @Override + public TopicEventsResponse fileuploadProgress(TopicEventsRequest> request, MessageHeaders headers) { + EventsReceiver webSocketData = new EventsReceiver<>(); + webSocketData.setBid(request.getBid()); + webSocketData.setSn(request.getGateway()); + + Optional deviceOpt = deviceRedisService.getDeviceOnline(request.getGateway()); + if (deviceOpt.isEmpty()) { + return null; + } + + DeviceDTO device = deviceOpt.get(); + String key = RedisConst.LOGS_FILE_PREFIX + request.getGateway(); + + try { + FileUploadProgress output = request.getData().getOutput(); + log.info("Logs upload progress: {}", output.toString()); + + LogsOutputProgressDTO progress; + boolean exist = RedisOpsUtils.checkExist(key); + if (!exist && !output.getStatus().isEnd()) { + progress = LogsOutputProgressDTO.builder().logsId(request.getBid()).build(); + RedisOpsUtils.hashSet(key, request.getBid(), progress); + } else if (exist) { + progress = (LogsOutputProgressDTO) RedisOpsUtils.hashGet(key, request.getBid()); + } else { + progress = LogsOutputProgressDTO.builder().build(); + } + progress.setStatus(output.getStatus()); + + // If the logs file is empty, delete the cache of this task. + List fileReceivers = output.getExt().getFiles(); + if (CollectionUtils.isEmpty(fileReceivers)) { + RedisOpsUtils.del(key); + } + + // refresh cache. + List fileProgressList = new ArrayList<>(); + fileReceivers.forEach(file -> { + LogFileProgress logsProgress = file.getProgress(); + if (!StringUtils.hasText(file.getDeviceSn())) { + if (LogModuleEnum.DOCK == file.getModule()) { + file.setDeviceSn(request.getGateway()); + } else if (LogModuleEnum.DRONE == file.getModule()) { + file.setDeviceSn(device.getChildDeviceSn()); + } + } + + fileProgressList.add(LogsProgressDTO.builder() + .deviceSn(file.getDeviceSn()) + .deviceModelDomain(file.getModule().getDomain()) + .result(logsProgress.getResult()) + .status(logsProgress.getStatus().getStatus()) + .uploadRate(logsProgress.getUploadRate()) + .progress(((logsProgress.getCurrentStep() - 1) * 100 + logsProgress.getProgress()) / logsProgress.getTotalStep()) + .build()); + }); + progress.setFiles(fileProgressList); + webSocketData.setOutput(progress); + RedisOpsUtils.hashSet(RedisConst.LOGS_FILE_PREFIX + request.getGateway(), request.getBid(), progress); + // Delete the cache at the end of the task. + if (output.getStatus().isEnd()) { + RedisOpsUtils.del(key); + updateLogsStatus(request.getBid(), DeviceLogsStatusEnum.find(output.getStatus()).getVal()); + + fileReceivers.forEach(file -> logsFileService.updateFile(request.getBid(), file)); + } + } catch (NullPointerException e) { + this.updateLogsStatus(request.getBid(), DeviceLogsStatusEnum.FAILED.getVal()); + RedisOpsUtils.del(key); + } + + webSocketMessageService.sendBatch(device.getWorkspaceId(), UserTypeEnum.WEB.getVal(), + BizCodeEnum.FILE_UPLOAD_PROGRESS.getCode(), webSocketData); + + return new TopicEventsResponse().setData(MqttReply.success()); + } + + @Override + public void updateLogsStatus(String logsId, Integer value) { + + mapper.update(DeviceLogsEntity.builder().status(value).build(), + new LambdaUpdateWrapper().eq(DeviceLogsEntity::getLogsId, logsId)); + if (DeviceLogsStatusEnum.DONE.getVal() == value) { + logsFileService.updateFileUploadStatus(logsId, true); + } + } + + @Override + public URL getLogsFileUrl(String logsId, String fileId) { + return logsFileService.getLogsFileUrl(logsId, fileId); + } + + private DeviceLogsDTO entity2Dto(DeviceLogsEntity entity) { + if (Objects.isNull(entity)) { + return null; + } + String key = RedisConst.LOGS_FILE_PREFIX + entity.getDeviceSn(); + LogsOutputProgressDTO progress = null; + if (RedisOpsUtils.hashCheck(key, entity.getLogsId())) { + progress = (LogsOutputProgressDTO) RedisOpsUtils.hashGet(key, entity.getLogsId()); + } + + return DeviceLogsDTO.builder() + .logsId(entity.getLogsId()) + .createTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getCreateTime()), ZoneId.systemDefault())) + .happenTime(Objects.isNull(entity.getHappenTime()) ? + null : LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getHappenTime()), ZoneId.systemDefault())) + .status(entity.getStatus()) + .logsInformation(entity.getLogsInfo()) + .userName(entity.getUsername()) + .deviceLogs(LogsFileUploadListDTO.builder().files(logsFileService.getLogsFileByLogsId(entity.getLogsId())).build()) + .logsProgress(Objects.requireNonNullElse(progress, new LogsOutputProgressDTO()).getFiles()) + .deviceTopo(topologyService.getDeviceTopologyByGatewaySn(entity.getDeviceSn()).orElse(null)) + .build(); + } +} diff --git a/src/main/java/com/dji/sample/manage/service/impl/DevicePayloadServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/DevicePayloadServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/DevicePayloadServiceImpl.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/DevicePayloadServiceImpl.java diff --git a/src/main/java/com/dji/sample/manage/service/impl/DeviceRedisServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceRedisServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/DeviceRedisServiceImpl.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/DeviceRedisServiceImpl.java diff --git a/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java new file mode 100644 index 0000000..0ef0386 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java @@ -0,0 +1,684 @@ +package com.dji.sample.manage.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dji.sample.common.error.CommonErrorEnum; +import com.dji.sample.component.mqtt.model.EventsReceiver; +import com.dji.sample.component.websocket.model.BizCodeEnum; +import com.dji.sample.component.websocket.service.IWebSocketMessageService; +import com.dji.sample.control.model.enums.DroneAuthorityEnum; +import com.dji.sample.manage.dao.IDeviceMapper; +import com.dji.sample.manage.model.dto.*; +import com.dji.sample.manage.model.entity.DeviceEntity; +import com.dji.sample.manage.model.enums.DeviceFirmwareStatusEnum; +import com.dji.sample.manage.model.enums.PropertySetFieldEnum; +import com.dji.sample.manage.model.enums.UserTypeEnum; +import com.dji.sample.manage.model.param.DeviceQueryParam; +import com.dji.sample.manage.model.receiver.BasicDeviceProperty; +import com.dji.sample.manage.service.*; +import com.dji.sdk.cloudapi.device.*; +import com.dji.sdk.cloudapi.firmware.*; +import com.dji.sdk.cloudapi.firmware.api.AbstractFirmwareService; +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; +import com.dji.sdk.mqtt.events.EventsSubscribe; +import com.dji.sdk.mqtt.osd.OsdSubscribe; +import com.dji.sdk.mqtt.property.PropertySetReplyResultEnum; +import com.dji.sdk.mqtt.property.PropertySetSubscribe; +import com.dji.sdk.mqtt.requests.RequestsSubscribe; +import com.dji.sdk.mqtt.services.ServicesReplyData; +import com.dji.sdk.mqtt.services.ServicesSubscribe; +import com.dji.sdk.mqtt.services.TopicServicesResponse; +import com.dji.sdk.mqtt.state.StateSubscribe; +import com.dji.sdk.mqtt.status.StatusSubscribe; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * + * @author sean.zhou + * @version 0.1 + * @date 2021/11/10 + */ +@Service +@Slf4j +@Transactional +public class DeviceServiceImpl implements IDeviceService { + + @Autowired + private MqttGatewayPublish messageSender; + + @Autowired + private IDeviceMapper mapper; + + @Autowired + private IDeviceDictionaryService dictionaryService; + + @Autowired + private IMqttTopicService topicService; + + @Autowired + private IWorkspaceService workspaceService; + + @Autowired + private IDevicePayloadService payloadService; + + @Autowired + private IWebSocketMessageService webSocketMessageService; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private IDeviceFirmwareService deviceFirmwareService; + + @Autowired + private ICapacityCameraService capacityCameraService; + + @Autowired + private IDeviceRedisService deviceRedisService; + + @Autowired + private StatusSubscribe statusSubscribe; + + @Autowired + private StateSubscribe stateSubscribe; + + @Autowired + private OsdSubscribe osdSubscribe; + + @Autowired + private ServicesSubscribe servicesSubscribe; + + @Autowired + private EventsSubscribe eventsSubscribe; + + @Autowired + private RequestsSubscribe requestsSubscribe; + + @Autowired + private PropertySetSubscribe propertySetSubscribe; + + @Autowired + private AbstractPropertyService abstractPropertyService; + + @Autowired + private AbstractFirmwareService abstractFirmwareService; + + @Override + public void subDeviceOffline(String deviceSn) { + // If no information about this device exists in the cache, the drone is considered to be offline. + Optional deviceOpt = deviceRedisService.getDeviceOnline(deviceSn); + if (deviceOpt.isEmpty()) { + log.debug("The drone is already offline."); + return; + } + try { + gatewayOnlineSubscribeTopic(SDKManager.getDeviceSDK(String.valueOf(deviceOpt.get().getParentSn()))); + } catch (CloudSDKException e) { + log.debug("The gateway is already offline.", e); + } + deviceRedisService.subDeviceOffline(deviceSn); + // Publish the latest device topology information in the current workspace. + pushDeviceOfflineTopo(deviceOpt.get().getWorkspaceId(), deviceSn); + log.debug("{} offline.", deviceSn); + } + + @Override + public void gatewayOffline(String gatewaySn) { + // If no information about this device exists in the cache, the drone is considered to be offline. + Optional deviceOpt = deviceRedisService.getDeviceOnline(gatewaySn); + if (deviceOpt.isEmpty()) { + log.debug("The gateway is already offline."); + return; + } + + deviceRedisService.subDeviceOffline(deviceOpt.get().getChildDeviceSn()); + deviceRedisService.gatewayOffline(gatewaySn); + offlineUnsubscribeTopic(SDKManager.getDeviceSDK(gatewaySn)); + // Publish the latest device topology information in the current workspace. + pushDeviceOfflineTopo(deviceOpt.get().getWorkspaceId(), gatewaySn); + log.debug("{} offline.", gatewaySn); + } + + @Override + public void gatewayOnlineSubscribeTopic(GatewayManager gateway) { + statusSubscribe.subscribe(gateway); + stateSubscribe.subscribe(gateway, true); + osdSubscribe.subscribe(gateway, true); + servicesSubscribe.subscribe(gateway); + eventsSubscribe.subscribe(gateway, true); + requestsSubscribe.subscribe(gateway); + propertySetSubscribe.subscribe(gateway); + } + + @Override + public void subDeviceOnlineSubscribeTopic(GatewayManager gateway) { + statusSubscribe.subscribe(gateway); + stateSubscribe.subscribe(gateway, false); + osdSubscribe.subscribe(gateway, false); + servicesSubscribe.subscribe(gateway); + eventsSubscribe.subscribe(gateway, false); + requestsSubscribe.subscribe(gateway); + propertySetSubscribe.subscribe(gateway); + } + + @Override + public void offlineUnsubscribeTopic(GatewayManager gateway) { + statusSubscribe.unsubscribe(gateway); + stateSubscribe.unsubscribe(gateway); + osdSubscribe.unsubscribe(gateway); + servicesSubscribe.unsubscribe(gateway); + eventsSubscribe.unsubscribe(gateway); + requestsSubscribe.unsubscribe(gateway); + propertySetSubscribe.unsubscribe(gateway); + } + + @Override + public List getDevicesByParams(DeviceQueryParam param) { + return mapper.selectList( + new LambdaQueryWrapper() + .eq(StringUtils.hasText(param.getDeviceSn()), + DeviceEntity::getDeviceSn, param.getDeviceSn()) + .eq(param.getDeviceType() != null, + DeviceEntity::getDeviceType, param.getDeviceType()) + .eq(param.getSubType() != null, + DeviceEntity::getSubType, param.getSubType()) + .eq(StringUtils.hasText(param.getChildSn()), + DeviceEntity::getChildSn, param.getChildSn()) + .and(!CollectionUtils.isEmpty(param.getDomains()), wrapper -> { + for (Integer domain : param.getDomains()) { + wrapper.eq(DeviceEntity::getDomain, domain).or(); + } + }) + .eq(StringUtils.hasText(param.getWorkspaceId()), + DeviceEntity::getWorkspaceId, param.getWorkspaceId()) + .eq(param.getBoundStatus() != null, DeviceEntity::getBoundStatus, param.getBoundStatus()) + .orderBy(param.isOrderBy(), + param.isAsc(), DeviceEntity::getId)) + .stream() + .map(this::deviceEntityConvertToDTO) + .collect(Collectors.toList()); + } + + @Override + public List getDevicesTopoForWeb(String workspaceId) { + List devicesList = this.getDevicesByParams( + DeviceQueryParam.builder() + .workspaceId(workspaceId) + .domains(List.of(DeviceDomainEnum.REMOTER_CONTROL.getDomain(), DeviceDomainEnum.DOCK.getDomain())) + .build()); + + devicesList.stream() + .filter(gateway -> DeviceDomainEnum.DOCK == gateway.getDomain() || + deviceRedisService.checkDeviceOnline(gateway.getDeviceSn())) + .forEach(this::spliceDeviceTopo); + + return devicesList; + } + + @Override + public void spliceDeviceTopo(DeviceDTO gateway) { + + gateway.setStatus(deviceRedisService.checkDeviceOnline(gateway.getDeviceSn())); + + // sub device + if (!StringUtils.hasText(gateway.getChildDeviceSn())) { + return; + } + + DeviceDTO subDevice = getDevicesByParams(DeviceQueryParam.builder().deviceSn(gateway.getChildDeviceSn()).build()).get(0); + subDevice.setStatus(deviceRedisService.checkDeviceOnline(subDevice.getDeviceSn())); + gateway.setChildren(subDevice); + + // payloads + subDevice.setPayloadsList(payloadService.getDevicePayloadEntitiesByDeviceSn(gateway.getChildDeviceSn())); + } + + @Override + public Optional getDeviceTopoForPilot(String sn) { + if (!StringUtils.hasText(sn)) { + return Optional.empty(); + } + List topologyDeviceList = this.getDevicesByParams( + DeviceQueryParam.builder() + .deviceSn(sn) + .build()) + .stream() + .map(this::deviceConvertToTopologyDTO) + .collect(Collectors.toList()); + if (topologyDeviceList.isEmpty()) { + return Optional.empty(); + } + return Optional.of(topologyDeviceList.get(0)); + } + + @Override + public TopologyDeviceDTO deviceConvertToTopologyDTO(DeviceDTO device) { + if (device == null) { + return null; + } + return new TopologyDeviceDTO() + .setSn(device.getDeviceSn()) + .setDeviceCallsign(device.getNickname()) + .setDeviceModel(new TopologyDeviceModel() + .setDomain(device.getDomain()) + .setSubType(device.getSubType()) + .setType(device.getType()) + .setDeviceModelKey(DeviceEnum.find(device.getDomain(), device.getType(), device.getSubType()))) + .setIconUrls(device.getIconUrl()) + .setOnlineStatus(deviceRedisService.checkDeviceOnline(device.getDeviceSn())) + .setUserCallsign(device.getNickname()) + .setBoundStatus(device.getBoundStatus()) + .setModel(device.getDeviceName()) + .setUserId(device.getUserId()) + .setDomain(device.getDomain()) + .setGatewaySn(device.getParentSn()); + } + + @Override + public void pushDeviceOfflineTopo(String workspaceId, String deviceSn) { + webSocketMessageService.sendBatch( + workspaceId, null, com.dji.sdk.websocket.BizCodeEnum.DEVICE_OFFLINE.getCode(), + new TopologyDeviceDTO().setSn(deviceSn).setOnlineStatus(false)); + } + + @Override + public void pushDeviceOnlineTopo(String workspaceId, String gatewaySn, String deviceSn) { + webSocketMessageService.sendBatch( + workspaceId, null, com.dji.sdk.websocket.BizCodeEnum.DEVICE_ONLINE.getCode(), + getDeviceTopoForPilot(deviceSn).orElseGet(TopologyDeviceDTO::new).setGatewaySn(gatewaySn)); + } + + @Override + public void pushOsdDataToPilot(String workspaceId, String sn, DeviceOsdHost data) { + webSocketMessageService.sendBatch( + workspaceId, UserTypeEnum.PILOT.getVal(), com.dji.sdk.websocket.BizCodeEnum.DEVICE_OSD.getCode(), + new DeviceOsdWsResponse() + .setSn(sn) + .setHost(data)); + } + + @Override + public void pushOsdDataToWeb(String workspaceId, BizCodeEnum codeEnum, String sn, Object data) { + webSocketMessageService.sendBatch( + workspaceId, UserTypeEnum.WEB.getVal(), codeEnum.getCode(), TelemetryDTO.builder().sn(sn).host(data).build()); + } + + /** + * Save the device information and update the information directly if the device already exists. + * @param device + * @return + */ + public Boolean saveOrUpdateDevice(DeviceDTO device) { + int count = mapper.selectCount( + new LambdaQueryWrapper() + .eq(DeviceEntity::getDeviceSn, device.getDeviceSn())); + return count > 0 ? updateDevice(device) : saveDevice(device) > 0; + } + + /** + * Save the device information. + * @param device + * @return + */ + public Integer saveDevice(DeviceDTO device) { + DeviceEntity entity = deviceDTO2Entity(device); + return mapper.insert(entity) > 0 ? entity.getId() : -1; + } + + /** + * Convert database entity object into device data transfer object. + * @param entity + * @return + */ + private DeviceDTO deviceEntityConvertToDTO(DeviceEntity entity) { + if (entity == null) { + return null; + } + DeviceDTO.DeviceDTOBuilder builder = DeviceDTO.builder(); + try { + builder + .deviceSn(entity.getDeviceSn()) + .childDeviceSn(entity.getChildSn()) + .deviceName(entity.getDeviceName()) + .deviceDesc(entity.getDeviceDesc()) + .controlSource(ControlSourceEnum.find(entity.getDeviceIndex())) + .workspaceId(entity.getWorkspaceId()) + .type(DeviceTypeEnum.find(entity.getDeviceType())) + .subType(DeviceSubTypeEnum.find(entity.getSubType())) + .domain(DeviceDomainEnum.find(entity.getDomain())) + .iconUrl(new DeviceIconUrl() + .setNormalIconUrl(entity.getUrlNormal()) + .setSelectIconUrl(entity.getUrlSelect())) + .boundStatus(entity.getBoundStatus()) + .loginTime(entity.getLoginTime() != null ? + LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getLoginTime()), ZoneId.systemDefault()) + : null) + .boundTime(entity.getBoundTime() != null ? + LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getBoundTime()), ZoneId.systemDefault()) + : null) + .nickname(entity.getNickname()) + .firmwareVersion(entity.getFirmwareVersion()) + .workspaceName(entity.getWorkspaceId() != null ? + workspaceService.getWorkspaceByWorkspaceId(entity.getWorkspaceId()) + .map(WorkspaceDTO::getWorkspaceName).orElse("") : "") + .firmwareStatus(DeviceFirmwareStatusEnum.NOT_UPGRADE) + .thingVersion(entity.getVersion()).build(); + } catch (CloudSDKException e) { + log.error(e.getLocalizedMessage() + "Entity: {}", entity); + } + DeviceDTO deviceDTO = builder.build(); + addFirmwareStatus(deviceDTO, entity); + return deviceDTO; + } + + private void addFirmwareStatus(DeviceDTO deviceDTO, DeviceEntity entity) { + if (!StringUtils.hasText(entity.getFirmwareVersion())) { + return; + } + // Query whether the device is updating firmware. + Optional> progressOpt = deviceRedisService.getFirmwareUpgradingProgress(entity.getDeviceSn()); + if (progressOpt.isPresent()) { + deviceDTO.setFirmwareStatus(DeviceFirmwareStatusEnum.UPGRADING); + deviceDTO.setFirmwareProgress(progressOpt.map(EventsReceiver::getOutput) + .map(OtaProgress::getProgress) + .map(OtaProgressData::getPercent) + .orElse(0)); + return; + } + + // First query the latest firmware version of the device model and compare it with the current firmware version + // to see if it needs to be upgraded. + Optional firmwareReleaseNoteOpt = deviceFirmwareService.getLatestFirmwareReleaseNote(entity.getDeviceName()); + if (firmwareReleaseNoteOpt.isEmpty()) { + deviceDTO.setFirmwareStatus(DeviceFirmwareStatusEnum.NOT_UPGRADE); + return; + } + if (entity.getFirmwareVersion().equals(firmwareReleaseNoteOpt.get().getProductVersion())) { + deviceDTO.setFirmwareStatus(entity.getCompatibleStatus() ? + DeviceFirmwareStatusEnum.NOT_UPGRADE : + DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE); + return; + } + deviceDTO.setFirmwareStatus(DeviceFirmwareStatusEnum.NORMAL_UPGRADE); + } + + @Override + public Boolean updateDevice(DeviceDTO deviceDTO) { + int update = mapper.update(this.deviceDTO2Entity(deviceDTO), + new LambdaUpdateWrapper().eq(DeviceEntity::getDeviceSn, deviceDTO.getDeviceSn())); + return update > 0; + } + + @Override + public Boolean bindDevice(DeviceDTO device) { + device.setBoundStatus(true); + device.setBoundTime(LocalDateTime.now()); + + boolean isUpd = this.updateDevice(device); + if (!isUpd) { + return false; + } + + Optional deviceOpt = deviceRedisService.getDeviceOnline(device.getDeviceSn()); + if (deviceOpt.isEmpty()) { + return false; + } + + DeviceDTO redisDevice = deviceOpt.get(); + redisDevice.setWorkspaceId(device.getWorkspaceId()); + deviceRedisService.setDeviceOnline(redisDevice); + + String gatewaySn, deviceSn; + if (DeviceDomainEnum.REMOTER_CONTROL == redisDevice.getDomain()) { + gatewaySn = device.getDeviceSn(); + deviceSn = redisDevice.getChildDeviceSn(); + } else { + gatewaySn = redisDevice.getParentSn(); + deviceSn = device.getDeviceSn(); + } + + pushDeviceOnlineTopo(device.getWorkspaceId(), gatewaySn, deviceSn); + subDeviceOnlineSubscribeTopic(SDKManager.getDeviceSDK(gatewaySn)); + return true; + } + + @Override + public PaginationData getBoundDevicesWithDomain(String workspaceId, Long page, + Long pageSize, Integer domain) { + + Page pagination = mapper.selectPage(new Page<>(page, pageSize), + new LambdaQueryWrapper() + .eq(DeviceEntity::getDomain, domain) + .eq(DeviceEntity::getWorkspaceId, workspaceId) + .eq(DeviceEntity::getBoundStatus, true)); + List devicesList = pagination.getRecords().stream().map(this::deviceEntityConvertToDTO) + .peek(device -> { + device.setStatus(deviceRedisService.checkDeviceOnline(device.getDeviceSn())); + if (StringUtils.hasText(device.getChildDeviceSn())) { + Optional childOpt = this.getDeviceBySn(device.getChildDeviceSn()); + childOpt.ifPresent(child -> { + child.setStatus(deviceRedisService.checkDeviceOnline(child.getDeviceSn())); + child.setWorkspaceName(device.getWorkspaceName()); + device.setChildren(child); + }); + } + }) + .collect(Collectors.toList()); + return new PaginationData(devicesList, new Pagination(pagination.getCurrent(), pagination.getSize(), pagination.getTotal())); + } + + @Override + public void unbindDevice(String deviceSn) { + + Optional deviceOpt = deviceRedisService.getDeviceOnline(deviceSn); + if (deviceOpt.isPresent()) { + subDeviceOffline(deviceSn); + } else { + deviceOpt = getDeviceBySn(deviceSn); + } + if (deviceOpt.isEmpty()) { + return; + } + DeviceDTO device = DeviceDTO.builder() + .deviceSn(deviceSn) + .workspaceId("") + .userId("") + .boundStatus(false) + .build(); + this.updateDevice(device); + } + + @Override + public Optional getDeviceBySn(String sn) { + List devicesList = this.getDevicesByParams(DeviceQueryParam.builder().deviceSn(sn).build()); + if (devicesList.isEmpty()) { + return Optional.empty(); + } + DeviceDTO device = devicesList.get(0); + device.setStatus(deviceRedisService.checkDeviceOnline(sn)); + return Optional.of(device); + } + + @Override + public HttpResultResponse createDeviceOtaJob(String workspaceId, List upgradeDTOS) { + List deviceOtaFirmwares = deviceFirmwareService.getDeviceOtaFirmware(workspaceId, upgradeDTOS); + if (deviceOtaFirmwares.isEmpty()) { + return HttpResultResponse.error(); + } + + Optional deviceOpt = deviceRedisService.getDeviceOnline(deviceOtaFirmwares.get(0).getSn()); + if (deviceOpt.isEmpty()) { + throw new RuntimeException("Device is offline."); + } + DeviceDTO device = deviceOpt.get(); + String gatewaySn = DeviceDomainEnum.DOCK == device.getDomain() ? device.getDeviceSn() : device.getParentSn(); + + checkOtaConditions(gatewaySn); + + TopicServicesResponse> response = abstractFirmwareService.otaCreate( + SDKManager.getDeviceSDK(gatewaySn), new OtaCreateRequest().setDevices(deviceOtaFirmwares)); + ServicesReplyData serviceReply = response.getData(); + String bid = response.getBid(); + if (!serviceReply.getResult().isSuccess()) { + return HttpResultResponse.error(serviceReply.getResult()); + } + + // Record the device state that needs to be updated. + deviceOtaFirmwares.forEach(deviceOta -> deviceRedisService.setFirmwareUpgrading(deviceOta.getSn(), + EventsReceiver.builder().bid(bid).sn(deviceOta.getSn()).build())); + return HttpResultResponse.success(); + } + + /** + * Determine whether the firmware can be upgraded. + * @param dockSn + */ + private void checkOtaConditions(String dockSn) { + Optional deviceOpt = deviceRedisService.getDeviceOsd(dockSn, OsdDock.class); + if (deviceOpt.isEmpty()) { + throw new RuntimeException("Dock is offline."); + } + boolean emergencyStopState = deviceOpt.get().getEmergencyStopState(); + if (emergencyStopState) { + throw new RuntimeException("The emergency stop button of the dock is pressed and can't be upgraded."); + } + + DockModeCodeEnum dockMode = this.getDockMode(dockSn); + if (DockModeCodeEnum.IDLE != dockMode) { + throw new RuntimeException("The current status of the dock can't be upgraded."); + } + } + + @Override + public int devicePropertySet(String workspaceId, String dockSn, JsonNode param) { + String property = param.fieldNames().next(); + PropertySetFieldEnum propertyEnum = PropertySetFieldEnum.find(property); + + Optional dockOpt = deviceRedisService.getDeviceOnline(dockSn); + if (dockOpt.isEmpty()) { + throw new RuntimeException("Dock is offline."); + } + String childSn = dockOpt.get().getChildDeviceSn(); + Optional osdOpt = deviceRedisService.getDeviceOsd(childSn, OsdDockDrone.class); + if (osdOpt.isEmpty()) { + throw new RuntimeException("Device is offline."); + } + + // Make sure the data is valid. + BasicDeviceProperty basicDeviceProperty = objectMapper.convertValue(param.get(property), propertyEnum.getClazz()); + boolean valid = basicDeviceProperty.valid(); + if (!valid) { + throw new IllegalArgumentException(CommonErrorEnum.ILLEGAL_ARGUMENT.getMessage()); + } + boolean isPublish = basicDeviceProperty.canPublish(osdOpt.get()); + if (!isPublish) { + return PropertySetReplyResultEnum.SUCCESS.getResult(); + } + BaseModel baseModel = objectMapper.convertValue(param, propertyEnum.getProperty().getClazz()); + PropertySetReplyResultEnum result = abstractPropertyService.propertySet( + SDKManager.getDeviceSDK(dockSn), propertyEnum.getProperty(), baseModel); + return result.getResult(); + } + + @Override + public DockModeCodeEnum getDockMode(String dockSn) { + return deviceRedisService.getDeviceOsd(dockSn, OsdDock.class) + .map(OsdDock::getModeCode).orElse(null); + } + + @Override + public DroneModeCodeEnum getDeviceMode(String deviceSn) { + return deviceRedisService.getDeviceOsd(deviceSn, OsdDockDrone.class) + .map(OsdDockDrone::getModeCode).orElse(DroneModeCodeEnum.DISCONNECTED); + } + + @Override + public Boolean checkDockDrcMode(String dockSn) { + return deviceRedisService.getDeviceOsd(dockSn, OsdDock.class) + .map(OsdDock::getDrcState) + .orElse(DrcStateEnum.DISCONNECTED) != DrcStateEnum.DISCONNECTED; + } + + @Override + public Boolean checkAuthorityFlight(String gatewaySn) { + return deviceRedisService.getDeviceOnline(gatewaySn).flatMap(gateway -> + Optional.of((DeviceDomainEnum.DOCK == gateway.getDomain() + || DeviceDomainEnum.REMOTER_CONTROL == gateway.getDomain()) + && ControlSourceEnum.A == gateway.getControlSource())) + .orElse(true); + } + + @Override + public void updateFlightControl(DeviceDTO gateway, ControlSourceEnum controlSource) { + if (controlSource == gateway.getControlSource()) { + return; + } + gateway.setControlSource(controlSource); + deviceRedisService.setDeviceOnline(gateway); + + webSocketMessageService.sendBatch(gateway.getWorkspaceId(), UserTypeEnum.WEB.getVal(), + BizCodeEnum.CONTROL_SOURCE_CHANGE.getCode(), + DeviceAuthorityDTO.builder() + .controlSource(gateway.getControlSource()) + .sn(gateway.getDeviceSn()) + .type(DroneAuthorityEnum.FLIGHT) + .build()); + } + + /** + * Convert device data transfer object into database entity object. + * @param dto + * @return + */ + private DeviceEntity deviceDTO2Entity(DeviceDTO dto) { + DeviceEntity.DeviceEntityBuilder builder = DeviceEntity.builder(); + if (dto == null) { + return builder.build(); + } + + return builder.deviceSn(dto.getDeviceSn()) + .deviceIndex(Optional.ofNullable(dto.getControlSource()) + .map(ControlSourceEnum::getControlSource).orElse(null)) + .deviceName(dto.getDeviceName()) + .version(dto.getThingVersion()) + .userId(dto.getUserId()) + .nickname(dto.getNickname()) + .workspaceId(dto.getWorkspaceId()) + .boundStatus(dto.getBoundStatus()) + .domain(Optional.ofNullable(dto.getDomain()).map(DeviceDomainEnum::getDomain).orElse(null)) + .deviceType(Optional.ofNullable(dto.getType()).map(DeviceTypeEnum::getType).orElse(null)) + .subType(Optional.ofNullable(dto.getSubType()).map(DeviceSubTypeEnum::getSubType).orElse(null)) + .loginTime(dto.getLoginTime() != null ? + dto.getLoginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() : null) + .boundTime(dto.getBoundTime() != null ? + dto.getBoundTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() : null) + .childSn(dto.getChildDeviceSn()) + .firmwareVersion(dto.getFirmwareVersion()) + .compatibleStatus(dto.getFirmwareStatus() == null ? null : + DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE != dto.getFirmwareStatus()) + .deviceDesc(dto.getDeviceDesc()) + .build(); + } +} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/service/impl/FirmwareModelServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/FirmwareModelServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/FirmwareModelServiceImpl.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/FirmwareModelServiceImpl.java diff --git a/sample/src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java new file mode 100644 index 0000000..300c88a --- /dev/null +++ b/sample/src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java @@ -0,0 +1,233 @@ +package com.dji.sample.manage.service.impl; + +import com.dji.sample.manage.model.dto.*; +import com.dji.sample.manage.model.param.DeviceQueryParam; +import com.dji.sample.manage.service.*; +import com.dji.sdk.cloudapi.device.DeviceDomainEnum; +import com.dji.sdk.cloudapi.device.VideoId; +import com.dji.sdk.cloudapi.livestream.*; +import com.dji.sdk.cloudapi.livestream.api.AbstractLivestreamService; +import com.dji.sdk.common.HttpResultResponse; +import com.dji.sdk.common.SDKManager; +import com.dji.sdk.mqtt.services.ServicesReplyData; +import com.dji.sdk.mqtt.services.TopicServicesResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @author sean.zhou + * @date 2021/11/22 + * @version 0.1 + */ +@Service +@Transactional +public class LiveStreamServiceImpl implements ILiveStreamService { + + @Autowired + private ICapacityCameraService capacityCameraService; + + @Autowired + private IDeviceService deviceService; + + @Autowired + private IWorkspaceService workspaceService; + + @Autowired + private IDeviceRedisService deviceRedisService; + + @Autowired + private AbstractLivestreamService abstractLivestreamService; + + @Override + public List getLiveCapacity(String workspaceId) { + + // Query all devices in this workspace. + List devicesList = deviceService.getDevicesByParams( + DeviceQueryParam.builder() + .workspaceId(workspaceId) + .domains(List.of(DeviceDomainEnum.DRONE.getDomain(), DeviceDomainEnum.DOCK.getDomain())) + .build()); + + // Query the live capability of each drone. + return devicesList.stream() + .filter(device -> deviceRedisService.checkDeviceOnline(device.getDeviceSn())) + .map(device -> CapacityDeviceDTO.builder() + .name(Objects.requireNonNullElse(device.getNickname(), device.getDeviceName())) + .sn(device.getDeviceSn()) + .camerasList(capacityCameraService.getCapacityCameraByDeviceSn(device.getDeviceSn())) + .build()) + .collect(Collectors.toList()); + } + + @Override + public HttpResultResponse liveStart(LiveTypeDTO liveParam) { + // Check if this lens is available live. + HttpResultResponse responseResult = this.checkBeforeLive(liveParam.getVideoId()); + if (HttpResultResponse.CODE_SUCCESS != responseResult.getCode()) { + return responseResult; + } + + ILivestreamUrl url = LiveStreamProperty.get(liveParam.getUrlType()); + url = setExt(liveParam.getUrlType(), url, liveParam.getVideoId()); + + TopicServicesResponse> response = abstractLivestreamService.liveStartPush( + SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), + new LiveStartPushRequest() + .setUrl(url) + .setUrlType(liveParam.getUrlType()) + .setVideoId(liveParam.getVideoId()) + .setVideoQuality(liveParam.getVideoQuality())); + + if (!response.getData().getResult().isSuccess()) { + return HttpResultResponse.error(response.getData().getResult()); + } + + LiveDTO live = new LiveDTO(); + + switch (liveParam.getUrlType()) { + case AGORA: + break; + case RTMP: + live.setUrl(url.toString().replace("rtmp", "webrtc")); + break; + case GB28181: + LivestreamGb28181Url gb28181 = (LivestreamGb28181Url) url; + live.setUrl(new StringBuilder() + .append("webrtc://") + .append(gb28181.getServerIP()) + .append("/live/") + .append(gb28181.getAgentID()) + .append("@") + .append(gb28181.getChannel()) + .toString()); + break; + case RTSP: + live.setUrl(response.getData().getOutput()); + break; + case WHIP: + live.setUrl(url.toString().replace("whip", "whep")); + break; + default: + return HttpResultResponse.error(LiveErrorCodeEnum.URL_TYPE_NOT_SUPPORTED); + } + + return HttpResultResponse.success(live); + } + + @Override + public HttpResultResponse liveStop(VideoId videoId) { + HttpResultResponse responseResult = this.checkBeforeLive(videoId); + if (HttpResultResponse.CODE_SUCCESS != responseResult.getCode()) { + return responseResult; + } + + TopicServicesResponse response = abstractLivestreamService.liveStopPush( + SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), new LiveStopPushRequest() + .setVideoId(videoId)); + if (!response.getData().getResult().isSuccess()) { + return HttpResultResponse.error(response.getData().getResult()); + } + + return HttpResultResponse.success(); + } + + @Override + public HttpResultResponse liveSetQuality(LiveTypeDTO liveParam) { + HttpResultResponse responseResult = this.checkBeforeLive(liveParam.getVideoId()); + if (responseResult.getCode() != 0) { + return responseResult; + } + + TopicServicesResponse response = abstractLivestreamService.liveSetQuality( + SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), new LiveSetQualityRequest() + .setVideoQuality(liveParam.getVideoQuality()) + .setVideoId(liveParam.getVideoId())); + if (!response.getData().getResult().isSuccess()) { + return HttpResultResponse.error(response.getData().getResult()); + } + + return HttpResultResponse.success(); + } + + @Override + public HttpResultResponse liveLensChange(LiveTypeDTO liveParam) { + HttpResultResponse responseResult = this.checkBeforeLive(liveParam.getVideoId()); + if (HttpResultResponse.CODE_SUCCESS != responseResult.getCode()) { + return responseResult; + } + + TopicServicesResponse response = abstractLivestreamService.liveLensChange( + SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), new LiveLensChangeRequest() + .setVideoType(liveParam.getVideoType()) + .setVideoId(liveParam.getVideoId())); + + if (!response.getData().getResult().isSuccess()) { + return HttpResultResponse.error(response.getData().getResult()); + } + + return HttpResultResponse.success(); + } + + /** + * Check if this lens is available live. + * @param videoId + * @return + */ + private HttpResultResponse checkBeforeLive(VideoId videoId) { + if (Objects.isNull(videoId)) { + return HttpResultResponse.error(LiveErrorCodeEnum.ERROR_PARAMETERS); + } + + Optional deviceOpt = deviceService.getDeviceBySn(videoId.getDroneSn()); + // Check if the gateway device connected to this drone exists + if (deviceOpt.isEmpty()) { + return HttpResultResponse.error(LiveErrorCodeEnum.NO_AIRCRAFT); + } + + if (DeviceDomainEnum.DOCK == deviceOpt.get().getDomain()) { + return HttpResultResponse.success(deviceOpt.get()); + } + List gatewayList = deviceService.getDevicesByParams( + DeviceQueryParam.builder() + .childSn(videoId.getDroneSn()) + .build()); + if (gatewayList.isEmpty()) { + return HttpResultResponse.error(LiveErrorCodeEnum.NO_FLIGHT_CONTROL); + } + + return HttpResultResponse.success(gatewayList.get(0)); + } + + /** + * This is business-customized logic and is only used for testing. + * @param type + * @param url + * @param videoId + */ + private ILivestreamUrl setExt(UrlTypeEnum type, ILivestreamUrl url, VideoId videoId) { + switch (type) { + case AGORA: + LivestreamAgoraUrl agoraUrl = (LivestreamAgoraUrl) url.clone(); + return agoraUrl.setSn(videoId.getDroneSn()); + case RTMP: + LivestreamRtmpUrl rtmpUrl = (LivestreamRtmpUrl) url.clone(); + return rtmpUrl.setUrl(rtmpUrl.getUrl() + videoId.getDroneSn() + "-" + videoId.getPayloadIndex().toString()); + case GB28181: + String random = String.valueOf(Math.abs(videoId.getDroneSn().hashCode()) % 1000); + LivestreamGb28181Url gbUrl = (LivestreamGb28181Url) url.clone(); + gbUrl.setAgentID(gbUrl.getAgentID().substring(0, 20 - random.length()) + random); + String deviceType = String.valueOf(videoId.getPayloadIndex().getType().getType()); + return gbUrl.setChannel(gbUrl.getChannel().substring(0, 20 - deviceType.length()) + deviceType); + case WHIP: + LivestreamWhipUrl whipUrl = (LivestreamWhipUrl) url.clone(); + return whipUrl.setUrl(whipUrl.getUrl() + videoId.getDroneSn() + "-" + videoId.getPayloadIndex().toString()); + } + return url; + } +} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/service/impl/LogsFileIndexServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/LogsFileIndexServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/LogsFileIndexServiceImpl.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/LogsFileIndexServiceImpl.java diff --git a/src/main/java/com/dji/sample/manage/service/impl/LogsFileServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/LogsFileServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/LogsFileServiceImpl.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/LogsFileServiceImpl.java diff --git a/src/main/java/com/dji/sample/manage/service/impl/RequestConfigContext.java b/sample/src/main/java/com/dji/sample/manage/service/impl/RequestConfigContext.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/RequestConfigContext.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/RequestConfigContext.java diff --git a/sample/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java b/sample/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java new file mode 100644 index 0000000..c449c9a --- /dev/null +++ b/sample/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java @@ -0,0 +1,500 @@ +package com.dji.sample.manage.service.impl; + +import com.dji.sample.component.websocket.model.BizCodeEnum; +import com.dji.sample.component.websocket.service.IWebSocketMessageService; +import com.dji.sample.manage.model.dto.DeviceDTO; +import com.dji.sample.manage.model.dto.DevicePayloadReceiver; +import com.dji.sample.manage.model.enums.DeviceFirmwareStatusEnum; +import com.dji.sample.manage.model.param.DeviceQueryParam; +import com.dji.sample.manage.service.IDeviceDictionaryService; +import com.dji.sample.manage.service.IDevicePayloadService; +import com.dji.sample.manage.service.IDeviceRedisService; +import com.dji.sample.manage.service.IDeviceService; +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.config.version.GatewayManager; +import com.dji.sdk.common.SDKManager; +import com.dji.sdk.mqtt.MqttReply; +import com.dji.sdk.mqtt.osd.TopicOsdRequest; +import com.dji.sdk.mqtt.state.TopicStateRequest; +import com.dji.sdk.mqtt.status.TopicStatusRequest; +import com.dji.sdk.mqtt.status.TopicStatusResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.messaging.MessageHeaders; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @author sean + * @version 1.7 + * @date 2023/7/4 + */ +@Service +@Slf4j +public class SDKDeviceService extends AbstractDeviceService { + + @Autowired + private IDeviceRedisService deviceRedisService; + + @Autowired + private IDeviceService deviceService; + + @Autowired + private IDeviceDictionaryService dictionaryService; + + @Autowired + private IWebSocketMessageService webSocketMessageService; + + @Autowired + private IDevicePayloadService devicePayloadService; + + @Override + public TopicStatusResponse updateTopoOnline(TopicStatusRequest request, MessageHeaders headers) { + UpdateTopoSubDevice updateTopoSubDevice = request.getData().getSubDevices().get(0); + String deviceSn = updateTopoSubDevice.getSn(); + + Optional deviceOpt = deviceRedisService.getDeviceOnline(deviceSn); + Optional gatewayOpt = deviceRedisService.getDeviceOnline(request.getFrom()); + GatewayManager gatewayManager = SDKManager.registerDevice(request.getFrom(), deviceSn, + request.getData().getDomain(), request.getData().getType(), + request.getData().getSubType(), request.getData().getThingVersion(), updateTopoSubDevice.getThingVersion()); + + if (deviceOpt.isPresent() && gatewayOpt.isPresent()) { + deviceOnlineAgain(deviceOpt.get().getWorkspaceId(), request.getFrom(), deviceSn); + return new TopicStatusResponse().setData(MqttReply.success()); + } + + changeSubDeviceParent(deviceSn, request.getFrom()); + + DeviceDTO gateway = deviceGatewayConvertToDevice(request.getFrom(), request.getData()); + Optional gatewayEntityOpt = onlineSaveDevice(gateway, deviceSn, null); + if (gatewayEntityOpt.isEmpty()) { + log.error("Failed to go online, please check the status data or code logic."); + return null; + } + DeviceDTO subDevice = subDeviceConvertToDevice(updateTopoSubDevice); + Optional subDeviceEntityOpt = onlineSaveDevice(subDevice, null, gateway.getDeviceSn()); + if (subDeviceEntityOpt.isEmpty()) { + log.error("Failed to go online, please check the status data or code logic."); + return null; + } + subDevice = subDeviceEntityOpt.get(); + gateway = gatewayEntityOpt.get(); + dockGoOnline(gateway, subDevice); + deviceService.gatewayOnlineSubscribeTopic(gatewayManager); + + if (!StringUtils.hasText(subDevice.getWorkspaceId())) { + return new TopicStatusResponse().setData(MqttReply.success()); + } + + // Subscribe to topic related to drone devices. + deviceService.subDeviceOnlineSubscribeTopic(gatewayManager); + deviceService.pushDeviceOnlineTopo(gateway.getWorkspaceId(), gateway.getDeviceSn(), subDevice.getDeviceSn()); + + log.debug("{} online.", subDevice.getDeviceSn()); + return new TopicStatusResponse().setData(MqttReply.success()); + } + + @Override + public TopicStatusResponse updateTopoOffline(TopicStatusRequest request, MessageHeaders headers) { + GatewayManager gatewayManager = SDKManager.registerDevice(request.getFrom(), null, + request.getData().getDomain(), request.getData().getType(), + request.getData().getSubType(), request.getData().getThingVersion(), null); + deviceService.gatewayOnlineSubscribeTopic(gatewayManager); + // Only the remote controller is logged in and the aircraft is not connected. + Optional deviceOpt = deviceRedisService.getDeviceOnline(request.getFrom()); + if (deviceOpt.isEmpty()) { + // When connecting for the first time + DeviceDTO gatewayDevice = deviceGatewayConvertToDevice(request.getFrom(), request.getData()); + Optional gatewayDeviceOpt = onlineSaveDevice(gatewayDevice, null, null); + if (gatewayDeviceOpt.isEmpty()) { + return null; + } + deviceService.pushDeviceOnlineTopo(gatewayDeviceOpt.get().getWorkspaceId(), request.getFrom(), null); + return new TopicStatusResponse().setData(MqttReply.success()); + } + + String deviceSn = deviceOpt.get().getChildDeviceSn(); + if (!StringUtils.hasText(deviceSn)) { + return new TopicStatusResponse().setData(MqttReply.success()); + } + + deviceService.subDeviceOffline(deviceSn); + return new TopicStatusResponse().setData(MqttReply.success()); + } + + @Override + public void osdDock(TopicOsdRequest request, MessageHeaders headers) { + String from = request.getFrom(); + Optional deviceOpt = deviceRedisService.getDeviceOnline(from); + if (deviceOpt.isEmpty() || !StringUtils.hasText(deviceOpt.get().getWorkspaceId())) { + deviceOpt = deviceService.getDeviceBySn(from); + if (deviceOpt.isEmpty()) { + log.error("Please restart the drone."); + return; + } + } + + DeviceDTO device = deviceOpt.get(); + if (!StringUtils.hasText(device.getWorkspaceId())) { + log.error("Please bind the dock first."); + } + if (StringUtils.hasText(device.getChildDeviceSn())) { + deviceService.getDeviceBySn(device.getChildDeviceSn()).ifPresent(device::setChildren); + } + + deviceRedisService.setDeviceOnline(device); + fillDockOsd(from, request.getData()); + + deviceService.pushOsdDataToWeb(device.getWorkspaceId(), BizCodeEnum.DOCK_OSD, from, request.getData()); + } + + @Override + public void osdDockDrone(TopicOsdRequest request, MessageHeaders headers) { + String from = request.getFrom(); + Optional deviceOpt = deviceRedisService.getDeviceOnline(from); + if (deviceOpt.isEmpty()) { + deviceOpt = deviceService.getDeviceBySn(from); + if (deviceOpt.isEmpty()) { + log.error("Please restart the drone."); + return; + } + } + + if (!StringUtils.hasText(deviceOpt.get().getWorkspaceId())) { + log.error("Please restart the drone."); + } + + DeviceDTO device = deviceOpt.get(); + deviceRedisService.setDeviceOnline(device); + deviceRedisService.setDeviceOsd(from, request.getData()); + + deviceService.pushOsdDataToWeb(device.getWorkspaceId(), BizCodeEnum.DEVICE_OSD, from, request.getData()); + } + + @Override + public void osdRemoteControl(TopicOsdRequest request, MessageHeaders headers) { + String from = request.getFrom(); + Optional deviceOpt = deviceRedisService.getDeviceOnline(from); + if (deviceOpt.isEmpty()) { + deviceOpt = deviceService.getDeviceBySn(from); + if (deviceOpt.isEmpty()) { + log.error("Please restart the drone."); + return; + } + } + DeviceDTO device = deviceOpt.get(); + if (StringUtils.hasText(device.getChildDeviceSn())) { + deviceService.getDeviceBySn(device.getChildDeviceSn()).ifPresent(device::setChildren); + } + deviceRedisService.setDeviceOnline(device); + + OsdRemoteControl data = request.getData(); + deviceService.pushOsdDataToPilot(device.getWorkspaceId(), from, + new DeviceOsdHost() + .setLatitude(data.getLatitude()) + .setLongitude(data.getLongitude()) + .setHeight(data.getHeight())); + deviceService.pushOsdDataToWeb(device.getWorkspaceId(), BizCodeEnum.RC_OSD, from, data); + + } + + @Override + public void osdRcDrone(TopicOsdRequest request, MessageHeaders headers) { + String from = request.getFrom(); + Optional deviceOpt = deviceRedisService.getDeviceOnline(from); + if (deviceOpt.isEmpty()) { + deviceOpt = deviceService.getDeviceBySn(from); + if (deviceOpt.isEmpty()) { + log.error("Please restart the drone."); + return; + } + } + DeviceDTO device = deviceOpt.get(); + if (!StringUtils.hasText(device.getWorkspaceId())) { + log.error("Please bind the drone first."); + } + + deviceRedisService.setDeviceOnline(device); + + OsdRcDrone data = request.getData(); + deviceService.pushOsdDataToPilot(device.getWorkspaceId(), from, + new DeviceOsdHost() + .setLatitude(data.getLatitude()) + .setLongitude(data.getLongitude()) + .setElevation(data.getElevation()) + .setHeight(data.getHeight()) + .setAttitudeHead(data.getAttitudeHead()) + .setElevation(data.getElevation()) + .setHorizontalSpeed(data.getHorizontalSpeed()) + .setVerticalSpeed(data.getVerticalSpeed())); + deviceService.pushOsdDataToWeb(device.getWorkspaceId(), BizCodeEnum.DEVICE_OSD, from, data); + } + + @Override + public void dockFirmwareVersionUpdate(TopicStateRequest request, MessageHeaders headers) { + // If the reported version is empty, it will not be processed to prevent misleading page. + if (!StringUtils.hasText(request.getData().getFirmwareVersion())) { + return; + } + + DeviceDTO device = DeviceDTO.builder() + .deviceSn(request.getFrom()) + .firmwareVersion(request.getData().getFirmwareVersion()) + .firmwareStatus(request.getData().getNeedCompatibleStatus() ? + DeviceFirmwareStatusEnum.UNKNOWN : DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE) + .build(); + boolean isUpd = deviceService.updateDevice(device); + if (!isUpd) { + log.error("Data update of firmware version failed. SN: {}", request.getFrom()); + } + } + + @Override + public void rcAndDroneFirmwareVersionUpdate(TopicStateRequest request, MessageHeaders headers) { + // If the reported version is empty, it will not be processed to prevent misleading page. + if (!StringUtils.hasText(request.getData().getFirmwareVersion())) { + return; + } + + DeviceDTO device = DeviceDTO.builder() + .deviceSn(request.getFrom()) + .firmwareVersion(request.getData().getFirmwareVersion()) + .build(); + boolean isUpd = deviceService.updateDevice(device); + if (!isUpd) { + log.error("Data update of firmware version failed. SN: {}", request.getFrom()); + } + } + + @Override + public void rcPayloadFirmwareVersionUpdate(TopicStateRequest request, MessageHeaders headers) { + // If the reported version is empty, it will not be processed to prevent misleading page. + if (!StringUtils.hasText(request.getData().getFirmwareVersion())) { + return; + } + + boolean isUpd = devicePayloadService.updateFirmwareVersion(request.getFrom(), request.getData()); + if (!isUpd) { + log.error("Data update of payload firmware version failed. SN: {}", request.getFrom()); + } + } + + @Override + public void dockControlSourceUpdate(TopicStateRequest request, MessageHeaders headers) { + // If the control source is empty, it will not be processed. + if (ControlSourceEnum.UNKNOWN == request.getData().getControlSource()) { + return; + } + Optional deviceOpt = deviceRedisService.getDeviceOnline(request.getFrom()); + if (deviceOpt.isEmpty()) { + return; + } + Optional dockOpt = deviceRedisService.getDeviceOnline(request.getGateway()); + if (dockOpt.isEmpty()) { + return; + } + + deviceService.updateFlightControl(dockOpt.get(), request.getData().getControlSource()); + devicePayloadService.updatePayloadControl(deviceOpt.get(), + request.getData().getPayloads().stream() + .map(p -> DevicePayloadReceiver.builder() + .controlSource(p.getControlSource()) + .payloadIndex(p.getPayloadIndex()) + .sn(p.getSn()) + .deviceSn(request.getFrom()) + .build()).collect(Collectors.toList())); + } + + @Override + public void rcControlSourceUpdate(TopicStateRequest request, MessageHeaders headers) { + // If the control source is empty, it will not be processed. + if (ControlSourceEnum.UNKNOWN == request.getData().getControlSource()) { + return; + } + Optional deviceOpt = deviceRedisService.getDeviceOnline(request.getFrom()); + if (deviceOpt.isEmpty()) { + return; + } + Optional dockOpt = deviceRedisService.getDeviceOnline(request.getGateway()); + if (dockOpt.isEmpty()) { + return; + } + + deviceService.updateFlightControl(dockOpt.get(), request.getData().getControlSource()); + devicePayloadService.updatePayloadControl(deviceOpt.get(), + request.getData().getPayloads().stream() + .map(p -> DevicePayloadReceiver.builder() + .controlSource(p.getControlSource()) + .payloadIndex(p.getPayloadIndex()) + .sn(p.getSn()) + .deviceSn(request.getFrom()) + .build()).collect(Collectors.toList())); + } + + private void dockGoOnline(DeviceDTO gateway, DeviceDTO subDevice) { + if (DeviceDomainEnum.DOCK != gateway.getDomain()) { + return; + } + if (!StringUtils.hasText(gateway.getWorkspaceId())) { + log.error("The dock is not bound, please bind it first and then go online."); + return; + } + 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.getDeviceSn()).workspaceId(gateway.getWorkspaceId()).build()); + subDevice.setWorkspaceId(gateway.getWorkspaceId()); + } + deviceRedisService.setDeviceOnline(subDevice); + } + + private void changeSubDeviceParent(String deviceSn, String gatewaySn) { + List gatewaysList = deviceService.getDevicesByParams( + DeviceQueryParam.builder() + .childSn(deviceSn) + .build()); + gatewaysList.stream() + .filter(gateway -> !gateway.getDeviceSn().equals(gatewaySn)) + .forEach(gateway -> { + gateway.setChildDeviceSn(""); + deviceService.updateDevice(gateway); + deviceRedisService.getDeviceOnline(gateway.getDeviceSn()) + .ifPresent(device -> { + device.setChildDeviceSn(null); + deviceRedisService.setDeviceOnline(device); + }); + }); + } + + + public void deviceOnlineAgain(String workspaceId, String gatewaySn, String deviceSn) { + DeviceDTO device = DeviceDTO.builder().loginTime(LocalDateTime.now()).deviceSn(deviceSn).build(); + DeviceDTO gateway = DeviceDTO.builder() + .loginTime(LocalDateTime.now()) + .deviceSn(gatewaySn) + .childDeviceSn(deviceSn).build(); + deviceService.updateDevice(gateway); + deviceService.updateDevice(device); + gateway = deviceRedisService.getDeviceOnline(gatewaySn).map(g -> { + g.setChildDeviceSn(deviceSn); + return g; + }).get(); + device = deviceRedisService.getDeviceOnline(deviceSn).map(d -> { + d.setParentSn(gatewaySn); + return d; + }).get(); + deviceRedisService.setDeviceOnline(gateway); + deviceRedisService.setDeviceOnline(device); + if (StringUtils.hasText(workspaceId)) { + deviceService.subDeviceOnlineSubscribeTopic(SDKManager.getDeviceSDK(gatewaySn)); + } + + log.warn("{} is already online.", deviceSn); + } + + /** + * Convert the received gateway device object into a database entity object. + * @param gateway + * @return + */ + private DeviceDTO deviceGatewayConvertToDevice(String gatewaySn, UpdateTopo gateway) { + if (null == gateway) { + throw new IllegalArgumentException(); + } + return DeviceDTO.builder() + .deviceSn(gatewaySn) + .subType(gateway.getSubType()) + .type(gateway.getType()) + .thingVersion(gateway.getThingVersion()) + .domain(gateway.getDomain()) + .controlSource(gateway.getSubDevices().isEmpty() ? null : + ControlSourceEnum.find(gateway.getSubDevices().get(0).getIndex().getControlSource())) + .build(); + } + + /** + * Convert the received drone device object into a database entity object. + * @param device + * @return + */ + private DeviceDTO subDeviceConvertToDevice(UpdateTopoSubDevice device) { + if (null == device) { + throw new IllegalArgumentException(); + } + return DeviceDTO.builder() + .deviceSn(device.getSn()) + .type(device.getType()) + .subType(device.getSubType()) + .thingVersion(device.getThingVersion()) + .domain(device.getDomain()) + .build(); + } + + private Optional onlineSaveDevice(DeviceDTO device, String childSn, String parentSn) { + + device.setChildDeviceSn(childSn); + device.setLoginTime(LocalDateTime.now()); + + Optional deviceOpt = deviceService.getDeviceBySn(device.getDeviceSn()); + + if (deviceOpt.isEmpty()) { + device.setIconUrl(new DeviceIconUrl()); + // Set the icon of the gateway device displayed in the pilot's map, required in the TSA module. + device.getIconUrl().setNormalIconUrl(IconUrlEnum.NORMAL_PERSON.getUrl()); + // Set the icon of the gateway device displayed in the pilot's map when it is selected, required in the TSA module. + device.getIconUrl().setSelectIconUrl(IconUrlEnum.SELECT_PERSON.getUrl()); + device.setBoundStatus(false); + + // Query the model information of this gateway device. + dictionaryService.getOneDictionaryInfoByTypeSubType( + device.getDomain().getDomain(), device.getType().getType(), device.getSubType().getSubType()) + .ifPresent(entity -> { + device.setDeviceName(entity.getDeviceName()); + device.setNickname(entity.getDeviceName()); + device.setDeviceDesc(entity.getDeviceDesc()); + }); + } + boolean success = deviceService.saveOrUpdateDevice(device); + if (!success) { + return Optional.empty(); + } + + deviceOpt = deviceService.getDeviceBySn(device.getDeviceSn()); + DeviceDTO redisDevice = deviceOpt.get(); + redisDevice.setStatus(true); + redisDevice.setParentSn(parentSn); + + deviceRedisService.setDeviceOnline(redisDevice); + return deviceOpt; + } + + private void fillDockOsd(String dockSn, OsdDock dock) { + Optional oldDockOpt = deviceRedisService.getDeviceOsd(dockSn, OsdDock.class); + if (Objects.nonNull(dock.getJobNumber())) { + return; + } + if (oldDockOpt.isEmpty()) { + deviceRedisService.setDeviceOsd(dockSn, dock); + return; + } + OsdDock oldDock = oldDockOpt.get(); + if (Objects.nonNull(dock.getModeCode())) { + dock.setDrcState(oldDock.getDrcState()); + deviceRedisService.setDeviceOsd(dockSn, dock); + return; + } + if (Objects.nonNull(dock.getDrcState()) ) { + oldDock.setDrcState(dock.getDrcState()); + deviceRedisService.setDeviceOsd(dockSn, oldDock); + } + } +} diff --git a/src/main/java/com/dji/sample/manage/service/impl/SDKLivestreamService.java b/sample/src/main/java/com/dji/sample/manage/service/impl/SDKLivestreamService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/SDKLivestreamService.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/SDKLivestreamService.java diff --git a/src/main/java/com/dji/sample/manage/service/impl/SDKLogService.java b/sample/src/main/java/com/dji/sample/manage/service/impl/SDKLogService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/SDKLogService.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/SDKLogService.java diff --git a/src/main/java/com/dji/sample/manage/service/impl/SDKOrganizationService.java b/sample/src/main/java/com/dji/sample/manage/service/impl/SDKOrganizationService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/SDKOrganizationService.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/SDKOrganizationService.java diff --git a/src/main/java/com/dji/sample/manage/service/impl/SDKPropertySetService.java b/sample/src/main/java/com/dji/sample/manage/service/impl/SDKPropertySetService.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/SDKPropertySetService.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/SDKPropertySetService.java diff --git a/src/main/java/com/dji/sample/manage/service/impl/TopologyServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/TopologyServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/TopologyServiceImpl.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/TopologyServiceImpl.java diff --git a/sample/src/main/java/com/dji/sample/manage/service/impl/UserServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..e824ce0 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/manage/service/impl/UserServiceImpl.java @@ -0,0 +1,214 @@ +package com.dji.sample.manage.service.impl; + +import com.auth0.jwt.JWT; +import com.auth0.jwt.exceptions.TokenExpiredException; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dji.sample.common.model.CustomClaim; +import com.dji.sample.common.util.JwtUtil; +import com.dji.sample.component.mqtt.config.MqttPropertyConfiguration; +import com.dji.sample.manage.dao.IUserMapper; +import com.dji.sample.manage.model.dto.UserDTO; +import com.dji.sample.manage.model.dto.UserListDTO; +import com.dji.sample.manage.model.dto.WorkspaceDTO; +import com.dji.sample.manage.model.entity.UserEntity; +import com.dji.sample.manage.model.enums.UserTypeEnum; +import com.dji.sample.manage.service.IUserService; +import com.dji.sample.manage.service.IWorkspaceService; +import com.dji.sdk.common.HttpResultResponse; +import com.dji.sdk.common.Pagination; +import com.dji.sdk.common.PaginationData; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + +@Service +@Transactional +public class UserServiceImpl implements IUserService { + + @Autowired + private IUserMapper mapper; + + @Autowired + private MqttPropertyConfiguration mqttPropertyConfiguration; + + @Autowired + private IWorkspaceService workspaceService; + + @Override + public HttpResultResponse getUserByUsername(String username, String workspaceId) { + + UserEntity userEntity = this.getUserByUsername(username); + if (userEntity == null) { + return new HttpResultResponse() + .setCode(HttpStatus.UNAUTHORIZED.value()) + .setMessage("invalid username"); + } + + UserDTO user = this.entityConvertToDTO(userEntity); + user.setWorkspaceId(workspaceId); + + return HttpResultResponse.success(user); + } + + @Override + public HttpResultResponse userLogin(String username, String password, Integer flag) { + // check user + UserEntity userEntity = this.getUserByUsername(username); + if (userEntity == null) { + return new HttpResultResponse() + .setCode(HttpStatus.UNAUTHORIZED.value()) + .setMessage("invalid username"); + } + if (flag.intValue() != userEntity.getUserType().intValue()) { + return HttpResultResponse.error("The account type does not match."); + } + if (!password.equals(userEntity.getPassword())) { + return new HttpResultResponse() + .setCode(HttpStatus.UNAUTHORIZED.value()) + .setMessage("invalid password"); + } + + Optional workspaceOpt = workspaceService.getWorkspaceByWorkspaceId(userEntity.getWorkspaceId()); + if (workspaceOpt.isEmpty()) { + return new HttpResultResponse() + .setCode(HttpStatus.UNAUTHORIZED.value()) + .setMessage("invalid workspace id"); + } + + CustomClaim customClaim = new CustomClaim(userEntity.getUserId(), + userEntity.getUsername(), userEntity.getUserType(), + workspaceOpt.get().getWorkspaceId()); + + // create token + String token = JwtUtil.createToken(customClaim.convertToMap()); + + UserDTO userDTO = entityConvertToDTO(userEntity); + userDTO.setMqttAddr(MqttPropertyConfiguration.getBasicMqttAddress()); + userDTO.setAccessToken(token); + userDTO.setWorkspaceId(workspaceOpt.get().getWorkspaceId()); + return HttpResultResponse.success(userDTO); + } + + @Override + public Optional refreshToken(String token) { + if (!StringUtils.hasText(token)) { + return Optional.empty(); + } + CustomClaim customClaim; + try { + DecodedJWT jwt = JwtUtil.verifyToken(token); + customClaim = new CustomClaim(jwt.getClaims()); + } catch (TokenExpiredException e) { + customClaim = new CustomClaim(JWT.decode(token).getClaims()); + } catch (Exception e) { + e.printStackTrace(); + return Optional.empty(); + } + String refreshToken = JwtUtil.createToken(customClaim.convertToMap()); + + UserDTO user = entityConvertToDTO(this.getUserByUsername(customClaim.getUsername())); + if (Objects.isNull(user)) { + return Optional.empty(); + } + user.setWorkspaceId(customClaim.getWorkspaceId()); + user.setAccessToken(refreshToken); + return Optional.of(user); + } + + @Override + public PaginationData getUsersByWorkspaceId(long page, long pageSize, String workspaceId) { + Page userEntityPage = mapper.selectPage( + new Page<>(page, pageSize), + new LambdaQueryWrapper().eq(UserEntity::getWorkspaceId, workspaceId)); + + List usersList = userEntityPage.getRecords() + .stream() + .map(this::entity2UserListDTO) + .collect(Collectors.toList()); + return new PaginationData<>(usersList, new Pagination(userEntityPage.getCurrent(), userEntityPage.getSize(), userEntityPage.getTotal())); + } + + @Override + public Boolean updateUser(String workspaceId, String userId, UserListDTO user) { + UserEntity userEntity = mapper.selectOne( + new LambdaQueryWrapper() + .eq(UserEntity::getUserId, userId) + .eq(UserEntity::getWorkspaceId, workspaceId)); + if (userEntity == null) { + return false; + } + userEntity.setMqttUsername(user.getMqttUsername()); + userEntity.setMqttPassword(user.getMqttPassword()); + userEntity.setUpdateTime(System.currentTimeMillis()); + int id = mapper.update(userEntity, new LambdaUpdateWrapper() + .eq(UserEntity::getUserId, userId) + .eq(UserEntity::getWorkspaceId, workspaceId)); + + return id > 0; + } + + /** + * Convert database entity objects into user data transfer object. + * @param entity + * @return + */ + private UserListDTO entity2UserListDTO(UserEntity entity) { + UserListDTO.UserListDTOBuilder builder = UserListDTO.builder(); + if (entity != null) { + builder.userId(entity.getUserId()) + .username(entity.getUsername()) + .mqttUsername(entity.getMqttUsername()) + .mqttPassword(entity.getMqttPassword()) + .userType(UserTypeEnum.find(entity.getUserType()).getDesc()) + .createTime(LocalDateTime.ofInstant( + Instant.ofEpochMilli(entity.getCreateTime()), ZoneId.systemDefault())); + Optional workspaceOpt = workspaceService.getWorkspaceByWorkspaceId(entity.getWorkspaceId()); + workspaceOpt.ifPresent(workspace -> builder.workspaceName(workspace.getWorkspaceName())); + } + + return builder.build(); + } + + /** + * Query a user by username. + * @param username + * @return + */ + private UserEntity getUserByUsername(String username) { + return mapper.selectOne(new QueryWrapper() + .eq("username", username)); + } + + /** + * Convert database entity objects into user data transfer object. + * @param entity + * @return + */ + private UserDTO entityConvertToDTO(UserEntity entity) { + if (entity == null) { + return null; + } + return UserDTO.builder() + .userId(entity.getUserId()) + .username(entity.getUsername()) + .userType(entity.getUserType()) + .mqttUsername(entity.getMqttUsername()) + .mqttPassword(entity.getMqttPassword()) + .mqttAddr(MqttPropertyConfiguration.getBasicMqttAddress()) + .build(); + } +} diff --git a/src/main/java/com/dji/sample/manage/service/impl/WorkspaceServiceImpl.java b/sample/src/main/java/com/dji/sample/manage/service/impl/WorkspaceServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/manage/service/impl/WorkspaceServiceImpl.java rename to sample/src/main/java/com/dji/sample/manage/service/impl/WorkspaceServiceImpl.java diff --git a/sample/src/main/java/com/dji/sample/map/controller/DeviceDataController.java b/sample/src/main/java/com/dji/sample/map/controller/DeviceDataController.java new file mode 100644 index 0000000..d1ed19d --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/controller/DeviceDataController.java @@ -0,0 +1,31 @@ +package com.dji.sample.map.controller; + +import com.dji.sample.map.model.dto.DeviceDataStatusDTO; +import com.dji.sample.map.service.IDeviceDataService; +import com.dji.sdk.common.HttpResultResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/24 + */ + +@RestController +@RequestMapping("${url.map.prefix}${url.map.version}/workspaces") +public class DeviceDataController { + + @Autowired + private IDeviceDataService deviceDataService; + + @GetMapping("/{workspace_id}/device-status") + public HttpResultResponse> getDeviceFlightAreaStatus(@PathVariable(name = "workspace_id") String workspaceId) { + return HttpResultResponse.success(deviceDataService.getDevicesDataStatus(workspaceId)); + } +} diff --git a/sample/src/main/java/com/dji/sample/map/controller/FlightAreaController.java b/sample/src/main/java/com/dji/sample/map/controller/FlightAreaController.java new file mode 100644 index 0000000..2bda1a7 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/controller/FlightAreaController.java @@ -0,0 +1,66 @@ +package com.dji.sample.map.controller; + +import com.dji.sample.common.model.CustomClaim; +import com.dji.sample.map.model.dto.FlightAreaDTO; +import com.dji.sample.map.model.param.PostFlightAreaParam; +import com.dji.sample.map.model.param.PutFlightAreaParam; +import com.dji.sample.map.model.param.SyncFlightAreaParam; +import com.dji.sample.map.service.IFlightAreaService; +import com.dji.sdk.common.HttpResultResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.List; + +import static com.dji.sample.component.AuthInterceptor.TOKEN_CLAIM; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/21 + */ +@RestController +@RequestMapping("${url.map.prefix}${url.map.version}/workspaces") +public class FlightAreaController { + + @Autowired + private IFlightAreaService flightAreaService; + + @GetMapping("/{workspace_id}/flight-areas") + public HttpResultResponse> getFlightAreas(@PathVariable(name = "workspace_id") String workspaceId) { + return HttpResultResponse.success(flightAreaService.getFlightAreaList(workspaceId)); + } + + @PostMapping("/{workspace_id}/flight-area") + public HttpResultResponse createFlightArea(@PathVariable(name = "workspace_id") String workspaceId, + @Valid @RequestBody PostFlightAreaParam param, HttpServletRequest req) { + CustomClaim claims = (CustomClaim) req.getAttribute(TOKEN_CLAIM); + flightAreaService.createFlightArea(workspaceId, claims.getUsername(), param); + return HttpResultResponse.success(); + } + + @DeleteMapping("/{workspace_id}/flight-area/{area_id}") + public HttpResultResponse deleteFlightArea(@PathVariable(name = "workspace_id") String workspaceId, + @PathVariable(name = "area_id") String areaId) { + flightAreaService.deleteFlightArea(workspaceId, areaId); + return HttpResultResponse.success(); + } + + @PutMapping("/{workspace_id}/flight-area/{area_id}") + public HttpResultResponse updateFlightArea(@PathVariable(name = "workspace_id") String workspaceId, + @PathVariable(name = "area_id") String areaId, + @RequestBody PutFlightAreaParam param) { + flightAreaService.updateFlightArea(workspaceId, areaId, param); + return HttpResultResponse.success(); + } + + @PostMapping("/{workspace_id}/flight-area/sync") + public HttpResultResponse syncFlightArea(@PathVariable(name = "workspace_id") String workspaceId, + @RequestBody @Valid SyncFlightAreaParam param) { + flightAreaService.syncFlightArea(workspaceId, param.getDeviceSns()); + return HttpResultResponse.success(); + } + +} diff --git a/sample/src/main/java/com/dji/sample/map/controller/WorkspaceElementController.java b/sample/src/main/java/com/dji/sample/map/controller/WorkspaceElementController.java new file mode 100644 index 0000000..4afc12d --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/controller/WorkspaceElementController.java @@ -0,0 +1,121 @@ +package com.dji.sample.map.controller; + +import com.dji.sample.common.model.CustomClaim; +import com.dji.sample.component.websocket.service.IWebSocketMessageService; +import com.dji.sample.map.service.IWorkspaceElementService; +import com.dji.sdk.cloudapi.map.CreateMapElementRequest; +import com.dji.sdk.cloudapi.map.CreateMapElementResponse; +import com.dji.sdk.cloudapi.map.GetMapElementsResponse; +import com.dji.sdk.cloudapi.map.UpdateMapElementRequest; +import com.dji.sdk.cloudapi.map.api.IHttpMapService; +import com.dji.sdk.common.HttpResultResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.util.List; + +import static com.dji.sample.component.AuthInterceptor.TOKEN_CLAIM; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/29 + */ +@RestController +public class WorkspaceElementController implements IHttpMapService { + + @Autowired + private IWorkspaceElementService elementService; + + @Autowired + private IWebSocketMessageService sendMessageService; + + /** + * Delete all the element information in this group based on the group id. + * @param workspaceId + * @param groupId + * @return + */ + @DeleteMapping("${url.map.prefix}${url.map.version}/workspaces/{workspace_id}/element-groups/{group_id}/elements") + public HttpResultResponse deleteAllElementByGroupId(@PathVariable(name = "workspace_id") String workspaceId, + @PathVariable(name = "group_id") String groupId) { + + return elementService.deleteAllElementByGroupId(workspaceId, groupId); + } + + /** + * In the first connection, pilot will send out this http request to obtain the group element list. + * Also, if pilot receives a group refresh instruction from WebSocket, + * it needs the same interface to request the group element list. + * @param workspaceId + * @param groupId + * @param isDistributed + * @return + */ + @Override + public HttpResultResponse> getMapElements(String workspaceId, String groupId, Boolean isDistributed, HttpServletRequest req, HttpServletResponse rsp) { + List groupsList = elementService.getAllGroupsByWorkspaceId(workspaceId, groupId, isDistributed); + return HttpResultResponse.>success(groupsList); + } + + /** + * When user draws a point, line or polygon on the PILOT/Web side. + * Save the element information to the database. + * @param workspaceId + * @param groupId + * @param elementCreate + * @return + */ + @Override + public HttpResultResponse createMapElement(String workspaceId, String groupId, + @Valid CreateMapElementRequest elementCreate, HttpServletRequest req, HttpServletResponse rsp) { + CustomClaim claims = (CustomClaim) req.getAttribute(TOKEN_CLAIM); + // Set the creator of the element + elementCreate.getResource().setUsername(claims.getUsername()); + + HttpResultResponse response = elementService.saveElement(workspaceId, groupId, elementCreate, true); + if (response.getCode() != HttpResultResponse.CODE_SUCCESS) { + return response; + } + + return HttpResultResponse.success(new CreateMapElementResponse().setId(elementCreate.getId())); + } + + /** + * When user edits a point, line or polygon on the PILOT/Web side. + * Update the element information to the database. + * @param workspaceId + * @param elementId + * @param elementUpdate + * @return + */ + @Override + public HttpResultResponse updateMapElement(String workspaceId, String elementId, @Valid UpdateMapElementRequest elementUpdate, HttpServletRequest req, HttpServletResponse rsp) { + CustomClaim claims = (CustomClaim) req.getAttribute(TOKEN_CLAIM); + + HttpResultResponse response = elementService.updateElement(workspaceId, elementId, elementUpdate, claims.getUsername(), true); + if (response.getCode() != HttpResultResponse.CODE_SUCCESS) { + return response; + } + + return response; + } + + /** + * When user delete a point, line or polygon on the PILOT/Web side, + * Delete the element information in the database. + * @param workspaceId + * @param elementId + * @return + */ + @Override + public HttpResultResponse deleteMapElement(String workspaceId, String elementId, HttpServletRequest req, HttpServletResponse rsp) { + + return elementService.deleteElement(workspaceId, elementId, true); + } +} \ No newline at end of file diff --git a/sample/src/main/java/com/dji/sample/map/dao/IDeviceFlightAreaMapper.java b/sample/src/main/java/com/dji/sample/map/dao/IDeviceFlightAreaMapper.java new file mode 100644 index 0000000..6d39cd9 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/dao/IDeviceFlightAreaMapper.java @@ -0,0 +1,12 @@ +package com.dji.sample.map.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dji.sample.map.model.entity.DeviceFlightAreaEntity; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/23 + */ +public interface IDeviceFlightAreaMapper extends BaseMapper { +} diff --git a/src/main/java/com/dji/sample/map/dao/IElementCoordinateMapper.java b/sample/src/main/java/com/dji/sample/map/dao/IElementCoordinateMapper.java similarity index 100% rename from src/main/java/com/dji/sample/map/dao/IElementCoordinateMapper.java rename to sample/src/main/java/com/dji/sample/map/dao/IElementCoordinateMapper.java diff --git a/sample/src/main/java/com/dji/sample/map/dao/IFlightAreaFileMapper.java b/sample/src/main/java/com/dji/sample/map/dao/IFlightAreaFileMapper.java new file mode 100644 index 0000000..7091605 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/dao/IFlightAreaFileMapper.java @@ -0,0 +1,12 @@ +package com.dji.sample.map.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dji.sample.map.model.entity.FlightAreaFileEntity; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +public interface IFlightAreaFileMapper extends BaseMapper { +} diff --git a/sample/src/main/java/com/dji/sample/map/dao/IFlightAreaPropertyMapper.java b/sample/src/main/java/com/dji/sample/map/dao/IFlightAreaPropertyMapper.java new file mode 100644 index 0000000..4085562 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/dao/IFlightAreaPropertyMapper.java @@ -0,0 +1,12 @@ +package com.dji.sample.map.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dji.sample.map.model.entity.FlightAreaPropertyEntity; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/21 + */ +public interface IFlightAreaPropertyMapper extends BaseMapper { +} diff --git a/src/main/java/com/dji/sample/map/dao/IGroupElementMapper.java b/sample/src/main/java/com/dji/sample/map/dao/IGroupElementMapper.java similarity index 100% rename from src/main/java/com/dji/sample/map/dao/IGroupElementMapper.java rename to sample/src/main/java/com/dji/sample/map/dao/IGroupElementMapper.java diff --git a/src/main/java/com/dji/sample/map/dao/IGroupMapper.java b/sample/src/main/java/com/dji/sample/map/dao/IGroupMapper.java similarity index 100% rename from src/main/java/com/dji/sample/map/dao/IGroupMapper.java rename to sample/src/main/java/com/dji/sample/map/dao/IGroupMapper.java diff --git a/sample/src/main/java/com/dji/sample/map/model/dto/DeviceDataStatusDTO.java b/sample/src/main/java/com/dji/sample/map/model/dto/DeviceDataStatusDTO.java new file mode 100644 index 0000000..7604092 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/dto/DeviceDataStatusDTO.java @@ -0,0 +1,28 @@ +package com.dji.sample.map.model.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/24 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class DeviceDataStatusDTO { + + private String deviceSn; + + private String nickname; + + private String deviceName; + + private Boolean online; + + private DeviceFlightAreaDTO flightAreaStatus; +} diff --git a/sample/src/main/java/com/dji/sample/map/model/dto/DeviceFlightAreaDTO.java b/sample/src/main/java/com/dji/sample/map/model/dto/DeviceFlightAreaDTO.java new file mode 100644 index 0000000..16e1ca3 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/dto/DeviceFlightAreaDTO.java @@ -0,0 +1,32 @@ +package com.dji.sample.map.model.dto; + +import com.dji.sdk.cloudapi.flightarea.FlightAreaSyncReasonEnum; +import com.dji.sdk.cloudapi.flightarea.FlightAreaSyncStatusEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/23 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class DeviceFlightAreaDTO { + + private String deviceSn; + + private String workspaceId; + + private String fileId; + + private FlightAreaSyncStatusEnum syncStatus; + + private FlightAreaSyncReasonEnum syncCode; + + private String syncMsg; +} diff --git a/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaContent.java b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaContent.java new file mode 100644 index 0000000..6c93e5f --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaContent.java @@ -0,0 +1,32 @@ +package com.dji.sample.map.model.dto; + +import com.dji.sdk.cloudapi.map.ElementGeometryType; +import com.dji.sdk.cloudapi.map.ElementProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class FlightAreaContent { + + @NotNull + @Valid + private ElementProperty properties; + + @NotNull + @Valid + private ElementGeometryType geometry; + +} diff --git a/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaDTO.java b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaDTO.java new file mode 100644 index 0000000..d5d7219 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaDTO.java @@ -0,0 +1,35 @@ +package com.dji.sample.map.model.dto; + +import com.dji.sdk.cloudapi.flightarea.GeofenceTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class FlightAreaDTO { + + private String areaId; + + private String name; + + private GeofenceTypeEnum type; + + private FlightAreaContent content; + + private Boolean status; + + private String username; + + private Long createTime; + + private Long updateTime; +} diff --git a/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaFileDTO.java b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaFileDTO.java new file mode 100644 index 0000000..4138bbd --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaFileDTO.java @@ -0,0 +1,32 @@ +package com.dji.sample.map.model.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/23 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class FlightAreaFileDTO { + + private String fileId; + + private String workspaceId; + + private String name; + + private String objectKey; + + private String sign; + + private Integer size; + + private Boolean latest; +} diff --git a/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaNotifyDTO.java b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaNotifyDTO.java new file mode 100644 index 0000000..bf3023b --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaNotifyDTO.java @@ -0,0 +1,26 @@ +package com.dji.sample.map.model.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/5 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class FlightAreaNotifyDTO { + + private String sn; + + private Integer result; + + private String status; + + private String message; +} diff --git a/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaPropertyDTO.java b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaPropertyDTO.java new file mode 100644 index 0000000..1edcc21 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaPropertyDTO.java @@ -0,0 +1,30 @@ +package com.dji.sample.map.model.dto; + +import com.dji.sdk.cloudapi.flightarea.GeofenceTypeEnum; +import com.dji.sdk.cloudapi.flightarea.GeometrySubTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class FlightAreaPropertyDTO { + + private String elementId; + + private Boolean status; + + private GeofenceTypeEnum type; + + private Float radius; + + private GeometrySubTypeEnum subType; +} diff --git a/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaPropertyUpdate.java b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaPropertyUpdate.java new file mode 100644 index 0000000..8a30d2e --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaPropertyUpdate.java @@ -0,0 +1,25 @@ +package com.dji.sample.map.model.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class FlightAreaPropertyUpdate { + + private String elementId; + + private Boolean status; + + private Float radius; + +} diff --git a/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaWs.java b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaWs.java new file mode 100644 index 0000000..99d7cd7 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/dto/FlightAreaWs.java @@ -0,0 +1,36 @@ +package com.dji.sample.map.model.dto; + +import com.dji.sample.map.model.enums.FlightAreaOpertaionEnum; +import com.dji.sdk.cloudapi.flightarea.GeofenceTypeEnum; +import lombok.*; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/1 + */ +@AllArgsConstructor +@NoArgsConstructor +@Data +@Builder +public class FlightAreaWs { + + private FlightAreaOpertaionEnum operation; + + private String areaId; + + private String name; + + private GeofenceTypeEnum type; + + private FlightAreaContent content; + + private Boolean status; + + private String username; + + private Long createTime; + + private Long updateTime; + +} diff --git a/src/main/java/com/dji/sample/map/model/dto/GroupElementDTO.java b/sample/src/main/java/com/dji/sample/map/model/dto/GroupElementDTO.java similarity index 100% rename from src/main/java/com/dji/sample/map/model/dto/GroupElementDTO.java rename to sample/src/main/java/com/dji/sample/map/model/dto/GroupElementDTO.java diff --git a/sample/src/main/java/com/dji/sample/map/model/entity/DeviceFlightAreaEntity.java b/sample/src/main/java/com/dji/sample/map/model/entity/DeviceFlightAreaEntity.java new file mode 100644 index 0000000..9d239c0 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/entity/DeviceFlightAreaEntity.java @@ -0,0 +1,46 @@ +package com.dji.sample.map.model.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/23 + */ +@TableName("device_flight_area") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DeviceFlightAreaEntity implements Serializable { + + @TableId(type = IdType.AUTO) + private Integer id; + + @TableField("device_sn") + private String deviceSn; + + @TableField("workspace_id") + private String workspaceId; + + @TableField("file_id") + private String fileId; + + @TableField("sync_status") + private String syncStatus; + + @TableField("sync_code") + private Integer syncCode; + + @TableField(value = "create_time", fill = FieldFill.INSERT) + private Long createTime; + + @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) + private Long updateTime; +} diff --git a/src/main/java/com/dji/sample/map/model/entity/ElementCoordinateEntity.java b/sample/src/main/java/com/dji/sample/map/model/entity/ElementCoordinateEntity.java similarity index 100% rename from src/main/java/com/dji/sample/map/model/entity/ElementCoordinateEntity.java rename to sample/src/main/java/com/dji/sample/map/model/entity/ElementCoordinateEntity.java diff --git a/sample/src/main/java/com/dji/sample/map/model/entity/FlightAreaFileEntity.java b/sample/src/main/java/com/dji/sample/map/model/entity/FlightAreaFileEntity.java new file mode 100644 index 0000000..0f8c33a --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/entity/FlightAreaFileEntity.java @@ -0,0 +1,52 @@ +package com.dji.sample.map.model.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +@TableName("flight_area_file") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class FlightAreaFileEntity implements Serializable { + + @TableId(type = IdType.AUTO) + private Integer id; + + @TableField("file_id") + private String fileId; + + @TableField("workspace_id") + private String workspaceId; + + @TableField("name") + private String name; + + @TableField("object_key") + private String objectKey; + + @TableField("sign") + private String sign; + + @TableField("size") + private Integer size; + + @TableField("latest") + private Boolean latest; + + @TableField(value = "create_time", fill = FieldFill.INSERT) + private Long createTime; + + @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) + private Long updateTime; +} diff --git a/sample/src/main/java/com/dji/sample/map/model/entity/FlightAreaPropertyEntity.java b/sample/src/main/java/com/dji/sample/map/model/entity/FlightAreaPropertyEntity.java new file mode 100644 index 0000000..227d403 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/entity/FlightAreaPropertyEntity.java @@ -0,0 +1,41 @@ +package com.dji.sample.map.model.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/21 + */ +@TableName("flight_area_property") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class FlightAreaPropertyEntity implements Serializable { + + @TableId(type = IdType.AUTO) + private Integer id; + + @TableField("element_id") + private String elementId; + + @TableField("type") + private String type; + + @TableField("enable") + private Boolean enable; + + @TableField("sub_type") + private String subType; + + @TableField("radius") + private Integer radius; + +} diff --git a/src/main/java/com/dji/sample/map/model/entity/GroupElementEntity.java b/sample/src/main/java/com/dji/sample/map/model/entity/GroupElementEntity.java similarity index 100% rename from src/main/java/com/dji/sample/map/model/entity/GroupElementEntity.java rename to sample/src/main/java/com/dji/sample/map/model/entity/GroupElementEntity.java diff --git a/src/main/java/com/dji/sample/map/model/entity/GroupEntity.java b/sample/src/main/java/com/dji/sample/map/model/entity/GroupEntity.java similarity index 100% rename from src/main/java/com/dji/sample/map/model/entity/GroupEntity.java rename to sample/src/main/java/com/dji/sample/map/model/entity/GroupEntity.java diff --git a/sample/src/main/java/com/dji/sample/map/model/enums/FlightAreaGeometryTypeEnum.java b/sample/src/main/java/com/dji/sample/map/model/enums/FlightAreaGeometryTypeEnum.java new file mode 100644 index 0000000..4cfda0d --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/enums/FlightAreaGeometryTypeEnum.java @@ -0,0 +1,37 @@ +package com.dji.sample.map.model.enums; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +import java.util.Arrays; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/24 + */ +public enum FlightAreaGeometryTypeEnum { + + CIRCLE("Circle"), + + POLYGON("Polygon"), + + ; + + private final String type; + + FlightAreaGeometryTypeEnum(String type) { + this.type = type; + } + + @JsonValue + public String getType() { + return type; + } + + @JsonCreator + public static FlightAreaGeometryTypeEnum find(String type) { + return Arrays.stream(values()).filter(typeEnum -> typeEnum.type.equals(type)).findAny() + .orElseThrow(() -> new RuntimeException("This type(" + type + ") is not supported.")); + } +} diff --git a/sample/src/main/java/com/dji/sample/map/model/enums/FlightAreaOpertaionEnum.java b/sample/src/main/java/com/dji/sample/map/model/enums/FlightAreaOpertaionEnum.java new file mode 100644 index 0000000..0642182 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/enums/FlightAreaOpertaionEnum.java @@ -0,0 +1,39 @@ +package com.dji.sample.map.model.enums; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +import java.util.Arrays; + +/** + * @author sean + * @version 1.9 + * @date 2023/12/1 + */ +public enum FlightAreaOpertaionEnum { + + ADD("add"), + + UPDATE("update"), + + DELETE("delete") + + ; + + private final String operation; + + FlightAreaOpertaionEnum(String operation) { + this.operation = operation; + } + + @JsonValue + public String getOperation() { + return operation; + } + + @JsonCreator + public static FlightAreaOpertaionEnum find(String operation) { + return Arrays.stream(values()).filter(operationEnum -> operationEnum.operation.equals(operation)).findAny() + .orElseThrow(() -> new RuntimeException("This operation(" + operation + ") is not supported.")); + } +} diff --git a/sample/src/main/java/com/dji/sample/map/model/param/PostFlightAreaParam.java b/sample/src/main/java/com/dji/sample/map/model/param/PostFlightAreaParam.java new file mode 100644 index 0000000..dbeae02 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/param/PostFlightAreaParam.java @@ -0,0 +1,30 @@ +package com.dji.sample.map.model.param; + +import com.dji.sample.map.model.dto.FlightAreaContent; +import com.dji.sdk.cloudapi.flightarea.GeofenceTypeEnum; +import lombok.Data; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +@Data +public class PostFlightAreaParam { + + @NotNull + private String id; + + @NotNull + private String name; + + @NotNull + private GeofenceTypeEnum type; + + @NotNull + @Valid + private FlightAreaContent content; +} diff --git a/sample/src/main/java/com/dji/sample/map/model/param/PutFlightAreaParam.java b/sample/src/main/java/com/dji/sample/map/model/param/PutFlightAreaParam.java new file mode 100644 index 0000000..a1ab489 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/param/PutFlightAreaParam.java @@ -0,0 +1,20 @@ +package com.dji.sample.map.model.param; + +import com.dji.sample.map.model.dto.FlightAreaContent; +import lombok.Data; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +@Data +public class PutFlightAreaParam { + + private String name; + + private FlightAreaContent content; + + private Boolean status; + +} diff --git a/sample/src/main/java/com/dji/sample/map/model/param/SyncFlightAreaParam.java b/sample/src/main/java/com/dji/sample/map/model/param/SyncFlightAreaParam.java new file mode 100644 index 0000000..c21b8fd --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/model/param/SyncFlightAreaParam.java @@ -0,0 +1,21 @@ +package com.dji.sample.map.model.param; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +@Data +public class SyncFlightAreaParam { + + @NotNull + @JsonProperty("device_sn") + private List deviceSns; + +} diff --git a/sample/src/main/java/com/dji/sample/map/service/IDeviceDataService.java b/sample/src/main/java/com/dji/sample/map/service/IDeviceDataService.java new file mode 100644 index 0000000..c729ec9 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/IDeviceDataService.java @@ -0,0 +1,19 @@ +package com.dji.sample.map.service; + +import com.dji.sample.map.model.dto.DeviceDataStatusDTO; +import com.dji.sample.map.model.dto.DeviceFlightAreaDTO; + +import java.util.List; +import java.util.Optional; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/24 + */ +public interface IDeviceDataService { + + List getDevicesDataStatus(String workspaceId); + + Optional getDeviceStatus(String workspaceId, String deviceSn); +} diff --git a/sample/src/main/java/com/dji/sample/map/service/IDeviceFlightAreaService.java b/sample/src/main/java/com/dji/sample/map/service/IDeviceFlightAreaService.java new file mode 100644 index 0000000..42cb625 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/IDeviceFlightAreaService.java @@ -0,0 +1,19 @@ +package com.dji.sample.map.service; + +import com.dji.sample.map.model.dto.DeviceFlightAreaDTO; + +import java.util.Optional; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/23 + */ +public interface IDeviceFlightAreaService { + + Optional getDeviceFlightAreaByDevice(String workspaceId, String deviceSn); + + Boolean updateDeviceFile(DeviceFlightAreaDTO deviceFile); + + Boolean updateOrSaveDeviceFile(DeviceFlightAreaDTO deviceFile); +} diff --git a/src/main/java/com/dji/sample/map/service/IElementCoordinateService.java b/sample/src/main/java/com/dji/sample/map/service/IElementCoordinateService.java similarity index 100% rename from src/main/java/com/dji/sample/map/service/IElementCoordinateService.java rename to sample/src/main/java/com/dji/sample/map/service/IElementCoordinateService.java diff --git a/sample/src/main/java/com/dji/sample/map/service/IFlightAreaFileService.java b/sample/src/main/java/com/dji/sample/map/service/IFlightAreaFileService.java new file mode 100644 index 0000000..eb32a10 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/IFlightAreaFileService.java @@ -0,0 +1,25 @@ +package com.dji.sample.map.service; + +import com.dji.sample.map.model.dto.FlightAreaDTO; +import com.dji.sample.map.model.dto.FlightAreaFileDTO; + +import java.util.List; +import java.util.Optional; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +public interface IFlightAreaFileService { + + Optional getFlightAreaFileByFileId(String fileId); + + Integer saveFlightAreaFile(FlightAreaFileDTO file); + + Integer setNonLatestByWorkspaceId(String workspaceId); + + Optional getLatestByWorkspaceId(String workspaceId); + + FlightAreaFileDTO packageFlightAreaFile(String workspaceId, List flightAreas); +} diff --git a/sample/src/main/java/com/dji/sample/map/service/IFlightAreaPropertyServices.java b/sample/src/main/java/com/dji/sample/map/service/IFlightAreaPropertyServices.java new file mode 100644 index 0000000..977cfdf --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/IFlightAreaPropertyServices.java @@ -0,0 +1,22 @@ +package com.dji.sample.map.service; + +import com.dji.sample.map.model.dto.FlightAreaPropertyDTO; +import com.dji.sample.map.model.dto.FlightAreaPropertyUpdate; + +import java.util.List; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +public interface IFlightAreaPropertyServices { + + List getPropertyByElementIds(List elementIds); + + Integer saveProperty(FlightAreaPropertyDTO property); + + Integer deleteProperty(String elementId); + + Integer updateProperty(FlightAreaPropertyUpdate property); +} diff --git a/sample/src/main/java/com/dji/sample/map/service/IFlightAreaService.java b/sample/src/main/java/com/dji/sample/map/service/IFlightAreaService.java new file mode 100644 index 0000000..8cd1dd8 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/IFlightAreaService.java @@ -0,0 +1,32 @@ +package com.dji.sample.map.service; + +import com.dji.sample.map.model.dto.FlightAreaDTO; +import com.dji.sample.map.model.dto.FlightAreaFileDTO; +import com.dji.sample.map.model.param.PostFlightAreaParam; +import com.dji.sample.map.model.param.PutFlightAreaParam; + +import java.util.List; +import java.util.Optional; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +public interface IFlightAreaService { + + Optional getFlightAreaByAreaId(String areaId); + + List getFlightAreaList(String workspaceId); + + void createFlightArea(String workspaceId, String username, PostFlightAreaParam param); + + void syncFlightArea(String workspaceId, List deviceSns); + + FlightAreaFileDTO packageFlightArea(String workspaceId); + + void deleteFlightArea(String workspaceId, String areaId); + + void updateFlightArea(String workspaceId, String areaId, PutFlightAreaParam param); + +} diff --git a/src/main/java/com/dji/sample/map/service/IGroupElementService.java b/sample/src/main/java/com/dji/sample/map/service/IGroupElementService.java similarity index 100% rename from src/main/java/com/dji/sample/map/service/IGroupElementService.java rename to sample/src/main/java/com/dji/sample/map/service/IGroupElementService.java diff --git a/sample/src/main/java/com/dji/sample/map/service/IGroupService.java b/sample/src/main/java/com/dji/sample/map/service/IGroupService.java new file mode 100644 index 0000000..9ff1170 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/IGroupService.java @@ -0,0 +1,31 @@ +package com.dji.sample.map.service; + +import com.dji.sdk.cloudapi.map.GetMapElementsResponse; + +import java.util.List; +import java.util.Optional; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/29 + */ +public interface IGroupService { + + /** + * Query all groups in the workspace based on the workspace's id. + * If the group id does not exist, do not add this filter condition. + * @param workspaceId + * @param groupId + * @param isDistributed Used to define if the group needs to be distributed. Default is true. + * @return + */ + List getAllGroupsByWorkspaceId(String workspaceId, String groupId, Boolean isDistributed); + + /** + * Get the custom flight area group under this workspace. + * @param workspaceId + * @return + */ + Optional getCustomGroupByWorkspaceId(String workspaceId); +} diff --git a/sample/src/main/java/com/dji/sample/map/service/IWorkspaceElementService.java b/sample/src/main/java/com/dji/sample/map/service/IWorkspaceElementService.java new file mode 100644 index 0000000..58f5fe9 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/IWorkspaceElementService.java @@ -0,0 +1,84 @@ +package com.dji.sample.map.service; + +import com.dji.sample.map.model.dto.GroupElementDTO; +import com.dji.sdk.cloudapi.map.*; +import com.dji.sdk.common.HttpResultResponse; + +import java.util.List; +import java.util.Optional; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/30 + */ +public interface IWorkspaceElementService { + + /** + * Query all groups in the workspace based on the workspace's id, + * including the information of the elements in the group, and the coordinate information in the elements. + * @param workspaceId + * @param groupId + * @param isDistributed + * @return + */ + List getAllGroupsByWorkspaceId(String workspaceId, String groupId, Boolean isDistributed); + + /** + * Save all the elements, including the information of the elements in the group, + * and the coordinate information in the elements. + * + * @param workspaceId + * @param groupId + * @param elementCreate + * @param notify + * @return + */ + HttpResultResponse saveElement(String workspaceId, String groupId, CreateMapElementRequest elementCreate, boolean notify); + + /** + * Update the element information based on the element id, + * including the information of the elements in the group, and the coordinate information in the elements. + * + * @param workspaceId + * @param elementId + * @param elementUpdate + * @param username + * @param notify + * @return + */ + HttpResultResponse updateElement(String workspaceId, String elementId, UpdateMapElementRequest elementUpdate, String username, boolean notify); + + /** + * Delete the element information based on the element id, + * including the information of the elements in the group, and the coordinate information in the elements. + * + * @param workspaceId + * @param elementId + * @param notify + * @return + */ + HttpResultResponse deleteElement(String workspaceId, String elementId, boolean notify); + + /** + * Query an element based on the element id, + * including the information of the elements in the group, and the coordinate information in the elements. + * @param elementId + * @return + */ + Optional getElementByElementId(String elementId); + + /** + * Delete all the elements information based on the group id, + * including the information of the elements in the group, and the coordinate information in the elements. + * + * @param workspaceId + * @param groupId + * @return + */ + HttpResultResponse deleteAllElementByGroupId(String workspaceId, String groupId); + + MapElementCreateWsResponse element2CreateWsElement(GroupElementDTO element); + + MapElementUpdateWsResponse element2UpdateWsElement(GroupElementDTO element); +} \ No newline at end of file diff --git a/sample/src/main/java/com/dji/sample/map/service/impl/DeviceDataServiceImpl.java b/sample/src/main/java/com/dji/sample/map/service/impl/DeviceDataServiceImpl.java new file mode 100644 index 0000000..ee591b3 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/impl/DeviceDataServiceImpl.java @@ -0,0 +1,62 @@ +package com.dji.sample.map.service.impl; + +import com.dji.sample.common.error.CommonErrorEnum; +import com.dji.sample.manage.model.dto.DeviceDTO; +import com.dji.sample.manage.model.param.DeviceQueryParam; +import com.dji.sample.manage.service.IDeviceRedisService; +import com.dji.sample.manage.service.IDeviceService; +import com.dji.sample.map.model.dto.DeviceDataStatusDTO; +import com.dji.sample.map.model.dto.DeviceFlightAreaDTO; +import com.dji.sample.map.service.IDeviceDataService; +import com.dji.sample.map.service.IDeviceFlightAreaService; +import com.dji.sdk.cloudapi.device.DeviceDomainEnum; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/24 + */ +@Service +public class DeviceDataServiceImpl implements IDeviceDataService { + + @Autowired + private IDeviceService deviceService; + + @Autowired + private IDeviceRedisService deviceRedisService; + + @Autowired + private IDeviceFlightAreaService deviceFlightAreaService; + + @Override + public List getDevicesDataStatus(String workspaceId) { + List devices = deviceService.getDevicesByParams(DeviceQueryParam.builder() + .domains(List.of(DeviceDomainEnum.DOCK.getDomain())).workspaceId(workspaceId).build()); + if (CollectionUtils.isEmpty(devices)) { + throw new RuntimeException(CommonErrorEnum.ILLEGAL_ARGUMENT.getMessage()); + } + return devices.stream().map(device -> DeviceDataStatusDTO.builder() + .deviceName(device.getDeviceName()) + .deviceSn(device.getDeviceSn()) + .nickname(device.getNickname()) + .online(deviceRedisService.checkDeviceOnline(device.getDeviceSn())) + .flightAreaStatus(getDeviceStatus(workspaceId, device.getDeviceSn()).orElse(null)) + .build()) + .filter(device -> Objects.nonNull(device.getFlightAreaStatus())) + .collect(Collectors.toList()); + } + + @Override + public Optional getDeviceStatus(String workspaceId, String deviceSn) { + return deviceFlightAreaService.getDeviceFlightAreaByDevice(workspaceId, deviceSn) + .map(area -> DeviceFlightAreaDTO.builder().syncStatus(area.getSyncStatus()).syncCode(area.getSyncCode()).syncMsg(area.getSyncMsg()).build()); + } +} diff --git a/sample/src/main/java/com/dji/sample/map/service/impl/DeviceFlightAreaServiceImpl.java b/sample/src/main/java/com/dji/sample/map/service/impl/DeviceFlightAreaServiceImpl.java new file mode 100644 index 0000000..4ad5ece --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/impl/DeviceFlightAreaServiceImpl.java @@ -0,0 +1,85 @@ +package com.dji.sample.map.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.dji.sample.map.dao.IDeviceFlightAreaMapper; +import com.dji.sample.map.model.dto.DeviceFlightAreaDTO; +import com.dji.sample.map.model.entity.DeviceFlightAreaEntity; +import com.dji.sample.map.service.IDeviceFlightAreaService; +import com.dji.sdk.cloudapi.flightarea.FlightAreaSyncReasonEnum; +import com.dji.sdk.cloudapi.flightarea.FlightAreaSyncStatusEnum; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/23 + */ +@Service +@Transactional +public class DeviceFlightAreaServiceImpl implements IDeviceFlightAreaService { + + @Autowired + private IDeviceFlightAreaMapper mapper; + + @Override + public Optional getDeviceFlightAreaByDevice(String workspaceId, String deviceSn) { + return Optional.ofNullable(mapper.selectOne(Wrappers.lambdaQuery(DeviceFlightAreaEntity.class) + .eq(DeviceFlightAreaEntity::getWorkspaceId, workspaceId) + .eq(DeviceFlightAreaEntity::getDeviceSn, deviceSn))) + .map(this::entity2Dto); + } + + @Override + public Boolean updateDeviceFile(DeviceFlightAreaDTO deviceFile) { + return mapper.update(dto2Entity(deviceFile), + Wrappers.lambdaUpdate(DeviceFlightAreaEntity.class) + .eq(DeviceFlightAreaEntity::getWorkspaceId, deviceFile.getWorkspaceId()) + .eq(DeviceFlightAreaEntity::getDeviceSn, deviceFile.getDeviceSn())) > 0; + } + + @Override + public Boolean updateOrSaveDeviceFile(DeviceFlightAreaDTO deviceFile) { + if (getDeviceFlightAreaByDevice(deviceFile.getWorkspaceId(), deviceFile.getDeviceSn()).isPresent()) { + return updateDeviceFile(deviceFile); + } + DeviceFlightAreaEntity entity = dto2Entity(deviceFile); + entity.setFileId(UUID.randomUUID().toString()); + return mapper.insert(entity) > 0; + } + + private DeviceFlightAreaEntity dto2Entity(DeviceFlightAreaDTO dto) { + if (Objects.isNull(dto)) { + return null; + } + return DeviceFlightAreaEntity.builder() + .deviceSn(dto.getDeviceSn()) + .workspaceId(dto.getWorkspaceId()) + .fileId(dto.getFileId()) + .syncCode(dto.getSyncCode().getReason()) + .syncStatus(dto.getSyncStatus().getStatus()) + .build(); + } + + private DeviceFlightAreaDTO entity2Dto(DeviceFlightAreaEntity entity) { + if (Objects.isNull(entity)) { + return null; + } + FlightAreaSyncReasonEnum syncCodeEnum = FlightAreaSyncReasonEnum.find(entity.getSyncCode()); + return DeviceFlightAreaDTO.builder() + .deviceSn(entity.getDeviceSn()) + .workspaceId(entity.getWorkspaceId()) + .fileId(entity.getFileId()) + .syncCode(syncCodeEnum) + .syncStatus(FlightAreaSyncStatusEnum.find(entity.getSyncStatus())) + .syncMsg(syncCodeEnum.getMsg()) + .build(); + } + + +} diff --git a/src/main/java/com/dji/sample/map/service/impl/ElementCoordinateServiceImpl.java b/sample/src/main/java/com/dji/sample/map/service/impl/ElementCoordinateServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/map/service/impl/ElementCoordinateServiceImpl.java rename to sample/src/main/java/com/dji/sample/map/service/impl/ElementCoordinateServiceImpl.java diff --git a/sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaFileServiceImpl.java b/sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaFileServiceImpl.java new file mode 100644 index 0000000..ed918ac --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaFileServiceImpl.java @@ -0,0 +1,184 @@ +package com.dji.sample.map.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.dji.sample.component.oss.model.OssConfiguration; +import com.dji.sample.component.oss.service.impl.OssServiceContext; +import com.dji.sample.map.dao.IFlightAreaFileMapper; +import com.dji.sample.map.model.dto.FlightAreaDTO; +import com.dji.sample.map.model.dto.FlightAreaFileDTO; +import com.dji.sample.map.model.entity.FlightAreaFileEntity; +import com.dji.sample.map.service.IFlightAreaFileService; +import com.dji.sample.map.service.IFlightAreaPropertyServices; +import com.dji.sample.map.service.IGroupService; +import com.dji.sample.map.service.IWorkspaceElementService; +import com.dji.sdk.cloudapi.flightarea.*; +import com.dji.sdk.cloudapi.map.ElementCircleGeometry; +import com.dji.sdk.cloudapi.map.ElementPointGeometry; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.codec.digest.DigestUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +@Service +@Transactional +public class FlightAreaFileServiceImpl implements IFlightAreaFileService { + + @Autowired + private IFlightAreaFileMapper mapper; + + @Autowired + private IWorkspaceElementService workspaceElementService; + + @Autowired + private IGroupService groupService; + + @Autowired + private OssServiceContext ossServiceContext; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private IFlightAreaPropertyServices flightAreaPropertyServices; + + @Override + public Optional getFlightAreaFileByFileId(String fileId) { + return Optional.ofNullable(mapper.selectOne(Wrappers.lambdaQuery(FlightAreaFileEntity.class) + .eq(FlightAreaFileEntity::getFileId, fileId))) + .map(this::entity2Dto); + } + + @Override + public Integer saveFlightAreaFile(FlightAreaFileDTO file) { + FlightAreaFileEntity entity = dto2Entity(file); + int id = mapper.insert(entity); + return id > 0 ? entity.getId() : id; + } + + @Override + public Integer setNonLatestByWorkspaceId(String workspaceId) { + return mapper.update(FlightAreaFileEntity.builder().latest(false).build(), + Wrappers.lambdaUpdate(FlightAreaFileEntity.class) + .eq(FlightAreaFileEntity::getWorkspaceId, workspaceId) + .eq(FlightAreaFileEntity::getLatest, true)); + } + + @Override + public Optional getLatestByWorkspaceId(String workspaceId) { + return Optional.ofNullable(mapper.selectOne(Wrappers.lambdaQuery(FlightAreaFileEntity.class) + .eq(FlightAreaFileEntity::getWorkspaceId, workspaceId) + .eq(FlightAreaFileEntity::getLatest, true) + .orderByDesc(FlightAreaFileEntity::getUpdateTime) + .last(" limit 1"))) + .map(this::entity2Dto); + } + + @Override + public FlightAreaFileDTO packageFlightAreaFile(String workspaceId, List flightAreas) { + Optional fileOpt = getLatestByWorkspaceId(workspaceId); + if (fileOpt.isPresent()) { + return fileOpt.get(); + } + FlightAreaFileDTO file = generateFlightAreaFile(workspaceId, flightAreas); + int id = saveFlightAreaFile(file); + if (id <= 0) { + throw new RuntimeException("Failed to save the flight area file."); + } + return file; + } + + private FlightAreaFileDTO generateFlightAreaFile(String workspaceId, List flightAreas) { + + FlightAreaJson flightAreaJson = new FlightAreaJson() + .setFeatures(flightAreas.stream() + .map(this::generateFlightAreaFeature) + .collect(Collectors.toList())); + try (ByteArrayOutputStream os = new ByteArrayOutputStream(64); + JsonGenerator generator = objectMapper.createGenerator(os);) { + generator.writePOJO(flightAreaJson); + try (ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray())) { + String name = String.format("geofence_%s.json", org.springframework.util.DigestUtils.md5DigestAsHex(is)); + is.reset(); + String objectKey = OssConfiguration.objectDirPrefix + "/" + name; + ossServiceContext.putObject(OssConfiguration.bucket, objectKey, is); + return FlightAreaFileDTO.builder() + .name(name) + .objectKey(objectKey) + .fileId(UUID.randomUUID().toString()) + .size(os.size()) + .workspaceId(workspaceId) + .sign(DigestUtils.sha256Hex(os.toByteArray())) + .latest(true) + .build(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + + } + + private FlightAreaFeature generateFlightAreaFeature(FlightAreaDTO area) { + GeometrySubTypeEnum subType = null; + Float radius = 0f; + if (area.getContent().getGeometry() instanceof ElementCircleGeometry) { + ElementCircleGeometry geometry = (ElementCircleGeometry) area.getContent().getGeometry(); + subType = GeometrySubTypeEnum.CIRCLE; + radius = geometry.getRadius(); + area.getContent().setGeometry(new ElementPointGeometry().setCoordinates(geometry.getCoordinates())); + } + return new FlightAreaFeature() + .setGeofenceType(area.getType()) + .setId(area.getAreaId()) + .setProperties(new FeatureProperty() + .setSubType(subType) + .setRadius(radius) + .setEnable(area.getStatus())) + .setGeometry(objectMapper.convertValue(area.getContent().getGeometry(), FlightAreaGeometry.class)); + } + + private FlightAreaFileDTO entity2Dto(FlightAreaFileEntity entity) { + if (Objects.isNull(entity)) { + return null; + } + return FlightAreaFileDTO.builder() + .fileId(entity.getFileId()) + .name(entity.getName()) + .objectKey(entity.getObjectKey()) + .sign(entity.getSign()) + .size(entity.getSize()) + .workspaceId(entity.getWorkspaceId()) + .latest(entity.getLatest()) + .build(); + } + + private FlightAreaFileEntity dto2Entity(FlightAreaFileDTO dto) { + if (dto == null) { + return null; + } + return FlightAreaFileEntity.builder() + .fileId(dto.getFileId()) + .size(dto.getSize()) + .name(dto.getName()) + .sign(dto.getSign()) + .objectKey(dto.getObjectKey()) + .workspaceId(dto.getWorkspaceId()) + .latest(dto.getLatest()) + .build(); + } +} diff --git a/sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaPropertyServiceImpl.java b/sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaPropertyServiceImpl.java new file mode 100644 index 0000000..79fc147 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaPropertyServiceImpl.java @@ -0,0 +1,100 @@ +package com.dji.sample.map.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.dji.sample.map.dao.IFlightAreaPropertyMapper; +import com.dji.sample.map.model.dto.FlightAreaPropertyDTO; +import com.dji.sample.map.model.dto.FlightAreaPropertyUpdate; +import com.dji.sample.map.model.entity.FlightAreaPropertyEntity; +import com.dji.sample.map.service.IFlightAreaPropertyServices; +import com.dji.sdk.cloudapi.flightarea.GeofenceTypeEnum; +import com.dji.sdk.cloudapi.flightarea.GeometrySubTypeEnum; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +@Service +@Transactional +public class FlightAreaPropertyServiceImpl implements IFlightAreaPropertyServices { + + @Autowired + private IFlightAreaPropertyMapper mapper; + + @Override + public List getPropertyByElementIds(List elementIds) { + if (CollectionUtils.isEmpty(elementIds)) { + return Collections.emptyList(); + } + return mapper.selectList( + Wrappers.lambdaQuery(FlightAreaPropertyEntity.class) + .in(FlightAreaPropertyEntity::getElementId, elementIds)).stream() + .map(this::fillProperty).collect(Collectors.toList()); + } + + @Override + public Integer saveProperty(FlightAreaPropertyDTO property) { + FlightAreaPropertyEntity entity = dto2Entity(property); + int id = mapper.insert(entity); + return id > 0 ? entity.getId() : id; + } + + @Override + public Integer deleteProperty(String elementId) { + return mapper.delete(Wrappers.lambdaUpdate(FlightAreaPropertyEntity.class).eq(FlightAreaPropertyEntity::getElementId, elementId)); + } + + @Override + public Integer updateProperty(FlightAreaPropertyUpdate property) { + return mapper.update(update2Entity(property), + Wrappers.lambdaUpdate(FlightAreaPropertyEntity.class).eq(FlightAreaPropertyEntity::getElementId, property.getElementId())); + } + + private FlightAreaPropertyDTO fillProperty(FlightAreaPropertyEntity entity) { + if (Objects.isNull(entity)) { + return null; + } + FlightAreaPropertyDTO.FlightAreaPropertyDTOBuilder builder = FlightAreaPropertyDTO.builder() + .elementId(entity.getElementId()) + .status(entity.getEnable()) + .type(GeofenceTypeEnum.find(entity.getType())) + .subType(Optional.ofNullable(entity.getSubType()).map(GeometrySubTypeEnum::find).orElse(null)) + .radius(entity.getRadius().floatValue() / 100); + + return builder.build(); + } + + private FlightAreaPropertyEntity dto2Entity(FlightAreaPropertyDTO dto) { + if (Objects.isNull(dto)) { + return null; + } + return FlightAreaPropertyEntity.builder() + .elementId(dto.getElementId()) + .enable(dto.getStatus()) + .subType(Optional.ofNullable(dto.getSubType()).map(GeometrySubTypeEnum::getSubType).orElse(null)) + .type(dto.getType().getType()) + .radius(Optional.ofNullable(dto.getRadius()).map(radius -> radius * 100).map(Float::intValue).orElse(null)) + .build(); + } + + private FlightAreaPropertyEntity update2Entity(FlightAreaPropertyUpdate property) { + if (Objects.isNull(property)) { + return null; + } + return FlightAreaPropertyEntity.builder() + .radius(Optional.ofNullable(property.getRadius()).map(radius -> radius * 100).map(Float::intValue).orElse(null)) + .enable(property.getStatus()) + .elementId(property.getElementId()) + .build(); + } +} diff --git a/sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaServiceImpl.java b/sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaServiceImpl.java new file mode 100644 index 0000000..8d210dd --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaServiceImpl.java @@ -0,0 +1,335 @@ +package com.dji.sample.map.service.impl; + +import com.dji.sample.common.error.CommonErrorEnum; +import com.dji.sample.component.oss.model.OssConfiguration; +import com.dji.sample.component.oss.service.impl.OssServiceContext; +import com.dji.sample.component.websocket.model.BizCodeEnum; +import com.dji.sample.component.websocket.service.IWebSocketMessageService; +import com.dji.sample.manage.model.dto.DeviceDTO; +import com.dji.sample.manage.model.dto.TelemetryDTO; +import com.dji.sample.manage.service.IDeviceRedisService; +import com.dji.sample.map.model.dto.*; +import com.dji.sample.map.model.enums.FlightAreaGeometryTypeEnum; +import com.dji.sample.map.model.enums.FlightAreaOpertaionEnum; +import com.dji.sample.map.model.param.PostFlightAreaParam; +import com.dji.sample.map.model.param.PutFlightAreaParam; +import com.dji.sample.map.service.*; +import com.dji.sdk.cloudapi.flightarea.*; +import com.dji.sdk.cloudapi.flightarea.api.AbstractFlightAreaService; +import com.dji.sdk.cloudapi.map.*; +import com.dji.sdk.common.HttpResultResponse; +import com.dji.sdk.common.SDKManager; +import com.dji.sdk.mqtt.MqttReply; +import com.dji.sdk.mqtt.events.TopicEventsRequest; +import com.dji.sdk.mqtt.events.TopicEventsResponse; +import com.dji.sdk.mqtt.requests.TopicRequestsRequest; +import com.dji.sdk.mqtt.requests.TopicRequestsResponse; +import com.dji.sdk.mqtt.services.ServicesReplyData; +import com.dji.sdk.mqtt.services.TopicServicesResponse; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.messaging.MessageHeaders; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +@Service +@Transactional +@Slf4j +public class FlightAreaServiceImpl extends AbstractFlightAreaService implements IFlightAreaService { + + @Autowired + private IFlightAreaPropertyServices flightAreaPropertyServices; + + @Autowired + private IGroupService groupService; + + @Autowired + private IWorkspaceElementService workspaceElementService; + + @Autowired + private IDeviceRedisService deviceRedisService; + + @Autowired + private SDKFlightAreaService abstractFlightAreaService; + + @Autowired + private IFlightAreaFileService flightAreaFileService; + + @Autowired + private IDeviceFlightAreaService deviceFlightAreaService; + + @Autowired + private OssServiceContext ossServiceContext; + + @Autowired + private IWebSocketMessageService webSocketMessageService; + + @Autowired + private ObjectMapper objectMapper; + + @Override + public Optional getFlightAreaByAreaId(String areaId) { + List properties = flightAreaPropertyServices.getPropertyByElementIds(List.of(areaId)); + if (CollectionUtils.isEmpty(properties)) { + return Optional.empty(); + } + Optional elementOpt = workspaceElementService.getElementByElementId(areaId); + return elementOpt.map(groupElementDTO -> this.element2FlightArea(objectMapper.convertValue(groupElementDTO, MapGroupElement.class), properties.get(0))); + } + + @Override + public List getFlightAreaList(String workspaceId) { + Optional> elementsOpt = groupService.getCustomGroupByWorkspaceId(workspaceId) + .map(group -> workspaceElementService.getAllGroupsByWorkspaceId(workspaceId, group.getId(), null)); + if (elementsOpt.isEmpty()) { + return Collections.emptyList(); + } + List elements = elementsOpt.get().get(0).getElements(); + Map propertyMap = flightAreaPropertyServices.getPropertyByElementIds( + elements.stream().map(MapGroupElement::getId).collect(Collectors.toList())) + .stream().collect(Collectors.toMap(FlightAreaPropertyDTO::getElementId, property -> property)); + return elements.stream().map(element -> this.element2FlightArea(element, propertyMap.get(element.getId()))).collect(Collectors.toList()); + } + + @Override + public void createFlightArea(String workspaceId, String username, PostFlightAreaParam param) { + Optional groupOpt = groupService.getCustomGroupByWorkspaceId(workspaceId); + if (groupOpt.isEmpty()) { + throw new RuntimeException("The custom flight area group does not exist, please create it first."); + } + ElementGeometryType geometry = param.getContent().getGeometry(); + String type = geometry.getType(); + ElementResourceTypeEnum typeEnum; + FlightAreaPropertyDTO property = new FlightAreaPropertyDTO(); + property.setType(param.getType()); + property.setStatus(true); + property.setElementId(param.getId()); + if (GeometrySubTypeEnum.CIRCLE.getSubType().equals(type)) { + ElementCircleGeometry circleGeometry = (ElementCircleGeometry) geometry; + property.setRadius(circleGeometry.getRadius()); + property.setSubType(GeometrySubTypeEnum.find(type)); + typeEnum = ElementResourceTypeEnum.find(ElementResourceTypeEnum.POINT.getTypeName()); + param.getContent().setGeometry(new ElementPointGeometry().setCoordinates(circleGeometry.getCoordinates())); + } else { + typeEnum = ElementResourceTypeEnum.find(type); + } + HttpResultResponse response = workspaceElementService.saveElement(workspaceId, groupOpt.get().getId(), + new CreateMapElementRequest().setId(param.getId()).setName(param.getName()) + .setResource(new ElementResource() + .setUsername(username) + .setType(typeEnum) + .setContent(new ElementContent() + .setGeometry(param.getContent().getGeometry()) + .setProperties(param.getContent().getProperties()))), false); + if (HttpResultResponse.CODE_FAILED == response.getCode()) { + throw new RuntimeException(response.getMessage()); + } + + int id = flightAreaPropertyServices.saveProperty(property); + if (id <= 0) { + throw new RuntimeException("Failed to save flight area properties."); + } + flightAreaFileService.setNonLatestByWorkspaceId(workspaceId); + + webSocketMessageService.sendBatch(workspaceId, BizCodeEnum.FLIGHT_AREAS_UPDATE.getCode(), + FlightAreaWs.builder() + .operation(FlightAreaOpertaionEnum.ADD) + .areaId(param.getId()) + .username(username) + .type(param.getType()) + .name(param.getName()) + .updateTime(System.currentTimeMillis()) + .createTime(System.currentTimeMillis()) + .content(FlightAreaContent.builder().geometry(geometry).properties(param.getContent().getProperties()).build()) + .status(true) + .build()); + } + + @Override + public void syncFlightArea(String workspaceId, List deviceSns) { + for (String deviceSn : deviceSns) { + Optional deviceOpt = deviceRedisService.getDeviceOnline(deviceSn); + if (deviceOpt.isEmpty() || !workspaceId.equals(deviceOpt.get().getWorkspaceId())) { + throw new RuntimeException(CommonErrorEnum.ILLEGAL_ARGUMENT.getMessage()); + } + TopicServicesResponse response = abstractFlightAreaService.flightAreasUpdate(SDKManager.getDeviceSDK(deviceSn)); + if (!response.getData().getResult().isSuccess()) { + throw new RuntimeException(response.getData().getResult().getMessage()); + } + } + packageFlightArea(workspaceId); + } + + @Override + public FlightAreaFileDTO packageFlightArea(String workspaceId) { + List flightAreas = getFlightAreaList(workspaceId); + return flightAreaFileService.packageFlightAreaFile(workspaceId, flightAreas); + } + + @Override + public void deleteFlightArea(String workspaceId, String areaId) { + HttpResultResponse response = workspaceElementService.deleteElement(workspaceId, areaId, false); + if (HttpResultResponse.CODE_SUCCESS !=response.getCode()) { + throw new RuntimeException(response.getMessage()); + } + int id = flightAreaPropertyServices.deleteProperty(areaId); + if (id <= 0) { + throw new RuntimeException("Failed to delete the flight area property."); + } + flightAreaFileService.setNonLatestByWorkspaceId(workspaceId); + webSocketMessageService.sendBatch(workspaceId, BizCodeEnum.FLIGHT_AREAS_UPDATE.getCode(), + FlightAreaWs.builder() + .operation(FlightAreaOpertaionEnum.DELETE) + .areaId(areaId) + .build()); + } + + @Override + public void updateFlightArea(String workspaceId, String areaId, PutFlightAreaParam param) { + Float radius = null; + if (Objects.nonNull(param.getContent())) { + ElementGeometryType geometry = param.getContent().getGeometry(); + FlightAreaGeometryTypeEnum typeEnum = FlightAreaGeometryTypeEnum.find(geometry.getType()); + if (FlightAreaGeometryTypeEnum.CIRCLE == typeEnum) { + radius = ((ElementCircleGeometry) geometry).getRadius(); + geometry = new ElementPointGeometry().setCoordinates(((ElementCircleGeometry) geometry).getCoordinates()); + } + Optional elementOpt = workspaceElementService.getElementByElementId(areaId); + if (elementOpt.isEmpty() || !elementOpt.get().getResource().getType().getTypeName().equals(geometry.getType())) { + throw new RuntimeException(CommonErrorEnum.ILLEGAL_ARGUMENT.getMessage()); + } + workspaceElementService.updateElement(workspaceId, areaId, + new UpdateMapElementRequest() + .setName(param.getName()) + .setContent(new ElementContent() + .setProperties(param.getContent().getProperties()) + .setGeometry(geometry)), + null, false); + } + + int id = flightAreaPropertyServices.updateProperty(FlightAreaPropertyUpdate.builder() + .elementId(areaId).status(param.getStatus()).radius(radius).build()); + if (id <= 0) { + throw new RuntimeException("Failed to update flight area properties."); + } + flightAreaFileService.setNonLatestByWorkspaceId(workspaceId); + Optional areaOpt = getFlightAreaByAreaId(areaId); + areaOpt.ifPresent(area -> webSocketMessageService.sendBatch(workspaceId, + BizCodeEnum.FLIGHT_AREAS_UPDATE.getCode(), + FlightAreaWs.builder() + .operation(FlightAreaOpertaionEnum.UPDATE) + .areaId(areaId) + .name(area.getName()) + .content(area.getContent()) + .status(area.getStatus()) + .type(area.getType()) + .username(area.getUsername()) + .createTime(area.getCreateTime()) + .updateTime(area.getUpdateTime()) + .build())); + + } + + @Override + public TopicEventsResponse flightAreasSyncProgress(TopicEventsRequest request, MessageHeaders headers) { + Optional deviceOpt = deviceRedisService.getDeviceOnline(request.getGateway()); + if (deviceOpt.isEmpty()) { + log.warn("method: flight_areas_sync_progress. Dock is offline."); + return null; + } + + FlightAreasSyncProgress data = request.getData(); + String workspaceId = deviceOpt.get().getWorkspaceId(); + + DeviceFlightAreaDTO deviceFlightArea = DeviceFlightAreaDTO.builder() + .deviceSn(request.getGateway()) + .workspaceId(workspaceId) + .syncStatus(data.getStatus()) + .syncCode(data.getReason()) + .build(); + deviceFlightAreaService.updateOrSaveDeviceFile(deviceFlightArea); + webSocketMessageService.sendBatch(workspaceId, BizCodeEnum.FLIGHT_AREAS_SYNC_PROGRESS.getCode(), + FlightAreaNotifyDTO.builder() + .sn(request.getGateway()) + .result(data.getReason().getReason()) + .message(data.getReason().getMsg()) + .status(data.getStatus().getStatus()) + .build()); + return new TopicEventsResponse<>(); + } + + @Override + public TopicEventsResponse flightAreasDroneLocation(TopicEventsRequest request, MessageHeaders headers) { + Optional deviceOpt = deviceRedisService.getDeviceOnline(request.getGateway()); + if (deviceOpt.isEmpty()) { + log.warn("method: flight_areas_drone_location. Dock is offline."); + return null; + } + if (request.getData().getDroneLocations().isEmpty()) { + return new TopicEventsResponse<>(); + } + webSocketMessageService.sendBatch(deviceOpt.get().getWorkspaceId(), BizCodeEnum.FLIGHT_AREAS_DRONE_LOCATION.getCode(), + TelemetryDTO.builder().sn(deviceOpt.get().getChildDeviceSn()).host(request.getData()).build()); + return new TopicEventsResponse<>(); + } + + @Override + public TopicRequestsResponse> flightAreasGet(TopicRequestsRequest request, MessageHeaders headers) { + Optional deviceOpt = deviceRedisService.getDeviceOnline(request.getGateway()); + if (deviceOpt.isEmpty()) { + return null; + } + DeviceDTO device = deviceOpt.get(); + Optional flightAreaOpt = deviceFlightAreaService.getDeviceFlightAreaByDevice(device.getWorkspaceId(), device.getDeviceSn()); + Optional fileOpt = Optional.empty(); + if (flightAreaOpt.isPresent()) { + fileOpt = flightAreaFileService.getFlightAreaFileByFileId(flightAreaOpt.get().getFileId()); + } + FlightAreaFileDTO file = fileOpt.orElse(null); + if (flightAreaOpt.isEmpty() || fileOpt.isEmpty()) { + file = packageFlightArea(device.getWorkspaceId()); + } + return new TopicRequestsResponse>().setData( + MqttReply.success(new FlightAreasGetResponse().setFiles( + List.of(new FlightAreaGetFile() + .setName(file.getName()) + .setSize(file.getSize()) + .setChecksum(file.getSign()) + .setUrl(ossServiceContext.getObjectUrl(OssConfiguration.bucket, file.getObjectKey()).toString()) + )))); + } + + private FlightAreaDTO element2FlightArea(MapGroupElement element, FlightAreaPropertyDTO property) { + FlightAreaDTO.FlightAreaDTOBuilder builder = FlightAreaDTO.builder() + .areaId(element.getId()) + .name(element.getName()) + .createTime(element.getCreateTime()) + .updateTime(element.getUpdateTime()) + .username(element.getResource().getUsername()) + .content(FlightAreaContent.builder() + .properties(element.getResource().getContent().getProperties()) + .geometry(element.getResource().getContent().getGeometry()) + .build()); + if (Objects.isNull(property)) { + return builder.build(); + } + FlightAreaDTO flightArea = builder.type(property.getType()).status(property.getStatus()).build(); + if (GeometrySubTypeEnum.CIRCLE == property.getSubType()) { + ElementPointGeometry point = (ElementPointGeometry) flightArea.getContent().getGeometry(); + flightArea.getContent().setGeometry(new ElementCircleGeometry() + .setRadius(property.getRadius()) + .setCoordinates(new Double[]{point.getCoordinates()[0], point.getCoordinates()[1]})); + } + return flightArea; + } +} diff --git a/sample/src/main/java/com/dji/sample/map/service/impl/GroupElementServiceImpl.java b/sample/src/main/java/com/dji/sample/map/service/impl/GroupElementServiceImpl.java new file mode 100644 index 0000000..21b25e5 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/impl/GroupElementServiceImpl.java @@ -0,0 +1,216 @@ +package com.dji.sample.map.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.dji.sample.map.dao.IGroupElementMapper; +import com.dji.sample.map.model.dto.GroupElementDTO; +import com.dji.sample.map.model.entity.GroupElementEntity; +import com.dji.sdk.cloudapi.map.ElementTypeEnum; +import com.dji.sample.map.service.IElementCoordinateService; +import com.dji.sample.map.service.IGroupElementService; +import com.dji.sdk.cloudapi.map.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/29 + */ +@Service +@Transactional +public class GroupElementServiceImpl implements IGroupElementService { + + @Autowired + private IGroupElementMapper mapper; + + @Autowired + private IElementCoordinateService elementCoordinateService; + + @Override + public List getElementsByGroupId(String groupId) { + List elementList = mapper.selectList( + new LambdaQueryWrapper() + .eq(GroupElementEntity::getGroupId, groupId)); + + List groupElementList = new ArrayList<>(); + for (GroupElementEntity elementEntity : elementList) { + MapGroupElement groupElement = this.entityConvertToDto(elementEntity); + groupElementList.add(groupElement); + + this.addCoordinateToElement(groupElement, elementEntity); + } + return groupElementList; + } + + @Override + public Boolean saveElement(String groupId, CreateMapElementRequest elementCreate) { + Optional groupElementOpt = this.getEntityByElementId(elementCreate.getId()); + + if (groupElementOpt.isPresent()) { + return false; + } + GroupElementEntity groupElement = this.createDtoConvertToEntity(elementCreate); + groupElement.setGroupId(groupId); + + boolean saveElement = mapper.insert(groupElement) > 0; + if (!saveElement) { + return false; + } + // save coordinate + return elementCoordinateService.saveCoordinate( + elementCreate.getResource().getContent().getGeometry().convertToList(), elementCreate.getId()); + } + + @Override + public Boolean updateElement(String elementId, UpdateMapElementRequest elementUpdate, String username) { + Optional groupElementOpt = this.getEntityByElementId(elementId); + if (groupElementOpt.isEmpty()) { + return false; + } + + GroupElementEntity groupElement = groupElementOpt.get(); + groupElement.setUsername(username); + this.updateEntityWithDto(elementUpdate, groupElement); + boolean update = mapper.updateById(groupElement) > 0; + if (!update) { + return false; + } + // delete all coordinates according to element id. + boolean delCoordinate = elementCoordinateService.deleteCoordinateByElementId(elementId); + // save coordinate + boolean saveCoordinate = elementCoordinateService.saveCoordinate( + elementUpdate.getContent().getGeometry().convertToList(), elementId); + return delCoordinate & saveCoordinate; + } + + @Override + public Boolean deleteElement(String elementId) { + Optional groupElementOpt = this.getEntityByElementId(elementId); + if (groupElementOpt.isEmpty()) { + return true; + } + + GroupElementEntity groupElement = groupElementOpt.get(); + return mapper.deleteById(groupElement.getId()) > 0; + } + + + @Override + public Optional getElementByElementId(String elementId) { + Optional elementEntityOpt = this.getEntityByElementId(elementId); + if (elementEntityOpt.isEmpty()) { + return Optional.empty(); + } + GroupElementEntity elementEntity = elementEntityOpt.get(); + MapGroupElement groupElement = this.entityConvertToDto(elementEntity); + + this.addCoordinateToElement(groupElement, elementEntity); + return Optional.ofNullable(groupElement2Dto(groupElement, elementEntity.getGroupId())); + } + + private GroupElementDTO groupElement2Dto(MapGroupElement element, String groupId) { + if (null == element) { + return null; + } + return GroupElementDTO.builder() + .elementId(element.getId()) + .groupId(groupId) + .updateTime(element.getUpdateTime()) + .createTime(element.getCreateTime()) + .name(element.getName()) + .resource(element.getResource()) + .build(); + } + + /** + * Adds the received coordinate data to the element object. + * @param element + * @param elementEntity + */ + private void addCoordinateToElement(MapGroupElement element, GroupElementEntity elementEntity) { + Optional coordinateOpt = ElementTypeEnum.findType(elementEntity.getElementType()); + if (coordinateOpt.isEmpty()) { + return; + } + element.getResource() + .setContent(new ElementContent() + .setProperties(new ElementProperty() + .setClampToGround(elementEntity.getClampToGround()) + .setColor(elementEntity.getColor())) + .setGeometry(coordinateOpt.get())); + + coordinateOpt.get().adapterCoordinateType( + elementCoordinateService.getCoordinateByElementId(elementEntity.getElementId())); + } + + /** + * Query an element based on the element id。 + * @param elementId + * @return + */ + private Optional getEntityByElementId(String elementId) { + return Optional.ofNullable(mapper.selectOne( + new LambdaQueryWrapper() + .eq(GroupElementEntity::getElementId, elementId))); + } + + /** + * Convert database entity objects into element data transfer object. + * @param entity + * @return + */ + private MapGroupElement entityConvertToDto(GroupElementEntity entity) { + if (entity == null) { + return null; + } + + return new MapGroupElement() + .setId(entity.getElementId()) + .setName(entity.getElementName()) + .setCreateTime(entity.getCreateTime()) + .setUpdateTime(entity.getUpdateTime()) + .setResource(new ElementResource() + .setType(ElementResourceTypeEnum.find(entity.getElementType())) + .setUsername(entity.getUsername())); + } + + /** + * Convert the received element object into a database entity object. + * @param elementCreate + * @return + */ + private GroupElementEntity createDtoConvertToEntity(CreateMapElementRequest elementCreate) { + ElementProperty properties = elementCreate.getResource().getContent().getProperties(); + return GroupElementEntity.builder() + .elementId(elementCreate.getId()) + .elementName(elementCreate.getName()) + .username(elementCreate.getResource().getUsername()) + .elementType(ElementTypeEnum.findVal(elementCreate.getResource().getContent().getGeometry().getType())) + .clampToGround(properties.getClampToGround() != null && properties.getClampToGround()) + .color(properties.getColor()) + .build(); + } + + /** + * Add the content that needs to be updated to the entity object to be updated. + * @param elementUpdate + * @param groupElement + */ + private void updateEntityWithDto(UpdateMapElementRequest elementUpdate, GroupElementEntity groupElement) { + if (elementUpdate == null || groupElement == null) { + return; + } + + groupElement.setElementName(elementUpdate.getName()); + groupElement.setElementType(ElementTypeEnum.findVal(elementUpdate.getContent().getGeometry().getType())); + groupElement.setColor(elementUpdate.getContent().getProperties().getColor()); + + Boolean clampToGround = elementUpdate.getContent().getProperties().getClampToGround(); + groupElement.setClampToGround(clampToGround); + } +} diff --git a/sample/src/main/java/com/dji/sample/map/service/impl/GroupServiceImpl.java b/sample/src/main/java/com/dji/sample/map/service/impl/GroupServiceImpl.java new file mode 100644 index 0000000..a73cc3b --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/impl/GroupServiceImpl.java @@ -0,0 +1,74 @@ +package com.dji.sample.map.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.dji.sample.map.dao.IGroupMapper; +import com.dji.sample.map.model.entity.GroupEntity; +import com.dji.sample.map.service.IGroupElementService; +import com.dji.sample.map.service.IGroupService; +import com.dji.sdk.cloudapi.map.GetMapElementsResponse; +import com.dji.sdk.cloudapi.map.GroupTypeEnum; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/29 + */ +@Service +@Transactional +public class GroupServiceImpl implements IGroupService { + + @Autowired + private IGroupMapper mapper; + + @Autowired + private IGroupElementService groupElementService; + + @Override + public List getAllGroupsByWorkspaceId(String workspaceId, String groupId, Boolean isDistributed) { + + return mapper.selectList( + new LambdaQueryWrapper() + .eq(GroupEntity::getWorkspaceId, workspaceId) + .eq(StringUtils.hasText(groupId), GroupEntity::getGroupId, groupId) + .eq(isDistributed != null, GroupEntity::getIsDistributed, isDistributed)) + .stream() + .map(this::entityConvertToDto) + .collect(Collectors.toList()); + } + + @Override + public Optional getCustomGroupByWorkspaceId(String workspaceId) { + return Optional.ofNullable(mapper.selectOne( + Wrappers.lambdaQuery(GroupEntity.class) + .eq(GroupEntity::getWorkspaceId, workspaceId) + .eq(GroupEntity::getGroupType, GroupTypeEnum.CUSTOM.getType()) + .last(" limit 1"))) + .map(this::entityConvertToDto); + } + + /** + * Convert database entity objects into group data transfer object. + * @param entity + * @return + */ + private GetMapElementsResponse entityConvertToDto(GroupEntity entity) { + if (entity == null) { + return null; + } + + return new GetMapElementsResponse() + .setId(entity.getGroupId()) + .setName(entity.getGroupName()) + .setType(GroupTypeEnum.find(entity.getGroupType())) + .setLock(entity.getIsLock()); + } +} diff --git a/sample/src/main/java/com/dji/sample/map/service/impl/SDKFlightAreaService.java b/sample/src/main/java/com/dji/sample/map/service/impl/SDKFlightAreaService.java new file mode 100644 index 0000000..7076452 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/impl/SDKFlightAreaService.java @@ -0,0 +1,14 @@ +package com.dji.sample.map.service.impl; + +import com.dji.sdk.cloudapi.flightarea.api.AbstractFlightAreaService; +import org.springframework.stereotype.Service; + +/** + * @author sean + * @version 1.9 + * @date 2023/11/22 + */ +@Service +public class SDKFlightAreaService extends AbstractFlightAreaService { + +} diff --git a/sample/src/main/java/com/dji/sample/map/service/impl/WorkspaceElementServiceImpl.java b/sample/src/main/java/com/dji/sample/map/service/impl/WorkspaceElementServiceImpl.java new file mode 100644 index 0000000..7773c0d --- /dev/null +++ b/sample/src/main/java/com/dji/sample/map/service/impl/WorkspaceElementServiceImpl.java @@ -0,0 +1,149 @@ +package com.dji.sample.map.service.impl; + +import com.dji.sample.component.websocket.model.BizCodeEnum; +import com.dji.sample.component.websocket.service.IWebSocketMessageService; +import com.dji.sample.map.model.dto.GroupElementDTO; +import com.dji.sample.map.service.IElementCoordinateService; +import com.dji.sample.map.service.IGroupElementService; +import com.dji.sample.map.service.IGroupService; +import com.dji.sample.map.service.IWorkspaceElementService; +import com.dji.sdk.cloudapi.map.*; +import com.dji.sdk.common.HttpResultResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Optional; + +/** + * @author sean + * @version 0.2 + * @date 2021/11/30 + */ +@Transactional +@Service +public class WorkspaceElementServiceImpl implements IWorkspaceElementService { + + @Autowired + private IGroupService groupService; + + @Autowired + private IGroupElementService groupElementService; + + @Autowired + private IElementCoordinateService elementCoordinateService; + + @Autowired + private IWebSocketMessageService webSocketMessageService; + + @Override + public List getAllGroupsByWorkspaceId(String workspaceId, String groupId, Boolean isDistributed) { + List groupList = groupService.getAllGroupsByWorkspaceId(workspaceId, groupId, isDistributed); + groupList.forEach(group -> group.setElements(groupElementService.getElementsByGroupId(group.getId()))); + return groupList; + } + + @Override + public HttpResultResponse saveElement(String workspaceId, String groupId, CreateMapElementRequest elementCreate, boolean notify) { + boolean saveElement = groupElementService.saveElement(groupId, elementCreate); + if (!saveElement) { + return HttpResultResponse.error("Failed to save the element."); + } + if (notify) { + // Notify all WebSocket connections in this workspace to be updated when an element is created. + getElementByElementId(elementCreate.getId()) + .ifPresent(groupElement -> webSocketMessageService.sendBatch( + workspaceId, BizCodeEnum.MAP_ELEMENT_CREATE.getCode(), + element2CreateWsElement(groupElement))); + } + return HttpResultResponse.success(); + } + + @Override + public HttpResultResponse updateElement(String workspaceId, String elementId, UpdateMapElementRequest elementUpdate, String username, boolean notify) { + boolean updElement = groupElementService.updateElement(elementId, elementUpdate, username); + if (!updElement) { + return HttpResultResponse.error("Failed to update the element."); + } + + if (notify) { + // Notify all WebSocket connections in this workspace to update when there is an element update. + getElementByElementId(elementId) + .ifPresent(groupElement -> webSocketMessageService.sendBatch( + workspaceId, BizCodeEnum.MAP_ELEMENT_UPDATE.getCode(), + element2UpdateWsElement(groupElement))); + } + return HttpResultResponse.success(); + } + + @Override + public HttpResultResponse deleteElement(String workspaceId, String elementId, boolean notify) { + Optional elementOpt = getElementByElementId(elementId); + boolean delElement = groupElementService.deleteElement(elementId); + if (!delElement) { + return HttpResultResponse.error("Failed to delete the element."); + } + + // delete all coordinates according to element id. + boolean delCoordinate = elementCoordinateService.deleteCoordinateByElementId(elementId); + if (!delCoordinate) { + return HttpResultResponse.error("Failed to delete the coordinate."); + } + + if (notify) { + // Notify all WebSocket connections in this workspace to update when an element is deleted. + elementOpt.ifPresent(element -> + webSocketMessageService.sendBatch(workspaceId, BizCodeEnum.MAP_ELEMENT_DELETE.getCode(), + new MapElementDeleteWsResponse() + .setGroupId(element.getGroupId()) + .setId(elementId))); + } + + return HttpResultResponse.success(); + } + + @Override + public Optional getElementByElementId(String elementId) { + return groupElementService.getElementByElementId(elementId); + } + + @Override + public HttpResultResponse deleteAllElementByGroupId(String workspaceId, String groupId) { + List groupElementList = groupElementService.getElementsByGroupId(groupId); + for (MapGroupElement groupElement : groupElementList) { + HttpResultResponse response = this.deleteElement(workspaceId, groupElement.getId(), true); + if (HttpResultResponse.CODE_SUCCESS != response.getCode()) { + return response; + } + } + + return HttpResultResponse.success(); + } + + public MapElementCreateWsResponse element2CreateWsElement(GroupElementDTO element) { + if (element == null) { + return null; + } + return new MapElementCreateWsResponse() + .setId(element.getElementId()) + .setGroupId(element.getGroupId()) + .setName(element.getName()) + .setResource(element.getResource()) + .setUpdateTime(element.getUpdateTime()) + .setCreateTime(element.getCreateTime()); + } + + public MapElementUpdateWsResponse element2UpdateWsElement(GroupElementDTO element) { + if (element == null) { + return null; + } + return new MapElementUpdateWsResponse() + .setId(element.getElementId()) + .setGroupId(element.getGroupId()) + .setName(element.getName()) + .setResource(element.getResource()) + .setUpdateTime(element.getUpdateTime()) + .setCreateTime(element.getCreateTime()); + } +} diff --git a/src/main/java/com/dji/sample/media/controller/FileController.java b/sample/src/main/java/com/dji/sample/media/controller/FileController.java similarity index 100% rename from src/main/java/com/dji/sample/media/controller/FileController.java rename to sample/src/main/java/com/dji/sample/media/controller/FileController.java diff --git a/src/main/java/com/dji/sample/media/controller/MediaController.java b/sample/src/main/java/com/dji/sample/media/controller/MediaController.java similarity index 100% rename from src/main/java/com/dji/sample/media/controller/MediaController.java rename to sample/src/main/java/com/dji/sample/media/controller/MediaController.java diff --git a/src/main/java/com/dji/sample/media/dao/IFileMapper.java b/sample/src/main/java/com/dji/sample/media/dao/IFileMapper.java similarity index 100% rename from src/main/java/com/dji/sample/media/dao/IFileMapper.java rename to sample/src/main/java/com/dji/sample/media/dao/IFileMapper.java diff --git a/src/main/java/com/dji/sample/media/model/MediaFileCountDTO.java b/sample/src/main/java/com/dji/sample/media/model/MediaFileCountDTO.java similarity index 100% rename from src/main/java/com/dji/sample/media/model/MediaFileCountDTO.java rename to sample/src/main/java/com/dji/sample/media/model/MediaFileCountDTO.java diff --git a/src/main/java/com/dji/sample/media/model/MediaFileDTO.java b/sample/src/main/java/com/dji/sample/media/model/MediaFileDTO.java similarity index 100% rename from src/main/java/com/dji/sample/media/model/MediaFileDTO.java rename to sample/src/main/java/com/dji/sample/media/model/MediaFileDTO.java diff --git a/src/main/java/com/dji/sample/media/model/MediaFileEntity.java b/sample/src/main/java/com/dji/sample/media/model/MediaFileEntity.java similarity index 100% rename from src/main/java/com/dji/sample/media/model/MediaFileEntity.java rename to sample/src/main/java/com/dji/sample/media/model/MediaFileEntity.java diff --git a/src/main/java/com/dji/sample/media/model/MediaMethodEnum.java b/sample/src/main/java/com/dji/sample/media/model/MediaMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sample/media/model/MediaMethodEnum.java rename to sample/src/main/java/com/dji/sample/media/model/MediaMethodEnum.java diff --git a/src/main/java/com/dji/sample/media/service/IFileService.java b/sample/src/main/java/com/dji/sample/media/service/IFileService.java similarity index 100% rename from src/main/java/com/dji/sample/media/service/IFileService.java rename to sample/src/main/java/com/dji/sample/media/service/IFileService.java diff --git a/src/main/java/com/dji/sample/media/service/IMediaRedisService.java b/sample/src/main/java/com/dji/sample/media/service/IMediaRedisService.java similarity index 100% rename from src/main/java/com/dji/sample/media/service/IMediaRedisService.java rename to sample/src/main/java/com/dji/sample/media/service/IMediaRedisService.java diff --git a/src/main/java/com/dji/sample/media/service/IMediaService.java b/sample/src/main/java/com/dji/sample/media/service/IMediaService.java similarity index 100% rename from src/main/java/com/dji/sample/media/service/IMediaService.java rename to sample/src/main/java/com/dji/sample/media/service/IMediaService.java diff --git a/sample/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java b/sample/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java new file mode 100644 index 0000000..7bef9d3 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java @@ -0,0 +1,176 @@ +package com.dji.sample.media.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dji.sample.component.oss.model.OssConfiguration; +import com.dji.sample.component.oss.service.impl.OssServiceContext; +import com.dji.sample.manage.model.dto.DeviceDictionaryDTO; +import com.dji.sample.manage.service.IDeviceDictionaryService; +import com.dji.sample.media.dao.IFileMapper; +import com.dji.sample.media.model.MediaFileDTO; +import com.dji.sample.media.model.MediaFileEntity; +import com.dji.sample.media.service.IFileService; +import com.dji.sdk.cloudapi.device.DeviceEnum; +import com.dji.sdk.cloudapi.media.MediaSubFileTypeEnum; +import com.dji.sdk.cloudapi.media.MediaUploadCallbackRequest; +import com.dji.sdk.common.Pagination; +import com.dji.sdk.common.PaginationData; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.net.URL; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author sean + * @version 0.2 + * @date 2021/12/9 + */ +@Service +@Transactional +public class FileServiceImpl implements IFileService { + + @Autowired + private IFileMapper mapper; + + @Autowired + private IDeviceDictionaryService deviceDictionaryService; + + @Autowired + private OssServiceContext ossService; + + private Optional getMediaByFingerprint(String workspaceId, String fingerprint) { + MediaFileEntity fileEntity = mapper.selectOne(new LambdaQueryWrapper() + .eq(MediaFileEntity::getWorkspaceId, workspaceId) + .eq(MediaFileEntity::getFingerprint, fingerprint)); + return Optional.ofNullable(fileEntity); + } + + private Optional getMediaByFileId(String workspaceId, String fileId) { + MediaFileEntity fileEntity = mapper.selectOne(new LambdaQueryWrapper() + .eq(MediaFileEntity::getWorkspaceId, workspaceId) + .eq(MediaFileEntity::getFileId, fileId)); + return Optional.ofNullable(fileEntity); + } + + @Override + public Boolean checkExist(String workspaceId, String fingerprint) { + return this.getMediaByFingerprint(workspaceId, fingerprint).isPresent(); + } + + @Override + public Integer saveFile(String workspaceId, MediaUploadCallbackRequest file) { + MediaFileEntity fileEntity = this.fileUploadConvertToEntity(file); + fileEntity.setWorkspaceId(workspaceId); + fileEntity.setFileId(UUID.randomUUID().toString()); + return mapper.insert(fileEntity); + } + + @Override + public List getAllFilesByWorkspaceId(String workspaceId) { + return mapper.selectList(new LambdaQueryWrapper() + .eq(MediaFileEntity::getWorkspaceId, workspaceId)) + .stream() + .map(this::entityConvertToDto) + .collect(Collectors.toList()); + } + + @Override + public PaginationData getMediaFilesPaginationByWorkspaceId(String workspaceId, long page, long pageSize) { + Page pageData = mapper.selectPage( + new Page(page, pageSize), + new LambdaQueryWrapper() + .eq(MediaFileEntity::getWorkspaceId, workspaceId) + .orderByDesc(MediaFileEntity::getId)); + List records = pageData.getRecords() + .stream() + .map(this::entityConvertToDto) + .collect(Collectors.toList()); + + return new PaginationData(records, new Pagination(pageData.getCurrent(), pageData.getSize(), pageData.getTotal())); + } + + @Override + public URL getObjectUrl(String workspaceId, String fileId) { + Optional mediaFileOpt = getMediaByFileId(workspaceId, fileId); + if (mediaFileOpt.isEmpty()) { + throw new IllegalArgumentException("{} doesn't exist."); + } + + return ossService.getObjectUrl(OssConfiguration.bucket, mediaFileOpt.get().getObjectKey()); + } + + @Override + public List getFilesByWorkspaceAndJobId(String workspaceId, String jobId) { + return mapper.selectList(new LambdaQueryWrapper() + .eq(MediaFileEntity::getWorkspaceId, workspaceId) + .eq(MediaFileEntity::getJobId, jobId)) + .stream() + .map(this::entityConvertToDto).collect(Collectors.toList()); + } + + /** + * Convert the received file object into a database entity object. + * @param file + * @return + */ + private MediaFileEntity fileUploadConvertToEntity(MediaUploadCallbackRequest file) { + MediaFileEntity.MediaFileEntityBuilder builder = MediaFileEntity.builder(); + + if (file != null) { + builder.fileName(file.getName()) + .filePath(file.getPath()) + .fingerprint(file.getFingerprint()) + .objectKey(file.getObjectKey()) + .subFileType(Optional.ofNullable(file.getSubFileType()).map(MediaSubFileTypeEnum::getType).orElse(null)) + .isOriginal(file.getExt().getOriginal()) + .jobId(file.getExt().getFileGroupId()) + .drone(file.getExt().getSn()) + .tinnyFingerprint(file.getExt().getTinnyFingerprint()) + .payload(file.getExt().getPayloadModelKey().getDevice()); + + // domain-type-subType + DeviceEnum payloadModelKey = file.getExt().getPayloadModelKey(); + Optional payloadDict = deviceDictionaryService + .getOneDictionaryInfoByTypeSubType(payloadModelKey.getDomain().getDomain(), + payloadModelKey.getType().getType(), payloadModelKey.getSubType().getSubType()); + payloadDict.ifPresent(payload -> builder.payload(payload.getDeviceName())); + } + return builder.build(); + } + + /** + * Convert database entity objects into file data transfer object. + * @param entity + * @return + */ + private MediaFileDTO entityConvertToDto(MediaFileEntity entity) { + MediaFileDTO.MediaFileDTOBuilder builder = MediaFileDTO.builder(); + + if (entity != null) { + builder.fileName(entity.getFileName()) + .fileId(entity.getFileId()) + .filePath(entity.getFilePath()) + .isOriginal(entity.getIsOriginal()) + .fingerprint(entity.getFingerprint()) + .objectKey(entity.getObjectKey()) + .tinnyFingerprint(entity.getTinnyFingerprint()) + .payload(entity.getPayload()) + .createTime(LocalDateTime.ofInstant( + Instant.ofEpochMilli(entity.getCreateTime()), ZoneId.systemDefault())) + .drone(entity.getDrone()) + .jobId(entity.getJobId()); + + } + + return builder.build(); + } + +} diff --git a/src/main/java/com/dji/sample/media/service/impl/MediaRedisServiceImpl.java b/sample/src/main/java/com/dji/sample/media/service/impl/MediaRedisServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/media/service/impl/MediaRedisServiceImpl.java rename to sample/src/main/java/com/dji/sample/media/service/impl/MediaRedisServiceImpl.java diff --git a/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java b/sample/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java rename to sample/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java diff --git a/src/main/java/com/dji/sample/storage/controller/StorageController.java b/sample/src/main/java/com/dji/sample/storage/controller/StorageController.java similarity index 100% rename from src/main/java/com/dji/sample/storage/controller/StorageController.java rename to sample/src/main/java/com/dji/sample/storage/controller/StorageController.java diff --git a/src/main/java/com/dji/sample/storage/service/IStorageService.java b/sample/src/main/java/com/dji/sample/storage/service/IStorageService.java similarity index 100% rename from src/main/java/com/dji/sample/storage/service/IStorageService.java rename to sample/src/main/java/com/dji/sample/storage/service/IStorageService.java diff --git a/src/main/java/com/dji/sample/storage/service/impl/StorageServiceImpl.java b/sample/src/main/java/com/dji/sample/storage/service/impl/StorageServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/storage/service/impl/StorageServiceImpl.java rename to sample/src/main/java/com/dji/sample/storage/service/impl/StorageServiceImpl.java diff --git a/src/main/java/com/dji/sample/wayline/controller/WaylineFileController.java b/sample/src/main/java/com/dji/sample/wayline/controller/WaylineFileController.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/controller/WaylineFileController.java rename to sample/src/main/java/com/dji/sample/wayline/controller/WaylineFileController.java diff --git a/src/main/java/com/dji/sample/wayline/controller/WaylineJobController.java b/sample/src/main/java/com/dji/sample/wayline/controller/WaylineJobController.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/controller/WaylineJobController.java rename to sample/src/main/java/com/dji/sample/wayline/controller/WaylineJobController.java diff --git a/src/main/java/com/dji/sample/wayline/dao/IWaylineFileMapper.java b/sample/src/main/java/com/dji/sample/wayline/dao/IWaylineFileMapper.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/dao/IWaylineFileMapper.java rename to sample/src/main/java/com/dji/sample/wayline/dao/IWaylineFileMapper.java diff --git a/src/main/java/com/dji/sample/wayline/dao/IWaylineJobMapper.java b/sample/src/main/java/com/dji/sample/wayline/dao/IWaylineJobMapper.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/dao/IWaylineJobMapper.java rename to sample/src/main/java/com/dji/sample/wayline/dao/IWaylineJobMapper.java diff --git a/src/main/java/com/dji/sample/wayline/model/dto/ConditionalWaylineJobKey.java b/sample/src/main/java/com/dji/sample/wayline/model/dto/ConditionalWaylineJobKey.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/dto/ConditionalWaylineJobKey.java rename to sample/src/main/java/com/dji/sample/wayline/model/dto/ConditionalWaylineJobKey.java diff --git a/src/main/java/com/dji/sample/wayline/model/dto/FlighttaskProgressExt.java b/sample/src/main/java/com/dji/sample/wayline/model/dto/FlighttaskProgressExt.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/dto/FlighttaskProgressExt.java rename to sample/src/main/java/com/dji/sample/wayline/model/dto/FlighttaskProgressExt.java diff --git a/src/main/java/com/dji/sample/wayline/model/dto/FlighttaskProgressProgress.java b/sample/src/main/java/com/dji/sample/wayline/model/dto/FlighttaskProgressProgress.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/dto/FlighttaskProgressProgress.java rename to sample/src/main/java/com/dji/sample/wayline/model/dto/FlighttaskProgressProgress.java diff --git a/src/main/java/com/dji/sample/wayline/model/dto/KmzFileProperties.java b/sample/src/main/java/com/dji/sample/wayline/model/dto/KmzFileProperties.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/dto/KmzFileProperties.java rename to sample/src/main/java/com/dji/sample/wayline/model/dto/KmzFileProperties.java diff --git a/src/main/java/com/dji/sample/wayline/model/dto/WaylineFileDTO.java b/sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineFileDTO.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/dto/WaylineFileDTO.java rename to sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineFileDTO.java diff --git a/src/main/java/com/dji/sample/wayline/model/dto/WaylineJobDTO.java b/sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineJobDTO.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/dto/WaylineJobDTO.java rename to sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineJobDTO.java diff --git a/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskConditionDTO.java b/sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskConditionDTO.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskConditionDTO.java rename to sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskConditionDTO.java diff --git a/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskCreateDTO.java b/sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskCreateDTO.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskCreateDTO.java rename to sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskCreateDTO.java diff --git a/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskExecutableConditionDTO.java b/sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskExecutableConditionDTO.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskExecutableConditionDTO.java rename to sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskExecutableConditionDTO.java diff --git a/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskFileDTO.java b/sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskFileDTO.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskFileDTO.java rename to sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskFileDTO.java diff --git a/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskProgressReceiver.java b/sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskProgressReceiver.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskProgressReceiver.java rename to sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskProgressReceiver.java diff --git a/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskReadyConditionDTO.java b/sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskReadyConditionDTO.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskReadyConditionDTO.java rename to sample/src/main/java/com/dji/sample/wayline/model/dto/WaylineTaskReadyConditionDTO.java diff --git a/src/main/java/com/dji/sample/wayline/model/entity/WaylineFileEntity.java b/sample/src/main/java/com/dji/sample/wayline/model/entity/WaylineFileEntity.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/entity/WaylineFileEntity.java rename to sample/src/main/java/com/dji/sample/wayline/model/entity/WaylineFileEntity.java diff --git a/src/main/java/com/dji/sample/wayline/model/entity/WaylineJobEntity.java b/sample/src/main/java/com/dji/sample/wayline/model/entity/WaylineJobEntity.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/entity/WaylineJobEntity.java rename to sample/src/main/java/com/dji/sample/wayline/model/entity/WaylineJobEntity.java diff --git a/src/main/java/com/dji/sample/wayline/model/enums/WaylineErrorCodeEnum.java b/sample/src/main/java/com/dji/sample/wayline/model/enums/WaylineErrorCodeEnum.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/enums/WaylineErrorCodeEnum.java rename to sample/src/main/java/com/dji/sample/wayline/model/enums/WaylineErrorCodeEnum.java diff --git a/src/main/java/com/dji/sample/wayline/model/enums/WaylineJobStatusEnum.java b/sample/src/main/java/com/dji/sample/wayline/model/enums/WaylineJobStatusEnum.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/enums/WaylineJobStatusEnum.java rename to sample/src/main/java/com/dji/sample/wayline/model/enums/WaylineJobStatusEnum.java diff --git a/src/main/java/com/dji/sample/wayline/model/enums/WaylineMethodEnum.java b/sample/src/main/java/com/dji/sample/wayline/model/enums/WaylineMethodEnum.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/enums/WaylineMethodEnum.java rename to sample/src/main/java/com/dji/sample/wayline/model/enums/WaylineMethodEnum.java diff --git a/src/main/java/com/dji/sample/wayline/model/enums/WaylineTaskStatusEnum.java b/sample/src/main/java/com/dji/sample/wayline/model/enums/WaylineTaskStatusEnum.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/enums/WaylineTaskStatusEnum.java rename to sample/src/main/java/com/dji/sample/wayline/model/enums/WaylineTaskStatusEnum.java diff --git a/src/main/java/com/dji/sample/wayline/model/enums/WaylineTemplateTypeEnum.java b/sample/src/main/java/com/dji/sample/wayline/model/enums/WaylineTemplateTypeEnum.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/enums/WaylineTemplateTypeEnum.java rename to sample/src/main/java/com/dji/sample/wayline/model/enums/WaylineTemplateTypeEnum.java diff --git a/src/main/java/com/dji/sample/wayline/model/param/CreateJobParam.java b/sample/src/main/java/com/dji/sample/wayline/model/param/CreateJobParam.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/param/CreateJobParam.java rename to sample/src/main/java/com/dji/sample/wayline/model/param/CreateJobParam.java diff --git a/src/main/java/com/dji/sample/wayline/model/param/UpdateJobParam.java b/sample/src/main/java/com/dji/sample/wayline/model/param/UpdateJobParam.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/param/UpdateJobParam.java rename to sample/src/main/java/com/dji/sample/wayline/model/param/UpdateJobParam.java diff --git a/src/main/java/com/dji/sample/wayline/model/param/WaylineQueryParam.java b/sample/src/main/java/com/dji/sample/wayline/model/param/WaylineQueryParam.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/model/param/WaylineQueryParam.java rename to sample/src/main/java/com/dji/sample/wayline/model/param/WaylineQueryParam.java diff --git a/src/main/java/com/dji/sample/wayline/service/IFlightTaskService.java b/sample/src/main/java/com/dji/sample/wayline/service/IFlightTaskService.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/service/IFlightTaskService.java rename to sample/src/main/java/com/dji/sample/wayline/service/IFlightTaskService.java diff --git a/src/main/java/com/dji/sample/wayline/service/IWaylineFileService.java b/sample/src/main/java/com/dji/sample/wayline/service/IWaylineFileService.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/service/IWaylineFileService.java rename to sample/src/main/java/com/dji/sample/wayline/service/IWaylineFileService.java diff --git a/src/main/java/com/dji/sample/wayline/service/IWaylineJobService.java b/sample/src/main/java/com/dji/sample/wayline/service/IWaylineJobService.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/service/IWaylineJobService.java rename to sample/src/main/java/com/dji/sample/wayline/service/IWaylineJobService.java diff --git a/src/main/java/com/dji/sample/wayline/service/IWaylineRedisService.java b/sample/src/main/java/com/dji/sample/wayline/service/IWaylineRedisService.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/service/IWaylineRedisService.java rename to sample/src/main/java/com/dji/sample/wayline/service/IWaylineRedisService.java diff --git a/src/main/java/com/dji/sample/wayline/service/impl/FlightTaskServiceImpl.java b/sample/src/main/java/com/dji/sample/wayline/service/impl/FlightTaskServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/service/impl/FlightTaskServiceImpl.java rename to sample/src/main/java/com/dji/sample/wayline/service/impl/FlightTaskServiceImpl.java diff --git a/src/main/java/com/dji/sample/wayline/service/impl/SDKWaylineService.java b/sample/src/main/java/com/dji/sample/wayline/service/impl/SDKWaylineService.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/service/impl/SDKWaylineService.java rename to sample/src/main/java/com/dji/sample/wayline/service/impl/SDKWaylineService.java diff --git a/sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java b/sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java new file mode 100644 index 0000000..bdc8a60 --- /dev/null +++ b/sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java @@ -0,0 +1,295 @@ +package com.dji.sample.wayline.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dji.sample.component.oss.model.OssConfiguration; +import com.dji.sample.component.oss.service.impl.OssServiceContext; +import com.dji.sample.wayline.dao.IWaylineFileMapper; +import com.dji.sample.wayline.model.dto.KmzFileProperties; +import com.dji.sample.wayline.model.dto.WaylineFileDTO; +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; +import com.dji.sdk.common.Pagination; +import com.dji.sdk.common.PaginationData; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Node; +import org.dom4j.io.SAXReader; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.DigestUtils; +import org.springframework.util.StringUtils; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.sql.SQLException; +import java.util.*; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import static com.dji.sample.wayline.model.dto.KmzFileProperties.WAYLINE_FILE_SUFFIX; + +/** + * @author sean + * @version 0.3 + * @date 2021/12/22 + */ +@Service +@Transactional +public class WaylineFileServiceImpl implements IWaylineFileService { + + @Autowired + private IWaylineFileMapper mapper; + + @Autowired + private OssServiceContext ossService; + + @Override + public PaginationData getWaylinesByParam(String workspaceId, GetWaylineListRequest param) { + // Paging Query + Page page = mapper.selectPage( + new Page(param.getPage(), param.getPageSize()), + new LambdaQueryWrapper() + .eq(WaylineFileEntity::getWorkspaceId, workspaceId) + .eq(Objects.nonNull(param.getFavorited()), WaylineFileEntity::getFavorited, param.getFavorited()) + .and(param.getTemplateType() != null, wrapper -> { + for (WaylineTypeEnum type : param.getTemplateType()) { + wrapper.like(WaylineFileEntity::getTemplateTypes, type.getValue()).or(); + } + }) + .and(param.getPayloadModelKey() != null, wrapper -> { + for (DeviceEnum type : param.getPayloadModelKey()) { + wrapper.like(WaylineFileEntity::getPayloadModelKeys, type.getType()).or(); + } + }) + .and(param.getDroneModelKeys() != null, wrapper -> { + for (DeviceEnum type : param.getDroneModelKeys()) { + wrapper.eq(WaylineFileEntity::getDroneModelKey, type.getType()).or(); + } + }) + .like(Objects.nonNull(param.getKey()), WaylineFileEntity::getName, param.getKey()) + // There is a risk of SQL injection + .last(Objects.nonNull(param.getOrderBy()), " order by " + param.getOrderBy().toString())); + + // Wrap the results of a paging query into a custom paging object. + List records = page.getRecords() + .stream() + .map(this::entityConvertToDTO) + .collect(Collectors.toList()); + + return new PaginationData<>(records, new Pagination(page.getCurrent(), page.getSize(), page.getTotal())); + } + + @Override + public Optional getWaylineByWaylineId(String workspaceId, String waylineId) { + return Optional.ofNullable( + this.entityConvertToDTO( + mapper.selectOne( + new LambdaQueryWrapper() + .eq(WaylineFileEntity::getWorkspaceId, workspaceId) + .eq(WaylineFileEntity::getWaylineId, waylineId)))); + } + + @Override + public URL getObjectUrl(String workspaceId, String waylineId) throws SQLException { + Optional waylineOpt = this.getWaylineByWaylineId(workspaceId, waylineId); + if (waylineOpt.isEmpty()) { + throw new SQLException(waylineId + " does not exist."); + } + return ossService.getObjectUrl(OssConfiguration.bucket, waylineOpt.get().getObjectKey()); + } + + @Override + public Integer saveWaylineFile(String workspaceId, WaylineFileDTO metadata) { + WaylineFileEntity file = this.dtoConvertToEntity(metadata); + file.setWaylineId(UUID.randomUUID().toString()); + file.setWorkspaceId(workspaceId); + + if (!StringUtils.hasText(file.getSign())) { + try (InputStream object = ossService.getObject(OssConfiguration.bucket, metadata.getObjectKey())) { + if (object.available() == 0) { + throw new RuntimeException("The file " + metadata.getObjectKey() + + " does not exist in the bucket[" + OssConfiguration.bucket + "]."); + } + file.setSign(DigestUtils.md5DigestAsHex(object)); + } catch (IOException e) { + e.printStackTrace(); + } + } + int insertId = mapper.insert(file); + return insertId > 0 ? file.getId() : insertId; + } + + @Override + public Boolean markFavorite(String workspaceId, List waylineIds, Boolean isFavorite) { + if (waylineIds.isEmpty()) { + return false; + } + if (isFavorite == null) { + return true; + } + return mapper.update(null, new LambdaUpdateWrapper() + .set(WaylineFileEntity::getFavorited, isFavorite) + .eq(WaylineFileEntity::getWorkspaceId, workspaceId) + .in(WaylineFileEntity::getWaylineId, waylineIds)) > 0; + } + + @Override + public List getDuplicateNames(String workspaceId, List names) { + return mapper.selectList(new LambdaQueryWrapper() + .eq(WaylineFileEntity::getWorkspaceId, workspaceId) + .in(WaylineFileEntity::getName, names)) + .stream() + .map(WaylineFileEntity::getName) + .collect(Collectors.toList()); + } + + @Override + public Boolean deleteByWaylineId(String workspaceId, String waylineId) { + Optional waylineOpt = this.getWaylineByWaylineId(workspaceId, waylineId); + if (waylineOpt.isEmpty()) { + return true; + } + GetWaylineListResponse wayline = waylineOpt.get(); + boolean isDel = mapper.delete(new LambdaUpdateWrapper() + .eq(WaylineFileEntity::getWorkspaceId, workspaceId) + .eq(WaylineFileEntity::getWaylineId, waylineId)) + > 0; + if (!isDel) { + return false; + } + return ossService.deleteObject(OssConfiguration.bucket, wayline.getObjectKey()); + } + + @Override + public void importKmzFile(MultipartFile file, String workspaceId, String creator) { + Optional waylineFileOpt = validKmzFile(file); + if (waylineFileOpt.isEmpty()) { + throw new RuntimeException("The file format is incorrect."); + } + + try { + WaylineFileDTO waylineFile = waylineFileOpt.get(); + waylineFile.setUsername(creator); + + ossService.putObject(OssConfiguration.bucket, waylineFile.getObjectKey(), file.getInputStream()); + this.saveWaylineFile(workspaceId, waylineFile); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private Optional validKmzFile(MultipartFile file) { + String filename = file.getOriginalFilename(); + if (Objects.nonNull(filename) && !filename.endsWith(WAYLINE_FILE_SUFFIX)) { + throw new RuntimeException("The file format is incorrect."); + } + try (ZipInputStream unzipFile = new ZipInputStream(file.getInputStream(), StandardCharsets.UTF_8)) { + + ZipEntry nextEntry = unzipFile.getNextEntry(); + while (Objects.nonNull(nextEntry)) { + boolean isWaylines = (KmzFileProperties.FILE_DIR_FIRST + "/" + KmzFileProperties.FILE_DIR_SECOND_TEMPLATE).equals(nextEntry.getName()); + if (!isWaylines) { + nextEntry = unzipFile.getNextEntry(); + continue; + } + SAXReader reader = new SAXReader(); + Document document = reader.read(unzipFile); + if (!StandardCharsets.UTF_8.name().equals(document.getXMLEncoding())) { + throw new RuntimeException("The file encoding format is incorrect."); + } + + Node droneNode = document.selectSingleNode("//" + KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_DRONE_INFO); + Node payloadNode = document.selectSingleNode("//" + KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_PAYLOAD_INFO); + if (Objects.isNull(droneNode) || Objects.isNull(payloadNode)) { + throw new RuntimeException("The file format is incorrect."); + } + + 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); + + return Optional.of(WaylineFileDTO.builder() + .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())) + .templateTypes(List.of(WaylineTypeEnum.find(templateType).getValue())) + .build()); + } + + } catch (IOException | DocumentException e) { + e.printStackTrace(); + } + return Optional.empty(); + } + /** + * Convert database entity objects into wayline data transfer object. + * @param entity + * @return + */ + private GetWaylineListResponse entityConvertToDTO(WaylineFileEntity entity) { + if (entity == null) { + return null; + } + return new GetWaylineListResponse() + .setDroneModelKey(DeviceEnum.find(entity.getDroneModelKey())) + .setFavorited(entity.getFavorited()) + .setName(entity.getName()) + .setPayloadModelKeys(entity.getPayloadModelKeys() != null ? + Arrays.stream(entity.getPayloadModelKeys().split(",")).map(DeviceEnum::find).collect(Collectors.toList()) : null) + .setTemplateTypes(Arrays.stream(entity.getTemplateTypes().split(",")) + .map(Integer::parseInt).map(WaylineTypeEnum::find) + .collect(Collectors.toList())) + .setUsername(entity.getUsername()) + .setObjectKey(entity.getObjectKey()) + .setSign(entity.getSign()) + .setUpdateTime(entity.getUpdateTime()) + .setCreateTime(entity.getCreateTime()) + .setId(entity.getWaylineId()); + + } + + /** + * Convert the received wayline object into a database entity object. + * @param file + * @return + */ + private WaylineFileEntity dtoConvertToEntity(WaylineFileDTO file) { + WaylineFileEntity.WaylineFileEntityBuilder builder = WaylineFileEntity.builder(); + + if (file != null) { + builder.droneModelKey(file.getDroneModelKey()) + .name(file.getName()) + .username(file.getUsername()) + .objectKey(file.getObjectKey()) + // Separate multiple payload data with ",". + .payloadModelKeys(String.join(",", file.getPayloadModelKeys())) + .templateTypes(file.getTemplateTypes().stream() + .map(String::valueOf) + .collect(Collectors.joining(","))) + .favorited(file.getFavorited()) + .sign(file.getSign()) + .build(); + } + + return builder.build(); + } +} diff --git a/sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java b/sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java new file mode 100644 index 0000000..e82ad3e --- /dev/null +++ b/sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java @@ -0,0 +1,298 @@ +package com.dji.sample.wayline.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dji.sample.component.mqtt.model.EventsReceiver; +import com.dji.sample.component.redis.RedisConst; +import com.dji.sample.component.redis.RedisOpsUtils; +import com.dji.sample.manage.model.dto.DeviceDTO; +import com.dji.sample.manage.service.IDeviceRedisService; +import com.dji.sample.manage.service.IDeviceService; +import com.dji.sample.media.model.MediaFileCountDTO; +import com.dji.sample.media.service.IFileService; +import com.dji.sample.wayline.dao.IWaylineJobMapper; +import com.dji.sample.wayline.model.dto.WaylineJobDTO; +import com.dji.sample.wayline.model.entity.WaylineJobEntity; +import com.dji.sample.wayline.model.enums.WaylineJobStatusEnum; +import com.dji.sample.wayline.model.param.CreateJobParam; +import com.dji.sample.wayline.service.IWaylineFileService; +import com.dji.sample.wayline.service.IWaylineJobService; +import com.dji.sample.wayline.service.IWaylineRedisService; +import com.dji.sdk.cloudapi.device.DockModeCodeEnum; +import com.dji.sdk.cloudapi.device.DroneModeCodeEnum; +import com.dji.sdk.cloudapi.device.OsdDock; +import com.dji.sdk.cloudapi.device.OsdDockDrone; +import com.dji.sdk.cloudapi.wayline.*; +import com.dji.sdk.common.Pagination; +import com.dji.sdk.common.PaginationData; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author sean + * @version 1.1 + * @date 2022/6/1 + */ +@Service +@Transactional +@Slf4j +public class WaylineJobServiceImpl implements IWaylineJobService { + + @Autowired + private IWaylineJobMapper mapper; + + @Autowired + private IWaylineFileService waylineFileService; + + @Autowired + private IDeviceService deviceService; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private IFileService fileService; + + @Autowired + private IDeviceRedisService deviceRedisService; + + @Autowired + private IWaylineRedisService waylineRedisService; + + private Optional insertWaylineJob(WaylineJobEntity jobEntity) { + int id = mapper.insert(jobEntity); + if (id <= 0) { + return Optional.empty(); + } + return Optional.ofNullable(this.entity2Dto(jobEntity)); + } + + @Override + public Optional createWaylineJob(CreateJobParam param, String workspaceId, String username, Long beginTime, Long endTime) { + if (Objects.isNull(param)) { + return Optional.empty(); + } + // Immediate tasks, allocating time on the backend. + WaylineJobEntity jobEntity = WaylineJobEntity.builder() + .name(param.getName()) + .dockSn(param.getDockSn()) + .fileId(param.getFileId()) + .username(username) + .workspaceId(workspaceId) + .jobId(UUID.randomUUID().toString()) + .beginTime(beginTime) + .endTime(endTime) + .status(WaylineJobStatusEnum.PENDING.getVal()) + .taskType(param.getTaskType().getType()) + .waylineType(param.getWaylineType().getValue()) + .outOfControlAction(param.getOutOfControlAction().getAction()) + .rthAltitude(param.getRthAltitude()) + .mediaCount(0) + .build(); + + return insertWaylineJob(jobEntity); + } + + @Override + public Optional createWaylineJobByParent(String workspaceId, String parentId) { + Optional parentJobOpt = this.getJobByJobId(workspaceId, parentId); + if (parentJobOpt.isEmpty()) { + return Optional.empty(); + } + WaylineJobEntity jobEntity = this.dto2Entity(parentJobOpt.get()); + jobEntity.setJobId(UUID.randomUUID().toString()); + jobEntity.setErrorCode(null); + jobEntity.setCompletedTime(null); + jobEntity.setExecuteTime(null); + jobEntity.setStatus(WaylineJobStatusEnum.PENDING.getVal()); + jobEntity.setParentId(parentId); + + return this.insertWaylineJob(jobEntity); + } + + public List getJobsByConditions(String workspaceId, Collection jobIds, WaylineJobStatusEnum status) { + return mapper.selectList( + new LambdaQueryWrapper() + .eq(WaylineJobEntity::getWorkspaceId, workspaceId) + .eq(Objects.nonNull(status), WaylineJobEntity::getStatus, status.getVal()) + .and(!CollectionUtils.isEmpty(jobIds), + wrapper -> jobIds.forEach(id -> wrapper.eq(WaylineJobEntity::getJobId, id).or()))) + .stream() + .map(this::entity2Dto) + .collect(Collectors.toList()); + } + + @Override + public Optional getJobByJobId(String workspaceId, String jobId) { + WaylineJobEntity jobEntity = mapper.selectOne( + new LambdaQueryWrapper() + .eq(WaylineJobEntity::getWorkspaceId, workspaceId) + .eq(WaylineJobEntity::getJobId, jobId)); + return Optional.ofNullable(entity2Dto(jobEntity)); + } + + @Override + public Boolean updateJob(WaylineJobDTO dto) { + return mapper.update(this.dto2Entity(dto), + new LambdaUpdateWrapper() + .eq(WaylineJobEntity::getJobId, dto.getJobId())) > 0; + } + + @Override + public PaginationData getJobsByWorkspaceId(String workspaceId, long page, long pageSize) { + Page pageData = mapper.selectPage( + new Page(page, pageSize), + new LambdaQueryWrapper() + .eq(WaylineJobEntity::getWorkspaceId, workspaceId) + .orderByDesc(WaylineJobEntity::getId)); + List records = pageData.getRecords() + .stream() + .map(this::entity2Dto) + .collect(Collectors.toList()); + + return new PaginationData(records, new Pagination(pageData.getCurrent(), pageData.getSize(), pageData.getTotal())); + } + + private WaylineJobEntity dto2Entity(WaylineJobDTO dto) { + WaylineJobEntity.WaylineJobEntityBuilder builder = WaylineJobEntity.builder(); + if (dto == null) { + return builder.build(); + } + if (Objects.nonNull(dto.getBeginTime())) { + builder.beginTime(dto.getBeginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); + } + if (Objects.nonNull(dto.getEndTime())) { + builder.endTime(dto.getEndTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); + } + if (Objects.nonNull(dto.getExecuteTime())) { + builder.executeTime(dto.getExecuteTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); + } + if (Objects.nonNull(dto.getCompletedTime())) { + builder.completedTime(dto.getCompletedTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); + } + return builder.status(dto.getStatus()) + .mediaCount(dto.getMediaCount()) + .name(dto.getJobName()) + .errorCode(dto.getCode()) + .jobId(dto.getJobId()) + .fileId(dto.getFileId()) + .dockSn(dto.getDockSn()) + .workspaceId(dto.getWorkspaceId()) + .taskType(Optional.ofNullable(dto.getTaskType()).map(TaskTypeEnum::getType).orElse(null)) + .waylineType(Optional.ofNullable(dto.getWaylineType()).map(WaylineTypeEnum::getValue).orElse(null)) + .username(dto.getUsername()) + .rthAltitude(dto.getRthAltitude()) + .outOfControlAction(Optional.ofNullable(dto.getOutOfControlAction()) + .map(OutOfControlActionEnum::getAction).orElse(null)) + .parentId(dto.getParentId()) + .build(); + } + + public WaylineJobStatusEnum getWaylineState(String dockSn) { + Optional dockOpt = deviceRedisService.getDeviceOnline(dockSn); + if (dockOpt.isEmpty() || !StringUtils.hasText(dockOpt.get().getChildDeviceSn())) { + return WaylineJobStatusEnum.UNKNOWN; + } + Optional dockOsdOpt = deviceRedisService.getDeviceOsd(dockSn, OsdDock.class); + Optional deviceOsdOpt = deviceRedisService.getDeviceOsd(dockOpt.get().getChildDeviceSn(), OsdDockDrone.class); + if (dockOsdOpt.isEmpty() || deviceOsdOpt.isEmpty() || DockModeCodeEnum.WORKING != dockOsdOpt.get().getModeCode()) { + return WaylineJobStatusEnum.UNKNOWN; + } + + OsdDockDrone osdDevice = deviceOsdOpt.get(); + if (DroneModeCodeEnum.WAYLINE == osdDevice.getModeCode() + || DroneModeCodeEnum.MANUAL == osdDevice.getModeCode() + || DroneModeCodeEnum.TAKEOFF_AUTO == osdDevice.getModeCode()) { + if (StringUtils.hasText(waylineRedisService.getPausedWaylineJobId(dockSn))) { + return WaylineJobStatusEnum.PAUSED; + } + if (waylineRedisService.getRunningWaylineJob(dockSn).isPresent()) { + return WaylineJobStatusEnum.IN_PROGRESS; + } + } + return WaylineJobStatusEnum.UNKNOWN; + } + + private WaylineJobDTO entity2Dto(WaylineJobEntity entity) { + if (entity == null) { + return null; + } + + WaylineJobDTO.WaylineJobDTOBuilder builder = WaylineJobDTO.builder() + .jobId(entity.getJobId()) + .jobName(entity.getName()) + .fileId(entity.getFileId()) + .fileName(waylineFileService.getWaylineByWaylineId(entity.getWorkspaceId(), entity.getFileId()) + .orElse(new GetWaylineListResponse()).getName()) + .dockSn(entity.getDockSn()) + .dockName(deviceService.getDeviceBySn(entity.getDockSn()) + .orElse(DeviceDTO.builder().build()).getNickname()) + .username(entity.getUsername()) + .workspaceId(entity.getWorkspaceId()) + .status(WaylineJobStatusEnum.IN_PROGRESS.getVal() == entity.getStatus() && + entity.getJobId().equals(waylineRedisService.getPausedWaylineJobId(entity.getDockSn())) ? + WaylineJobStatusEnum.PAUSED.getVal() : entity.getStatus()) + .code(entity.getErrorCode()) + .beginTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getBeginTime()), ZoneId.systemDefault())) + .endTime(Objects.nonNull(entity.getEndTime()) ? + LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getEndTime()), ZoneId.systemDefault()) : null) + .executeTime(Objects.nonNull(entity.getExecuteTime()) ? + LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getExecuteTime()), ZoneId.systemDefault()) : null) + .completedTime(WaylineJobStatusEnum.find(entity.getStatus()).getEnd() ? + LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getUpdateTime()), ZoneId.systemDefault()) : null) + .taskType(TaskTypeEnum.find(entity.getTaskType())) + .waylineType(WaylineTypeEnum.find(entity.getWaylineType())) + .rthAltitude(entity.getRthAltitude()) + .outOfControlAction(OutOfControlActionEnum.find(entity.getOutOfControlAction())) + .mediaCount(entity.getMediaCount()); + + if (Objects.nonNull(entity.getEndTime())) { + builder.endTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getEndTime()), ZoneId.systemDefault())); + } + if (WaylineJobStatusEnum.IN_PROGRESS.getVal() == entity.getStatus()) { + builder.progress(waylineRedisService.getRunningWaylineJob(entity.getDockSn()) + .map(EventsReceiver::getOutput) + .map(FlighttaskProgress::getProgress) + .map(FlighttaskProgressData::getPercent) + .orElse(null)); + } + + if (entity.getMediaCount() == 0) { + return builder.build(); + } + + // sync the number of media files + String key = RedisConst.MEDIA_HIGHEST_PRIORITY_PREFIX + entity.getDockSn(); + String countKey = RedisConst.MEDIA_FILE_PREFIX + entity.getDockSn(); + Object mediaFileCount = RedisOpsUtils.hashGet(countKey, entity.getJobId()); + if (Objects.nonNull(mediaFileCount)) { + builder.uploadedCount(((MediaFileCountDTO) mediaFileCount).getUploadedCount()) + .uploading(RedisOpsUtils.checkExist(key) && entity.getJobId().equals(((MediaFileCountDTO)RedisOpsUtils.get(key)).getJobId())); + return builder.build(); + } + + int uploadedSize = fileService.getFilesByWorkspaceAndJobId(entity.getWorkspaceId(), entity.getJobId()).size(); + // All media for this job have been uploaded. + if (uploadedSize >= entity.getMediaCount()) { + return builder.uploadedCount(uploadedSize).build(); + } + RedisOpsUtils.hashSet(countKey, entity.getJobId(), + MediaFileCountDTO.builder() + .jobId(entity.getJobId()) + .mediaCount(entity.getMediaCount()) + .uploadedCount(uploadedSize).build()); + return builder.build(); + } +} diff --git a/src/main/java/com/dji/sample/wayline/service/impl/WaylineRedisServiceImpl.java b/sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineRedisServiceImpl.java similarity index 100% rename from src/main/java/com/dji/sample/wayline/service/impl/WaylineRedisServiceImpl.java rename to sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineRedisServiceImpl.java diff --git a/sample/src/main/resources/application.yml b/sample/src/main/resources/application.yml new file mode 100644 index 0000000..6a128ab --- /dev/null +++ b/sample/src/main/resources/application.yml @@ -0,0 +1,171 @@ +server: + port: 6789 +spring: + main: + allow-bean-definition-overriding: true + application: + name: cloud-api-sample + datasource: + druid: + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://cloud_api_sample_mysql:3306/cloud_sample?useSSL=false&allowPublicKeyRetrieval=true + username: root + password: root + initial-size: 10 + min-idle: 10 + max-active: 20 + max-wait: 60000 + + redis: + host: cloud_api_sample_redis + port: 6379 + database: 0 + username: # if you enable + password: + lettuce: + pool: + max-active: 8 + max-idle: 8 + min-idle: 0 + + servlet: + multipart: + max-file-size: 2GB + max-request-size: 2GB + +jwt: + issuer: DJI + subject: CloudApiSample + secret: CloudApiSample + age: 86400 + +mqtt: + # @see com.dji.sample.component.mqtt.model.MqttUseEnum + # BASIC parameters are required. + BASIC: + protocol: MQTT # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum + host: Please enter your ip. + port: 1883 + username: JavaServer + password: 123456 + client-id: 123456 + # If the protocol is ws/wss, this value is required. + path: + DRC: + protocol: WS # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum + host: Please enter your ip. + port: 8083 + path: /mqtt + username: JavaServer + password: 123456 + +cloud-sdk: + mqtt: + # Topics that need to be subscribed when initially connecting to mqtt, multiple topics are divided by ",". + inbound-topic: sys/product/+/status,thing/product/+/requests + +url: + manage: + prefix: manage + version: /api/v1 + map: + prefix: map + version: /api/v1 + media: + prefix: media + version: /api/v1 + wayline: + prefix: wayline + version: /api/v1 + storage: + prefix: storage + version: /api/v1 + control: + prefix: control + version: /api/v1 + +# Tutorial: https://www.alibabacloud.com/help/en/object-storage-service/latest/use-a-temporary-credential-provided-by-sts-to-access-oss +oss: + enable: false + provider: ALIYUN # @see com.dji.sample.component.OssConfiguration.model.enums.OssTypeEnum + endpoint: https://oss-cn-hangzhou.aliyuncs.com + access-key: Please enter your access key. + secret-key: Please enter your secret key. + expire: 3600 + region: Please enter your oss region. # cn-hangzhou + role-session-name: cloudApi + role-arn: Please enter your role arn. # acs:ram::123456789:role/stsrole + bucket: Please enter your bucket name. + object-dir-prefix: Please enter a folder name. + +#oss: +# enable: true +# provider: aws +# endpoint: https://s3.us-east-1.amazonaws.com +# access-key: +# secret-key: +# expire: 3600 +# region: us-east-1 +# role-session-name: cloudApi +# role-arn: +# bucket: cloudapi-bucket +# object-dir-prefix: wayline + +#oss: +# enable: true +# provider: minio +# endpoint: http://192.168.1.1:9000 +# access-key: minioadmin +# secret-key: minioadmin +# bucket: cloud-bucket +# expire: 3600 +# region: us-east-1 +# object-dir-prefix: wayline + +logging: + level: + com.dji: debug + file: + name: logs/cloud-api-sample.log + +ntp: + server: + host: Google.mzr.me + +# To create a license for an application: https://developer.dji.com/user/apps/#all +cloud-api: + app: + id: Please enter the app id. + key: Please enter the app key. + license: Please enter the app license. + +livestream: + url: + # It is recommended to use a program to create Token. https://github.com/AgoraIO/Tools/blob/master/DynamicKey/AgoraDynamicKey/java/src/main/java/io/agora/media/RtcTokenBuilder2.java + agora: + channel: Please enter the agora channel. + token: Please enter the agora temporary token. + uid: 654321 + + # RTMP Note: This IP is the address of the streaming server. If you want to see livestream on web page, you need to convert the RTMP stream to WebRTC stream. + rtmp: + url: Please enter the rtmp access address. # Example: 'rtmp://192.168.1.1/live/' + rtsp: + username: Please enter the username. + password: Please enter the password. + port: 8554 + + # GB28181 Note:If you don't know what these parameters mean, you can go to Pilot2 and select the GB28181 page in the cloud platform. Where the parameters same as these parameters. + gb28181: + serverIP: Please enter the server ip. + serverPort: Please enter the server port. + serverID: Please enter the server id. + agentID: Please enter the agent id. + agentPassword: Please enter the agent password. + localPort: Please enter the local port. + channel: Please enter the channel. + + # Webrtc: Only supports using whip standard + whip: + url: Please enter the rtmp access address. # Example:http://192.168.1.1:1985/rtc/v1/whip/?app=live&stream= \ No newline at end of file diff --git a/src/main/resources/hms.json b/sample/src/main/resources/hms.json similarity index 100% rename from src/main/resources/hms.json rename to sample/src/main/resources/hms.json diff --git a/sql/cloud_sample.sql b/sql/cloud_sample.sql index 2e76af1..b8ac32b 100644 --- a/sql/cloud_sample.sql +++ b/sql/cloud_sample.sql @@ -11,6 +11,65 @@ SET NAMES utf8mb4; +# device_flight_area +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `device_flight_area`; + +CREATE TABLE `device_flight_area` ( + `id` int unsigned NOT NULL AUTO_INCREMENT, + `device_sn` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `workspace_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `file_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `sync_status` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `sync_code` int NOT NULL DEFAULT '0', + `create_time` bigint NOT NULL, + `update_time` bigint NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + + + +# flight_area_file +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `flight_area_file`; + +CREATE TABLE `flight_area_file` ( + `id` int unsigned NOT NULL AUTO_INCREMENT, + `file_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `workspace_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `object_key` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `sign` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'sha256', + `size` int NOT NULL, + `latest` tinyint(1) NOT NULL COMMENT 'The latest version?', + `create_time` bigint NOT NULL, + `update_time` bigint NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `UNI_FILE_ID` (`file_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + + + +# flight_area_property +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `flight_area_property`; + +CREATE TABLE `flight_area_property` ( + `id` int unsigned NOT NULL AUTO_INCREMENT, + `element_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'dfence/nfz', + `enable` tinyint(1) NOT NULL, + `sub_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT 'options: Circle ', + `radius` int NOT NULL DEFAULT '0' COMMENT 'unit: cm', + PRIMARY KEY (`id`), + UNIQUE KEY `UNI_AREA_ID` (`element_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + + + # logs_file # ------------------------------------------------------------ @@ -361,7 +420,8 @@ LOCK TABLES `map_group` WRITE; INSERT INTO `map_group` (`id`, `group_id`, `group_name`, `group_type`, `workspace_id`, `is_distributed`, `is_lock`, `create_time`, `update_time`) VALUES (1,'e3dea0f5-37f2-4d79-ae58-490af3228060','Pilot Share Layer',2,'e3dea0f5-37f2-4d79-ae58-490af3228069',1,0,1638330077356,1638330077356), - (2,'e3dea0f5-37f2-4d79-ae58-490af3228011','Default Layer',1,'e3dea0f5-37f2-4d79-ae58-490af3228069',1,0,1638330077356,1638330077356); + (2,'e3dea0f5-37f2-4d79-ae58-490af3228011','Default Layer',1,'e3dea0f5-37f2-4d79-ae58-490af3228069',1,0,1638330077356,1638330077356), + (3,'d58479c8-4a80-4036-aa55-8beffb7158e9','Custom Flight Area',0,'e3dea0f5-37f2-4d79-ae58-490af3228069',1,0,1638330077356,1638330077356); /*!40000 ALTER TABLE `map_group` ENABLE KEYS */; UNLOCK TABLES; diff --git a/src/main/java/com/dji/sample/component/oss/service/impl/AliyunOssServiceImpl.java b/src/main/java/com/dji/sample/component/oss/service/impl/AliyunOssServiceImpl.java deleted file mode 100644 index cf78637..0000000 --- a/src/main/java/com/dji/sample/component/oss/service/impl/AliyunOssServiceImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.dji.sample.component.oss.service.impl; - -import com.aliyun.oss.OSS; -import com.aliyun.oss.OSSClientBuilder; -import com.aliyun.oss.OSSException; -import com.aliyun.oss.model.ObjectMetadata; -import com.aliyun.oss.model.PutObjectRequest; -import com.aliyun.oss.model.PutObjectResult; -import com.aliyuncs.DefaultAcsClient; -import com.aliyuncs.IAcsClient; -import com.aliyuncs.exceptions.ClientException; -import com.aliyuncs.profile.DefaultProfile; -import com.aliyuncs.sts.model.v20150401.AssumeRoleRequest; -import com.aliyuncs.sts.model.v20150401.AssumeRoleResponse; -import com.dji.sample.component.oss.model.OssConfiguration; -import com.dji.sample.component.oss.service.IOssService; -import com.dji.sdk.cloudapi.storage.CredentialsToken; -import com.dji.sdk.cloudapi.storage.OssTypeEnum; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.io.InputStream; -import java.net.URL; -import java.util.Date; -import java.util.Objects; - -/** - * @author sean - * @version 0.3 - * @date 2021/12/23 - */ -@Service -@Slf4j -public class AliyunOssServiceImpl implements IOssService { - - private OSS ossClient; - - @Override - public OssTypeEnum getOssType() { - return OssTypeEnum.ALIYUN; - } - - @Override - public CredentialsToken getCredentials() { - - try { - DefaultProfile profile = DefaultProfile.getProfile( - OssConfiguration.region, OssConfiguration.accessKey, OssConfiguration.secretKey); - IAcsClient client = new DefaultAcsClient(profile); - - AssumeRoleRequest request = new AssumeRoleRequest(); - request.setDurationSeconds(OssConfiguration.expire); - request.setRoleArn(OssConfiguration.roleArn); - request.setRoleSessionName(OssConfiguration.roleSessionName); - - AssumeRoleResponse response = client.getAcsResponse(request); - return new CredentialsToken(response.getCredentials(), OssConfiguration.expire); - - } catch (ClientException e) { - log.debug("Failed to obtain sts."); - e.printStackTrace(); - } - return null; - } - - @Override - public URL getObjectUrl(String bucket, String objectKey) { - // First check if the object can be fetched. - boolean isExist = ossClient.doesObjectExist(bucket, objectKey); - if (!isExist) { - throw new OSSException("The object does not exist."); - } - - return ossClient.generatePresignedUrl(bucket, objectKey, - new Date(System.currentTimeMillis() + OssConfiguration.expire * 1000)); - } - - @Override - public Boolean deleteObject(String bucket, String objectKey) { - if (!ossClient.doesObjectExist(bucket, objectKey)) { - return true; - } - ossClient.deleteObject(bucket, objectKey); - return true; - } - - @Override - public InputStream getObject(String bucket, String objectKey) { - return ossClient.getObject(bucket, objectKey).getObjectContent(); - } - - @Override - public void putObject(String bucket, String objectKey, InputStream input) { - if (ossClient.doesObjectExist(bucket, objectKey)) { - throw new RuntimeException("The filename already exists."); - } - PutObjectResult objectResult = ossClient.putObject(new PutObjectRequest(bucket, objectKey, input, new ObjectMetadata())); - log.info("Upload FlighttaskCreateFile: {}", objectResult.getETag()); - } - - public void createClient() { - if (Objects.nonNull(this.ossClient)) { - return; - } - this.ossClient = new OSSClientBuilder() - .build(OssConfiguration.endpoint, OssConfiguration.accessKey, OssConfiguration.secretKey); - } -} diff --git a/src/main/java/com/dji/sample/component/oss/service/impl/AmazonS3ServiceImpl.java b/src/main/java/com/dji/sample/component/oss/service/impl/AmazonS3ServiceImpl.java deleted file mode 100644 index 10e109a..0000000 --- a/src/main/java/com/dji/sample/component/oss/service/impl/AmazonS3ServiceImpl.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.dji.sample.component.oss.service.impl; - -import com.amazonaws.HttpMethod; -import com.amazonaws.auth.AWSStaticCredentialsProvider; -import com.amazonaws.auth.BasicAWSCredentials; -import com.amazonaws.services.s3.AmazonS3; -import com.amazonaws.services.s3.AmazonS3ClientBuilder; -import com.amazonaws.services.s3.model.*; -import com.amazonaws.services.securitytoken.AWSSecurityTokenService; -import com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClientBuilder; -import com.amazonaws.services.securitytoken.model.AssumeRoleRequest; -import com.amazonaws.services.securitytoken.model.AssumeRoleResult; -import com.amazonaws.services.securitytoken.model.Credentials; -import com.dji.sample.component.AuthInterceptor; -import com.dji.sample.component.oss.model.OssConfiguration; -import com.dji.sample.component.oss.service.IOssService; -import com.dji.sdk.cloudapi.storage.CredentialsToken; -import com.dji.sdk.cloudapi.storage.OssTypeEnum; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import javax.annotation.PostConstruct; -import java.io.InputStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Objects; - -/** - * @author sean - * @version 1.0 - * @date 2022/4/27 - */ -@Slf4j -@Service -public class AmazonS3ServiceImpl implements IOssService { - - private AmazonS3 client; - - @Override - public OssTypeEnum getOssType() { - return OssTypeEnum.AWS; - } - - @Override - public CredentialsToken getCredentials() { - AWSSecurityTokenService stsClient = AWSSecurityTokenServiceClientBuilder.standard() - .withCredentials(new AWSStaticCredentialsProvider( - new BasicAWSCredentials(OssConfiguration.accessKey, OssConfiguration.secretKey))) - .withRegion(OssConfiguration.region).build(); - - AssumeRoleRequest request = new AssumeRoleRequest() - .withRoleArn(OssConfiguration.roleArn) - .withRoleSessionName(OssConfiguration.roleSessionName) - .withDurationSeconds(Math.toIntExact(OssConfiguration.expire)); - AssumeRoleResult result = stsClient.assumeRole(request); - Credentials credentials = result.getCredentials(); - return new CredentialsToken(credentials); - } - - @Override - public URL getObjectUrl(String bucket, String objectKey) { - return client.generatePresignedUrl(bucket, objectKey, - new Date(System.currentTimeMillis() + OssConfiguration.expire * 1000), HttpMethod.GET); - } - - @Override - public Boolean deleteObject(String bucket, String objectKey) { - if (!client.doesObjectExist(bucket, objectKey)) { - return true; - } - client.deleteObject(bucket, objectKey); - return true; - } - - public InputStream getObject(String bucket, String objectKey) { - return client.getObject(bucket, objectKey).getObjectContent().getDelegateStream(); - } - - @Override - public void putObject(String bucket, String objectKey, InputStream input) { - if (client.doesObjectExist(bucket, objectKey)) { - throw new RuntimeException("The filename already exists."); - } - PutObjectResult objectResult = client.putObject(new PutObjectRequest(bucket, objectKey, input, new ObjectMetadata())); - log.info("Upload FlighttaskCreateFile: {}", objectResult.toString()); - } - - public void createClient() { - if (Objects.nonNull(this.client)) { - return; - } - this.client = AmazonS3ClientBuilder.standard() - .withCredentials( - new AWSStaticCredentialsProvider( - new BasicAWSCredentials(OssConfiguration.accessKey, OssConfiguration.secretKey))) - .withRegion(OssConfiguration.region) - .build(); - } - - /** - * Configuring cross-origin resource sharing - */ - @PostConstruct - private void configCORS() { - if (!OssConfiguration.enable || !OssTypeEnum.AWS.getType().equals(OssConfiguration.provider)) { - return; - } - List allowedMethods = new ArrayList<>(); - allowedMethods.add(CORSRule.AllowedMethods.GET); - allowedMethods.add(CORSRule.AllowedMethods.POST); - allowedMethods.add(CORSRule.AllowedMethods.DELETE); - - CORSRule rule = new CORSRule() - .withId("CORSAccessRule") - .withAllowedOrigins(List.of("*")) - .withAllowedHeaders(List.of(AuthInterceptor.PARAM_TOKEN)) - .withAllowedMethods(allowedMethods); - - client.setBucketCrossOriginConfiguration(OssConfiguration.bucket, - new BucketCrossOriginConfiguration().withRules(rule)); - - } -} diff --git a/src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java b/src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java deleted file mode 100644 index 5039094..0000000 --- a/src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.dji.sample.component.oss.service.impl; - -import com.dji.sample.component.oss.model.OssConfiguration; -import com.dji.sample.component.oss.service.IOssService; -import com.dji.sdk.cloudapi.storage.CredentialsToken; -import com.dji.sdk.cloudapi.storage.OssTypeEnum; -import io.minio.*; -import io.minio.credentials.AssumeRoleProvider; -import io.minio.errors.*; -import io.minio.http.Method; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.util.Objects; - -/** - * @author sean - * @version 0.3 - * @date 2021/12/23 - */ -@Service -@Slf4j -public class MinIOServiceImpl implements IOssService { - - private MinioClient client; - - @Override - public OssTypeEnum getOssType() { - return OssTypeEnum.MINIO; - } - - @Override - public CredentialsToken getCredentials() { - try { - AssumeRoleProvider provider = new AssumeRoleProvider(OssConfiguration.endpoint, OssConfiguration.accessKey, - OssConfiguration.secretKey, Math.toIntExact(OssConfiguration.expire), - null, OssConfiguration.region, null, null, null, null); - return new CredentialsToken(provider.fetch(), OssConfiguration.expire); - } catch (NoSuchAlgorithmException e) { - log.debug("Failed to obtain sts."); - e.printStackTrace(); - } - return null; - } - - @Override - public URL getObjectUrl(String bucket, String objectKey) { - try { - return new URL( - client.getPresignedObjectUrl( - GetPresignedObjectUrlArgs.builder() - .method(Method.GET) - .bucket(bucket) - .object(objectKey) - .expiry(Math.toIntExact(OssConfiguration.expire)) - .build())); - } catch (ErrorResponseException | InsufficientDataException | InternalException | - InvalidKeyException | InvalidResponseException | IOException | - NoSuchAlgorithmException | XmlParserException | ServerException e) { - throw new RuntimeException("The file does not exist on the OssConfiguration."); - } - } - - @Override - public Boolean deleteObject(String bucket, String objectKey) { - try { - client.removeObject(RemoveObjectArgs.builder().bucket(bucket).object(objectKey).build()); - } catch (MinioException | NoSuchAlgorithmException | IOException | InvalidKeyException e) { - log.error("Failed to delete file."); - e.printStackTrace(); - return false; - } - return true; - } - - @Override - public InputStream getObject(String bucket, String objectKey) { - try { - GetObjectResponse object = client.getObject(GetObjectArgs.builder().bucket(bucket).object(objectKey).build()); - return new ByteArrayInputStream(object.readAllBytes()); - } catch (ErrorResponseException | InsufficientDataException | InternalException | InvalidKeyException | InvalidResponseException | IOException | NoSuchAlgorithmException | ServerException | XmlParserException e) { - e.printStackTrace(); - } - return InputStream.nullInputStream(); - } - - @Override - public void putObject(String bucket, String objectKey, InputStream input) { - try { - client.statObject(StatObjectArgs.builder().bucket(bucket).object(objectKey).build()); - throw new RuntimeException("The filename already exists."); - } catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) { - log.info("The file does not exist, start uploading."); - try { - ObjectWriteResponse response = client.putObject( - PutObjectArgs.builder().bucket(bucket).object(objectKey).stream(input, input.available(), 0).build()); - log.info("Upload FlighttaskCreateFile: {}", response.etag()); - } catch (MinioException | IOException | InvalidKeyException | NoSuchAlgorithmException ex) { - log.error("Failed to upload FlighttaskCreateFile {}.", objectKey); - ex.printStackTrace(); - } - } - } - - public void createClient() { - if (Objects.nonNull(this.client)) { - return; - } - this.client = MinioClient.builder() - .endpoint(OssConfiguration.endpoint) - .credentials(OssConfiguration.accessKey, OssConfiguration.secretKey) - .region(OssConfiguration.region) - .build(); - } -} diff --git a/src/main/java/com/dji/sample/component/websocket/model/BizCodeEnum.java b/src/main/java/com/dji/sample/component/websocket/model/BizCodeEnum.java deleted file mode 100644 index cecbf57..0000000 --- a/src/main/java/com/dji/sample/component/websocket/model/BizCodeEnum.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.dji.sample.component.websocket.model; - -/** - * @author sean - * @version 0.1 - * @date 2021/11/26 - */ -public enum BizCodeEnum { - - DEVICE_ONLINE("device_online"), - - DEVICE_OFFLINE("device_offline"), - - DEVICE_UPDATE_TOPO("device_update_topo"), - - DEVICE_OSD("device_osd"), - - RC_OSD("gateway_osd"), - - DOCK_OSD("dock_osd"), - - MAP_ELEMENT_CREATE("map_element_create"), - - MAP_ELEMENT_UPDATE("map_element_update"), - - MAP_ELEMENT_DELETE("map_element_delete"), - - MAP_GROUP_REFRESH("map_group_refresh"), - - FLIGHT_TASK_PROGRESS("flighttask_progress"), - - DEVICE_HMS("device_hms"), - - DEVICE_REBOOT("device_reboot"), - - DRONE_OPEN("drone_open"), - - DRONE_CLOSE("drone_close"), - - DEVICE_CHECK("device_check"), - - DRONE_FORMAT("drone_format"), - - DEVICE_FORMAT("device_format"), - - COVER_OPEN("cover_open"), - - COVER_CLOSE("cover_close"), - - PUTTER_OPEN("putter_open"), - - PUTTER_CLOSE("putter_close"), - - CHARGE_OPEN("charge_open"), - - CHARGE_CLOSE("charge_close"), - - FILE_UPLOAD_CALLBACK("file_upload_callback"), - - FILE_UPLOAD_PROGRESS("fileupload_progress"), - - OTA_PROGRESS("ota_progress"), - - HIGHEST_PRIORITY_UPLOAD_FLIGHT_TASK_MEDIA("highest_priority_upload_flighttask_media"), - - CONTROL_SOURCE_CHANGE("control_source_change"), - - FLY_TO_POINT_PROGRESS("fly_to_point_progress"), - - TAKE_OFF_TO_POINT_PROGRESS("takeoff_to_point_progress"), - - DRC_STATUS_NOTIFY("drc_status_notify"), - - JOYSTICK_INVALID_NOTIFY("joystick_invalid_notify") - ; - - private String code; - - BizCodeEnum(String code) { - this.code = code; - } - - public String getCode() { - return code; - } -} diff --git a/src/main/java/com/dji/sample/control/model/param/FlyToPointParam.java b/src/main/java/com/dji/sample/control/model/param/FlyToPointParam.java deleted file mode 100644 index d003c67..0000000 --- a/src/main/java/com/dji/sample/control/model/param/FlyToPointParam.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.dji.sample.control.model.param; - -import com.dji.sdk.cloudapi.control.Point; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Range; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.List; - -/** - * @author sean - * @version 1.3 - * @date 2023/2/14 - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -public class FlyToPointParam { - - private String flyToId; - - @Range(min = 1, max = 15) - @NotNull - private Integer maxSpeed; - - /** - * The M30 series only support one point. - */ - @Size(min = 1) - @Valid - @NotNull - private List points; -} diff --git a/src/main/java/com/dji/sample/manage/model/dto/LiveTypeDTO.java b/src/main/java/com/dji/sample/manage/model/dto/LiveTypeDTO.java deleted file mode 100644 index ebd932c..0000000 --- a/src/main/java/com/dji/sample/manage/model/dto/LiveTypeDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.dji.sample.manage.model.dto; - -import com.dji.sdk.cloudapi.livestream.LensChangeVideoTypeEnum; -import com.dji.sdk.cloudapi.livestream.UrlTypeEnum; -import com.dji.sdk.cloudapi.livestream.VideoQualityEnum; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - * Receive live parameters. - * @author sean.zhou - * @version 0.1 - * @date 2021/11/22 - */ -@Data -public class LiveTypeDTO { - - @JsonProperty("url_type") - private UrlTypeEnum urlType; - - private String url; - - @JsonProperty("video_id") - private String videoId; - - @JsonProperty("video_quality") - private VideoQualityEnum videoQuality; - - private LensChangeVideoTypeEnum videoType; - -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/model/dto/UserLoginDTO.java b/src/main/java/com/dji/sample/manage/model/dto/UserLoginDTO.java deleted file mode 100644 index 7c0d8f4..0000000 --- a/src/main/java/com/dji/sample/manage/model/dto/UserLoginDTO.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.dji.sample.manage.model.dto; - -import lombok.Data; -import lombok.NonNull; - -@Data -public class UserLoginDTO { - - @NonNull - private String username; - - @NonNull - private String password; - - @NonNull - private Integer flag; -} diff --git a/src/main/java/com/dji/sample/manage/service/ILiveStreamService.java b/src/main/java/com/dji/sample/manage/service/ILiveStreamService.java deleted file mode 100644 index 3bd82e4..0000000 --- a/src/main/java/com/dji/sample/manage/service/ILiveStreamService.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.dji.sample.manage.service; - -import com.dji.sample.manage.model.dto.CapacityDeviceDTO; -import com.dji.sample.manage.model.dto.LiveTypeDTO; -import com.dji.sdk.common.HttpResultResponse; - -import java.util.List; - -/** - * @author sean.zhou - * @date 2021/11/19 - * @version 0.1 - */ -public interface ILiveStreamService { - - /** - * Get all the drone data that can be broadcast live in this workspace. - * @param workspaceId - * @return - */ - List getLiveCapacity(String workspaceId); - - /** - * Initiate a live streaming by publishing mqtt message. - * @param liveParam Parameters needed for on-demand. - * @return - */ - HttpResultResponse liveStart(LiveTypeDTO liveParam); - - /** - * Stop the live streaming by publishing mqtt message. - * @param videoId - * @return - */ - HttpResultResponse liveStop(String videoId); - - /** - * Readjust the clarity of the live streaming by publishing mqtt messages. - * @param liveParam - * @return - */ - HttpResultResponse liveSetQuality(LiveTypeDTO liveParam); - - /** - * Switches the lens of the device during the live streaming. - * @param liveParam - * @return - */ - HttpResultResponse liveLensChange(LiveTypeDTO liveParam); -} diff --git a/src/main/java/com/dji/sample/manage/service/impl/DeviceFirmwareServiceImpl.java b/src/main/java/com/dji/sample/manage/service/impl/DeviceFirmwareServiceImpl.java deleted file mode 100644 index edd7114..0000000 --- a/src/main/java/com/dji/sample/manage/service/impl/DeviceFirmwareServiceImpl.java +++ /dev/null @@ -1,353 +0,0 @@ -package com.dji.sample.manage.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.dji.sample.component.mqtt.model.EventsReceiver; -import com.dji.sample.component.oss.model.OssConfiguration; -import com.dji.sample.component.oss.service.impl.OssServiceContext; -import com.dji.sample.component.redis.RedisConst; -import com.dji.sample.component.redis.RedisOpsUtils; -import com.dji.sample.component.websocket.model.BizCodeEnum; -import com.dji.sample.component.websocket.service.IWebSocketMessageService; -import com.dji.sample.manage.dao.IDeviceFirmwareMapper; -import com.dji.sample.manage.model.dto.*; -import com.dji.sample.manage.model.entity.DeviceFirmwareEntity; -import com.dji.sample.manage.model.enums.UserTypeEnum; -import com.dji.sample.manage.model.param.DeviceFirmwareQueryParam; -import com.dji.sample.manage.model.param.DeviceFirmwareUploadParam; -import com.dji.sample.manage.service.IDeviceFirmwareService; -import com.dji.sample.manage.service.IDeviceRedisService; -import com.dji.sample.manage.service.IFirmwareModelService; -import com.dji.sdk.cloudapi.firmware.FirmwareUpgradeTypeEnum; -import com.dji.sdk.cloudapi.firmware.OtaCreateDevice; -import com.dji.sdk.cloudapi.firmware.OtaProgress; -import com.dji.sdk.cloudapi.firmware.OtaProgressStatusEnum; -import com.dji.sdk.cloudapi.firmware.api.AbstractFirmwareService; -import com.dji.sdk.common.Pagination; -import com.dji.sdk.common.PaginationData; -import com.dji.sdk.mqtt.MqttReply; -import com.dji.sdk.mqtt.events.EventsDataRequest; -import com.dji.sdk.mqtt.events.TopicEventsRequest; -import com.dji.sdk.mqtt.events.TopicEventsResponse; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.messaging.MessageHeaders; -import org.springframework.stereotype.Service; -import org.springframework.util.DigestUtils; -import org.springframework.util.StringUtils; -import org.springframework.web.multipart.MultipartFile; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.time.Instant; -import java.time.LocalDate; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.stream.Collectors; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -/** - * @author sean - * @version 1.2 - * @date 2022/8/16 - */ -@Service -@Slf4j -public class DeviceFirmwareServiceImpl extends AbstractFirmwareService implements IDeviceFirmwareService { - - @Autowired - private IDeviceFirmwareMapper mapper; - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private IWebSocketMessageService webSocketMessageService; - - @Autowired - private OssServiceContext ossServiceContext; - - @Autowired - private IFirmwareModelService firmwareModelService; - - @Autowired - private IDeviceRedisService deviceRedisService; - - @Override - public Optional getFirmware(String workspaceId, String deviceName, String version) { - return Optional.ofNullable(entity2Dto(mapper.selectOne( - new LambdaQueryWrapper() - .eq(DeviceFirmwareEntity::getWorkspaceId, workspaceId) - .eq(DeviceFirmwareEntity::getFirmwareVersion, version) - .eq(DeviceFirmwareEntity::getStatus, true), - deviceName))); - } - - @Override - public Optional getLatestFirmwareReleaseNote(String deviceName) { - return Optional.ofNullable(entity2NoteDto(mapper.selectOne( - Wrappers.lambdaQuery(DeviceFirmwareEntity.class) - .eq(DeviceFirmwareEntity::getStatus, true) - .orderByDesc(DeviceFirmwareEntity::getReleaseDate, DeviceFirmwareEntity::getFirmwareVersion), - deviceName))); - } - - @Override - public List getDeviceOtaFirmware(String workspaceId, List upgradeDTOS) { - List deviceOtaList = new ArrayList<>(); - upgradeDTOS.forEach(upgradeDevice -> { - boolean exist = deviceRedisService.checkDeviceOnline(upgradeDevice.getSn()); - if (!exist) { - throw new IllegalArgumentException("Device is offline."); - } - Optional firmwareOpt = this.getFirmware( - workspaceId, upgradeDevice.getDeviceName(), upgradeDevice.getProductVersion()); - if (firmwareOpt.isEmpty()) { - throw new IllegalArgumentException("This firmware version does not exist or is not available."); - } - OtaCreateDevice ota = dto2OtaCreateDto(firmwareOpt.get()); - ota.setSn(upgradeDevice.getSn()); - ota.setFirmwareUpgradeType(FirmwareUpgradeTypeEnum.find(upgradeDevice.getFirmwareUpgradeType())); - deviceOtaList.add(ota); - }); - return deviceOtaList; - } - - @Override - public TopicEventsResponse otaProgress(TopicEventsRequest> request, MessageHeaders headers) { - String sn = request.getGateway(); - - EventsReceiver eventsReceiver = new EventsReceiver() - .setBid(request.getBid()) - .setOutput(request.getData().getOutput()) - .setResult(request.getData().getResult()); - - - log.info("SN: {}, {} ===> Upgrading progress: {}", - sn, request.getMethod(), eventsReceiver.getOutput().getProgress()); - - if (!eventsReceiver.getResult().isSuccess()) { - log.error("SN: {}, {} ===> Error: {}", sn, request.getMethod(), eventsReceiver.getResult()); - } - - Optional deviceOpt = deviceRedisService.getDeviceOnline(sn); - if (deviceOpt.isEmpty()) { - return null; - } - - OtaProgressStatusEnum statusEnum = eventsReceiver.getOutput().getStatus(); - DeviceDTO device = deviceOpt.get(); - handleProgress(device.getWorkspaceId(), sn, eventsReceiver, statusEnum.isEnd()); - handleProgress(device.getWorkspaceId(), device.getChildDeviceSn(), eventsReceiver, statusEnum.isEnd()); - - return new TopicEventsResponse().setData(MqttReply.success()); - } - - private void handleProgress(String workspaceId, String sn, EventsReceiver events, boolean isEnd) { - boolean upgrade = deviceRedisService.getFirmwareUpgradingProgress(sn).isPresent(); - if (!upgrade) { - return; - } - if (isEnd) { - // Delete the cache after the update is complete. - deviceRedisService.delFirmwareUpgrading(sn); - } else { - // Update the update progress of the dock in redis. - deviceRedisService.setFirmwareUpgrading(sn, events); - } - events.setSn(sn); - webSocketMessageService.sendBatch(workspaceId, UserTypeEnum.WEB.getVal(), BizCodeEnum.OTA_PROGRESS.getCode(), events); - } - - @Override - public Boolean checkFileExist(String workspaceId, String fileMd5) { - return RedisOpsUtils.checkExist(RedisConst.FILE_UPLOADING_PREFIX + workspaceId + fileMd5) || - mapper.selectCount(new LambdaQueryWrapper() - .eq(DeviceFirmwareEntity::getWorkspaceId, workspaceId) - .eq(DeviceFirmwareEntity::getFileMd5, fileMd5)) - > 0; - } - - @Override - public PaginationData getAllFirmwarePagination(String workspaceId, DeviceFirmwareQueryParam param) { - Page page = mapper.selectPage(new Page<>(param.getPage(), param.getPageSize()), - new LambdaQueryWrapper() - .eq(DeviceFirmwareEntity::getWorkspaceId, workspaceId) - .eq(Objects.nonNull(param.getStatus()), DeviceFirmwareEntity::getStatus, param.getStatus()) - .like(StringUtils.hasText(param.getProductVersion()), DeviceFirmwareEntity::getFirmwareVersion, param.getProductVersion()) - .orderByDesc(DeviceFirmwareEntity::getReleaseDate), param.getDeviceName()); - - List data = page.getRecords().stream().map(this::entity2Dto).collect(Collectors.toList()); - return new PaginationData(data, new Pagination(page)); - } - - - @Override - public void importFirmwareFile(String workspaceId, String creator, DeviceFirmwareUploadParam param, MultipartFile file) { - String key = RedisConst.FILE_UPLOADING_PREFIX + workspaceId; - String existKey = key + file.getOriginalFilename(); - if (RedisOpsUtils.getExpire(existKey) > 0) { - throw new RuntimeException("Please try again later."); - } - RedisOpsUtils.setWithExpire(existKey, true, RedisConst.DEVICE_ALIVE_SECOND); - try (InputStream is = file.getInputStream()) { - long size = is.available(); - String md5 = DigestUtils.md5DigestAsHex(is); - key += md5; - boolean exist = checkFileExist(workspaceId, md5); - if (exist) { - throw new RuntimeException("The file already exists."); - } - RedisOpsUtils.set(key, System.currentTimeMillis()); - Optional firmwareOpt = verifyFirmwareFile(file); - if (firmwareOpt.isEmpty()) { - throw new RuntimeException("The file format is incorrect."); - } - - String firmwareId = UUID.randomUUID().toString(); - String objectKey = OssConfiguration.objectDirPrefix + File.separator + firmwareId + FirmwareFileProperties.FIRMWARE_FILE_SUFFIX; - - ossServiceContext.putObject(OssConfiguration.bucket, objectKey, file.getInputStream()); - log.info("upload success. {}", file.getOriginalFilename()); - DeviceFirmwareDTO firmware = DeviceFirmwareDTO.builder() - .releaseNote(param.getReleaseNote()) - .firmwareStatus(param.getStatus()) - .fileMd5(md5) - .objectKey(objectKey) - .fileName(file.getOriginalFilename()) - .workspaceId(workspaceId) - .username(creator) - .fileSize(size) - .productVersion(firmwareOpt.get().getProductVersion()) - .releasedTime(firmwareOpt.get().getReleasedTime()) - .firmwareId(firmwareId) - .build(); - - saveFirmwareInfo(firmware, param.getDeviceName()); - } catch (IOException e) { - e.printStackTrace(); - } finally { - RedisOpsUtils.del(key); - } - } - - @Override - public void saveFirmwareInfo(DeviceFirmwareDTO firmware, List deviceNames) { - DeviceFirmwareEntity entity = dto2Entity(firmware); - mapper.insert(entity); - firmwareModelService.saveFirmwareDeviceName( - FirmwareModelDTO.builder().firmwareId(entity.getFirmwareId()).deviceNames(deviceNames).build()); - } - - @Override - public void updateFirmwareInfo(DeviceFirmwareDTO firmware) { - mapper.update(dto2Entity(firmware), - new LambdaUpdateWrapper() - .eq(DeviceFirmwareEntity::getFirmwareId, firmware.getFirmwareId())); - } - - /** - * Parse firmware file information. - * @param file - * @return - */ - private Optional verifyFirmwareFile(MultipartFile file) { - try (ZipInputStream unzipFile = new ZipInputStream(file.getInputStream(), StandardCharsets.UTF_8)) { - ZipEntry nextEntry = unzipFile.getNextEntry(); - while (Objects.nonNull(nextEntry)) { - String configName = nextEntry.getName(); - if (!configName.contains(File.separator) && configName.endsWith(FirmwareFileProperties.FIRMWARE_CONFIG_FILE_SUFFIX + FirmwareFileProperties.FIRMWARE_SIG_FILE_SUFFIX)) { - String[] filenameArr = configName.split(FirmwareFileProperties.FIRMWARE_FILE_DELIMITER); - String date = filenameArr[FirmwareFileProperties.FILENAME_RELEASE_DATE_INDEX]; - int index = date.indexOf("."); - if (index != -1) { - date = date.substring(0, index); - } - return Optional.of(DeviceFirmwareDTO.builder() - .releasedTime(LocalDate.parse( - date, - DateTimeFormatter.ofPattern(FirmwareFileProperties.FILENAME_RELEASE_DATE_FORMAT))) - // delete the string v. - .productVersion(filenameArr[FirmwareFileProperties.FILENAME_VERSION_INDEX].substring(1)) - .build()); - } - nextEntry = unzipFile.getNextEntry(); - } - - } catch (IOException e) { - e.printStackTrace(); - } - return Optional.empty(); - } - - private DeviceFirmwareEntity dto2Entity(DeviceFirmwareDTO dto) { - if (dto == null) { - return null; - } - return DeviceFirmwareEntity.builder() - .fileName(dto.getFileName()) - .fileMd5(dto.getFileMd5()) - .fileSize(dto.getFileSize()) - .firmwareId(dto.getFirmwareId()) - .firmwareVersion(dto.getProductVersion()) - .objectKey(dto.getObjectKey()) - .releaseDate(Objects.nonNull(dto.getReleasedTime()) ? - dto.getReleasedTime().atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli() : null) - .releaseNote(dto.getReleaseNote()) - .status(dto.getFirmwareStatus()) - .workspaceId(dto.getWorkspaceId()) - .username(dto.getUsername()) - .build(); - } - - private DeviceFirmwareNoteDTO entity2NoteDto (DeviceFirmwareEntity entity) { - if (entity == null) { - return null; - } - return DeviceFirmwareNoteDTO.builder() - .deviceName(entity.getDeviceName()) - .productVersion(entity.getFirmwareVersion()) - .releasedTime(LocalDate.ofInstant(Instant.ofEpochMilli(entity.getReleaseDate()), ZoneId.systemDefault())) - .releaseNote(entity.getReleaseNote()) - .build(); - } - - private DeviceFirmwareDTO entity2Dto (DeviceFirmwareEntity entity) { - if (entity == null) { - return null; - } - return DeviceFirmwareDTO.builder() - .deviceName(Arrays.asList(entity.getDeviceName().split(","))) - .fileMd5(entity.getFileMd5()) - .fileSize(entity.getFileSize()) - .objectKey(entity.getObjectKey()) - .firmwareId(entity.getFirmwareId()) - .fileName(entity.getFileName()) - .productVersion(entity.getFirmwareVersion()) - .releasedTime(LocalDate.ofInstant(Instant.ofEpochMilli(entity.getReleaseDate()), ZoneId.systemDefault())) - .releaseNote(entity.getReleaseNote()) - .firmwareStatus(entity.getStatus()) - .workspaceId(entity.getWorkspaceId()) - .username(entity.getUsername()) - .build(); - } - - private OtaCreateDevice dto2OtaCreateDto(DeviceFirmwareDTO dto) { - if (dto == null) { - return null; - } - return new OtaCreateDevice() - .setFileSize(dto.getFileSize()) - .setFileUrl(ossServiceContext.getObjectUrl(OssConfiguration.bucket, dto.getObjectKey()).toString()) - .setFileName(dto.getFileName()) - .setMd5(dto.getFileMd5()) - .setProductVersion(dto.getProductVersion()); - } -} diff --git a/src/main/java/com/dji/sample/manage/service/impl/DeviceHmsServiceImpl.java b/src/main/java/com/dji/sample/manage/service/impl/DeviceHmsServiceImpl.java deleted file mode 100644 index 3348c64..0000000 --- a/src/main/java/com/dji/sample/manage/service/impl/DeviceHmsServiceImpl.java +++ /dev/null @@ -1,292 +0,0 @@ -package com.dji.sample.manage.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.dji.sample.component.websocket.model.BizCodeEnum; -import com.dji.sample.component.websocket.service.IWebSocketMessageService; -import com.dji.sample.manage.dao.IDeviceHmsMapper; -import com.dji.sample.manage.model.common.HmsJsonUtil; -import com.dji.sample.manage.model.common.HmsMessage; -import com.dji.sample.manage.model.dto.DeviceDTO; -import com.dji.sample.manage.model.dto.DeviceHmsDTO; -import com.dji.sample.manage.model.dto.TelemetryDTO; -import com.dji.sample.manage.model.entity.DeviceHmsEntity; -import com.dji.sample.manage.model.enums.UserTypeEnum; -import com.dji.sample.manage.model.param.DeviceHmsQueryParam; -import com.dji.sample.manage.service.IDeviceHmsService; -import com.dji.sample.manage.service.IDeviceRedisService; -import com.dji.sdk.cloudapi.device.DeviceDomainEnum; -import com.dji.sdk.cloudapi.hms.*; -import com.dji.sdk.cloudapi.hms.api.AbstractHmsService; -import com.dji.sdk.common.Pagination; -import com.dji.sdk.common.PaginationData; -import com.dji.sdk.mqtt.events.TopicEventsRequest; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.messaging.MessageHeaders; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; - -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -/** - * @author sean - * @version 1.1 - * @date 2022/7/6 - */ -@Service -@Transactional -@Slf4j -public class DeviceHmsServiceImpl extends AbstractHmsService implements IDeviceHmsService { - - @Autowired - private IDeviceHmsMapper mapper; - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private IWebSocketMessageService sendMessageService; - - @Autowired - private IDeviceRedisService deviceRedisService; - - private static final Pattern PATTERN_KEY = Pattern.compile( - "(" + - Arrays.stream(HmsFormatKeyEnum.values()) - .map(HmsFormatKeyEnum::getKey) - .collect(Collectors.joining("|")) + - ")"); - - @Override - public void hms(TopicEventsRequest response, MessageHeaders headers) { - String sn = response.getFrom(); - DeviceHmsEntity entity = DeviceHmsEntity.builder() - .bid(response.getBid()) - .tid(response.getTid()) - .createTime(response.getTimestamp()) - .updateTime(0L) - .sn(sn) - .build(); - // Query all unread hms messages of the device in redis. - Set hmsMap = deviceRedisService.getAllHmsKeys(sn); - - List unReadList = new ArrayList<>(); - response.getData().getList() - .forEach(hmsReceiver -> { - final DeviceHmsEntity hms = entity.clone(); - this.fillEntity(hms, hmsReceiver); - // The same unread hms are no longer incremented. - if (hmsMap.contains(hms.getHmsKey())) { - return; - } - this.fillMessage(hms, hmsReceiver.getArgs()); - unReadList.add(entity2Dto(hms)); - mapper.insert(hms); - }); - - if (unReadList.isEmpty()) { - return; - } - deviceRedisService.addEndHmsKeys(sn, unReadList.stream().map(DeviceHmsDTO::getKey).toArray(String[]::new)); - // push to the web - Optional deviceOpt = deviceRedisService.getDeviceOnline(sn); - if (deviceOpt.isEmpty()) { - return; - } - sendMessageService.sendBatch(deviceOpt.get().getWorkspaceId(), UserTypeEnum.WEB.getVal(), - BizCodeEnum.DEVICE_HMS.getCode(), TelemetryDTO.>builder().sn(sn).host(unReadList).build()); - } - - @Override - public PaginationData getDeviceHmsByParam(DeviceHmsQueryParam param) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() - .and(wrapper -> param.getDeviceSn().forEach(sn -> wrapper.eq(DeviceHmsEntity::getSn, sn).or())) - .between(param.getBeginTime() != null && param.getEndTime() != null, - DeviceHmsEntity::getCreateTime, param.getBeginTime(), param.getEndTime()) - .eq(param.getUpdateTime() != null, DeviceHmsEntity::getUpdateTime, param.getUpdateTime()) - .eq(param.getLevel() != null, DeviceHmsEntity::getLevel, param.getLevel()) - .like(StringUtils.hasText(param.getMessage()) && - HmsMessageLanguageEnum.ZH.getLanguage().equals(param.getLanguage()), - DeviceHmsEntity::getMessageZh, param.getMessage()) - .like(StringUtils.hasText(param.getMessage()) && - HmsMessageLanguageEnum.EN.getLanguage().equals(param.getLanguage()), - DeviceHmsEntity::getMessageEn, param.getMessage()) - .orderByDesc(DeviceHmsEntity::getCreateTime); - if (param.getPage() == null || param.getPageSize() == null) { - param.setPage(1L); - param.setPageSize(Long.valueOf(mapper.selectCount(queryWrapper))); - } - - Page pagination = mapper.selectPage(new Page<>(param.getPage(), param.getPageSize()), queryWrapper); - - List deviceHmsList = pagination.getRecords().stream().map(this::entity2Dto).collect(Collectors.toList()); - - return new PaginationData(deviceHmsList, new Pagination(pagination)); - } - - @Override - public void updateUnreadHms(String deviceSn) { - mapper.update(DeviceHmsEntity.builder().updateTime(System.currentTimeMillis()).build(), - new LambdaUpdateWrapper() - .eq(DeviceHmsEntity::getSn, deviceSn) - .eq(DeviceHmsEntity::getUpdateTime, 0L)); - // Delete unread messages cached in redis. - deviceRedisService.delHmsKeysBySn(deviceSn); - } - - private DeviceHmsDTO entity2Dto(DeviceHmsEntity entity) { - if (entity == null) { - return null; - } - return DeviceHmsDTO.builder() - .bid(entity.getBid()) - .tid(entity.getTid()) - .createTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getCreateTime()), ZoneId.systemDefault())) - .updateTime(entity.getUpdateTime().intValue() == 0 ? - null : LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getUpdateTime()), ZoneId.systemDefault())) - .sn(entity.getSn()) - .hmsId(entity.getHmsId()) - .key(entity.getHmsKey()) - .level(entity.getLevel()) - .module(entity.getModule()) - .messageEn(entity.getMessageEn()) - .messageZh(entity.getMessageZh()) - .build(); - } - - /** - * Populate the received data into the entity. Please refer to the documentation for splicing rules. - * @param dto - * @param receiver - */ - private void fillEntity(DeviceHmsEntity dto, DeviceHms receiver) { - dto.setLevel(receiver.getLevel().getLevel()); - dto.setModule(receiver.getModule().getModule()); - dto.setHmsId(UUID.randomUUID().toString()); - DeviceDomainEnum domain = receiver.getDeviceType().getDomain(); - if (DeviceDomainEnum.DOCK == domain) { - dto.setHmsKey(HmsFaqIdEnum.DOCK_TIP.getText() + receiver.getCode()); - return; - } - StringBuilder key = new StringBuilder(HmsFaqIdEnum.FPV_TIP.getText()).append(receiver.getCode()); - - if (receiver.getInTheSky()) { - key.append(HmsInTheSkyEnum.IN_THE_SKY.getText()); - } - dto.setHmsKey(key.toString()); - } - - /** - * Replace wildcards in messages according to the relevant rules. - * Please refer to the documentation for splicing rules. - * @param dto - * @param args - */ - private void fillMessage(DeviceHmsEntity dto, DeviceHmsArgs args) { - HmsMessage hmsMessage = HmsJsonUtil.get(dto.getHmsKey()); - String zh = StringUtils.hasText(hmsMessage.getZh()) ? hmsMessage.getZh() : String.format("未知错误(%s)", dto.getHmsKey()); - String en = StringUtils.hasText(hmsMessage.getEn()) ? hmsMessage.getEn() : String.format("Unknown(%s)", dto.getHmsKey());// - - dto.setMessageZh(format(Locale.CHINESE.getLanguage(), zh, args)); - dto.setMessageEn(format(Locale.ENGLISH.getLanguage(), en, args)); - } - - /** - * Set the matching parameters for key. - * @param l language: zh or en - * @param hmsArgs - * @return - */ - private Map fillKeyArgs(String l, DeviceHmsArgs hmsArgs) { - Map args = new HashMap<>(); - args.put(HmsFormatKeyEnum.ALARM_ID.getKey(), Objects.nonNull(hmsArgs.getAlarmId()) ? Long.toHexString(hmsArgs.getAlarmId()) : null); - args.put(HmsFormatKeyEnum.COMPONENT_INDEX.getKey(), - Objects.nonNull(hmsArgs.getComponentIndex()) ? String.valueOf(hmsArgs.getComponentIndex() + 1) : null); - if (Objects.nonNull(hmsArgs.getSensorIndex())) { - args.put(HmsFormatKeyEnum.INDEX.getKey(), String.valueOf(hmsArgs.getSensorIndex() + 1)); - - HmsBatteryIndexEnum hmsBatteryIndexEnum = Optional.ofNullable(hmsArgs.getSensorIndex()) - .filter(arg -> arg <= 1).map(HmsBatteryIndexEnum::find).orElse(null); - HmsDockCoverIndexEnum hmsDockCoverIndexEnum = Optional.ofNullable(hmsArgs.getSensorIndex()) - .filter(arg -> arg <= 1).map(HmsDockCoverIndexEnum::find).orElse(null); - HmsChargingRodIndexEnum hmsChargingRodIndexEnum = Optional.ofNullable(hmsArgs.getSensorIndex()) - .filter(arg -> arg <= 3).map(HmsChargingRodIndexEnum::find).orElse(null); - - switch (l) { - case "zh": - args.put(HmsFormatKeyEnum.BATTERY_INDEX.getKey(), Optional.ofNullable(hmsBatteryIndexEnum) - .map(HmsBatteryIndexEnum::getZh).orElse(null)); - args.put(HmsFormatKeyEnum.DOCK_COVER_INDEX.getKey(), Optional.ofNullable(hmsDockCoverIndexEnum) - .map(HmsDockCoverIndexEnum::getZh).orElse(null)); - args.put(HmsFormatKeyEnum.CHARGING_ROD_INDEX.getKey(), Optional.ofNullable(hmsChargingRodIndexEnum) - .map(HmsChargingRodIndexEnum::getZh).orElse(null)); - break; - case "en": - args.put(HmsFormatKeyEnum.BATTERY_INDEX.getKey(), Optional.ofNullable(hmsBatteryIndexEnum) - .map(HmsBatteryIndexEnum::getEn).orElse(null)); - args.put(HmsFormatKeyEnum.DOCK_COVER_INDEX.getKey(), Optional.ofNullable(hmsDockCoverIndexEnum) - .map(HmsDockCoverIndexEnum::getEn).orElse(null)); - args.put(HmsFormatKeyEnum.CHARGING_ROD_INDEX.getKey(), Optional.ofNullable(hmsChargingRodIndexEnum) - .map(HmsChargingRodIndexEnum::getEn).orElse(null)); - break; - default: - break; - } - - } - return args; - } - - /** - * Returns a formatted string using the specified locale, format string, and arguments. - * @param l language: zh or en - * @param format - * @param hmsArgs - * @return - */ - private String format(String l, String format, DeviceHmsArgs hmsArgs) { - Map args = fillKeyArgs(l, hmsArgs); - List list = parse(format); - StringBuilder sb = new StringBuilder(); - for (String word : list) { - if (!StringUtils.hasText(word)) { - continue; - } - sb.append(args.getOrDefault(word, word)); - } - return sb.toString(); - } - - /** - * Finds format specifiers in the format string. - * @param s - * @return - */ - private List parse(String s) { - List list = new ArrayList<>(); - Matcher matcher = PATTERN_KEY.matcher(s); - for (int i = 0; i < s.length(); ) { - if (matcher.find(i)) { - if (matcher.start() != i) { - list.add(s.substring(i, matcher.start())); - } - list.add(matcher.group()); - i = matcher.end(); - } else { - list.add(s.substring(i)); - break; - } - } - return list; - } -} diff --git a/src/main/java/com/dji/sample/manage/service/impl/DeviceLogsServiceImpl.java b/src/main/java/com/dji/sample/manage/service/impl/DeviceLogsServiceImpl.java deleted file mode 100644 index 799de27..0000000 --- a/src/main/java/com/dji/sample/manage/service/impl/DeviceLogsServiceImpl.java +++ /dev/null @@ -1,314 +0,0 @@ -package com.dji.sample.manage.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.dji.sample.component.mqtt.model.EventsReceiver; -import com.dji.sample.component.redis.RedisConst; -import com.dji.sample.component.redis.RedisOpsUtils; -import com.dji.sample.component.websocket.model.BizCodeEnum; -import com.dji.sample.component.websocket.service.IWebSocketMessageService; -import com.dji.sample.manage.dao.IDeviceLogsMapper; -import com.dji.sample.manage.model.dto.*; -import com.dji.sample.manage.model.entity.DeviceLogsEntity; -import com.dji.sample.manage.model.enums.DeviceLogsStatusEnum; -import com.dji.sample.manage.model.enums.UserTypeEnum; -import com.dji.sample.manage.model.param.DeviceLogsCreateParam; -import com.dji.sample.manage.model.param.DeviceLogsQueryParam; -import com.dji.sample.manage.service.IDeviceLogsService; -import com.dji.sample.manage.service.IDeviceRedisService; -import com.dji.sample.manage.service.ILogsFileService; -import com.dji.sample.manage.service.ITopologyService; -import com.dji.sample.storage.service.IStorageService; -import com.dji.sdk.cloudapi.log.*; -import com.dji.sdk.cloudapi.log.api.AbstractLogService; -import com.dji.sdk.cloudapi.storage.StsCredentialsResponse; -import com.dji.sdk.common.HttpResultResponse; -import com.dji.sdk.common.Pagination; -import com.dji.sdk.common.PaginationData; -import com.dji.sdk.common.SDKManager; -import com.dji.sdk.mqtt.MqttReply; -import com.dji.sdk.mqtt.events.EventsDataRequest; -import com.dji.sdk.mqtt.events.TopicEventsRequest; -import com.dji.sdk.mqtt.events.TopicEventsResponse; -import com.dji.sdk.mqtt.services.ServicesReplyData; -import com.dji.sdk.mqtt.services.TopicServicesResponse; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.messaging.MessageHeaders; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import java.net.URL; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author sean - * @version 1.2 - * @date 2022/9/7 - */ -@Service -@Transactional -@Slf4j -public class DeviceLogsServiceImpl extends AbstractLogService implements IDeviceLogsService { - - private static final String LOGS_FILE_SUFFIX = ".tar"; - - @Autowired - private IDeviceLogsMapper mapper; - - @Autowired - private ITopologyService topologyService; - - @Autowired - private ILogsFileService logsFileService; - - @Autowired - private IStorageService storageService; - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private IWebSocketMessageService webSocketMessageService; - - @Autowired - private IDeviceRedisService deviceRedisService; - - @Autowired - private AbstractLogService abstractLogService; - - @Override - public PaginationData getUploadedLogs(String deviceSn, DeviceLogsQueryParam param) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() - .eq(DeviceLogsEntity::getDeviceSn, deviceSn) - .between(Objects.nonNull(param.getBeginTime()) && Objects.nonNull(param.getEndTime()), - DeviceLogsEntity::getCreateTime, param.getBeginTime(), param.getEndTime()) - .eq(Objects.nonNull(param.getStatus()), DeviceLogsEntity::getStatus, param.getStatus()) - .like(StringUtils.hasText(param.getLogsInformation()), - DeviceLogsEntity::getLogsInfo, param.getLogsInformation()) - .orderByDesc(DeviceLogsEntity::getCreateTime); - - Page pagination = mapper.selectPage(new Page<>(param.getPage(), param.getPageSize()), queryWrapper); - - List deviceLogsList = pagination.getRecords().stream().map(this::entity2Dto).collect(Collectors.toList()); - - return new PaginationData(deviceLogsList, new Pagination(pagination)); - } - - @Override - public HttpResultResponse getRealTimeLogs(String deviceSn, List domainList) { - boolean exist = deviceRedisService.checkDeviceOnline(deviceSn); - if (!exist) { - return HttpResultResponse.error("Device is offline."); - } - - TopicServicesResponse> response = abstractLogService - .fileuploadList(SDKManager.getDeviceSDK(deviceSn), new FileUploadListRequest().setModuleList(domainList)); - for (FileUploadListFile file : response.getData().getOutput().getFiles()) { - if (file.getDeviceSn().isBlank()) { - file.setDeviceSn(deviceSn); - } - } - return HttpResultResponse.success(response.getData().getOutput()); - } - - @Override - public String insertDeviceLogs(String bid, String username, String deviceSn, DeviceLogsCreateParam param) { - DeviceLogsEntity entity = DeviceLogsEntity.builder() - .deviceSn(deviceSn) - .username(username) - .happenTime(param.getHappenTime()) - .logsInfo(Objects.requireNonNullElse(param.getLogsInformation(), "")) - .logsId(bid) - .status(DeviceLogsStatusEnum.UPLOADING.getVal()) - .build(); - boolean insert = mapper.insert(entity) > 0; - if (!insert) { - return ""; - } - for (FileUploadStartFile file : param.getFiles()) { - insert = logsFileService.insertFile(file, entity.getLogsId()); - if (!insert) { - return ""; - } - } - - return bid; - } - - - @Override - public HttpResultResponse pushFileUpload(String username, String deviceSn, DeviceLogsCreateParam param) { - StsCredentialsResponse stsCredentials = storageService.getSTSCredentials(); - stsCredentials.getCredentials().setExpire(System.currentTimeMillis() + (stsCredentials.getCredentials().getExpire() - 60) * 1000); - LogsUploadCredentialsDTO credentialsDTO = new LogsUploadCredentialsDTO(stsCredentials); - // Set the storage name of the file. - List files = param.getFiles(); - files.forEach(file -> file.setObjectKey(credentialsDTO.getObjectKeyPrefix() + "/" + UUID.randomUUID().toString() + LOGS_FILE_SUFFIX)); - - credentialsDTO.setParams(new FileUploadStartParam().setFiles(files)); - - TopicServicesResponse response = abstractLogService.fileuploadStart( - SDKManager.getDeviceSDK(deviceSn), new FileUploadStartRequest() - .setCredentials(stsCredentials.getCredentials()) - .setBucket(stsCredentials.getBucket()) - .setEndpoint(stsCredentials.getEndpoint()) - .setFileStoreDir(stsCredentials.getObjectKeyPrefix()) - .setProvider(stsCredentials.getProvider()) - .setRegion(stsCredentials.getRegion()) - .setParams(new FileUploadStartParam().setFiles(files))); - - if (!response.getData().getResult().isSuccess()) { - return HttpResultResponse.error(response.getData().getResult()); - } - - String id = this.insertDeviceLogs(response.getBid(), username, deviceSn, param); - - // Save the status of the log upload. - RedisOpsUtils.hashSet(RedisConst.LOGS_FILE_PREFIX + deviceSn, id, LogsOutputProgressDTO.builder().logsId(id).build()); - return HttpResultResponse.success(); - - } - - @Override - public HttpResultResponse pushUpdateFile(String deviceSn, FileUploadUpdateRequest param) { - TopicServicesResponse response = abstractLogService.fileuploadUpdate(SDKManager.getDeviceSDK(deviceSn), param); - - if (!response.getData().getResult().isSuccess()) { - return HttpResultResponse.error(response.getData().getResult()); - } - return HttpResultResponse.success(); - } - - @Override - public void deleteLogs(String deviceSn, String logsId) { - mapper.delete(new LambdaUpdateWrapper() - .eq(DeviceLogsEntity::getLogsId, logsId).eq(DeviceLogsEntity::getDeviceSn, deviceSn)); - logsFileService.deleteFileByLogsId(logsId); - } - - @Override - public TopicEventsResponse fileuploadProgress(TopicEventsRequest> request, MessageHeaders headers) { - EventsReceiver webSocketData = new EventsReceiver<>(); - webSocketData.setBid(request.getBid()); - webSocketData.setSn(request.getGateway()); - - Optional deviceOpt = deviceRedisService.getDeviceOnline(request.getGateway()); - if (deviceOpt.isEmpty()) { - return null; - } - - DeviceDTO device = deviceOpt.get(); - String key = RedisConst.LOGS_FILE_PREFIX + request.getGateway(); - - try { - FileUploadProgress output = request.getData().getOutput(); - log.info("Logs upload progress: {}", output.toString()); - - LogsOutputProgressDTO progress; - boolean exist = RedisOpsUtils.checkExist(key); - if (!exist && !output.getStatus().isEnd()) { - progress = LogsOutputProgressDTO.builder().logsId(request.getBid()).build(); - RedisOpsUtils.hashSet(key, request.getBid(), progress); - } else if (exist) { - progress = (LogsOutputProgressDTO) RedisOpsUtils.hashGet(key, request.getBid()); - } else { - progress = LogsOutputProgressDTO.builder().build(); - } - progress.setStatus(output.getStatus()); - - // If the logs file is empty, delete the cache of this task. - List fileReceivers = output.getExt().getFiles(); - if (CollectionUtils.isEmpty(fileReceivers)) { - RedisOpsUtils.del(key); - } - - // refresh cache. - List fileProgressList = new ArrayList<>(); - fileReceivers.forEach(file -> { - LogFileProgress logsProgress = file.getProgress(); - if (!StringUtils.hasText(file.getDeviceSn())) { - if (LogModuleEnum.DOCK == file.getModule()) { - file.setDeviceSn(request.getGateway()); - } else if (LogModuleEnum.DRONE == file.getModule()) { - file.setDeviceSn(device.getChildDeviceSn()); - } - } - - fileProgressList.add(LogsProgressDTO.builder() - .deviceSn(file.getDeviceSn()) - .deviceModelDomain(file.getModule().getDomain()) - .result(logsProgress.getResult()) - .status(logsProgress.getStatus().getStatus()) - .uploadRate(logsProgress.getUploadRate()) - .progress(((logsProgress.getCurrentStep() - 1) * 100 + logsProgress.getProgress()) / logsProgress.getTotalStep()) - .build()); - }); - progress.setFiles(fileProgressList); - webSocketData.setOutput(progress); - RedisOpsUtils.hashSet(RedisConst.LOGS_FILE_PREFIX + request.getGateway(), request.getBid(), progress); - // Delete the cache at the end of the task. - if (output.getStatus().isEnd()) { - RedisOpsUtils.del(key); - updateLogsStatus(request.getBid(), DeviceLogsStatusEnum.find(output.getStatus()).getVal()); - - fileReceivers.forEach(file -> logsFileService.updateFile(request.getBid(), file)); - } - } catch (NullPointerException e) { - this.updateLogsStatus(request.getBid(), DeviceLogsStatusEnum.FAILED.getVal()); - RedisOpsUtils.del(key); - } - - webSocketMessageService.sendBatch(device.getWorkspaceId(), UserTypeEnum.WEB.getVal(), - BizCodeEnum.FILE_UPLOAD_PROGRESS.getCode(), webSocketData); - - return new TopicEventsResponse().setData(MqttReply.success()); - } - - @Override - public void updateLogsStatus(String logsId, Integer value) { - - mapper.update(DeviceLogsEntity.builder().status(value).build(), - new LambdaUpdateWrapper().eq(DeviceLogsEntity::getLogsId, logsId)); - if (DeviceLogsStatusEnum.DONE.getVal() == value) { - logsFileService.updateFileUploadStatus(logsId, true); - } - } - - @Override - public URL getLogsFileUrl(String logsId, String fileId) { - return logsFileService.getLogsFileUrl(logsId, fileId); - } - - private DeviceLogsDTO entity2Dto(DeviceLogsEntity entity) { - if (Objects.isNull(entity)) { - return null; - } - String key = RedisConst.LOGS_FILE_PREFIX + entity.getDeviceSn(); - LogsOutputProgressDTO progress = null; - if (RedisOpsUtils.hashCheck(key, entity.getLogsId())) { - progress = (LogsOutputProgressDTO) RedisOpsUtils.hashGet(key, entity.getLogsId()); - } - - return DeviceLogsDTO.builder() - .logsId(entity.getLogsId()) - .createTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getCreateTime()), ZoneId.systemDefault())) - .happenTime(Objects.isNull(entity.getHappenTime()) ? - null : LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getHappenTime()), ZoneId.systemDefault())) - .status(entity.getStatus()) - .logsInformation(entity.getLogsInfo()) - .userName(entity.getUsername()) - .deviceLogs(LogsFileUploadListDTO.builder().files(logsFileService.getLogsFileByLogsId(entity.getLogsId())).build()) - .logsProgress(Objects.requireNonNullElse(progress, new LogsOutputProgressDTO()).getFiles()) - .deviceTopo(topologyService.getDeviceTopologyByGatewaySn(entity.getDeviceSn()).orElse(null)) - .build(); - } -} diff --git a/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java b/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java deleted file mode 100644 index c4107c6..0000000 --- a/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java +++ /dev/null @@ -1,684 +0,0 @@ -package com.dji.sample.manage.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.dji.sample.common.error.CommonErrorEnum; -import com.dji.sample.component.mqtt.model.EventsReceiver; -import com.dji.sample.component.websocket.model.BizCodeEnum; -import com.dji.sample.component.websocket.service.IWebSocketMessageService; -import com.dji.sample.control.model.enums.DroneAuthorityEnum; -import com.dji.sample.manage.dao.IDeviceMapper; -import com.dji.sample.manage.model.dto.*; -import com.dji.sample.manage.model.entity.DeviceEntity; -import com.dji.sample.manage.model.enums.DeviceFirmwareStatusEnum; -import com.dji.sample.manage.model.enums.PropertySetFieldEnum; -import com.dji.sample.manage.model.enums.UserTypeEnum; -import com.dji.sample.manage.model.param.DeviceQueryParam; -import com.dji.sample.manage.model.receiver.BasicDeviceProperty; -import com.dji.sample.manage.service.*; -import com.dji.sdk.cloudapi.device.*; -import com.dji.sdk.cloudapi.firmware.*; -import com.dji.sdk.cloudapi.firmware.api.AbstractFirmwareService; -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; -import com.dji.sdk.mqtt.events.EventsSubscribe; -import com.dji.sdk.mqtt.osd.OsdSubscribe; -import com.dji.sdk.mqtt.property.PropertySetReplyResultEnum; -import com.dji.sdk.mqtt.property.PropertySetSubscribe; -import com.dji.sdk.mqtt.requests.RequestsSubscribe; -import com.dji.sdk.mqtt.services.ServicesReplyData; -import com.dji.sdk.mqtt.services.ServicesSubscribe; -import com.dji.sdk.mqtt.services.TopicServicesResponse; -import com.dji.sdk.mqtt.state.StateSubscribe; -import com.dji.sdk.mqtt.status.StatusSubscribe; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * - * @author sean.zhou - * @version 0.1 - * @date 2021/11/10 - */ -@Service -@Slf4j -@Transactional -public class DeviceServiceImpl implements IDeviceService { - - @Autowired - private MqttGatewayPublish messageSender; - - @Autowired - private IDeviceMapper mapper; - - @Autowired - private IDeviceDictionaryService dictionaryService; - - @Autowired - private IMqttTopicService topicService; - - @Autowired - private IWorkspaceService workspaceService; - - @Autowired - private IDevicePayloadService payloadService; - - @Autowired - private IWebSocketMessageService webSocketMessageService; - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private IDeviceFirmwareService deviceFirmwareService; - - @Autowired - private ICapacityCameraService capacityCameraService; - - @Autowired - private IDeviceRedisService deviceRedisService; - - @Autowired - private StatusSubscribe statusSubscribe; - - @Autowired - private StateSubscribe stateSubscribe; - - @Autowired - private OsdSubscribe osdSubscribe; - - @Autowired - private ServicesSubscribe servicesSubscribe; - - @Autowired - private EventsSubscribe eventsSubscribe; - - @Autowired - private RequestsSubscribe requestsSubscribe; - - @Autowired - private PropertySetSubscribe propertySetSubscribe; - - @Autowired - private AbstractPropertyService abstractPropertyService; - - @Autowired - private AbstractFirmwareService abstractFirmwareService; - - @Override - public void subDeviceOffline(String deviceSn) { - // If no information about this device exists in the cache, the drone is considered to be offline. - Optional deviceOpt = deviceRedisService.getDeviceOnline(deviceSn); - if (deviceOpt.isEmpty()) { - log.debug("The drone is already offline."); - return; - } - try { - gatewayOnlineSubscribeTopic(SDKManager.getDeviceSDK(String.valueOf(deviceOpt.get().getParentSn()))); - } catch (CloudSDKException e) { - log.debug("The gateway is already offline.", e); - } - deviceRedisService.subDeviceOffline(deviceSn); - // Publish the latest device topology information in the current workspace. - pushDeviceOfflineTopo(deviceOpt.get().getWorkspaceId(), deviceSn); - log.debug("{} offline.", deviceSn); - } - - @Override - public void gatewayOffline(String gatewaySn) { - // If no information about this device exists in the cache, the drone is considered to be offline. - Optional deviceOpt = deviceRedisService.getDeviceOnline(gatewaySn); - if (deviceOpt.isEmpty()) { - log.debug("The gateway is already offline."); - return; - } - - deviceRedisService.subDeviceOffline(deviceOpt.get().getChildDeviceSn()); - deviceRedisService.gatewayOffline(gatewaySn); - offlineUnsubscribeTopic(SDKManager.getDeviceSDK(gatewaySn)); - // Publish the latest device topology information in the current workspace. - pushDeviceOfflineTopo(deviceOpt.get().getWorkspaceId(), gatewaySn); - log.debug("{} offline.", gatewaySn); - } - - @Override - public void gatewayOnlineSubscribeTopic(GatewayManager gateway) { - statusSubscribe.subscribe(gateway); - stateSubscribe.subscribe(gateway, true); - osdSubscribe.subscribe(gateway, true); - servicesSubscribe.subscribe(gateway); - eventsSubscribe.subscribe(gateway, true); - requestsSubscribe.subscribe(gateway); - propertySetSubscribe.subscribe(gateway); - } - - @Override - public void subDeviceOnlineSubscribeTopic(GatewayManager gateway) { - statusSubscribe.subscribe(gateway); - stateSubscribe.subscribe(gateway, false); - osdSubscribe.subscribe(gateway, false); - servicesSubscribe.subscribe(gateway); - eventsSubscribe.subscribe(gateway, false); - requestsSubscribe.subscribe(gateway); - propertySetSubscribe.subscribe(gateway); - } - - @Override - public void offlineUnsubscribeTopic(GatewayManager gateway) { - statusSubscribe.unsubscribe(gateway); - stateSubscribe.unsubscribe(gateway); - osdSubscribe.unsubscribe(gateway); - servicesSubscribe.unsubscribe(gateway); - eventsSubscribe.unsubscribe(gateway); - requestsSubscribe.unsubscribe(gateway); - propertySetSubscribe.unsubscribe(gateway); - } - - @Override - public List getDevicesByParams(DeviceQueryParam param) { - return mapper.selectList( - new LambdaQueryWrapper() - .eq(StringUtils.hasText(param.getDeviceSn()), - DeviceEntity::getDeviceSn, param.getDeviceSn()) - .eq(param.getDeviceType() != null, - DeviceEntity::getDeviceType, param.getDeviceType()) - .eq(param.getSubType() != null, - DeviceEntity::getSubType, param.getSubType()) - .eq(StringUtils.hasText(param.getChildSn()), - DeviceEntity::getChildSn, param.getChildSn()) - .and(!CollectionUtils.isEmpty(param.getDomains()), wrapper -> { - for (Integer domain : param.getDomains()) { - wrapper.eq(DeviceEntity::getDomain, domain).or(); - } - }) - .eq(StringUtils.hasText(param.getWorkspaceId()), - DeviceEntity::getWorkspaceId, param.getWorkspaceId()) - .eq(param.getBoundStatus() != null, DeviceEntity::getBoundStatus, param.getBoundStatus()) - .orderBy(param.isOrderBy(), - param.isAsc(), DeviceEntity::getId)) - .stream() - .map(this::deviceEntityConvertToDTO) - .collect(Collectors.toList()); - } - - @Override - public List getDevicesTopoForWeb(String workspaceId) { - List devicesList = this.getDevicesByParams( - DeviceQueryParam.builder() - .workspaceId(workspaceId) - .domains(List.of(DeviceDomainEnum.REMOTER_CONTROL.getDomain(), DeviceDomainEnum.DOCK.getDomain())) - .build()); - - devicesList.stream() - .filter(gateway -> DeviceDomainEnum.DOCK == gateway.getDomain() || - deviceRedisService.checkDeviceOnline(gateway.getDeviceSn())) - .forEach(this::spliceDeviceTopo); - - return devicesList; - } - - @Override - public void spliceDeviceTopo(DeviceDTO gateway) { - - gateway.setStatus(deviceRedisService.checkDeviceOnline(gateway.getDeviceSn())); - - // sub device - if (!StringUtils.hasText(gateway.getChildDeviceSn())) { - return; - } - - DeviceDTO subDevice = getDevicesByParams(DeviceQueryParam.builder().deviceSn(gateway.getChildDeviceSn()).build()).get(0); - subDevice.setStatus(deviceRedisService.checkDeviceOnline(subDevice.getDeviceSn())); - gateway.setChildren(subDevice); - - // payloads - subDevice.setPayloadsList(payloadService.getDevicePayloadEntitiesByDeviceSn(gateway.getChildDeviceSn())); - } - - @Override - public Optional getDeviceTopoForPilot(String sn) { - if (!StringUtils.hasText(sn)) { - return Optional.empty(); - } - List topologyDeviceList = this.getDevicesByParams( - DeviceQueryParam.builder() - .deviceSn(sn) - .build()) - .stream() - .map(this::deviceConvertToTopologyDTO) - .collect(Collectors.toList()); - if (topologyDeviceList.isEmpty()) { - return Optional.empty(); - } - return Optional.of(topologyDeviceList.get(0)); - } - - @Override - public TopologyDeviceDTO deviceConvertToTopologyDTO(DeviceDTO device) { - if (device == null) { - return null; - } - return new TopologyDeviceDTO() - .setSn(device.getDeviceSn()) - .setDeviceCallsign(device.getNickname()) - .setDeviceModel(new TopologyDeviceModel() - .setDomain(device.getDomain()) - .setSubType(device.getSubType()) - .setType(device.getType()) - .setDeviceModelKey(DeviceEnum.find(device.getDomain(), device.getType(), device.getSubType()))) - .setIconUrls(device.getIconUrl()) - .setOnlineStatus(deviceRedisService.checkDeviceOnline(device.getDeviceSn())) - .setUserCallsign(device.getNickname()) - .setBoundStatus(device.getBoundStatus()) - .setModel(device.getDeviceName()) - .setUserId(device.getUserId()) - .setDomain(device.getDomain()) - .setGatewaySn(device.getParentSn()); - } - - @Override - public void pushDeviceOfflineTopo(String workspaceId, String deviceSn) { - webSocketMessageService.sendBatch( - workspaceId, null, com.dji.sdk.websocket.BizCodeEnum.DEVICE_OFFLINE.getCode(), - new TopologyDeviceDTO().setSn(deviceSn).setOnlineStatus(false)); - } - - @Override - public void pushDeviceOnlineTopo(String workspaceId, String gatewaySn, String deviceSn) { - webSocketMessageService.sendBatch( - workspaceId, null, com.dji.sdk.websocket.BizCodeEnum.DEVICE_ONLINE.getCode(), - getDeviceTopoForPilot(deviceSn).orElseGet(TopologyDeviceDTO::new).setGatewaySn(gatewaySn)); - } - - @Override - public void pushOsdDataToPilot(String workspaceId, String sn, DeviceOsdHost data) { - webSocketMessageService.sendBatch( - workspaceId, UserTypeEnum.PILOT.getVal(), com.dji.sdk.websocket.BizCodeEnum.DEVICE_OSD.getCode(), - new DeviceOsdWsResponse() - .setSn(sn) - .setHost(data)); - } - - @Override - public void pushOsdDataToWeb(String workspaceId, BizCodeEnum codeEnum, String sn, Object data) { - webSocketMessageService.sendBatch( - workspaceId, UserTypeEnum.WEB.getVal(), codeEnum.getCode(), TelemetryDTO.builder().sn(sn).host(data).build()); - } - - /** - * Save the device information and update the information directly if the device already exists. - * @param device - * @return - */ - public Boolean saveOrUpdateDevice(DeviceDTO device) { - int count = mapper.selectCount( - new LambdaQueryWrapper() - .eq(DeviceEntity::getDeviceSn, device.getDeviceSn())); - return count > 0 ? updateDevice(device) : saveDevice(device) > 0; - } - - /** - * Save the device information. - * @param device - * @return - */ - public Integer saveDevice(DeviceDTO device) { - DeviceEntity entity = deviceDTO2Entity(device); - return mapper.insert(entity) > 0 ? entity.getId() : -1; - } - - /** - * Convert database entity object into device data transfer object. - * @param entity - * @return - */ - private DeviceDTO deviceEntityConvertToDTO(DeviceEntity entity) { - if (entity == null) { - return null; - } - DeviceDTO.DeviceDTOBuilder builder = DeviceDTO.builder(); - try { - builder - .deviceSn(entity.getDeviceSn()) - .childDeviceSn(entity.getChildSn()) - .deviceName(entity.getDeviceName()) - .deviceDesc(entity.getDeviceDesc()) - .controlSource(ControlSourceEnum.find(entity.getDeviceIndex())) - .workspaceId(entity.getWorkspaceId()) - .type(DeviceTypeEnum.find(entity.getDeviceType())) - .subType(DeviceSubTypeEnum.find(entity.getSubType())) - .domain(DeviceDomainEnum.find(entity.getDomain())) - .iconUrl(new DeviceIconUrl() - .setNormalIconUrl(entity.getUrlNormal()) - .setSelectIconUrl(entity.getUrlSelect())) - .boundStatus(entity.getBoundStatus()) - .loginTime(entity.getLoginTime() != null ? - LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getLoginTime()), ZoneId.systemDefault()) - : null) - .boundTime(entity.getBoundTime() != null ? - LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getBoundTime()), ZoneId.systemDefault()) - : null) - .nickname(entity.getNickname()) - .firmwareVersion(entity.getFirmwareVersion()) - .workspaceName(entity.getWorkspaceId() != null ? - workspaceService.getWorkspaceByWorkspaceId(entity.getWorkspaceId()) - .map(WorkspaceDTO::getWorkspaceName).orElse("") : "") - .firmwareStatus(DeviceFirmwareStatusEnum.NOT_UPGRADE) - .thingVersion(entity.getVersion()).build(); - } catch (CloudSDKException e) { - log.error(e.getLocalizedMessage() + "Entity: {}", entity); - } - DeviceDTO deviceDTO = builder.build(); - addFirmwareStatus(deviceDTO, entity); - return deviceDTO; - } - - private void addFirmwareStatus(DeviceDTO deviceDTO, DeviceEntity entity) { - if (!StringUtils.hasText(entity.getFirmwareVersion())) { - return; - } - // Query whether the device is updating firmware. - Optional> progressOpt = deviceRedisService.getFirmwareUpgradingProgress(entity.getDeviceSn()); - if (progressOpt.isPresent()) { - deviceDTO.setFirmwareStatus(DeviceFirmwareStatusEnum.UPGRADING); - deviceDTO.setFirmwareProgress(progressOpt.map(EventsReceiver::getOutput) - .map(OtaProgress::getProgress) - .map(OtaProgressData::getPercent) - .orElse(0)); - return; - } - - // First query the latest firmware version of the device model and compare it with the current firmware version - // to see if it needs to be upgraded. - Optional firmwareReleaseNoteOpt = deviceFirmwareService.getLatestFirmwareReleaseNote(entity.getDeviceName()); - if (firmwareReleaseNoteOpt.isEmpty()) { - deviceDTO.setFirmwareStatus(DeviceFirmwareStatusEnum.NOT_UPGRADE); - return; - } - if (entity.getFirmwareVersion().equals(firmwareReleaseNoteOpt.get().getProductVersion())) { - deviceDTO.setFirmwareStatus(entity.getCompatibleStatus() ? - DeviceFirmwareStatusEnum.NOT_UPGRADE : - DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE); - return; - } - deviceDTO.setFirmwareStatus(DeviceFirmwareStatusEnum.NORMAL_UPGRADE); - } - - @Override - public Boolean updateDevice(DeviceDTO deviceDTO) { - int update = mapper.update(this.deviceDTO2Entity(deviceDTO), - new LambdaUpdateWrapper().eq(DeviceEntity::getDeviceSn, deviceDTO.getDeviceSn())); - return update > 0; - } - - @Override - public Boolean bindDevice(DeviceDTO device) { - device.setBoundStatus(true); - device.setBoundTime(LocalDateTime.now()); - - boolean isUpd = this.updateDevice(device); - if (!isUpd) { - return false; - } - - Optional deviceOpt = deviceRedisService.getDeviceOnline(device.getDeviceSn()); - if (deviceOpt.isEmpty()) { - return false; - } - - DeviceDTO redisDevice = deviceOpt.get(); - redisDevice.setWorkspaceId(device.getWorkspaceId()); - deviceRedisService.setDeviceOnline(redisDevice); - - String gatewaySn, deviceSn; - if (DeviceDomainEnum.REMOTER_CONTROL == redisDevice.getDomain()) { - gatewaySn = device.getDeviceSn(); - deviceSn = redisDevice.getChildDeviceSn(); - } else { - gatewaySn = redisDevice.getParentSn(); - deviceSn = device.getDeviceSn(); - } - - pushDeviceOnlineTopo(device.getWorkspaceId(), gatewaySn, deviceSn); - subDeviceOnlineSubscribeTopic(SDKManager.getDeviceSDK(gatewaySn)); - return true; - } - - @Override - public PaginationData getBoundDevicesWithDomain(String workspaceId, Long page, - Long pageSize, Integer domain) { - - Page pagination = mapper.selectPage(new Page<>(page, pageSize), - new LambdaQueryWrapper() - .eq(DeviceEntity::getDomain, domain) - .eq(DeviceEntity::getWorkspaceId, workspaceId) - .eq(DeviceEntity::getBoundStatus, true)); - List devicesList = pagination.getRecords().stream().map(this::deviceEntityConvertToDTO) - .peek(device -> { - device.setStatus(deviceRedisService.checkDeviceOnline(device.getDeviceSn())); - if (StringUtils.hasText(device.getChildDeviceSn())) { - Optional childOpt = this.getDeviceBySn(device.getChildDeviceSn()); - childOpt.ifPresent(child -> { - child.setStatus(deviceRedisService.checkDeviceOnline(child.getDeviceSn())); - child.setWorkspaceName(device.getWorkspaceName()); - device.setChildren(child); - }); - } - }) - .collect(Collectors.toList()); - return new PaginationData(devicesList, new Pagination(pagination)); - } - - @Override - public void unbindDevice(String deviceSn) { - - Optional deviceOpt = deviceRedisService.getDeviceOnline(deviceSn); - if (deviceOpt.isPresent()) { - subDeviceOffline(deviceSn); - } else { - deviceOpt = getDeviceBySn(deviceSn); - } - if (deviceOpt.isEmpty()) { - return; - } - DeviceDTO device = DeviceDTO.builder() - .deviceSn(deviceSn) - .workspaceId("") - .userId("") - .boundStatus(false) - .build(); - this.updateDevice(device); - } - - @Override - public Optional getDeviceBySn(String sn) { - List devicesList = this.getDevicesByParams(DeviceQueryParam.builder().deviceSn(sn).build()); - if (devicesList.isEmpty()) { - return Optional.empty(); - } - DeviceDTO device = devicesList.get(0); - device.setStatus(deviceRedisService.checkDeviceOnline(sn)); - return Optional.of(device); - } - - @Override - public HttpResultResponse createDeviceOtaJob(String workspaceId, List upgradeDTOS) { - List deviceOtaFirmwares = deviceFirmwareService.getDeviceOtaFirmware(workspaceId, upgradeDTOS); - if (deviceOtaFirmwares.isEmpty()) { - return HttpResultResponse.error(); - } - - Optional deviceOpt = deviceRedisService.getDeviceOnline(deviceOtaFirmwares.get(0).getSn()); - if (deviceOpt.isEmpty()) { - throw new RuntimeException("Device is offline."); - } - DeviceDTO device = deviceOpt.get(); - String gatewaySn = DeviceDomainEnum.DOCK == device.getDomain() ? device.getDeviceSn() : device.getParentSn(); - - checkOtaConditions(gatewaySn); - - TopicServicesResponse> response = abstractFirmwareService.otaCreate( - SDKManager.getDeviceSDK(gatewaySn), new OtaCreateRequest().setDevices(deviceOtaFirmwares)); - ServicesReplyData serviceReply = response.getData(); - String bid = response.getBid(); - if (!serviceReply.getResult().isSuccess()) { - return HttpResultResponse.error(serviceReply.getResult()); - } - - // Record the device state that needs to be updated. - deviceOtaFirmwares.forEach(deviceOta -> deviceRedisService.setFirmwareUpgrading(deviceOta.getSn(), - EventsReceiver.builder().bid(bid).sn(deviceOta.getSn()).build())); - return HttpResultResponse.success(); - } - - /** - * Determine whether the firmware can be upgraded. - * @param dockSn - */ - private void checkOtaConditions(String dockSn) { - Optional deviceOpt = deviceRedisService.getDeviceOsd(dockSn, OsdDock.class); - if (deviceOpt.isEmpty()) { - throw new RuntimeException("Dock is offline."); - } - boolean emergencyStopState = deviceOpt.get().getEmergencyStopState(); - if (emergencyStopState) { - throw new RuntimeException("The emergency stop button of the dock is pressed and can't be upgraded."); - } - - DockModeCodeEnum dockMode = this.getDockMode(dockSn); - if (DockModeCodeEnum.IDLE != dockMode) { - throw new RuntimeException("The current status of the dock can't be upgraded."); - } - } - - @Override - public int devicePropertySet(String workspaceId, String dockSn, JsonNode param) { - String property = param.fieldNames().next(); - PropertySetFieldEnum propertyEnum = PropertySetFieldEnum.find(property); - - Optional dockOpt = deviceRedisService.getDeviceOnline(dockSn); - if (dockOpt.isEmpty()) { - throw new RuntimeException("Dock is offline."); - } - String childSn = dockOpt.get().getChildDeviceSn(); - Optional osdOpt = deviceRedisService.getDeviceOsd(childSn, OsdDockDrone.class); - if (osdOpt.isEmpty()) { - throw new RuntimeException("Device is offline."); - } - - // Make sure the data is valid. - BasicDeviceProperty basicDeviceProperty = objectMapper.convertValue(param.get(property), propertyEnum.getClazz()); - boolean valid = basicDeviceProperty.valid(); - if (!valid) { - throw new IllegalArgumentException(CommonErrorEnum.ILLEGAL_ARGUMENT.getMessage()); - } - boolean isPublish = basicDeviceProperty.canPublish(osdOpt.get()); - if (!isPublish) { - return PropertySetReplyResultEnum.SUCCESS.getResult(); - } - BaseModel baseModel = objectMapper.convertValue(param, propertyEnum.getProperty().getClazz()); - PropertySetReplyResultEnum result = abstractPropertyService.propertySet( - SDKManager.getDeviceSDK(dockSn), propertyEnum.getProperty(), baseModel); - return result.getResult(); - } - - @Override - public DockModeCodeEnum getDockMode(String dockSn) { - return deviceRedisService.getDeviceOsd(dockSn, OsdDock.class) - .map(OsdDock::getModeCode).orElse(null); - } - - @Override - public DroneModeCodeEnum getDeviceMode(String deviceSn) { - return deviceRedisService.getDeviceOsd(deviceSn, OsdDockDrone.class) - .map(OsdDockDrone::getModeCode).orElse(DroneModeCodeEnum.DISCONNECTED); - } - - @Override - public Boolean checkDockDrcMode(String dockSn) { - return deviceRedisService.getDeviceOsd(dockSn, OsdDock.class) - .map(OsdDock::getDrcState) - .orElse(DrcStateEnum.DISCONNECTED) != DrcStateEnum.DISCONNECTED; - } - - @Override - public Boolean checkAuthorityFlight(String gatewaySn) { - return deviceRedisService.getDeviceOnline(gatewaySn).flatMap(gateway -> - Optional.of((DeviceDomainEnum.DOCK == gateway.getDomain() - || DeviceDomainEnum.REMOTER_CONTROL == gateway.getDomain()) - && ControlSourceEnum.A == gateway.getControlSource())) - .orElse(true); - } - - @Override - public void updateFlightControl(DeviceDTO gateway, ControlSourceEnum controlSource) { - if (controlSource == gateway.getControlSource()) { - return; - } - gateway.setControlSource(controlSource); - deviceRedisService.setDeviceOnline(gateway); - - webSocketMessageService.sendBatch(gateway.getWorkspaceId(), UserTypeEnum.WEB.getVal(), - BizCodeEnum.CONTROL_SOURCE_CHANGE.getCode(), - DeviceAuthorityDTO.builder() - .controlSource(gateway.getControlSource()) - .sn(gateway.getDeviceSn()) - .type(DroneAuthorityEnum.FLIGHT) - .build()); - } - - /** - * Convert device data transfer object into database entity object. - * @param dto - * @return - */ - private DeviceEntity deviceDTO2Entity(DeviceDTO dto) { - DeviceEntity.DeviceEntityBuilder builder = DeviceEntity.builder(); - if (dto == null) { - return builder.build(); - } - - return builder.deviceSn(dto.getDeviceSn()) - .deviceIndex(Optional.ofNullable(dto.getControlSource()) - .map(ControlSourceEnum::getControlSource).orElse(null)) - .deviceName(dto.getDeviceName()) - .version(dto.getThingVersion()) - .userId(dto.getUserId()) - .nickname(dto.getNickname()) - .workspaceId(dto.getWorkspaceId()) - .boundStatus(dto.getBoundStatus()) - .domain(Optional.ofNullable(dto.getDomain()).map(DeviceDomainEnum::getDomain).orElse(null)) - .deviceType(Optional.ofNullable(dto.getType()).map(DeviceTypeEnum::getType).orElse(null)) - .subType(Optional.ofNullable(dto.getSubType()).map(DeviceSubTypeEnum::getSubType).orElse(null)) - .loginTime(dto.getLoginTime() != null ? - dto.getLoginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() : null) - .boundTime(dto.getBoundTime() != null ? - dto.getBoundTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() : null) - .childSn(dto.getChildDeviceSn()) - .firmwareVersion(dto.getFirmwareVersion()) - .compatibleStatus(dto.getFirmwareStatus() == null ? null : - DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE != dto.getFirmwareStatus()) - .deviceDesc(dto.getDeviceDesc()) - .build(); - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java b/src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java deleted file mode 100644 index 2b1f590..0000000 --- a/src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java +++ /dev/null @@ -1,253 +0,0 @@ -package com.dji.sample.manage.service.impl; - -import com.dji.sample.manage.model.dto.*; -import com.dji.sample.manage.model.param.DeviceQueryParam; -import com.dji.sample.manage.service.*; -import com.dji.sdk.cloudapi.device.DeviceDomainEnum; -import com.dji.sdk.cloudapi.device.VideoId; -import com.dji.sdk.cloudapi.livestream.*; -import com.dji.sdk.cloudapi.livestream.api.AbstractLivestreamService; -import com.dji.sdk.common.HttpResultResponse; -import com.dji.sdk.common.SDKManager; -import com.dji.sdk.mqtt.services.ServicesReplyData; -import com.dji.sdk.mqtt.services.TopicServicesResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; - -import java.lang.reflect.Field; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * @author sean.zhou - * @date 2021/11/22 - * @version 0.1 - */ -@Service -@Transactional -public class LiveStreamServiceImpl implements ILiveStreamService { - - @Autowired - private ICapacityCameraService capacityCameraService; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private IWorkspaceService workspaceService; - - @Autowired - private IDeviceRedisService deviceRedisService; - - @Autowired - private AbstractLivestreamService abstractLivestreamService; - - @Override - public List getLiveCapacity(String workspaceId) { - - // Query all devices in this workspace. - List devicesList = deviceService.getDevicesByParams( - DeviceQueryParam.builder() - .workspaceId(workspaceId) - .domains(List.of(DeviceDomainEnum.DRONE.getDomain(), DeviceDomainEnum.DOCK.getDomain())) - .build()); - - // Query the live capability of each drone. - return devicesList.stream() - .filter(device -> deviceRedisService.checkDeviceOnline(device.getDeviceSn())) - .map(device -> CapacityDeviceDTO.builder() - .name(Objects.requireNonNullElse(device.getNickname(), device.getDeviceName())) - .sn(device.getDeviceSn()) - .camerasList(capacityCameraService.getCapacityCameraByDeviceSn(device.getDeviceSn())) - .build()) - .collect(Collectors.toList()); - } - - @Override - public HttpResultResponse liveStart(LiveTypeDTO liveParam) { - // Check if this lens is available live. - HttpResultResponse responseResult = this.checkBeforeLive(liveParam.getVideoId()); - if (HttpResultResponse.CODE_SUCCESS != responseResult.getCode()) { - return responseResult; - } - - TopicServicesResponse> response = abstractLivestreamService.liveStartPush( - SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), new LiveStartPushRequest() - .setUrl(liveParam.getUrl()) - .setUrlType(liveParam.getUrlType()) - .setVideoId(new VideoId(liveParam.getVideoId())) - .setVideoQuality(liveParam.getVideoQuality())); - - if (!response.getData().getResult().isSuccess()) { - return HttpResultResponse.error(response.getData().getResult()); - } - - LiveDTO live = new LiveDTO(); - - switch (liveParam.getUrlType()) { - case AGORA: - break; - case RTMP: - live.setUrl(liveParam.getUrl().replace("rtmp", "webrtc")); - break; - case GB28181: - LiveUrlGB28181DTO gb28181 = urlToGB28181(liveParam.getUrl()); - live.setUrl(new StringBuilder() - .append("webrtc://") - .append(gb28181.getServerIP()) - .append("/live/") - .append(gb28181.getAgentID()) - .append("@") - .append(gb28181.getChannel()) - .toString()); - break; - case RTSP: - String url = response.getData().getOutput(); - this.resolveUrlUser(url, live); - break; - default: - return HttpResultResponse.error(LiveErrorCodeEnum.URL_TYPE_NOT_SUPPORTED); - } - - return HttpResultResponse.success(live); - } - - @Override - public HttpResultResponse liveStop(String videoId) { - HttpResultResponse responseResult = this.checkBeforeLive(videoId); - if (HttpResultResponse.CODE_SUCCESS != responseResult.getCode()) { - return responseResult; - } - - TopicServicesResponse response = abstractLivestreamService.liveStopPush( - SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), new LiveStopPushRequest() - .setVideoId(new VideoId(videoId))); - if (!response.getData().getResult().isSuccess()) { - return HttpResultResponse.error(response.getData().getResult()); - } - - return HttpResultResponse.success(); - } - - @Override - public HttpResultResponse liveSetQuality(LiveTypeDTO liveParam) { - HttpResultResponse responseResult = this.checkBeforeLive(liveParam.getVideoId()); - if (responseResult.getCode() != 0) { - return responseResult; - } - - TopicServicesResponse response = abstractLivestreamService.liveSetQuality( - SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), new LiveSetQualityRequest() - .setVideoQuality(liveParam.getVideoQuality()) - .setVideoId(new VideoId(liveParam.getVideoId()))); - if (!response.getData().getResult().isSuccess()) { - return HttpResultResponse.error(response.getData().getResult()); - } - - return HttpResultResponse.success(); - } - - @Override - public HttpResultResponse liveLensChange(LiveTypeDTO liveParam) { - HttpResultResponse responseResult = this.checkBeforeLive(liveParam.getVideoId()); - if (HttpResultResponse.CODE_SUCCESS != responseResult.getCode()) { - return responseResult; - } - - TopicServicesResponse response = abstractLivestreamService.liveLensChange( - SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), new LiveLensChangeRequest() - .setVideoType(liveParam.getVideoType()) - .setVideoId(new VideoId(liveParam.getVideoId()))); - - if (!response.getData().getResult().isSuccess()) { - return HttpResultResponse.error(response.getData().getResult()); - } - - return HttpResultResponse.success(); - } - - /** - * Check if this lens is available live. - * @param videoId - * @return - */ - private HttpResultResponse checkBeforeLive(String videoId) { - if (!StringUtils.hasText(videoId)) { - return HttpResultResponse.error(LiveErrorCodeEnum.ERROR_PARAMETERS); - } - String[] videoIdArr = videoId.split("/"); - // drone sn / enumeration value of the location where the payload is mounted / payload lens - if (videoIdArr.length != 3) { - return HttpResultResponse.error(LiveErrorCodeEnum.ERROR_PARAMETERS); - } - - Optional deviceOpt = deviceService.getDeviceBySn(videoIdArr[0]); - // Check if the gateway device connected to this drone exists - if (deviceOpt.isEmpty()) { - return HttpResultResponse.error(LiveErrorCodeEnum.NO_AIRCRAFT); - } - - if (DeviceDomainEnum.DOCK == deviceOpt.get().getDomain()) { - return HttpResultResponse.success(deviceOpt.get()); - } - List gatewayList = deviceService.getDevicesByParams( - DeviceQueryParam.builder() - .childSn(videoIdArr[0]) - .build()); - if (gatewayList.isEmpty()) { - return HttpResultResponse.error(LiveErrorCodeEnum.NO_FLIGHT_CONTROL); - } - - return HttpResultResponse.success(gatewayList.get(0)); - } - - /** - * When using rtsp live, the account and password are parsed from the information returned by the pilot. - * @param url - * @param live - */ - private void resolveUrlUser(String url, LiveDTO live) { - if (!StringUtils.hasText(url)) { - return; - } - int start = url.indexOf("//"); - int end = url.lastIndexOf("@"); - String user = url.substring(start + 2, end); - - url = url.replace(user + "@", ""); - String[] userArr = user.split(":"); - live.setUsername(userArr[0]); - live.setPassword(userArr[1]); - live.setUrl(url); - } - - /** - * When using GB28181 live, url parameters are resolved into objects. - * @param url - * @return - */ - private LiveUrlGB28181DTO urlToGB28181(String url) { - String[] arr = url.split("\\=|\\&"); - LiveUrlGB28181DTO gb28181 = new LiveUrlGB28181DTO(); - try { - Class clazz = LiveUrlGB28181DTO.class; - for (int i = 0; i < arr.length - 1; i += 2) { - Field field = clazz.getDeclaredField(arr[i]); - field.setAccessible(true); - - if (field.getType().equals(Integer.class)) { - field.set(gb28181, Integer.valueOf(arr[i + 1])); - continue; - } - field.set(gb28181, arr[i + 1]); - } - } catch (NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); - } - return gb28181; - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java b/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java deleted file mode 100644 index f882487..0000000 --- a/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java +++ /dev/null @@ -1,501 +0,0 @@ -package com.dji.sample.manage.service.impl; - -import com.dji.sample.component.websocket.model.BizCodeEnum; -import com.dji.sample.component.websocket.service.IWebSocketMessageService; -import com.dji.sample.manage.model.dto.DeviceDTO; -import com.dji.sample.manage.model.dto.DevicePayloadReceiver; -import com.dji.sample.manage.model.enums.DeviceFirmwareStatusEnum; -import com.dji.sample.manage.model.param.DeviceQueryParam; -import com.dji.sample.manage.service.IDeviceDictionaryService; -import com.dji.sample.manage.service.IDevicePayloadService; -import com.dji.sample.manage.service.IDeviceRedisService; -import com.dji.sample.manage.service.IDeviceService; -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.config.version.GatewayManager; -import com.dji.sdk.common.SDKManager; -import com.dji.sdk.mqtt.MqttReply; -import com.dji.sdk.mqtt.osd.TopicOsdRequest; -import com.dji.sdk.mqtt.state.TopicStateRequest; -import com.dji.sdk.mqtt.status.TopicStatusRequest; -import com.dji.sdk.mqtt.status.TopicStatusResponse; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.messaging.MessageHeaders; -import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * @author sean - * @version 1.7 - * @date 2023/7/4 - */ -@Service -@Slf4j -public class SDKDeviceService extends AbstractDeviceService { - - @Autowired - private IDeviceRedisService deviceRedisService; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private IDeviceDictionaryService dictionaryService; - - @Autowired - private IWebSocketMessageService webSocketMessageService; - - @Autowired - private IDevicePayloadService devicePayloadService; - - @Override - public TopicStatusResponse updateTopoOnline(TopicStatusRequest request, MessageHeaders headers) { - UpdateTopoSubDevice updateTopoSubDevice = request.getData().getSubDevices().get(0); - String deviceSn = updateTopoSubDevice.getSn(); - - Optional deviceOpt = deviceRedisService.getDeviceOnline(deviceSn); - Optional gatewayOpt = deviceRedisService.getDeviceOnline(request.getFrom()); - GatewayManager gatewayManager = SDKManager.registerDevice(request.getFrom(), deviceSn, - request.getData().getDomain(), request.getData().getType(), - request.getData().getSubType(), request.getData().getThingVersion(), updateTopoSubDevice.getThingVersion()); - - if (deviceOpt.isPresent() && gatewayOpt.isPresent()) { - deviceOnlineAgain(deviceOpt.get().getWorkspaceId(), request.getFrom(), deviceSn); - return new TopicStatusResponse().setData(MqttReply.success()); - } - - changeSubDeviceParent(deviceSn, request.getFrom()); - - DeviceDTO gateway = deviceGatewayConvertToDevice(request.getFrom(), request.getData()); - Optional gatewayEntityOpt = onlineSaveDevice(gateway, deviceSn, null); - if (gatewayEntityOpt.isEmpty()) { - log.error("Failed to go online, please check the status data or code logic."); - return null; - } - DeviceDTO subDevice = subDeviceConvertToDevice(updateTopoSubDevice); - Optional subDeviceEntityOpt = onlineSaveDevice(subDevice, null, gateway.getDeviceSn()); - if (subDeviceEntityOpt.isEmpty()) { - log.error("Failed to go online, please check the status data or code logic."); - return null; - } - subDevice = subDeviceEntityOpt.get(); - gateway = gatewayEntityOpt.get(); - dockGoOnline(gateway, subDevice); - deviceService.gatewayOnlineSubscribeTopic(gatewayManager); - - if (!StringUtils.hasText(subDevice.getWorkspaceId())) { - return new TopicStatusResponse().setData(MqttReply.success()); - } - - // Subscribe to topic related to drone devices. - deviceService.subDeviceOnlineSubscribeTopic(gatewayManager); - deviceService.pushDeviceOnlineTopo(gateway.getWorkspaceId(), gateway.getDeviceSn(), subDevice.getDeviceSn()); - - log.debug("{} online.", subDevice.getDeviceSn()); - return new TopicStatusResponse().setData(MqttReply.success()); - } - - @Override - public TopicStatusResponse updateTopoOffline(TopicStatusRequest request, MessageHeaders headers) { - GatewayManager gatewayManager = SDKManager.registerDevice(request.getFrom(), null, - request.getData().getDomain(), request.getData().getType(), - request.getData().getSubType(), request.getData().getThingVersion(), null); - deviceService.gatewayOnlineSubscribeTopic(gatewayManager); - // Only the remote controller is logged in and the aircraft is not connected. - Optional deviceOpt = deviceRedisService.getDeviceOnline(request.getFrom()); - if (deviceOpt.isEmpty()) { - // When connecting for the first time - DeviceDTO gatewayDevice = deviceGatewayConvertToDevice(request.getFrom(), request.getData()); - Optional gatewayDeviceOpt = onlineSaveDevice(gatewayDevice, null, null); - if (gatewayDeviceOpt.isEmpty()) { - return null; - } - deviceService.pushDeviceOnlineTopo(gatewayDeviceOpt.get().getWorkspaceId(), request.getFrom(), null); - return new TopicStatusResponse().setData(MqttReply.success()); - } - - String deviceSn = deviceOpt.get().getChildDeviceSn(); - if (!StringUtils.hasText(deviceSn)) { - return new TopicStatusResponse().setData(MqttReply.success()); - } - - deviceService.subDeviceOffline(deviceSn); - return new TopicStatusResponse().setData(MqttReply.success()); - } - - @Override - public void osdDock(TopicOsdRequest request, MessageHeaders headers) { - String from = request.getFrom(); - Optional deviceOpt = deviceRedisService.getDeviceOnline(from); - if (deviceOpt.isEmpty()) { - deviceOpt = deviceService.getDeviceBySn(from); - if (deviceOpt.isEmpty()) { - log.error("Please restart the drone."); - 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()); - - deviceService.pushOsdDataToWeb(device.getWorkspaceId(), BizCodeEnum.DOCK_OSD, from, request.getData()); - } - - @Override - public void osdDockDrone(TopicOsdRequest request, MessageHeaders headers) { - String from = request.getFrom(); - Optional deviceOpt = deviceRedisService.getDeviceOnline(from); - if (deviceOpt.isEmpty()) { - deviceOpt = deviceService.getDeviceBySn(from); - if (deviceOpt.isEmpty()) { - log.error("Please restart the drone."); - return; - } - } - - if (!StringUtils.hasText(deviceOpt.get().getWorkspaceId())) { - log.error("Please restart the drone."); - return; - } - - DeviceDTO device = deviceOpt.get(); - deviceRedisService.setDeviceOnline(device); - deviceRedisService.setDeviceOsd(from, request.getData()); - - deviceService.pushOsdDataToWeb(device.getWorkspaceId(), BizCodeEnum.DEVICE_OSD, from, request.getData()); - } - - @Override - public void osdRemoteControl(TopicOsdRequest request, MessageHeaders headers) { - String from = request.getFrom(); - Optional deviceOpt = deviceRedisService.getDeviceOnline(from); - if (deviceOpt.isEmpty()) { - deviceOpt = deviceService.getDeviceBySn(from); - if (deviceOpt.isEmpty()) { - log.error("Please restart the drone."); - return; - } - } - DeviceDTO device = deviceOpt.get(); - if (StringUtils.hasText(device.getChildDeviceSn())) { - deviceRedisService.getDeviceOnline(device.getChildDeviceSn()).ifPresent(device::setChildren); - } - deviceRedisService.setDeviceOnline(device); - - OsdRemoteControl data = request.getData(); - deviceService.pushOsdDataToPilot(device.getWorkspaceId(), from, - new DeviceOsdHost() - .setLatitude(data.getLatitude()) - .setLongitude(data.getLongitude()) - .setHeight(data.getHeight())); - deviceService.pushOsdDataToWeb(device.getWorkspaceId(), BizCodeEnum.RC_OSD, from, data); - - } - - @Override - public void osdRcDrone(TopicOsdRequest request, MessageHeaders headers) { - String from = request.getFrom(); - Optional deviceOpt = deviceRedisService.getDeviceOnline(from); - if (deviceOpt.isEmpty()) { - deviceOpt = deviceService.getDeviceBySn(from); - if (deviceOpt.isEmpty()) { - log.error("Please restart the drone."); - return; - } - } - DeviceDTO device = deviceOpt.get(); - deviceRedisService.setDeviceOnline(device); - if (!StringUtils.hasText(device.getWorkspaceId())) { - log.error("Please bind the drone first."); - return; - } - - OsdRcDrone data = request.getData(); - deviceService.pushOsdDataToPilot(device.getWorkspaceId(), from, - new DeviceOsdHost() - .setLatitude(data.getLatitude()) - .setLongitude(data.getLongitude()) - .setElevation(data.getElevation()) - .setHeight(data.getHeight()) - .setAttitudeHead(data.getAttitudeHead()) - .setElevation(data.getElevation()) - .setHorizontalSpeed(data.getHorizontalSpeed()) - .setVerticalSpeed(data.getVerticalSpeed())); - deviceService.pushOsdDataToWeb(device.getWorkspaceId(), BizCodeEnum.DEVICE_OSD, from, data); - } - - @Override - public void dockFirmwareVersionUpdate(TopicStateRequest request, MessageHeaders headers) { - // If the reported version is empty, it will not be processed to prevent misleading page. - if (!StringUtils.hasText(request.getData().getFirmwareVersion())) { - return; - } - - DeviceDTO device = DeviceDTO.builder() - .deviceSn(request.getFrom()) - .firmwareVersion(request.getData().getFirmwareVersion()) - .firmwareStatus(request.getData().getNeedCompatibleStatus() ? - DeviceFirmwareStatusEnum.UNKNOWN : DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE) - .build(); - boolean isUpd = deviceService.updateDevice(device); - if (!isUpd) { - log.error("Data update of firmware version failed. SN: {}", request.getFrom()); - } - } - - @Override - public void rcFirmwareVersionUpdate(TopicStateRequest request, MessageHeaders headers) { - // If the reported version is empty, it will not be processed to prevent misleading page. - if (!StringUtils.hasText(request.getData().getFirmwareVersion())) { - return; - } - - DeviceDTO device = DeviceDTO.builder() - .deviceSn(request.getFrom()) - .firmwareVersion(request.getData().getFirmwareVersion()) - .build(); - boolean isUpd = deviceService.updateDevice(device); - if (!isUpd) { - log.error("Data update of firmware version failed. SN: {}", request.getFrom()); - } - } - - @Override - public void rcPayloadFirmwareVersionUpdate(TopicStateRequest request, MessageHeaders headers) { - // If the reported version is empty, it will not be processed to prevent misleading page. - if (!StringUtils.hasText(request.getData().getFirmwareVersion())) { - return; - } - - boolean isUpd = devicePayloadService.updateFirmwareVersion(request.getFrom(), request.getData()); - if (!isUpd) { - log.error("Data update of payload firmware version failed. SN: {}", request.getFrom()); - } - } - - @Override - public void dockControlSourceUpdate(TopicStateRequest request, MessageHeaders headers) { - // If the control source is empty, it will not be processed. - if (ControlSourceEnum.UNKNOWN == request.getData().getControlSource()) { - return; - } - Optional deviceOpt = deviceRedisService.getDeviceOnline(request.getFrom()); - if (deviceOpt.isEmpty()) { - return; - } - Optional dockOpt = deviceRedisService.getDeviceOnline(request.getGateway()); - if (dockOpt.isEmpty()) { - return; - } - - deviceService.updateFlightControl(dockOpt.get(), request.getData().getControlSource()); - devicePayloadService.updatePayloadControl(deviceOpt.get(), - request.getData().getPayloads().stream() - .map(p -> DevicePayloadReceiver.builder() - .controlSource(p.getControlSource()) - .payloadIndex(p.getPayloadIndex()) - .sn(p.getSn()) - .deviceSn(request.getFrom()) - .build()).collect(Collectors.toList())); - } - - @Override - public void rcControlSourceUpdate(TopicStateRequest request, MessageHeaders headers) { - // If the control source is empty, it will not be processed. - if (ControlSourceEnum.UNKNOWN == request.getData().getControlSource()) { - return; - } - Optional deviceOpt = deviceRedisService.getDeviceOnline(request.getFrom()); - if (deviceOpt.isEmpty()) { - return; - } - Optional dockOpt = deviceRedisService.getDeviceOnline(request.getGateway()); - if (dockOpt.isEmpty()) { - return; - } - - deviceService.updateFlightControl(dockOpt.get(), request.getData().getControlSource()); - devicePayloadService.updatePayloadControl(deviceOpt.get(), - request.getData().getPayloads().stream() - .map(p -> DevicePayloadReceiver.builder() - .controlSource(p.getControlSource()) - .payloadIndex(p.getPayloadIndex()) - .sn(p.getSn()) - .deviceSn(request.getFrom()) - .build()).collect(Collectors.toList())); - } - - private void dockGoOnline(DeviceDTO gateway, DeviceDTO subDevice) { - if (DeviceDomainEnum.DOCK != gateway.getDomain()) { - return; - } - if (!StringUtils.hasText(gateway.getWorkspaceId())) { - log.error("The dock is not bound, please bind it first and then go online."); - return; - } - 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.getDeviceSn()).workspaceId(gateway.getWorkspaceId()).build()); - subDevice.setWorkspaceId(gateway.getWorkspaceId()); - } - deviceRedisService.setDeviceOnline(subDevice); - } - - private void changeSubDeviceParent(String deviceSn, String gatewaySn) { - List gatewaysList = deviceService.getDevicesByParams( - DeviceQueryParam.builder() - .childSn(deviceSn) - .build()); - gatewaysList.stream() - .filter(gateway -> !gateway.getDeviceSn().equals(gatewaySn)) - .forEach(gateway -> { - gateway.setChildDeviceSn(""); - deviceService.updateDevice(gateway); - deviceRedisService.getDeviceOnline(gateway.getDeviceSn()) - .ifPresent(device -> { - device.setChildDeviceSn(null); - deviceRedisService.setDeviceOnline(device); - }); - }); - } - - - public void deviceOnlineAgain(String workspaceId, String gatewaySn, String deviceSn) { - DeviceDTO device = DeviceDTO.builder().loginTime(LocalDateTime.now()).deviceSn(deviceSn).build(); - DeviceDTO gateway = DeviceDTO.builder() - .loginTime(LocalDateTime.now()) - .deviceSn(gatewaySn) - .childDeviceSn(deviceSn).build(); - deviceService.updateDevice(gateway); - deviceService.updateDevice(device); - gateway = deviceRedisService.getDeviceOnline(gatewaySn).map(g -> { - g.setChildDeviceSn(deviceSn); - return g; - }).get(); - device = deviceRedisService.getDeviceOnline(deviceSn).map(d -> { - d.setParentSn(gatewaySn); - return d; - }).get(); - deviceRedisService.setDeviceOnline(gateway); - deviceRedisService.setDeviceOnline(device); - if (StringUtils.hasText(workspaceId)) { - deviceService.subDeviceOnlineSubscribeTopic(SDKManager.getDeviceSDK(gatewaySn)); - } - - log.warn("{} is already online.", deviceSn); - } - - /** - * Convert the received gateway device object into a database entity object. - * @param gateway - * @return - */ - private DeviceDTO deviceGatewayConvertToDevice(String gatewaySn, UpdateTopo gateway) { - if (null == gateway) { - throw new IllegalArgumentException(); - } - return DeviceDTO.builder() - .deviceSn(gatewaySn) - .subType(gateway.getSubType()) - .type(gateway.getType()) - .thingVersion(gateway.getThingVersion()) - .domain(gateway.getDomain()) - .controlSource(gateway.getSubDevices().isEmpty() ? null : - ControlSourceEnum.find(gateway.getSubDevices().get(0).getIndex().getControlSource())) - .build(); - } - - /** - * Convert the received drone device object into a database entity object. - * @param device - * @return - */ - private DeviceDTO subDeviceConvertToDevice(UpdateTopoSubDevice device) { - if (null == device) { - throw new IllegalArgumentException(); - } - return DeviceDTO.builder() - .deviceSn(device.getSn()) - .type(device.getType()) - .subType(device.getSubType()) - .thingVersion(device.getThingVersion()) - .domain(device.getDomain()) - .build(); - } - - private Optional onlineSaveDevice(DeviceDTO device, String childSn, String parentSn) { - - device.setChildDeviceSn(childSn); - device.setLoginTime(LocalDateTime.now()); - - Optional deviceOpt = deviceService.getDeviceBySn(device.getDeviceSn()); - - if (deviceOpt.isEmpty()) { - device.setIconUrl(new DeviceIconUrl()); - // Set the icon of the gateway device displayed in the pilot's map, required in the TSA module. - device.getIconUrl().setNormalIconUrl(IconUrlEnum.NORMAL_PERSON.getUrl()); - // Set the icon of the gateway device displayed in the pilot's map when it is selected, required in the TSA module. - device.getIconUrl().setSelectIconUrl(IconUrlEnum.SELECT_PERSON.getUrl()); - device.setBoundStatus(false); - - // Query the model information of this gateway device. - dictionaryService.getOneDictionaryInfoByTypeSubType( - device.getDomain().getDomain(), device.getType().getType(), device.getSubType().getSubType()) - .ifPresent(entity -> { - device.setDeviceName(entity.getDeviceName()); - device.setNickname(entity.getDeviceName()); - device.setDeviceDesc(entity.getDeviceDesc()); - }); - } - boolean success = deviceService.saveOrUpdateDevice(device); - if (!success) { - return Optional.empty(); - } - - deviceOpt = deviceService.getDeviceBySn(device.getDeviceSn()); - DeviceDTO redisDevice = deviceOpt.get(); - redisDevice.setStatus(true); - redisDevice.setParentSn(parentSn); - - deviceRedisService.setDeviceOnline(redisDevice); - return deviceOpt; - } - - private void fillDockOsd(String dockSn, OsdDock dock) { - Optional oldDockOpt = deviceRedisService.getDeviceOsd(dockSn, OsdDock.class); - if (Objects.nonNull(dock.getJobNumber())) { - return; - } - if (oldDockOpt.isEmpty()) { - deviceRedisService.setDeviceOsd(dockSn, dock); - return; - } - OsdDock oldDock = oldDockOpt.get(); - if (Objects.nonNull(dock.getModeCode())) { - dock.setDrcState(oldDock.getDrcState()); - deviceRedisService.setDeviceOsd(dockSn, dock); - return; - } - if (Objects.nonNull(dock.getDrcState()) ) { - oldDock.setDrcState(dock.getDrcState()); - deviceRedisService.setDeviceOsd(dockSn, oldDock); - } - } -} diff --git a/src/main/java/com/dji/sample/manage/service/impl/UserServiceImpl.java b/src/main/java/com/dji/sample/manage/service/impl/UserServiceImpl.java deleted file mode 100644 index d466897..0000000 --- a/src/main/java/com/dji/sample/manage/service/impl/UserServiceImpl.java +++ /dev/null @@ -1,214 +0,0 @@ -package com.dji.sample.manage.service.impl; - -import com.auth0.jwt.JWT; -import com.auth0.jwt.exceptions.TokenExpiredException; -import com.auth0.jwt.interfaces.DecodedJWT; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.dji.sample.common.model.CustomClaim; -import com.dji.sample.common.util.JwtUtil; -import com.dji.sample.component.mqtt.config.MqttPropertyConfiguration; -import com.dji.sample.manage.dao.IUserMapper; -import com.dji.sample.manage.model.dto.UserDTO; -import com.dji.sample.manage.model.dto.UserListDTO; -import com.dji.sample.manage.model.dto.WorkspaceDTO; -import com.dji.sample.manage.model.entity.UserEntity; -import com.dji.sample.manage.model.enums.UserTypeEnum; -import com.dji.sample.manage.service.IUserService; -import com.dji.sample.manage.service.IWorkspaceService; -import com.dji.sdk.common.HttpResultResponse; -import com.dji.sdk.common.Pagination; -import com.dji.sdk.common.PaginationData; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; - -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; - -@Service -@Transactional -public class UserServiceImpl implements IUserService { - - @Autowired - private IUserMapper mapper; - - @Autowired - private MqttPropertyConfiguration mqttPropertyConfiguration; - - @Autowired - private IWorkspaceService workspaceService; - - @Override - public HttpResultResponse getUserByUsername(String username, String workspaceId) { - - UserEntity userEntity = this.getUserByUsername(username); - if (userEntity == null) { - return new HttpResultResponse() - .setCode(HttpStatus.UNAUTHORIZED.value()) - .setMessage("invalid username"); - } - - UserDTO user = this.entityConvertToDTO(userEntity); - user.setWorkspaceId(workspaceId); - - return HttpResultResponse.success(user); - } - - @Override - public HttpResultResponse userLogin(String username, String password, Integer flag) { - // check user - UserEntity userEntity = this.getUserByUsername(username); - if (userEntity == null) { - return new HttpResultResponse() - .setCode(HttpStatus.UNAUTHORIZED.value()) - .setMessage("invalid username"); - } - if (flag.intValue() != userEntity.getUserType().intValue()) { - return HttpResultResponse.error("The account type does not match."); - } - if (!password.equals(userEntity.getPassword())) { - return new HttpResultResponse() - .setCode(HttpStatus.UNAUTHORIZED.value()) - .setMessage("invalid password"); - } - - Optional workspaceOpt = workspaceService.getWorkspaceByWorkspaceId(userEntity.getWorkspaceId()); - if (workspaceOpt.isEmpty()) { - return new HttpResultResponse() - .setCode(HttpStatus.UNAUTHORIZED.value()) - .setMessage("invalid workspace id"); - } - - CustomClaim customClaim = new CustomClaim(userEntity.getUserId(), - userEntity.getUsername(), userEntity.getUserType(), - workspaceOpt.get().getWorkspaceId()); - - // create token - String token = JwtUtil.createToken(customClaim.convertToMap()); - - UserDTO userDTO = entityConvertToDTO(userEntity); - userDTO.setMqttAddr(MqttPropertyConfiguration.getBasicMqttAddress()); - userDTO.setAccessToken(token); - userDTO.setWorkspaceId(workspaceOpt.get().getWorkspaceId()); - return HttpResultResponse.success(userDTO); - } - - @Override - public Optional refreshToken(String token) { - if (!StringUtils.hasText(token)) { - return Optional.empty(); - } - CustomClaim customClaim; - try { - DecodedJWT jwt = JwtUtil.verifyToken(token); - customClaim = new CustomClaim(jwt.getClaims()); - } catch (TokenExpiredException e) { - customClaim = new CustomClaim(JWT.decode(token).getClaims()); - } catch (Exception e) { - e.printStackTrace(); - return Optional.empty(); - } - String refreshToken = JwtUtil.createToken(customClaim.convertToMap()); - - UserDTO user = entityConvertToDTO(this.getUserByUsername(customClaim.getUsername())); - if (Objects.isNull(user)) { - return Optional.empty(); - } - user.setWorkspaceId(customClaim.getWorkspaceId()); - user.setAccessToken(refreshToken); - return Optional.of(user); - } - - @Override - public PaginationData getUsersByWorkspaceId(long page, long pageSize, String workspaceId) { - Page userEntityPage = mapper.selectPage( - new Page<>(page, pageSize), - new LambdaQueryWrapper().eq(UserEntity::getWorkspaceId, workspaceId)); - - List usersList = userEntityPage.getRecords() - .stream() - .map(this::entity2UserListDTO) - .collect(Collectors.toList()); - return new PaginationData<>(usersList, new Pagination(userEntityPage)); - } - - @Override - public Boolean updateUser(String workspaceId, String userId, UserListDTO user) { - UserEntity userEntity = mapper.selectOne( - new LambdaQueryWrapper() - .eq(UserEntity::getUserId, userId) - .eq(UserEntity::getWorkspaceId, workspaceId)); - if (userEntity == null) { - return false; - } - userEntity.setMqttUsername(user.getMqttUsername()); - userEntity.setMqttPassword(user.getMqttPassword()); - userEntity.setUpdateTime(System.currentTimeMillis()); - int id = mapper.update(userEntity, new LambdaUpdateWrapper() - .eq(UserEntity::getUserId, userId) - .eq(UserEntity::getWorkspaceId, workspaceId)); - - return id > 0; - } - - /** - * Convert database entity objects into user data transfer object. - * @param entity - * @return - */ - private UserListDTO entity2UserListDTO(UserEntity entity) { - UserListDTO.UserListDTOBuilder builder = UserListDTO.builder(); - if (entity != null) { - builder.userId(entity.getUserId()) - .username(entity.getUsername()) - .mqttUsername(entity.getMqttUsername()) - .mqttPassword(entity.getMqttPassword()) - .userType(UserTypeEnum.find(entity.getUserType()).getDesc()) - .createTime(LocalDateTime.ofInstant( - Instant.ofEpochMilli(entity.getCreateTime()), ZoneId.systemDefault())); - Optional workspaceOpt = workspaceService.getWorkspaceByWorkspaceId(entity.getWorkspaceId()); - workspaceOpt.ifPresent(workspace -> builder.workspaceName(workspace.getWorkspaceName())); - } - - return builder.build(); - } - - /** - * Query a user by username. - * @param username - * @return - */ - private UserEntity getUserByUsername(String username) { - return mapper.selectOne(new QueryWrapper() - .eq("username", username)); - } - - /** - * Convert database entity objects into user data transfer object. - * @param entity - * @return - */ - private UserDTO entityConvertToDTO(UserEntity entity) { - if (entity == null) { - return null; - } - return UserDTO.builder() - .userId(entity.getUserId()) - .username(entity.getUsername()) - .userType(entity.getUserType()) - .mqttUsername(entity.getMqttUsername()) - .mqttPassword(entity.getMqttPassword()) - .mqttAddr(MqttPropertyConfiguration.getBasicMqttAddress()) - .build(); - } -} diff --git a/src/main/java/com/dji/sample/map/controller/WorkspaceElementController.java b/src/main/java/com/dji/sample/map/controller/WorkspaceElementController.java deleted file mode 100644 index ce65c19..0000000 --- a/src/main/java/com/dji/sample/map/controller/WorkspaceElementController.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.dji.sample.map.controller; - -import com.dji.sample.common.model.CustomClaim; -import com.dji.sample.component.websocket.service.IWebSocketMessageService; -import com.dji.sample.map.service.IWorkspaceElementService; -import com.dji.sdk.cloudapi.map.CreateMapElementRequest; -import com.dji.sdk.cloudapi.map.CreateMapElementResponse; -import com.dji.sdk.cloudapi.map.GetMapElementsResponse; -import com.dji.sdk.cloudapi.map.UpdateMapElementRequest; -import com.dji.sdk.cloudapi.map.api.IHttpMapService; -import com.dji.sdk.common.HttpResultResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.util.List; - -import static com.dji.sample.component.AuthInterceptor.TOKEN_CLAIM; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/29 - */ -@RestController -public class WorkspaceElementController implements IHttpMapService { - - @Autowired - private IWorkspaceElementService elementService; - - @Autowired - private IWebSocketMessageService sendMessageService; - - /** - * Delete all the element information in this group based on the group id. - * @param workspaceId - * @param groupId - * @return - */ - @DeleteMapping("${url.map.prefix}${url.map.version}/workspaces/{workspace_id}/element-groups/{group_id}/elements") - public HttpResultResponse deleteAllElementByGroupId(@PathVariable(name = "workspace_id") String workspaceId, - @PathVariable(name = "group_id") String groupId) { - - return elementService.deleteAllElementByGroupId(workspaceId, groupId); - } - - /** - * In the first connection, pilot will send out this http request to obtain the group element list. - * Also, if pilot receives a group refresh instruction from WebSocket, - * it needs the same interface to request the group element list. - * @param workspaceId - * @param groupId - * @param isDistributed - * @return - */ - @Override - public HttpResultResponse> getMapElements(String workspaceId, String groupId, Boolean isDistributed, HttpServletRequest req, HttpServletResponse rsp) { - List groupsList = elementService.getAllGroupsByWorkspaceId(workspaceId, groupId, isDistributed); - return HttpResultResponse.>success(groupsList); - } - - /** - * When user draws a point, line or polygon on the PILOT/Web side. - * Save the element information to the database. - * @param workspaceId - * @param groupId - * @param elementCreate - * @return - */ - @Override - public HttpResultResponse createMapElement(String workspaceId, String groupId, - @Valid CreateMapElementRequest elementCreate, HttpServletRequest req, HttpServletResponse rsp) { - CustomClaim claims = (CustomClaim) req.getAttribute(TOKEN_CLAIM); - // Set the creator of the element - elementCreate.getResource().setUsername(claims.getUsername()); - - HttpResultResponse response = elementService.saveElement(workspaceId, groupId, elementCreate); - if (response.getCode() != HttpResultResponse.CODE_SUCCESS) { - return response; - } - - return HttpResultResponse.success(new CreateMapElementResponse().setId(elementCreate.getId())); - } - - /** - * When user edits a point, line or polygon on the PILOT/Web side. - * Update the element information to the database. - * @param workspaceId - * @param elementId - * @param elementUpdate - * @return - */ - @Override - public HttpResultResponse updateMapElement(String workspaceId, String elementId, @Valid UpdateMapElementRequest elementUpdate, HttpServletRequest req, HttpServletResponse rsp) { - CustomClaim claims = (CustomClaim) req.getAttribute(TOKEN_CLAIM); - - HttpResultResponse response = elementService.updateElement(workspaceId, elementId, elementUpdate, claims.getUsername()); - if (response.getCode() != HttpResultResponse.CODE_SUCCESS) { - return response; - } - - return response; - } - - /** - * When user delete a point, line or polygon on the PILOT/Web side, - * Delete the element information in the database. - * @param workspaceId - * @param elementId - * @return - */ - @Override - public HttpResultResponse deleteMapElement(String workspaceId, String elementId, HttpServletRequest req, HttpServletResponse rsp) { - - return elementService.deleteElement(workspaceId, elementId); - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/map/model/enums/ElementTypeEnum.java b/src/main/java/com/dji/sample/map/model/enums/ElementTypeEnum.java deleted file mode 100644 index 0b91b61..0000000 --- a/src/main/java/com/dji/sample/map/model/enums/ElementTypeEnum.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.dji.sample.map.model.enums; - -import com.dji.sdk.cloudapi.map.*; - -import java.util.Optional; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/30 - */ -public enum ElementTypeEnum { - - POINT(ElementResourceTypeEnum.POINT), - - LINE_STRING(ElementResourceTypeEnum.LINE_STRING), - - POLYGON(ElementResourceTypeEnum.POLYGON); - - private ElementResourceTypeEnum typeEnum; - - ElementTypeEnum(ElementResourceTypeEnum typeEnum) { - this.typeEnum = typeEnum; - } - - public static Optional findType(int val) { - if (POINT.typeEnum.getType() == val) { - return Optional.of(new ElementPointGeometry()); - } - - if (LINE_STRING.typeEnum.getType() == val) { - return Optional.of(new ElementLineStringGeometry()); - } - - if (POLYGON.typeEnum.getType() == val) { - return Optional.of(new ElementPolygonGeometry()); - } - - return Optional.empty(); - } - - public String getDesc() { - return typeEnum.getTypeName(); - } - - public static int findVal(String desc) { - if (POINT.typeEnum.getTypeName().equals(desc)) { - return POINT.typeEnum.getType(); - } - - if (LINE_STRING.typeEnum.getTypeName().equals(desc)) { - return LINE_STRING.typeEnum.getType(); - } - - if (POLYGON.typeEnum.getTypeName().equals(desc)) { - return POLYGON.typeEnum.getType(); - } - - throw new RuntimeException("unknown type:" + desc); - } -} diff --git a/src/main/java/com/dji/sample/map/service/IGroupService.java b/src/main/java/com/dji/sample/map/service/IGroupService.java deleted file mode 100644 index 14cefd8..0000000 --- a/src/main/java/com/dji/sample/map/service/IGroupService.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.dji.sample.map.service; - -import com.dji.sdk.cloudapi.map.GetMapElementsResponse; - -import java.util.List; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/29 - */ -public interface IGroupService { - - /** - * Query all groups in the workspace based on the workspace's id. - * If the group id does not exist, do not add this filter condition. - * @param workspaceId - * @param groupId - * @param isDistributed Used to define if the group needs to be distributed. Default is true. - * @return - */ - List getAllGroupsByWorkspaceId(String workspaceId, String groupId, Boolean isDistributed); - -} diff --git a/src/main/java/com/dji/sample/map/service/IWorkspaceElementService.java b/src/main/java/com/dji/sample/map/service/IWorkspaceElementService.java deleted file mode 100644 index 2d4699f..0000000 --- a/src/main/java/com/dji/sample/map/service/IWorkspaceElementService.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.dji.sample.map.service; - -import com.dji.sample.map.model.dto.GroupElementDTO; -import com.dji.sdk.cloudapi.map.*; -import com.dji.sdk.common.HttpResultResponse; - -import java.util.List; -import java.util.Optional; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/30 - */ -public interface IWorkspaceElementService { - - /** - * Query all groups in the workspace based on the workspace's id, - * including the information of the elements in the group, and the coordinate information in the elements. - * @param workspaceId - * @param groupId - * @param isDistributed - * @return - */ - List getAllGroupsByWorkspaceId(String workspaceId, String groupId, Boolean isDistributed); - - /** - * Save all the elements, including the information of the elements in the group, - * and the coordinate information in the elements. - * - * @param workspaceId - * @param groupId - * @param elementCreate - * @return - */ - HttpResultResponse saveElement(String workspaceId, String groupId, CreateMapElementRequest elementCreate); - - /** - * Update the element information based on the element id, - * including the information of the elements in the group, and the coordinate information in the elements. - * - * @param workspaceId - * @param elementId - * @param elementUpdate - * @param username - * @return - */ - HttpResultResponse updateElement(String workspaceId, String elementId, UpdateMapElementRequest elementUpdate, String username); - - /** - * Delete the element information based on the element id, - * including the information of the elements in the group, and the coordinate information in the elements. - * - * @param workspaceId - * @param elementId - * @return - */ - HttpResultResponse deleteElement(String workspaceId, String elementId); - - /** - * Query an element based on the element id, - * including the information of the elements in the group, and the coordinate information in the elements. - * @param elementId - * @return - */ - Optional getElementByElementId(String elementId); - - /** - * Delete all the elements information based on the group id, - * including the information of the elements in the group, and the coordinate information in the elements. - * - * @param workspaceId - * @param groupId - * @return - */ - HttpResultResponse deleteAllElementByGroupId(String workspaceId, String groupId); - - MapElementCreateWsResponse element2CreateWsElement(GroupElementDTO element); - - MapElementUpdateWsResponse element2UpdateWsElement(GroupElementDTO element); -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/map/service/impl/GroupElementServiceImpl.java b/src/main/java/com/dji/sample/map/service/impl/GroupElementServiceImpl.java deleted file mode 100644 index 675a0f7..0000000 --- a/src/main/java/com/dji/sample/map/service/impl/GroupElementServiceImpl.java +++ /dev/null @@ -1,216 +0,0 @@ -package com.dji.sample.map.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.dji.sample.map.dao.IGroupElementMapper; -import com.dji.sample.map.model.dto.GroupElementDTO; -import com.dji.sample.map.model.entity.GroupElementEntity; -import com.dji.sample.map.model.enums.ElementTypeEnum; -import com.dji.sample.map.service.IElementCoordinateService; -import com.dji.sample.map.service.IGroupElementService; -import com.dji.sdk.cloudapi.map.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/29 - */ -@Service -@Transactional -public class GroupElementServiceImpl implements IGroupElementService { - - @Autowired - private IGroupElementMapper mapper; - - @Autowired - private IElementCoordinateService elementCoordinateService; - - @Override - public List getElementsByGroupId(String groupId) { - List elementList = mapper.selectList( - new LambdaQueryWrapper() - .eq(GroupElementEntity::getGroupId, groupId)); - - List groupElementList = new ArrayList<>(); - for (GroupElementEntity elementEntity : elementList) { - MapGroupElement groupElement = this.entityConvertToDto(elementEntity); - groupElementList.add(groupElement); - - this.addCoordinateToElement(groupElement, elementEntity); - } - return groupElementList; - } - - @Override - public Boolean saveElement(String groupId, CreateMapElementRequest elementCreate) { - Optional groupElementOpt = this.getEntityByElementId(elementCreate.getId()); - - if (groupElementOpt.isPresent()) { - return false; - } - GroupElementEntity groupElement = this.createDtoConvertToEntity(elementCreate); - groupElement.setGroupId(groupId); - - boolean saveElement = mapper.insert(groupElement) > 0; - if (!saveElement) { - return false; - } - // save coordinate - return elementCoordinateService.saveCoordinate( - elementCreate.getResource().getContent().getGeometry().convertToList(), elementCreate.getId()); - } - - @Override - public Boolean updateElement(String elementId, UpdateMapElementRequest elementUpdate, String username) { - Optional groupElementOpt = this.getEntityByElementId(elementId); - if (groupElementOpt.isEmpty()) { - return false; - } - - GroupElementEntity groupElement = groupElementOpt.get(); - groupElement.setUsername(username); - this.updateEntityWithDto(elementUpdate, groupElement); - boolean update = mapper.updateById(groupElement) > 0; - if (!update) { - return false; - } - // delete all coordinates according to element id. - boolean delCoordinate = elementCoordinateService.deleteCoordinateByElementId(elementId); - // save coordinate - boolean saveCoordinate = elementCoordinateService.saveCoordinate( - elementUpdate.getContent().getGeometry().convertToList(), elementId); - return delCoordinate & saveCoordinate; - } - - @Override - public Boolean deleteElement(String elementId) { - Optional groupElementOpt = this.getEntityByElementId(elementId); - if (groupElementOpt.isEmpty()) { - return true; - } - - GroupElementEntity groupElement = groupElementOpt.get(); - return mapper.deleteById(groupElement.getId()) > 0; - } - - - @Override - public Optional getElementByElementId(String elementId) { - Optional elementEntityOpt = this.getEntityByElementId(elementId); - if (elementEntityOpt.isEmpty()) { - return Optional.empty(); - } - GroupElementEntity elementEntity = elementEntityOpt.get(); - MapGroupElement groupElement = this.entityConvertToDto(elementEntity); - - this.addCoordinateToElement(groupElement, elementEntity); - return Optional.ofNullable(groupElement2Dto(groupElement, elementEntity.getGroupId())); - } - - private GroupElementDTO groupElement2Dto(MapGroupElement element, String groupId) { - if (null == element) { - return null; - } - return GroupElementDTO.builder() - .elementId(element.getId()) - .groupId(groupId) - .updateTime(element.getUpdateTime()) - .createTime(element.getCreateTime()) - .name(element.getName()) - .resource(element.getResource()) - .build(); - } - - /** - * Adds the received coordinate data to the element object. - * @param element - * @param elementEntity - */ - private void addCoordinateToElement(MapGroupElement element, GroupElementEntity elementEntity) { - Optional coordinateOpt = ElementTypeEnum.findType(elementEntity.getElementType()); - if (coordinateOpt.isEmpty()) { - return; - } - element.getResource() - .setContent(new ElementContent() - .setProperties(new ElementProperty() - .setClampToGround(elementEntity.getClampToGround()) - .setColor(elementEntity.getColor())) - .setGeometry(coordinateOpt.get())); - - coordinateOpt.get().adapterCoordinateType( - elementCoordinateService.getCoordinateByElementId(elementEntity.getElementId())); - } - - /** - * Query an element based on the element id。 - * @param elementId - * @return - */ - private Optional getEntityByElementId(String elementId) { - return Optional.ofNullable(mapper.selectOne( - new LambdaQueryWrapper() - .eq(GroupElementEntity::getElementId, elementId))); - } - - /** - * Convert database entity objects into element data transfer object. - * @param entity - * @return - */ - private MapGroupElement entityConvertToDto(GroupElementEntity entity) { - if (entity == null) { - return null; - } - - return new MapGroupElement() - .setId(entity.getElementId()) - .setName(entity.getElementName()) - .setCreateTime(entity.getCreateTime()) - .setUpdateTime(entity.getUpdateTime()) - .setResource(new ElementResource() - .setType(ElementResourceTypeEnum.find(entity.getElementType())) - .setUsername(entity.getUsername())); - } - - /** - * Convert the received element object into a database entity object. - * @param elementCreate - * @return - */ - private GroupElementEntity createDtoConvertToEntity(CreateMapElementRequest elementCreate) { - ElementProperty properties = elementCreate.getResource().getContent().getProperties(); - return GroupElementEntity.builder() - .elementId(elementCreate.getId()) - .elementName(elementCreate.getName()) - .username(elementCreate.getResource().getUsername()) - .elementType(ElementTypeEnum.findVal(elementCreate.getResource().getContent().getGeometry().getType())) - .clampToGround(properties.getClampToGround() != null && properties.getClampToGround()) - .color(properties.getColor()) - .build(); - } - - /** - * Add the content that needs to be updated to the entity object to be updated. - * @param elementUpdate - * @param groupElement - */ - private void updateEntityWithDto(UpdateMapElementRequest elementUpdate, GroupElementEntity groupElement) { - if (elementUpdate == null || groupElement == null) { - return; - } - - groupElement.setElementName(elementUpdate.getName()); - groupElement.setElementType(ElementTypeEnum.findVal(elementUpdate.getContent().getGeometry().getType())); - groupElement.setColor(elementUpdate.getContent().getProperties().getColor()); - - Boolean clampToGround = elementUpdate.getContent().getProperties().getClampToGround(); - groupElement.setClampToGround(clampToGround); - } -} diff --git a/src/main/java/com/dji/sample/map/service/impl/GroupServiceImpl.java b/src/main/java/com/dji/sample/map/service/impl/GroupServiceImpl.java deleted file mode 100644 index 5c3e913..0000000 --- a/src/main/java/com/dji/sample/map/service/impl/GroupServiceImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.dji.sample.map.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.dji.sample.map.dao.IGroupMapper; -import com.dji.sample.map.model.entity.GroupEntity; -import com.dji.sample.map.service.IGroupElementService; -import com.dji.sample.map.service.IGroupService; -import com.dji.sdk.cloudapi.map.GetMapElementsResponse; -import com.dji.sdk.cloudapi.map.GroupTypeEnum; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/29 - */ -@Service -@Transactional -public class GroupServiceImpl implements IGroupService { - - @Autowired - private IGroupMapper mapper; - - @Autowired - private IGroupElementService groupElementService; - - @Override - public List getAllGroupsByWorkspaceId(String workspaceId, String groupId, Boolean isDistributed) { - - return mapper.selectList( - new LambdaQueryWrapper() - .eq(GroupEntity::getWorkspaceId, workspaceId) - .eq(StringUtils.hasText(groupId), GroupEntity::getGroupId, groupId) - .eq(isDistributed != null, GroupEntity::getIsDistributed, isDistributed)) - .stream() - .map(this::entityConvertToDto) - .collect(Collectors.toList()); - } - - /** - * Convert database entity objects into group data transfer object. - * @param entity - * @return - */ - private GetMapElementsResponse entityConvertToDto(GroupEntity entity) { - if (entity == null) { - return null; - } - - return new GetMapElementsResponse() - .setId(entity.getGroupId()) - .setName(entity.getGroupName()) - .setType(GroupTypeEnum.find(entity.getGroupType())) - .setLock(entity.getIsLock()); - } -} diff --git a/src/main/java/com/dji/sample/map/service/impl/WorkspaceElementServiceImpl.java b/src/main/java/com/dji/sample/map/service/impl/WorkspaceElementServiceImpl.java deleted file mode 100644 index 7b6c134..0000000 --- a/src/main/java/com/dji/sample/map/service/impl/WorkspaceElementServiceImpl.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.dji.sample.map.service.impl; - -import com.dji.sample.component.websocket.model.BizCodeEnum; -import com.dji.sample.component.websocket.service.IWebSocketMessageService; -import com.dji.sample.map.model.dto.GroupElementDTO; -import com.dji.sample.map.service.IElementCoordinateService; -import com.dji.sample.map.service.IGroupElementService; -import com.dji.sample.map.service.IGroupService; -import com.dji.sample.map.service.IWorkspaceElementService; -import com.dji.sdk.cloudapi.map.*; -import com.dji.sdk.common.HttpResultResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; -import java.util.Optional; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/30 - */ -@Transactional -@Service -public class WorkspaceElementServiceImpl implements IWorkspaceElementService { - - @Autowired - private IGroupService groupService; - - @Autowired - private IGroupElementService groupElementService; - - @Autowired - private IElementCoordinateService elementCoordinateService; - - @Autowired - private IWebSocketMessageService webSocketMessageService; - - @Override - public List getAllGroupsByWorkspaceId(String workspaceId, String groupId, Boolean isDistributed) { - List groupList = groupService.getAllGroupsByWorkspaceId(workspaceId, groupId, isDistributed); - groupList.forEach(group -> group.setElements(groupElementService.getElementsByGroupId(group.getId()))); - return groupList; - } - - @Override - public HttpResultResponse saveElement(String workspaceId, String groupId, CreateMapElementRequest elementCreate) { - boolean saveElement = groupElementService.saveElement(groupId, elementCreate); - if (!saveElement) { - return HttpResultResponse.error("Failed to save the element."); - } - // Notify all WebSocket connections in this workspace to be updated when an element is created. - getElementByElementId(elementCreate.getId()) - .ifPresent(groupElement -> webSocketMessageService.sendBatch( - workspaceId, BizCodeEnum.MAP_ELEMENT_CREATE.getCode(), - element2CreateWsElement(groupElement))); - return HttpResultResponse.success(); - } - - @Override - public HttpResultResponse updateElement(String workspaceId, String elementId, UpdateMapElementRequest elementUpdate, String username) { - boolean updElement = groupElementService.updateElement(elementId, elementUpdate, username); - if (!updElement) { - return HttpResultResponse.error("Failed to update the element."); - } - - // Notify all WebSocket connections in this workspace to update when there is an element update. - getElementByElementId(elementId) - .ifPresent(groupElement -> webSocketMessageService.sendBatch( - workspaceId, BizCodeEnum.MAP_ELEMENT_UPDATE.getCode(), - element2UpdateWsElement(groupElement))); - return HttpResultResponse.success(); - } - - @Override - public HttpResultResponse deleteElement(String workspaceId, String elementId) { - Optional elementOpt = getElementByElementId(elementId); - boolean delElement = groupElementService.deleteElement(elementId); - if (!delElement) { - return HttpResultResponse.error("Failed to delete the element."); - } - - // delete all coordinates according to element id. - boolean delCoordinate = elementCoordinateService.deleteCoordinateByElementId(elementId); - if (!delCoordinate) { - return HttpResultResponse.error("Failed to delete the coordinate."); - } - - // Notify all WebSocket connections in this workspace to update when an element is deleted. - elementOpt.ifPresent(element -> - webSocketMessageService.sendBatch(workspaceId, BizCodeEnum.MAP_ELEMENT_DELETE.getCode(), - new MapElementDeleteWsResponse() - .setGroupId(element.getGroupId()) - .setId(elementId))); - - return HttpResultResponse.success(); - } - - @Override - public Optional getElementByElementId(String elementId) { - return groupElementService.getElementByElementId(elementId); - } - - @Override - public HttpResultResponse deleteAllElementByGroupId(String workspaceId, String groupId) { - List groupElementList = groupElementService.getElementsByGroupId(groupId); - for (MapGroupElement groupElement : groupElementList) { - HttpResultResponse response = this.deleteElement(workspaceId, groupElement.getId()); - if (HttpResultResponse.CODE_SUCCESS != response.getCode()) { - return response; - } - } - - return HttpResultResponse.success(); - } - - public MapElementCreateWsResponse element2CreateWsElement(GroupElementDTO element) { - if (element == null) { - return null; - } - return new MapElementCreateWsResponse() - .setId(element.getElementId()) - .setGroupId(element.getGroupId()) - .setName(element.getName()) - .setResource(element.getResource()) - .setUpdateTime(element.getUpdateTime()) - .setCreateTime(element.getCreateTime()); - } - - public MapElementUpdateWsResponse element2UpdateWsElement(GroupElementDTO element) { - if (element == null) { - return null; - } - return new MapElementUpdateWsResponse() - .setId(element.getElementId()) - .setGroupId(element.getGroupId()) - .setName(element.getName()) - .setResource(element.getResource()) - .setUpdateTime(element.getUpdateTime()) - .setCreateTime(element.getCreateTime()); - } -} diff --git a/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java b/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java deleted file mode 100644 index de82e5e..0000000 --- a/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java +++ /dev/null @@ -1,176 +0,0 @@ -package com.dji.sample.media.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.dji.sample.component.oss.model.OssConfiguration; -import com.dji.sample.component.oss.service.impl.OssServiceContext; -import com.dji.sample.manage.model.dto.DeviceDictionaryDTO; -import com.dji.sample.manage.service.IDeviceDictionaryService; -import com.dji.sample.media.dao.IFileMapper; -import com.dji.sample.media.model.MediaFileDTO; -import com.dji.sample.media.model.MediaFileEntity; -import com.dji.sample.media.service.IFileService; -import com.dji.sdk.cloudapi.device.DeviceEnum; -import com.dji.sdk.cloudapi.media.MediaSubFileTypeEnum; -import com.dji.sdk.cloudapi.media.MediaUploadCallbackRequest; -import com.dji.sdk.common.Pagination; -import com.dji.sdk.common.PaginationData; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.net.URL; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import java.util.stream.Collectors; - -/** - * @author sean - * @version 0.2 - * @date 2021/12/9 - */ -@Service -@Transactional -public class FileServiceImpl implements IFileService { - - @Autowired - private IFileMapper mapper; - - @Autowired - private IDeviceDictionaryService deviceDictionaryService; - - @Autowired - private OssServiceContext ossService; - - private Optional getMediaByFingerprint(String workspaceId, String fingerprint) { - MediaFileEntity fileEntity = mapper.selectOne(new LambdaQueryWrapper() - .eq(MediaFileEntity::getWorkspaceId, workspaceId) - .eq(MediaFileEntity::getFingerprint, fingerprint)); - return Optional.ofNullable(fileEntity); - } - - private Optional getMediaByFileId(String workspaceId, String fileId) { - MediaFileEntity fileEntity = mapper.selectOne(new LambdaQueryWrapper() - .eq(MediaFileEntity::getWorkspaceId, workspaceId) - .eq(MediaFileEntity::getFileId, fileId)); - return Optional.ofNullable(fileEntity); - } - - @Override - public Boolean checkExist(String workspaceId, String fingerprint) { - return this.getMediaByFingerprint(workspaceId, fingerprint).isPresent(); - } - - @Override - public Integer saveFile(String workspaceId, MediaUploadCallbackRequest file) { - MediaFileEntity fileEntity = this.fileUploadConvertToEntity(file); - fileEntity.setWorkspaceId(workspaceId); - fileEntity.setFileId(UUID.randomUUID().toString()); - return mapper.insert(fileEntity); - } - - @Override - public List getAllFilesByWorkspaceId(String workspaceId) { - return mapper.selectList(new LambdaQueryWrapper() - .eq(MediaFileEntity::getWorkspaceId, workspaceId)) - .stream() - .map(this::entityConvertToDto) - .collect(Collectors.toList()); - } - - @Override - public PaginationData getMediaFilesPaginationByWorkspaceId(String workspaceId, long page, long pageSize) { - Page pageData = mapper.selectPage( - new Page(page, pageSize), - new LambdaQueryWrapper() - .eq(MediaFileEntity::getWorkspaceId, workspaceId) - .orderByDesc(MediaFileEntity::getId)); - List records = pageData.getRecords() - .stream() - .map(this::entityConvertToDto) - .collect(Collectors.toList()); - - return new PaginationData(records, new Pagination(pageData)); - } - - @Override - public URL getObjectUrl(String workspaceId, String fileId) { - Optional mediaFileOpt = getMediaByFileId(workspaceId, fileId); - if (mediaFileOpt.isEmpty()) { - throw new IllegalArgumentException("{} doesn't exist."); - } - - return ossService.getObjectUrl(OssConfiguration.bucket, mediaFileOpt.get().getObjectKey()); - } - - @Override - public List getFilesByWorkspaceAndJobId(String workspaceId, String jobId) { - return mapper.selectList(new LambdaQueryWrapper() - .eq(MediaFileEntity::getWorkspaceId, workspaceId) - .eq(MediaFileEntity::getJobId, jobId)) - .stream() - .map(this::entityConvertToDto).collect(Collectors.toList()); - } - - /** - * Convert the received file object into a database entity object. - * @param file - * @return - */ - private MediaFileEntity fileUploadConvertToEntity(MediaUploadCallbackRequest file) { - MediaFileEntity.MediaFileEntityBuilder builder = MediaFileEntity.builder(); - - if (file != null) { - builder.fileName(file.getName()) - .filePath(file.getPath()) - .fingerprint(file.getFingerprint()) - .objectKey(file.getObjectKey()) - .subFileType(Optional.ofNullable(file.getSubFileType()).map(MediaSubFileTypeEnum::getType).orElse(null)) - .isOriginal(file.getExt().getOriginal()) - .jobId(file.getExt().getFileGroupId()) - .drone(file.getExt().getSn()) - .tinnyFingerprint(file.getExt().getTinnyFingerprint()) - .payload(file.getExt().getPayloadModelKey().getDevice()); - - // domain-type-subType - DeviceEnum payloadModelKey = file.getExt().getPayloadModelKey(); - Optional payloadDict = deviceDictionaryService - .getOneDictionaryInfoByTypeSubType(payloadModelKey.getDomain().getDomain(), - payloadModelKey.getType().getType(), payloadModelKey.getSubType().getSubType()); - payloadDict.ifPresent(payload -> builder.payload(payload.getDeviceName())); - } - return builder.build(); - } - - /** - * Convert database entity objects into file data transfer object. - * @param entity - * @return - */ - private MediaFileDTO entityConvertToDto(MediaFileEntity entity) { - MediaFileDTO.MediaFileDTOBuilder builder = MediaFileDTO.builder(); - - if (entity != null) { - builder.fileName(entity.getFileName()) - .fileId(entity.getFileId()) - .filePath(entity.getFilePath()) - .isOriginal(entity.getIsOriginal()) - .fingerprint(entity.getFingerprint()) - .objectKey(entity.getObjectKey()) - .tinnyFingerprint(entity.getTinnyFingerprint()) - .payload(entity.getPayload()) - .createTime(LocalDateTime.ofInstant( - Instant.ofEpochMilli(entity.getCreateTime()), ZoneId.systemDefault())) - .drone(entity.getDrone()) - .jobId(entity.getJobId()); - - } - - return builder.build(); - } - -} diff --git a/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java b/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java deleted file mode 100644 index e478e8a..0000000 --- a/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java +++ /dev/null @@ -1,283 +0,0 @@ -package com.dji.sample.wayline.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.dji.sample.component.oss.model.OssConfiguration; -import com.dji.sample.component.oss.service.impl.OssServiceContext; -import com.dji.sample.wayline.dao.IWaylineFileMapper; -import com.dji.sample.wayline.model.dto.KmzFileProperties; -import com.dji.sample.wayline.model.dto.WaylineFileDTO; -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; -import com.dji.sdk.common.Pagination; -import com.dji.sdk.common.PaginationData; -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.Node; -import org.dom4j.io.SAXReader; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.DigestUtils; -import org.springframework.util.StringUtils; -import org.springframework.web.multipart.MultipartFile; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.sql.SQLException; -import java.util.*; -import java.util.stream.Collectors; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import static com.dji.sample.wayline.model.dto.KmzFileProperties.WAYLINE_FILE_SUFFIX; - -/** - * @author sean - * @version 0.3 - * @date 2021/12/22 - */ -@Service -@Transactional -public class WaylineFileServiceImpl implements IWaylineFileService { - - @Autowired - private IWaylineFileMapper mapper; - - @Autowired - private OssServiceContext ossService; - - @Override - public PaginationData getWaylinesByParam(String workspaceId, GetWaylineListRequest param) { - // Paging Query - Page page = mapper.selectPage( - new Page(param.getPage(), param.getPageSize()), - new LambdaQueryWrapper() - .eq(WaylineFileEntity::getWorkspaceId, workspaceId) - .eq(Objects.nonNull(param.getFavorited()), WaylineFileEntity::getFavorited, param.getFavorited()) - .and(param.getTemplateType() != null, wrapper -> { - for (WaylineTypeEnum type : param.getTemplateType()) { - wrapper.like(WaylineFileEntity::getTemplateTypes, type.getValue()).or(); - } - }) - // There is a risk of SQL injection - .last(StringUtils.hasText(param.getOrderBy()), " order by " + param.getOrderBy())); - - // Wrap the results of a paging query into a custom paging object. - List records = page.getRecords() - .stream() - .map(this::entityConvertToDTO) - .collect(Collectors.toList()); - - return new PaginationData<>(records, new Pagination(page)); - } - - @Override - public Optional getWaylineByWaylineId(String workspaceId, String waylineId) { - return Optional.ofNullable( - this.entityConvertToDTO( - mapper.selectOne( - new LambdaQueryWrapper() - .eq(WaylineFileEntity::getWorkspaceId, workspaceId) - .eq(WaylineFileEntity::getWaylineId, waylineId)))); - } - - @Override - public URL getObjectUrl(String workspaceId, String waylineId) throws SQLException { - Optional waylineOpt = this.getWaylineByWaylineId(workspaceId, waylineId); - if (waylineOpt.isEmpty()) { - throw new SQLException(waylineId + " does not exist."); - } - return ossService.getObjectUrl(OssConfiguration.bucket, waylineOpt.get().getObjectKey()); - } - - @Override - public Integer saveWaylineFile(String workspaceId, WaylineFileDTO metadata) { - WaylineFileEntity file = this.dtoConvertToEntity(metadata); - file.setWaylineId(UUID.randomUUID().toString()); - file.setWorkspaceId(workspaceId); - - if (!StringUtils.hasText(file.getSign())) { - try (InputStream object = ossService.getObject(OssConfiguration.bucket, metadata.getObjectKey())) { - if (object.available() == 0) { - throw new RuntimeException("The file " + metadata.getObjectKey() + - " does not exist in the bucket[" + OssConfiguration.bucket + "]."); - } - file.setSign(DigestUtils.md5DigestAsHex(object)); - } catch (IOException e) { - e.printStackTrace(); - } - } - int insertId = mapper.insert(file); - return insertId > 0 ? file.getId() : insertId; - } - - @Override - public Boolean markFavorite(String workspaceId, List waylineIds, Boolean isFavorite) { - if (waylineIds.isEmpty()) { - return false; - } - if (isFavorite == null) { - return true; - } - return mapper.update(null, new LambdaUpdateWrapper() - .set(WaylineFileEntity::getFavorited, isFavorite) - .eq(WaylineFileEntity::getWorkspaceId, workspaceId) - .in(WaylineFileEntity::getWaylineId, waylineIds)) > 0; - } - - @Override - public List getDuplicateNames(String workspaceId, List names) { - return mapper.selectList(new LambdaQueryWrapper() - .eq(WaylineFileEntity::getWorkspaceId, workspaceId) - .in(WaylineFileEntity::getName, names)) - .stream() - .map(WaylineFileEntity::getName) - .collect(Collectors.toList()); - } - - @Override - public Boolean deleteByWaylineId(String workspaceId, String waylineId) { - Optional waylineOpt = this.getWaylineByWaylineId(workspaceId, waylineId); - if (waylineOpt.isEmpty()) { - return true; - } - GetWaylineListResponse wayline = waylineOpt.get(); - boolean isDel = mapper.delete(new LambdaUpdateWrapper() - .eq(WaylineFileEntity::getWorkspaceId, workspaceId) - .eq(WaylineFileEntity::getWaylineId, waylineId)) - > 0; - if (!isDel) { - return false; - } - return ossService.deleteObject(OssConfiguration.bucket, wayline.getObjectKey()); - } - - @Override - public void importKmzFile(MultipartFile file, String workspaceId, String creator) { - Optional waylineFileOpt = validKmzFile(file); - if (waylineFileOpt.isEmpty()) { - throw new RuntimeException("The file format is incorrect."); - } - - try { - WaylineFileDTO waylineFile = waylineFileOpt.get(); - waylineFile.setUsername(creator); - - ossService.putObject(OssConfiguration.bucket, waylineFile.getObjectKey(), file.getInputStream()); - this.saveWaylineFile(workspaceId, waylineFile); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private Optional validKmzFile(MultipartFile file) { - String filename = file.getOriginalFilename(); - if (Objects.nonNull(filename) && !filename.endsWith(WAYLINE_FILE_SUFFIX)) { - throw new RuntimeException("The file format is incorrect."); - } - try (ZipInputStream unzipFile = new ZipInputStream(file.getInputStream(), StandardCharsets.UTF_8)) { - - ZipEntry nextEntry = unzipFile.getNextEntry(); - while (Objects.nonNull(nextEntry)) { - boolean isWaylines = (KmzFileProperties.FILE_DIR_FIRST + "/" + KmzFileProperties.FILE_DIR_SECOND_TEMPLATE).equals(nextEntry.getName()); - if (!isWaylines) { - nextEntry = unzipFile.getNextEntry(); - continue; - } - SAXReader reader = new SAXReader(); - Document document = reader.read(unzipFile); - if (!StandardCharsets.UTF_8.name().equals(document.getXMLEncoding())) { - throw new RuntimeException("The file encoding format is incorrect."); - } - - Node droneNode = document.selectSingleNode("//" + KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_DRONE_INFO); - Node payloadNode = document.selectSingleNode("//" + KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_PAYLOAD_INFO); - if (Objects.isNull(droneNode) || Objects.isNull(payloadNode)) { - throw new RuntimeException("The file format is incorrect."); - } - - 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); - - return Optional.of(WaylineFileDTO.builder() - .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())) - .templateTypes(List.of(WaylineTypeEnum.find(templateType).getValue())) - .build()); - } - - } catch (IOException | DocumentException e) { - e.printStackTrace(); - } - return Optional.empty(); - } - /** - * Convert database entity objects into wayline data transfer object. - * @param entity - * @return - */ - private GetWaylineListResponse entityConvertToDTO(WaylineFileEntity entity) { - if (entity == null) { - return null; - } - return new GetWaylineListResponse() - .setDroneModelKey(DeviceEnum.find(entity.getDroneModelKey())) - .setFavorited(entity.getFavorited()) - .setName(entity.getName()) - .setPayloadModelKeys(entity.getPayloadModelKeys() != null ? - Arrays.stream(entity.getPayloadModelKeys().split(",")).map(DeviceEnum::find).collect(Collectors.toList()) : null) - .setTemplateTypes(Arrays.stream(entity.getTemplateTypes().split(",")) - .map(Integer::parseInt).map(WaylineTypeEnum::find) - .collect(Collectors.toList())) - .setUsername(entity.getUsername()) - .setObjectKey(entity.getObjectKey()) - .setSign(entity.getSign()) - .setUpdateTime(entity.getUpdateTime()) - .setId(entity.getWaylineId()); - - } - - /** - * Convert the received wayline object into a database entity object. - * @param file - * @return - */ - private WaylineFileEntity dtoConvertToEntity(WaylineFileDTO file) { - WaylineFileEntity.WaylineFileEntityBuilder builder = WaylineFileEntity.builder(); - - if (file != null) { - builder.droneModelKey(file.getDroneModelKey()) - .name(file.getName()) - .username(file.getUsername()) - .objectKey(file.getObjectKey()) - // Separate multiple payload data with ",". - .payloadModelKeys(String.join(",", file.getPayloadModelKeys())) - .templateTypes(file.getTemplateTypes().stream() - .map(String::valueOf) - .collect(Collectors.joining(","))) - .favorited(file.getFavorited()) - .sign(file.getSign()) - .build(); - } - - return builder.build(); - } -} diff --git a/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java b/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java deleted file mode 100644 index 923fd93..0000000 --- a/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java +++ /dev/null @@ -1,298 +0,0 @@ -package com.dji.sample.wayline.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.dji.sample.component.mqtt.model.EventsReceiver; -import com.dji.sample.component.redis.RedisConst; -import com.dji.sample.component.redis.RedisOpsUtils; -import com.dji.sample.manage.model.dto.DeviceDTO; -import com.dji.sample.manage.service.IDeviceRedisService; -import com.dji.sample.manage.service.IDeviceService; -import com.dji.sample.media.model.MediaFileCountDTO; -import com.dji.sample.media.service.IFileService; -import com.dji.sample.wayline.dao.IWaylineJobMapper; -import com.dji.sample.wayline.model.dto.WaylineJobDTO; -import com.dji.sample.wayline.model.entity.WaylineJobEntity; -import com.dji.sample.wayline.model.enums.WaylineJobStatusEnum; -import com.dji.sample.wayline.model.param.CreateJobParam; -import com.dji.sample.wayline.service.IWaylineFileService; -import com.dji.sample.wayline.service.IWaylineJobService; -import com.dji.sample.wayline.service.IWaylineRedisService; -import com.dji.sdk.cloudapi.device.DockModeCodeEnum; -import com.dji.sdk.cloudapi.device.DroneModeCodeEnum; -import com.dji.sdk.cloudapi.device.OsdDock; -import com.dji.sdk.cloudapi.device.OsdDockDrone; -import com.dji.sdk.cloudapi.wayline.*; -import com.dji.sdk.common.Pagination; -import com.dji.sdk.common.PaginationData; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author sean - * @version 1.1 - * @date 2022/6/1 - */ -@Service -@Transactional -@Slf4j -public class WaylineJobServiceImpl implements IWaylineJobService { - - @Autowired - private IWaylineJobMapper mapper; - - @Autowired - private IWaylineFileService waylineFileService; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private IFileService fileService; - - @Autowired - private IDeviceRedisService deviceRedisService; - - @Autowired - private IWaylineRedisService waylineRedisService; - - private Optional insertWaylineJob(WaylineJobEntity jobEntity) { - int id = mapper.insert(jobEntity); - if (id <= 0) { - return Optional.empty(); - } - return Optional.ofNullable(this.entity2Dto(jobEntity)); - } - - @Override - public Optional createWaylineJob(CreateJobParam param, String workspaceId, String username, Long beginTime, Long endTime) { - if (Objects.isNull(param)) { - return Optional.empty(); - } - // Immediate tasks, allocating time on the backend. - WaylineJobEntity jobEntity = WaylineJobEntity.builder() - .name(param.getName()) - .dockSn(param.getDockSn()) - .fileId(param.getFileId()) - .username(username) - .workspaceId(workspaceId) - .jobId(UUID.randomUUID().toString()) - .beginTime(beginTime) - .endTime(endTime) - .status(WaylineJobStatusEnum.PENDING.getVal()) - .taskType(param.getTaskType().getType()) - .waylineType(param.getWaylineType().getValue()) - .outOfControlAction(param.getOutOfControlAction().getAction()) - .rthAltitude(param.getRthAltitude()) - .mediaCount(0) - .build(); - - return insertWaylineJob(jobEntity); - } - - @Override - public Optional createWaylineJobByParent(String workspaceId, String parentId) { - Optional parentJobOpt = this.getJobByJobId(workspaceId, parentId); - if (parentJobOpt.isEmpty()) { - return Optional.empty(); - } - WaylineJobEntity jobEntity = this.dto2Entity(parentJobOpt.get()); - jobEntity.setJobId(UUID.randomUUID().toString()); - jobEntity.setErrorCode(null); - jobEntity.setCompletedTime(null); - jobEntity.setExecuteTime(null); - jobEntity.setStatus(WaylineJobStatusEnum.PENDING.getVal()); - jobEntity.setParentId(parentId); - - return this.insertWaylineJob(jobEntity); - } - - public List getJobsByConditions(String workspaceId, Collection jobIds, WaylineJobStatusEnum status) { - return mapper.selectList( - new LambdaQueryWrapper() - .eq(WaylineJobEntity::getWorkspaceId, workspaceId) - .eq(Objects.nonNull(status), WaylineJobEntity::getStatus, status.getVal()) - .and(!CollectionUtils.isEmpty(jobIds), - wrapper -> jobIds.forEach(id -> wrapper.eq(WaylineJobEntity::getJobId, id).or()))) - .stream() - .map(this::entity2Dto) - .collect(Collectors.toList()); - } - - @Override - public Optional getJobByJobId(String workspaceId, String jobId) { - WaylineJobEntity jobEntity = mapper.selectOne( - new LambdaQueryWrapper() - .eq(WaylineJobEntity::getWorkspaceId, workspaceId) - .eq(WaylineJobEntity::getJobId, jobId)); - return Optional.ofNullable(entity2Dto(jobEntity)); - } - - @Override - public Boolean updateJob(WaylineJobDTO dto) { - return mapper.update(this.dto2Entity(dto), - new LambdaUpdateWrapper() - .eq(WaylineJobEntity::getJobId, dto.getJobId())) > 0; - } - - @Override - public PaginationData getJobsByWorkspaceId(String workspaceId, long page, long pageSize) { - Page pageData = mapper.selectPage( - new Page(page, pageSize), - new LambdaQueryWrapper() - .eq(WaylineJobEntity::getWorkspaceId, workspaceId) - .orderByDesc(WaylineJobEntity::getId)); - List records = pageData.getRecords() - .stream() - .map(this::entity2Dto) - .collect(Collectors.toList()); - - return new PaginationData(records, new Pagination(pageData)); - } - - private WaylineJobEntity dto2Entity(WaylineJobDTO dto) { - WaylineJobEntity.WaylineJobEntityBuilder builder = WaylineJobEntity.builder(); - if (dto == null) { - return builder.build(); - } - if (Objects.nonNull(dto.getBeginTime())) { - builder.beginTime(dto.getBeginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); - } - if (Objects.nonNull(dto.getEndTime())) { - builder.endTime(dto.getEndTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); - } - if (Objects.nonNull(dto.getExecuteTime())) { - builder.executeTime(dto.getExecuteTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); - } - if (Objects.nonNull(dto.getCompletedTime())) { - builder.completedTime(dto.getCompletedTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); - } - return builder.status(dto.getStatus()) - .mediaCount(dto.getMediaCount()) - .name(dto.getJobName()) - .errorCode(dto.getCode()) - .jobId(dto.getJobId()) - .fileId(dto.getFileId()) - .dockSn(dto.getDockSn()) - .workspaceId(dto.getWorkspaceId()) - .taskType(Optional.ofNullable(dto.getTaskType()).map(TaskTypeEnum::getType).orElse(null)) - .waylineType(Optional.ofNullable(dto.getWaylineType()).map(WaylineTypeEnum::getValue).orElse(null)) - .username(dto.getUsername()) - .rthAltitude(dto.getRthAltitude()) - .outOfControlAction(Optional.ofNullable(dto.getOutOfControlAction()) - .map(OutOfControlActionEnum::getAction).orElse(null)) - .parentId(dto.getParentId()) - .build(); - } - - public WaylineJobStatusEnum getWaylineState(String dockSn) { - Optional dockOpt = deviceRedisService.getDeviceOnline(dockSn); - if (dockOpt.isEmpty() || !StringUtils.hasText(dockOpt.get().getChildDeviceSn())) { - return WaylineJobStatusEnum.UNKNOWN; - } - Optional dockOsdOpt = deviceRedisService.getDeviceOsd(dockSn, OsdDock.class); - Optional deviceOsdOpt = deviceRedisService.getDeviceOsd(dockOpt.get().getChildDeviceSn(), OsdDockDrone.class); - if (dockOsdOpt.isEmpty() || deviceOsdOpt.isEmpty() || DockModeCodeEnum.WORKING != dockOsdOpt.get().getModeCode()) { - return WaylineJobStatusEnum.UNKNOWN; - } - - OsdDockDrone osdDevice = deviceOsdOpt.get(); - if (DroneModeCodeEnum.WAYLINE == osdDevice.getModeCode() - || DroneModeCodeEnum.MANUAL == osdDevice.getModeCode() - || DroneModeCodeEnum.TAKEOFF_AUTO == osdDevice.getModeCode()) { - if (StringUtils.hasText(waylineRedisService.getPausedWaylineJobId(dockSn))) { - return WaylineJobStatusEnum.PAUSED; - } - if (waylineRedisService.getRunningWaylineJob(dockSn).isPresent()) { - return WaylineJobStatusEnum.IN_PROGRESS; - } - } - return WaylineJobStatusEnum.UNKNOWN; - } - - private WaylineJobDTO entity2Dto(WaylineJobEntity entity) { - if (entity == null) { - return null; - } - - WaylineJobDTO.WaylineJobDTOBuilder builder = WaylineJobDTO.builder() - .jobId(entity.getJobId()) - .jobName(entity.getName()) - .fileId(entity.getFileId()) - .fileName(waylineFileService.getWaylineByWaylineId(entity.getWorkspaceId(), entity.getFileId()) - .orElse(new GetWaylineListResponse()).getName()) - .dockSn(entity.getDockSn()) - .dockName(deviceService.getDeviceBySn(entity.getDockSn()) - .orElse(DeviceDTO.builder().build()).getNickname()) - .username(entity.getUsername()) - .workspaceId(entity.getWorkspaceId()) - .status(WaylineJobStatusEnum.IN_PROGRESS.getVal() == entity.getStatus() && - entity.getJobId().equals(waylineRedisService.getPausedWaylineJobId(entity.getDockSn())) ? - WaylineJobStatusEnum.PAUSED.getVal() : entity.getStatus()) - .code(entity.getErrorCode()) - .beginTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getBeginTime()), ZoneId.systemDefault())) - .endTime(Objects.nonNull(entity.getEndTime()) ? - LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getEndTime()), ZoneId.systemDefault()) : null) - .executeTime(Objects.nonNull(entity.getExecuteTime()) ? - LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getExecuteTime()), ZoneId.systemDefault()) : null) - .completedTime(WaylineJobStatusEnum.find(entity.getStatus()).getEnd() ? - LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getUpdateTime()), ZoneId.systemDefault()) : null) - .taskType(TaskTypeEnum.find(entity.getTaskType())) - .waylineType(WaylineTypeEnum.find(entity.getWaylineType())) - .rthAltitude(entity.getRthAltitude()) - .outOfControlAction(OutOfControlActionEnum.find(entity.getOutOfControlAction())) - .mediaCount(entity.getMediaCount()); - - if (Objects.nonNull(entity.getEndTime())) { - builder.endTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(entity.getEndTime()), ZoneId.systemDefault())); - } - if (WaylineJobStatusEnum.IN_PROGRESS.getVal() == entity.getStatus()) { - builder.progress(waylineRedisService.getRunningWaylineJob(entity.getDockSn()) - .map(EventsReceiver::getOutput) - .map(FlighttaskProgress::getProgress) - .map(FlighttaskProgressData::getPercent) - .orElse(null)); - } - - if (entity.getMediaCount() == 0) { - return builder.build(); - } - - // sync the number of media files - String key = RedisConst.MEDIA_HIGHEST_PRIORITY_PREFIX + entity.getDockSn(); - String countKey = RedisConst.MEDIA_FILE_PREFIX + entity.getDockSn(); - Object mediaFileCount = RedisOpsUtils.hashGet(countKey, entity.getJobId()); - if (Objects.nonNull(mediaFileCount)) { - builder.uploadedCount(((MediaFileCountDTO) mediaFileCount).getUploadedCount()) - .uploading(RedisOpsUtils.checkExist(key) && entity.getJobId().equals(((MediaFileCountDTO)RedisOpsUtils.get(key)).getJobId())); - return builder.build(); - } - - int uploadedSize = fileService.getFilesByWorkspaceAndJobId(entity.getWorkspaceId(), entity.getJobId()).size(); - // All media for this job have been uploaded. - if (uploadedSize >= entity.getMediaCount()) { - return builder.uploadedCount(uploadedSize).build(); - } - RedisOpsUtils.hashSet(countKey, entity.getJobId(), - MediaFileCountDTO.builder() - .jobId(entity.getJobId()) - .mediaCount(entity.getMediaCount()) - .uploadedCount(uploadedSize).build()); - return builder.build(); - } -} diff --git a/src/main/java/com/dji/sdk/README.md b/src/main/java/com/dji/sdk/README.md deleted file mode 100644 index f3f5ff5..0000000 --- a/src/main/java/com/dji/sdk/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# 如何接入CloudSDK -### 1. 在组件扫描中增加包名:com.dji.sdk -### [2. 连接MQTT](#如何连接MQTT) -### [3. 实现SDK 的方法](#如何实现SDK的方法) -### [4. 调用SDK 的方法](#如何调用SDK的方法) - - -## 如何连接MQTT -- 在spring容器中注入MqttConnectOptions和MqttPahoClientFactory; - ![1](../../../../resources/image/6.png) - -- 在application.yml中配置cloud-sdk.mqtt.inbound-topic,未配置则不进行初始化订阅。 - - -## 如何实现SDK的方法 - - 定义一个类,继承com.dji.sdk.cloudapi.*.api包中的抽象类; - - 重写具体的方法以实现功能; - - 将定义的类放入spring容器中,由spring管理bean的生命周期。 -### 【设备上线】示例: - - 定义一个类:SDKDeviceService 继承AbstractDeviceService; -![1](../../../../resources/image/1.png) - - 重写方法updateTopoOnline,实现设备上线功能。 -![1](../../../../resources/image/2.png) - -## 如何调用SDK的方法 - - 定义一个类,继承com.dji.sdk.cloudapi.*.api包中的抽象类; - - 在需要调用的类中注入该类; - - 调用具体的方法。 -### 【航线预下发命令】示例: - - 定义一个类:SDKWaylineService 继承 AbstractWaylineService; -![1](../../../../resources/image/3.png) - - 在WaylineJobServiceImpl中注入该类; -![1](../../../../resources/image/4.png) - - 调用下发命令的方法: -![1](../../../../resources/image/5.png) - -## 如何实现CloudAPI 定义的http 接口 - - 定义一个类,实现com.dji.sdk.cloudapi.*.api包中的http接口类; - - 重写具体的方法以实现接口,无需定义请求地址和方法等数据。 - ![1](../../../../resources/image/7.png) - -## 如何查看CloudAPI 定义的所有http 接口 - - 启动程序 - - 浏览器打开:http://localhost:6789/swagger-ui/index.html - -## 如何接入WebSocket - - CloudSDK 已经定义了WebSocket服务,但是没有实现WebSocket管理。默认地址为:http://localhost:6789/api/v1/ws - - 自定义接入参考:com.dji.sample.component.websocket.config \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/cloudapi/control/ControlMethodEnum.java b/src/main/java/com/dji/sdk/cloudapi/control/ControlMethodEnum.java deleted file mode 100644 index 4aab79d..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/control/ControlMethodEnum.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.dji.sdk.cloudapi.control; - -/** - * @author sean - * @version 1.4 - * @date 2023/3/2 - */ -public enum ControlMethodEnum { - - FLIGHT_AUTHORITY_GRAB("flight_authority_grab"), - - PAYLOAD_AUTHORITY_GRAB("payload_authority_grab"), - - DRC_MODE_ENTER("drc_mode_enter"), - - DRC_MODE_EXIT("drc_mode_exit"), - - FLY_TO_POINT("fly_to_point"), - - FLY_TO_POINT_STOP("fly_to_point_stop"), - - TAKEOFF_TO_POINT("takeoff_to_point"), - - CAMERA_MODE_SWITCH("camera_mode_switch"), - - CAMERA_PHOTO_TAKE("camera_photo_take"), - - CAMERA_RECORDING_START("camera_recording_start"), - - CAMERA_RECORDING_STOP("camera_recording_stop"), - - CAMERA_AIM("camera_aim"), - - CAMERA_FOCAL_LENGTH_SET("camera_focal_length_set"), - - GIMBAL_RESET("gimbal_reset"), - - DRONE_CONTROL("drone_control"), - - DRONE_EMERGENCY_STOP("drone_emergency_stop"), - - HEART_BEAT("heart_beat"); - - private final String method; - - ControlMethodEnum(String method) { - this.method = method; - } - - public String getMethod() { - return method; - } - -} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointRequest.java b/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointRequest.java deleted file mode 100644 index 8af4ca9..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/control/FlyToPointRequest.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.dji.sdk.cloudapi.control; - -import com.dji.sdk.common.BaseModel; - -import javax.validation.Valid; -import javax.validation.constraints.*; -import java.util.List; - -/** - * @author sean - * @version 1.3 - * @date 2023/2/14 - */ -public class FlyToPointRequest extends BaseModel { - - @Pattern(regexp = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") - @NotNull - private String flyToId; - - @Min(1) - @Max(15) - @NotNull - private Integer maxSpeed; - - /** - * The M30 series only support one point. - */ - @Size(min = 1) - @Valid - @NotNull - private List points; - - public FlyToPointRequest() { - } - - @Override - public String toString() { - return "FlyToPointRequest{" + - "flyToId='" + flyToId + '\'' + - ", maxSpeed=" + maxSpeed + - ", points=" + points + - '}'; - } - - public String getFlyToId() { - return flyToId; - } - - public FlyToPointRequest setFlyToId(String flyToId) { - this.flyToId = flyToId; - return this; - } - - public Integer getMaxSpeed() { - return maxSpeed; - } - - public FlyToPointRequest setMaxSpeed(Integer maxSpeed) { - this.maxSpeed = maxSpeed; - return this; - } - - public List getPoints() { - return points; - } - - public FlyToPointRequest setPoints(List points) { - this.points = points; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/PayloadControlMethodEnum.java b/src/main/java/com/dji/sdk/cloudapi/control/PayloadControlMethodEnum.java deleted file mode 100644 index d9a14aa..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/control/PayloadControlMethodEnum.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.dji.sdk.cloudapi.control; - -import com.dji.sdk.common.BaseModel; -import com.dji.sdk.exception.CloudSDKException; - -import java.util.Arrays; - -/** - * @author sean - * @version 1.4 - * @date 2023/3/2 - */ -public enum PayloadControlMethodEnum { - - CAMERA_MODE_SWITCH(ControlMethodEnum.CAMERA_MODE_SWITCH, CameraModeSwitchRequest.class), - - CAMERA_PHOTO_TAKE(ControlMethodEnum.CAMERA_PHOTO_TAKE, CameraPhotoTakeRequest.class), - - CAMERA_RECORDING_START(ControlMethodEnum.CAMERA_RECORDING_START, CameraRecordingStartRequest.class), - - CAMERA_RECORDING_STOP(ControlMethodEnum.CAMERA_RECORDING_STOP, CameraRecordingStopRequest.class), - - CAMERA_AIM(ControlMethodEnum.CAMERA_AIM, CameraAimRequest.class), - - CAMERA_FOCAL_LENGTH_SET(ControlMethodEnum.CAMERA_FOCAL_LENGTH_SET, CameraFocalLengthSetRequest.class), - - GIMBAL_RESET(ControlMethodEnum.GIMBAL_RESET, GimbalResetRequest.class), - ; - - private final ControlMethodEnum payloadMethod; - - private final Class clazz; - - PayloadControlMethodEnum(ControlMethodEnum payloadMethod, Class clazz) { - this.payloadMethod = payloadMethod; - this.clazz = clazz; - } - - public ControlMethodEnum getPayloadMethod() { - return payloadMethod; - } - - public Class getClazz() { - return clazz; - } - - public static PayloadControlMethodEnum find(String method) { - return Arrays.stream(values()).filter(methodEnum -> methodEnum.payloadMethod.getMethod().equals(method)).findAny() - .orElseThrow(() -> new CloudSDKException(PayloadControlMethodEnum.class, method)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointProgress.java b/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointProgress.java deleted file mode 100644 index 008e238..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointProgress.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.dji.sdk.cloudapi.control; - -import com.dji.sdk.cloudapi.wayline.WaylineErrorCodeEnum; - -/** - * @author sean - * @version 1.4 - * @date 2023/3/14 - */ -public class TakeoffToPointProgress { - - private WaylineErrorCodeEnum result; - - private TakeoffStatusEnum status; - - private String flightId; - - private String trackId; - - private Integer wayPointIndex; - - public TakeoffToPointProgress() { - } - - @Override - public String toString() { - return "TakeoffToPointProgress{" + - "result=" + result + - ", status=" + status + - ", flightId='" + flightId + '\'' + - ", trackId='" + trackId + '\'' + - ", wayPointIndex=" + wayPointIndex + - '}'; - } - - public WaylineErrorCodeEnum getResult() { - return result; - } - - public TakeoffToPointProgress setResult(WaylineErrorCodeEnum result) { - this.result = result; - return this; - } - - public TakeoffStatusEnum getStatus() { - return status; - } - - public TakeoffToPointProgress setStatus(TakeoffStatusEnum status) { - this.status = status; - return this; - } - - public String getFlightId() { - return flightId; - } - - public TakeoffToPointProgress setFlightId(String flightId) { - this.flightId = flightId; - return this; - } - - public String getTrackId() { - return trackId; - } - - public TakeoffToPointProgress setTrackId(String trackId) { - this.trackId = trackId; - return this; - } - - public Integer getWayPointIndex() { - return wayPointIndex; - } - - public TakeoffToPointProgress setWayPointIndex(Integer wayPointIndex) { - this.wayPointIndex = wayPointIndex; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointRequest.java b/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointRequest.java deleted file mode 100644 index d3d7e39..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/control/TakeoffToPointRequest.java +++ /dev/null @@ -1,218 +0,0 @@ -package com.dji.sdk.cloudapi.control; - -import com.dji.sdk.annotations.CloudSDKVersion; -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.config.version.CloudSDKVersionEnum; - -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - -/** - * @author sean - * @version 1.4 - * @date 2023/3/1 - */ -public class TakeoffToPointRequest extends BaseModel { - - @Pattern(regexp = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") - @NotNull - private String flightId; - - @Min(-180) - @Max(180) - @NotNull - private Float targetLongitude; - - @Min(-90) - @Max(90) - @NotNull - private Float targetLatitude; - - @Min(2) - @Max(10000) - @NotNull - private Float targetHeight; - - @Min(2) - @Max(1500) - @NotNull - private Float securityTakeoffHeight; - - @Min(2) - @Max(1500) - @NotNull - private Float rthAltitude; - - @NotNull - private RcLostActionEnum rcLostAction; - - @NotNull - private ExitWaylineWhenRcLostEnum exitWaylineWhenRcLost; - - @Min(1) - @Max(15) - @NotNull - private Integer maxSpeed; - - @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) - @NotNull - private RthModeEnum rthMode; - - @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) - @NotNull - private CommanderModeLostActionEnum commanderModeLostAction; - - @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) - @NotNull - private CommanderFlightModeEnum commanderFlightMode; - - @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) - @NotNull - @Min(2) - @Max(3000) - private Float commanderFlightHeight; - - public TakeoffToPointRequest() { - } - - @Override - public String toString() { - return "TakeoffToPointRequest{" + - "flightId='" + flightId + '\'' + - ", targetLongitude=" + targetLongitude + - ", targetLatitude=" + targetLatitude + - ", targetHeight=" + targetHeight + - ", securityTakeoffHeight=" + securityTakeoffHeight + - ", rthAltitude=" + rthAltitude + - ", rcLostAction=" + rcLostAction + - ", exitWaylineWhenRcLost=" + exitWaylineWhenRcLost + - ", maxSpeed=" + maxSpeed + - ", rthMode=" + rthMode + - ", commanderModeLostAction=" + commanderModeLostAction + - ", commanderFlightMode=" + commanderFlightMode + - ", commanderFlightHeight=" + commanderFlightHeight + - '}'; - } - - public String getFlightId() { - return flightId; - } - - public TakeoffToPointRequest setFlightId(String flightId) { - this.flightId = flightId; - return this; - } - - public Float getTargetLongitude() { - return targetLongitude; - } - - public TakeoffToPointRequest setTargetLongitude(Float targetLongitude) { - this.targetLongitude = targetLongitude; - return this; - } - - public Float getTargetLatitude() { - return targetLatitude; - } - - public TakeoffToPointRequest setTargetLatitude(Float targetLatitude) { - this.targetLatitude = targetLatitude; - return this; - } - - public Float getTargetHeight() { - return targetHeight; - } - - public TakeoffToPointRequest setTargetHeight(Float targetHeight) { - this.targetHeight = targetHeight; - return this; - } - - public Float getSecurityTakeoffHeight() { - return securityTakeoffHeight; - } - - public TakeoffToPointRequest setSecurityTakeoffHeight(Float securityTakeoffHeight) { - this.securityTakeoffHeight = securityTakeoffHeight; - return this; - } - - public Float getRthAltitude() { - return rthAltitude; - } - - public TakeoffToPointRequest setRthAltitude(Float rthAltitude) { - this.rthAltitude = rthAltitude; - return this; - } - - public RcLostActionEnum getRcLostAction() { - return rcLostAction; - } - - public TakeoffToPointRequest setRcLostAction(RcLostActionEnum rcLostAction) { - this.rcLostAction = rcLostAction; - return this; - } - - public ExitWaylineWhenRcLostEnum getExitWaylineWhenRcLost() { - return exitWaylineWhenRcLost; - } - - public TakeoffToPointRequest setExitWaylineWhenRcLost(ExitWaylineWhenRcLostEnum exitWaylineWhenRcLost) { - this.exitWaylineWhenRcLost = exitWaylineWhenRcLost; - return this; - } - - public Integer getMaxSpeed() { - return maxSpeed; - } - - public RthModeEnum getRthMode() { - return rthMode; - } - - public TakeoffToPointRequest setRthMode(RthModeEnum rthMode) { - this.rthMode = rthMode; - return this; - } - - public CommanderModeLostActionEnum getCommanderModeLostAction() { - return commanderModeLostAction; - } - - public TakeoffToPointRequest setCommanderModeLostAction(CommanderModeLostActionEnum commanderModeLostAction) { - this.commanderModeLostAction = commanderModeLostAction; - return this; - } - - public CommanderFlightModeEnum getCommanderFlightMode() { - return commanderFlightMode; - } - - public TakeoffToPointRequest setCommanderFlightMode(CommanderFlightModeEnum commanderFlightMode) { - this.commanderFlightMode = commanderFlightMode; - return this; - } - - public Float getCommanderFlightHeight() { - return commanderFlightHeight; - } - - public TakeoffToPointRequest setCommanderFlightHeight(Float commanderFlightHeight) { - this.commanderFlightHeight = commanderFlightHeight; - return this; - } - - public TakeoffToPointRequest setMaxSpeed(Integer maxSpeed) { - this.maxSpeed = maxSpeed; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/control/api/AbstractControlService.java b/src/main/java/com/dji/sdk/cloudapi/control/api/AbstractControlService.java deleted file mode 100644 index b95af0d..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/control/api/AbstractControlService.java +++ /dev/null @@ -1,401 +0,0 @@ -package com.dji.sdk.cloudapi.control.api; - -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.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; -import com.dji.sdk.mqtt.drc.DrcDownPublish; -import com.dji.sdk.mqtt.drc.DrcUpData; -import com.dji.sdk.mqtt.drc.TopicDrcRequest; -import com.dji.sdk.mqtt.events.TopicEventsRequest; -import com.dji.sdk.mqtt.events.TopicEventsResponse; -import com.dji.sdk.mqtt.services.ServicesPublish; -import com.dji.sdk.mqtt.services.ServicesReplyData; -import com.dji.sdk.mqtt.services.TopicServicesResponse; -import org.springframework.integration.annotation.ServiceActivator; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageHeaders; - -import javax.annotation.Resource; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/29 - */ -public abstract class AbstractControlService { - - @Resource - private ServicesPublish servicesPublish; - - @Resource - private DrcDownPublish drcDownPublish; - - /** - * Event notification of flyto result - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_FLY_TO_POINT_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS) - public TopicEventsResponse flyToPointProgress(TopicEventsRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("flyToPointProgress not implemented"); - } - - /** - * Event notification of one-key taking off result - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_TAKEOFF_TO_POINT_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS) - public TopicEventsResponse takeoffToPointProgress(TopicEventsRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("takeoffToPointProgress not implemented"); - } - - /** - * Notification of DRC link state - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_DRC_STATUS_NOTIFY, outputChannel = ChannelName.OUTBOUND_EVENTS) - public TopicEventsResponse drcStatusNotify(TopicEventsRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("drcStatusNotify not implemented"); - } - - /** - * Reason notification of invalid Joystick control - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_JOYSTICK_INVALID_NOTIFY, outputChannel = ChannelName.OUTBOUND_EVENTS) - public TopicEventsResponse joystickInvalidNotify(TopicEventsRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("joystickInvalidNotify not implemented"); - } - - /** - * Flight control authority grabbing - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse flightAuthorityGrab(GatewayManager gateway) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.FLIGHT_AUTHORITY_GRAB.getMethod()); - } - - /** - * Payload control authority grabbing - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse payloadAuthorityGrab(GatewayManager gateway, PayloadAuthorityGrabRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.PAYLOAD_AUTHORITY_GRAB.getMethod(), - request); - } - - /** - * Enter the live flight controls mode - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse drcModeEnter(GatewayManager gateway, DrcModeEnterRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.DRC_MODE_ENTER.getMethod(), - request); - } - - /** - * Exit the live flight controls mode - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse drcModeExit(GatewayManager gateway) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.DRC_MODE_EXIT.getMethod()); - } - - /** - * One-key taking off - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse takeoffToPoint(GatewayManager gateway, TakeoffToPointRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.TAKEOFF_TO_POINT.getMethod(), - request); - } - - /** - * flyto target point - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse flyToPoint(GatewayManager gateway, FlyToPointRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.FLY_TO_POINT.getMethod(), - request); - } - - /** - * End the task of flying to target point - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse flyToPointStop(GatewayManager gateway) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.FLY_TO_POINT_STOP.getMethod()); - } - - /** - * Payload control - switch the camera mode - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse cameraModeSwitch(GatewayManager gateway, CameraModeSwitchRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.CAMERA_MODE_SWITCH.getMethod(), - request); - } - - /** - * Payload control - take single photo - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse cameraPhotoTake(GatewayManager gateway, CameraPhotoTakeRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.CAMERA_PHOTO_TAKE.getMethod(), - request); - } - - /** - * Payload control - start recording - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse cameraRecordingStart(GatewayManager gateway, CameraRecordingStartRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.CAMERA_RECORDING_START.getMethod(), - request); - } - - /** - * Payload control - stop recording - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse cameraRecordingStop(GatewayManager gateway, CameraRecordingStopRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.CAMERA_RECORDING_STOP.getMethod(), - request); - } - - /** - * Payload control - double tab to become AIM - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse cameraAim(GatewayManager gateway, CameraAimRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.CAMERA_AIM.getMethod(), - request); - } - - /** - * Payload control - zoom - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse cameraFocalLengthSet(GatewayManager gateway, CameraFocalLengthSetRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.CAMERA_FOCAL_LENGTH_SET.getMethod(), - request); - } - - /** - * Payload control - reset the gimbal - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse gimbalReset(GatewayManager gateway, GimbalResetRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.GIMBAL_RESET.getMethod(), - request); - } - - /** - * Payload control - * @param gateway - * @param request data - * @return services_reply - */ - public TopicServicesResponse payloadControl(GatewayManager gateway, PayloadControlMethodEnum methodEnum, BaseModel request) { - try { - AbstractControlService abstractControlService = SpringBeanUtils.getBean(this.getClass()); - Method method = abstractControlService.getClass().getDeclaredMethod( - Common.convertSnake(methodEnum.getPayloadMethod().getMethod()),GatewayManager.class, methodEnum.getClazz()); - return (TopicServicesResponse) method.invoke(abstractControlService, gateway, request); - } catch (NoSuchMethodException | IllegalAccessException e) { - throw new CloudSDKException(e); - } catch (InvocationTargetException e) { - throw new CloudSDKException(e.getTargetException()); - } - } - - - /** - * DRC-flight control - * @param gateway - * @param request data - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - protected void droneControlDown(GatewayManager gateway, DroneControlRequest request) { - drcDownPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.DRONE_CONTROL.getMethod(), - request); - } - - /** - * Drc up notification of drone control result - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_DRC_UP_DRONE_CONTROL) - public void droneControlUp(TopicDrcRequest> request, MessageHeaders headers) { - throw new UnsupportedOperationException("droneControlUp not implemented"); - } - - /** - * DRC-drone emergency stop - * @param gateway - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public void droneEmergencyStopDown(GatewayManager gateway) { - drcDownPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.DRONE_EMERGENCY_STOP.getMethod()); - } - - /** - * Drc up notification of drone emergency stop result - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_DRC_UP_DRONE_EMERGENCY_STOP) - public void droneEmergencyStopUp(TopicDrcRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("droneEmergencyStopUp not implemented"); - } - - - /** - * DRC-heart beat - * @param gateway - * @param request data - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public void heartBeatDown(GatewayManager gateway, HeartBeatRequest request) { - drcDownPublish.publish( - gateway.getGatewaySn(), - ControlMethodEnum.HEART_BEAT.getMethod(), - request); - } - - /** - * Drc up notification of heart beat result - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_DRC_UP_HEART_BEAT) - public void heartBeatUp(TopicDrcRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("heartBeatUp not implemented"); - } - - /** - * DRC-obstacle avoidance information pushing - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_DRC_UP_HSI_INFO_PUSH) - public void hsiInfoPush(TopicDrcRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("hsiInfoPush not implemented"); - } - - /** - * DRC-delay information pushing of image transmission link - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_DRC_UP_DELAY_INFO_PUSH) - public void delayInfoPush(TopicDrcRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("delayInfoPush not implemented"); - } - - /** - * DRC-high frequency osd information pushing - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_DRC_UP_OSD_INFO_PUSH) - public void osdInfoPush(TopicDrcRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("osdInfoPush not implemented"); - } - - -} diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/DebugMethodEnum.java b/src/main/java/com/dji/sdk/cloudapi/debug/DebugMethodEnum.java deleted file mode 100644 index ec69c0f..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/debug/DebugMethodEnum.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.dji.sdk.cloudapi.debug; - -import com.dji.sdk.common.BaseModel; -import com.dji.sdk.exception.CloudSDKException; - -import java.util.Arrays; - -/** - * @author sean - * @version 1.3 - * @date 2022/11/14 - */ -public enum DebugMethodEnum { - - DEBUG_MODE_OPEN("debug_mode_open", null), - - DEBUG_MODE_CLOSE("debug_mode_close", null), - - SUPPLEMENT_LIGHT_OPEN("supplement_light_open", null), - - SUPPLEMENT_LIGHT_CLOSE("supplement_light_close", null), - - DEVICE_REBOOT("device_reboot", null), - - DRONE_OPEN("drone_open", null), - - DRONE_CLOSE("drone_close", null), - - DRONE_FORMAT("drone_format", null), - - DEVICE_FORMAT("device_format", null), - - COVER_OPEN("cover_open", null), - - COVER_CLOSE("cover_close", null), - - PUTTER_OPEN("putter_open", null), - - PUTTER_CLOSE("putter_close", null), - - CHARGE_OPEN("charge_open", null), - - CHARGE_CLOSE("charge_close", null), - - BATTERY_MAINTENANCE_SWITCH("battery_maintenance_switch", BatteryMaintenanceSwitchRequest.class), - - ALARM_STATE_SWITCH("alarm_state_switch", AlarmStateSwitchRequest.class), - - BATTERY_STORE_MODE_SWITCH("battery_store_mode_switch", BatteryStoreModeSwitchRequest.class), - - SDR_WORKMODE_SWITCH("sdr_workmode_switch", SdrWorkmodeSwitchRequest.class), - - AIR_CONDITIONER_MODE_SWITCH("air_conditioner_mode_switch", AirConditionerModeSwitchRequest.class); - - private final String method; - - private final Class clazz; - - DebugMethodEnum(String method, Class clazz) { - this.method = method; - this.clazz = clazz; - } - - public String getMethod() { - return method; - } - - public Class getClazz() { - return clazz; - } - - public static DebugMethodEnum find(String method) { - return Arrays.stream(values()).filter(methodEnum -> methodEnum.method.equals(method)).findAny() - .orElseThrow(() -> new CloudSDKException(DebugMethodEnum.class, method)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/debug/api/AbstractDebugService.java b/src/main/java/com/dji/sdk/cloudapi/debug/api/AbstractDebugService.java deleted file mode 100644 index 08d3933..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/debug/api/AbstractDebugService.java +++ /dev/null @@ -1,349 +0,0 @@ -package com.dji.sdk.cloudapi.debug.api; - -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.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; -import com.dji.sdk.mqtt.events.EventsDataRequest; -import com.dji.sdk.mqtt.events.TopicEventsRequest; -import com.dji.sdk.mqtt.events.TopicEventsResponse; -import com.dji.sdk.mqtt.services.ServicesPublish; -import com.dji.sdk.mqtt.services.ServicesReplyData; -import com.dji.sdk.mqtt.services.TopicServicesResponse; -import com.fasterxml.jackson.core.type.TypeReference; -import org.springframework.integration.annotation.ServiceActivator; -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; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/29 - */ -public abstract class AbstractDebugService { - - @Resource - private ServicesPublish servicesPublish; - - /** - * Open the debug mode - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> debugModeOpen(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.DEBUG_MODE_OPEN.getMethod()); - } - - /** - * Close the debug mode - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> debugModeClose(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.DEBUG_MODE_CLOSE.getMethod()); - } - - /** - * Open the supplement light - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> supplementLightOpen(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.SUPPLEMENT_LIGHT_OPEN.getMethod()); - } - - /** - * Close the supplement light - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> supplementLightClose(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.SUPPLEMENT_LIGHT_CLOSE.getMethod()); - } - - /** - * Maintenance state switch of battery - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> batteryMaintenanceSwitch(GatewayManager gateway, BatteryMaintenanceSwitchRequest request) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.BATTERY_MAINTENANCE_SWITCH.getMethod(), - request); - } - - /** - * Air conditioner working mode switch of dock - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> airConditionerModeSwitch(GatewayManager gateway, AirConditionerModeSwitchRequest request) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.AIR_CONDITIONER_MODE_SWITCH.getMethod(), - request); - } - - /** - * Sound and light alarm switch of dock - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> alarmStateSwitch(GatewayManager gateway, AlarmStateSwitchRequest request) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.AIR_CONDITIONER_MODE_SWITCH.getMethod(), - request); - } - - /** - * Battery storage mode switch of dock - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> batteryStoreModeSwitch(GatewayManager gateway, BatteryStoreModeSwitchRequest request) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.BATTERY_STORE_MODE_SWITCH.getMethod(), - request); - } - - /** - * Reboot the dock - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> deviceReboot(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.DEVICE_REBOOT.getMethod()); - } - - /** - * Power on the aircraft - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> droneOpen(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.DRONE_OPEN.getMethod()); - } - - /** - * Power off the aircraft - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> droneClose(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.DRONE_CLOSE.getMethod()); - } - - /** - * Format the dock data - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> deviceFormat(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.DEVICE_FORMAT.getMethod()); - } - - /** - * Format the aircraft data - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> droneFormat(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.DRONE_FORMAT.getMethod()); - } - - /** - * Open the dock cover - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> coverOpen(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.COVER_OPEN.getMethod()); - } - - /** - * Close the dock cover - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> coverClose(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.COVER_CLOSE.getMethod()); - } - - /** - * Open the putter - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = {GatewayTypeEnum.RC, GatewayTypeEnum.DOCK2}) - public TopicServicesResponse> putterOpen(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.PUTTER_OPEN.getMethod()); - } - - /** - * Close the putter - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = {GatewayTypeEnum.RC, GatewayTypeEnum.DOCK2}) - public TopicServicesResponse> putterClose(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.PUTTER_CLOSE.getMethod()); - } - - /** - * Turn on charging - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> chargeOpen(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.CHARGE_OPEN.getMethod()); - } - - /** - * Turn off charging - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> chargeClose(GatewayManager gateway) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.CHARGE_CLOSE.getMethod()); - } - - /** - * Switch of 4G enhancement mode - * @param gateway - * @param request data - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse> sdrWorkmodeSwitch(GatewayManager gateway, SdrWorkmodeSwitchRequest request) { - return servicesPublish.publish( - new TypeReference() {}, - gateway.getGatewaySn(), - DebugMethodEnum.SDR_WORKMODE_SWITCH.getMethod(), - request); - } - - /** - * Common interface for remote debugging - * @param gateway - * @param methodEnum - * @param request data - * @return services_reply - */ - public TopicServicesResponse> remoteDebug(GatewayManager gateway, DebugMethodEnum methodEnum, BaseModel request) { - try { - List clazz = new ArrayList<>(); - List args = new ArrayList<>(); - clazz.add(GatewayManager.class); - args.add(gateway); - if (Objects.nonNull(request)) { - clazz.add(request.getClass()); - args.add(request); - } - AbstractDebugService abstractDebugService = SpringBeanUtils.getBean(this.getClass()); - Method method = abstractDebugService.getClass().getDeclaredMethod(Common.convertSnake(methodEnum.getMethod()), clazz.toArray(Class[]::new)); - return (TopicServicesResponse>) method.invoke(abstractDebugService, args.toArray()); - } catch (NoSuchMethodException | IllegalAccessException e) { - throw new CloudSDKException(e); - } catch (InvocationTargetException e) { - throw new CloudSDKException(e.getTargetException()); - } - } - - /** - * Inform of remote debug progress - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS) - public TopicEventsResponse remoteDebugProgress(TopicEventsRequest> request, MessageHeaders headers) { - throw new UnsupportedOperationException("remoteDebugProgress not implemented"); - } - -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/CameraModeEnum.java b/src/main/java/com/dji/sdk/cloudapi/device/CameraModeEnum.java deleted file mode 100644 index 3f82d43..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/CameraModeEnum.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.dji.sdk.cloudapi.device; - -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.4 - * @date 2023/3/3 - */ -public enum CameraModeEnum { - - PHOTO(0), - - VIDEO(1); - - private final int mode; - - CameraModeEnum(int mode) { - this.mode = mode; - } - - @JsonValue - public int getMode() { - return mode; - } - - @JsonCreator - public static CameraModeEnum find(int mode) { - return Arrays.stream(values()).filter(modeEnum -> modeEnum.mode == mode).findAny() - .orElseThrow(() -> new CloudSDKException(CameraModeEnum.class, mode)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockDronePayload.java b/src/main/java/com/dji/sdk/cloudapi/device/DockDronePayload.java deleted file mode 100644 index 8351aa1..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/DockDronePayload.java +++ /dev/null @@ -1,236 +0,0 @@ -package com.dji.sdk.cloudapi.device; - -import java.util.List; - -/** - * @author sean - * @version 1.0 - * @date 2022/5/6 - */ -public class DockDronePayload { - - private PayloadIndex payloadIndex; - - private Float gimbalPitch; - - private Float gimbalRoll; - - private Float gimbalYaw; - - private Float measureTargetAltitude; - - private Float measureTargetDistance; - - private Float measureTargetLatitude; - - private Float measureTargetLongitude; - - private MeasureTargetStateEnum measureTargetErrorState; - - private Integer version; - - private ThermalPaletteStyleEnum thermalCurrentPaletteStyle; - - private ThermalGainModeEnum thermalGainMode; - - private Float thermalGlobalTemperatureMax; - - private Float thermalGlobalTemperatureMin; - - private Integer thermalIsothermLowerLimit; - - private SwitchActionEnum thermalIsothermState; - - private Integer thermalIsothermUpperLimit; - - private List smartTrackPoint; - - public DockDronePayload() { - } - - @Override - public String toString() { - return "DockDronePayload{" + - "payloadIndex=" + payloadIndex + - ", gimbalPitch=" + gimbalPitch + - ", gimbalRoll=" + gimbalRoll + - ", gimbalYaw=" + gimbalYaw + - ", measureTargetAltitude=" + measureTargetAltitude + - ", measureTargetDistance=" + measureTargetDistance + - ", measureTargetLatitude=" + measureTargetLatitude + - ", measureTargetLongitude=" + measureTargetLongitude + - ", measureTargetErrorState=" + measureTargetErrorState + - ", version=" + version + - ", thermalCurrentPaletteStyle=" + thermalCurrentPaletteStyle + - ", thermalGainMode=" + thermalGainMode + - ", thermalGlobalTemperatureMax=" + thermalGlobalTemperatureMax + - ", thermalGlobalTemperatureMin=" + thermalGlobalTemperatureMin + - ", thermalIsothermLowerLimit=" + thermalIsothermLowerLimit + - ", thermalIsothermState=" + thermalIsothermState + - ", thermalIsothermUpperLimit=" + thermalIsothermUpperLimit + - ", smartTrackPoint=" + smartTrackPoint + - '}'; - } - - public PayloadIndex getPayloadIndex() { - return payloadIndex; - } - - public DockDronePayload setPayloadIndex(PayloadIndex payloadIndex) { - this.payloadIndex = payloadIndex; - return this; - } - - public Float getGimbalPitch() { - return gimbalPitch; - } - - public DockDronePayload setGimbalPitch(Float gimbalPitch) { - this.gimbalPitch = gimbalPitch; - return this; - } - - public Float getGimbalRoll() { - return gimbalRoll; - } - - public DockDronePayload setGimbalRoll(Float gimbalRoll) { - this.gimbalRoll = gimbalRoll; - return this; - } - - public Float getGimbalYaw() { - return gimbalYaw; - } - - public DockDronePayload setGimbalYaw(Float gimbalYaw) { - this.gimbalYaw = gimbalYaw; - return this; - } - - public Float getMeasureTargetAltitude() { - return measureTargetAltitude; - } - - public DockDronePayload setMeasureTargetAltitude(Float measureTargetAltitude) { - this.measureTargetAltitude = measureTargetAltitude; - return this; - } - - public Float getMeasureTargetDistance() { - return measureTargetDistance; - } - - public DockDronePayload setMeasureTargetDistance(Float measureTargetDistance) { - this.measureTargetDistance = measureTargetDistance; - return this; - } - - public Float getMeasureTargetLatitude() { - return measureTargetLatitude; - } - - public DockDronePayload setMeasureTargetLatitude(Float measureTargetLatitude) { - this.measureTargetLatitude = measureTargetLatitude; - return this; - } - - public Float getMeasureTargetLongitude() { - return measureTargetLongitude; - } - - public DockDronePayload setMeasureTargetLongitude(Float measureTargetLongitude) { - this.measureTargetLongitude = measureTargetLongitude; - return this; - } - - public MeasureTargetStateEnum getMeasureTargetErrorState() { - return measureTargetErrorState; - } - - public DockDronePayload setMeasureTargetErrorState(MeasureTargetStateEnum measureTargetErrorState) { - this.measureTargetErrorState = measureTargetErrorState; - return this; - } - - public Integer getVersion() { - return version; - } - - public DockDronePayload setVersion(Integer version) { - this.version = version; - return this; - } - - public ThermalPaletteStyleEnum getThermalCurrentPaletteStyle() { - return thermalCurrentPaletteStyle; - } - - public DockDronePayload setThermalCurrentPaletteStyle(ThermalPaletteStyleEnum thermalCurrentPaletteStyle) { - this.thermalCurrentPaletteStyle = thermalCurrentPaletteStyle; - return this; - } - - public ThermalGainModeEnum getThermalGainMode() { - return thermalGainMode; - } - - public DockDronePayload setThermalGainMode(ThermalGainModeEnum thermalGainMode) { - this.thermalGainMode = thermalGainMode; - return this; - } - - public Float getThermalGlobalTemperatureMax() { - return thermalGlobalTemperatureMax; - } - - public DockDronePayload setThermalGlobalTemperatureMax(Float thermalGlobalTemperatureMax) { - this.thermalGlobalTemperatureMax = thermalGlobalTemperatureMax; - return this; - } - - public Float getThermalGlobalTemperatureMin() { - return thermalGlobalTemperatureMin; - } - - public DockDronePayload setThermalGlobalTemperatureMin(Float thermalGlobalTemperatureMin) { - this.thermalGlobalTemperatureMin = thermalGlobalTemperatureMin; - return this; - } - - public Integer getThermalIsothermLowerLimit() { - return thermalIsothermLowerLimit; - } - - public DockDronePayload setThermalIsothermLowerLimit(Integer thermalIsothermLowerLimit) { - this.thermalIsothermLowerLimit = thermalIsothermLowerLimit; - return this; - } - - public SwitchActionEnum getThermalIsothermState() { - return thermalIsothermState; - } - - public DockDronePayload setThermalIsothermState(SwitchActionEnum thermalIsothermState) { - this.thermalIsothermState = thermalIsothermState; - return this; - } - - public Integer getThermalIsothermUpperLimit() { - return thermalIsothermUpperLimit; - } - - public DockDronePayload setThermalIsothermUpperLimit(Integer thermalIsothermUpperLimit) { - this.thermalIsothermUpperLimit = thermalIsothermUpperLimit; - return this; - } - - public List getSmartTrackPoint() { - return smartTrackPoint; - } - - public DockDronePayload setSmartTrackPoint(List smartTrackPoint) { - this.smartTrackPoint = smartTrackPoint; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockPayload.java b/src/main/java/com/dji/sdk/cloudapi/device/DockPayload.java deleted file mode 100644 index 723719f..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/DockPayload.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.dji.sdk.cloudapi.device; - -import java.util.Arrays; - -/** - * @author sean - * @version 1.7 - * @date 2023/5/23 - */ -public class DockPayload { - - private PayloadIndex payloadIndex; - - private ThermalPaletteStyleEnum[] thermalSupportedPaletteStyles; - - private Integer version; - - public DockPayload() { - } - - @Override - public String toString() { - return "DockPayload{" + - "payloadIndex=" + payloadIndex + - ", thermalSupportedPaletteStyles=" + Arrays.toString(thermalSupportedPaletteStyles) + - ", version=" + version + - '}'; - } - - public PayloadIndex getPayloadIndex() { - return payloadIndex; - } - - public DockPayload setPayloadIndex(PayloadIndex payloadIndex) { - this.payloadIndex = payloadIndex; - return this; - } - - public ThermalPaletteStyleEnum[] getThermalSupportedPaletteStyles() { - return thermalSupportedPaletteStyles; - } - - public DockPayload setThermalSupportedPaletteStyles(ThermalPaletteStyleEnum[] thermalSupportedPaletteStyles) { - this.thermalSupportedPaletteStyles = thermalSupportedPaletteStyles; - return this; - } - - public Integer getVersion() { - return version; - } - - public DockPayload setVersion(Integer version) { - this.version = version; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DockWpmzVersion.java b/src/main/java/com/dji/sdk/cloudapi/device/DockWpmzVersion.java deleted file mode 100644 index 29c6bef..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/DockWpmzVersion.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.dji.sdk.cloudapi.device; - -/** - * @author sean - * @version 1.7 - * @date 2023/5/23 - */ -public class DockWpmzVersion { - - private String wpmzVersion; - - public DockWpmzVersion() { - } - - @Override - public String toString() { - return "DockWpmzVersion{" + - "wpmzVersion='" + wpmzVersion + '\'' + - '}'; - } - - public String getWpmzVersion() { - return wpmzVersion; - } - - public DockWpmzVersion setWpmzVersion(String wpmzVersion) { - this.wpmzVersion = wpmzVersion; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenanceInfo.java b/src/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenanceInfo.java deleted file mode 100644 index af85d37..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/DroneBatteryMaintenanceInfo.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.dji.sdk.cloudapi.device; - -import java.util.List; - -/** - * @author sean - * @version 1.4 - * @date 2022/11/3 - */ -public class DroneBatteryMaintenanceInfo { - - private List batteries; - - public DroneBatteryMaintenanceInfo() { - } - - @Override - public String toString() { - return "DroneBatteryMaintenanceInfo{" + - "batteries=" + batteries + - '}'; - } - - public List getBatteries() { - return batteries; - } - - public DroneBatteryMaintenanceInfo setBatteries(List batteries) { - this.batteries = batteries; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/DroneModeCodeEnum.java b/src/main/java/com/dji/sdk/cloudapi/device/DroneModeCodeEnum.java deleted file mode 100644 index 526460b..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/DroneModeCodeEnum.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.dji.sdk.cloudapi.device; - -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.4 - * @date 2023/3/9 - */ -public enum DroneModeCodeEnum { - - IDLE(0), - - TAKEOFF_PREPARE(1), - - TAKEOFF_FINISHED(2), - - MANUAL(3), - - TAKEOFF_AUTO(4), - - WAYLINE(5), - - PANORAMIC_SHOT(6), - - ACTIVE_TRACK(7), - - ADS_B_AVOIDANCE(8), - - RETURN_AUTO(9), - - LANDING_AUTO(10), - - LANDING_FORCED(11), - - LANDING_THREE_PROPELLER(12), - - UPGRADING(13), - - DISCONNECTED(14), - - APAS(15), - - VIRTUAL_JOYSTICK(16); - - private final int code; - - DroneModeCodeEnum(int code) { - this.code = code; - } - - @JsonValue - public int getCode() { - return code; - } - - @JsonCreator - public static DroneModeCodeEnum find(int code) { - return Arrays.stream(values()).filter(modeCodeEnum -> modeCodeEnum.ordinal() == code).findAny() - .orElseThrow(() -> new CloudSDKException(DroneModeCodeEnum.class, code)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/FlighttaskStepCodeEnum.java b/src/main/java/com/dji/sdk/cloudapi/device/FlighttaskStepCodeEnum.java deleted file mode 100644 index 00ed09f..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/FlighttaskStepCodeEnum.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.dji.sdk.cloudapi.device; - -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 - * @date 2023/6/30 - */ -public enum FlighttaskStepCodeEnum { - - TASK_PREPARING(0), - - TASK_OPERATING(1), - - STATE_RECOVERING(2), - - WORKING(4), - - // TODO 确认状态 - UNKNOWN(5), - - UNKNOWN1(255), - - UNKNOWN2(256), - ; - - private final int code; - - FlighttaskStepCodeEnum(int code) { - this.code = code; - } - - @JsonValue - public int getCode() { - return code; - } - - @JsonCreator - public static FlighttaskStepCodeEnum find(int code) { - return Arrays.stream(values()).filter(codeEnum -> codeEnum.code == code).findAny() - .orElseThrow(() -> new CloudSDKException(FlighttaskStepCodeEnum.class, code)); - } - -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/ModeCodeReasonEnum.java b/src/main/java/com/dji/sdk/cloudapi/device/ModeCodeReasonEnum.java deleted file mode 100644 index dd8f67a..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/ModeCodeReasonEnum.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.dji.sdk.cloudapi.device; - -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.4 - * @date 2023/2/28 - */ -public enum ModeCodeReasonEnum { - - NO_MEANING(0), - - LOW_POWER(1), - - LOW_VOLTAGE(2), - - SERIOUS_LOW_VOLTAGE(3), - - RC_CONTROL(4), - - APP_CONTROL(5), - - RC_SIGNAL_LOST(6), - - EXTERNAL_DEVICE_TRIGGERED(7), - - GEO_ZONE(8), - - HOME_POINT_TOO_CLOSED(9), - - HOME_POINT_TOO_FAR(10), - - EXECUTING_WAYPOINT_MISSION(11), - - ARRIVE_HOME_POINT(12), - - SECOND_LIMIT_LANDING(13), - - APP_FORCIBLY_BREAK_PROTECTION(14), - - PLANES_PASSING_NEARBY(15), - - HEIGHT_CONTROL_FAILED(16), - - LOW_POWER_RTH(17), - - AP_CONTROL(18), - - HARDWARE_ABNORMAL(19), - - TOUCHDOWN_AVOIDANCE_PROTECTION(20), - - CANCEL_RTH(21), - - RTH_OBSTACLE_AVOIDANCE(22), - ; - - private final int reason; - - ModeCodeReasonEnum(int reason) { - this.reason = reason; - } - - @JsonValue - public int getReason() { - return reason; - } - - @JsonCreator - public static ModeCodeReasonEnum find(int reason) { - return Arrays.stream(values()).filter(reasonEnum -> reasonEnum.reason == reason).findAny() - .orElseThrow(() -> new CloudSDKException(ModeCodeReasonEnum.class, reason)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/OsdCamera.java b/src/main/java/com/dji/sdk/cloudapi/device/OsdCamera.java deleted file mode 100644 index 0d829ba..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/OsdCamera.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.dji.sdk.cloudapi.device; - -/** - * @author sean - * @version 1.4 - * @date 2023/3/8 - */ -public class OsdCamera { - - private CameraModeEnum cameraMode; - - private LiveviewWorldRegion liveviewWorldRegion; - - private PayloadIndex payloadIndex; - - private CameraStateEnum photoState; - - private Integer recordTime; - - private CameraStateEnum recordingState; - - private Long remainPhotoNum; - - private Integer remainRecordDuration; - - private Float zoomFactor; - - private Float irZoomFactor; - - public OsdCamera() { - } - - @Override - public String toString() { - return "OsdCamera{" + - "cameraMode=" + cameraMode + - ", liveviewWorldRegion=" + liveviewWorldRegion + - ", payloadIndex=" + payloadIndex + - ", photoState=" + photoState + - ", recordTime=" + recordTime + - ", recordingState=" + recordingState + - ", remainPhotoNum=" + remainPhotoNum + - ", remainRecordDuration=" + remainRecordDuration + - ", zoomFactor=" + zoomFactor + - ", irZoomFactor=" + irZoomFactor + - '}'; - } - - public CameraModeEnum getCameraMode() { - return cameraMode; - } - - public OsdCamera setCameraMode(CameraModeEnum cameraMode) { - this.cameraMode = cameraMode; - return this; - } - - public LiveviewWorldRegion getLiveviewWorldRegion() { - return liveviewWorldRegion; - } - - public OsdCamera setLiveviewWorldRegion(LiveviewWorldRegion liveviewWorldRegion) { - this.liveviewWorldRegion = liveviewWorldRegion; - return this; - } - - public PayloadIndex getPayloadIndex() { - return payloadIndex; - } - - public OsdCamera setPayloadIndex(PayloadIndex payloadIndex) { - this.payloadIndex = payloadIndex; - return this; - } - - public CameraStateEnum getPhotoState() { - return photoState; - } - - public OsdCamera setPhotoState(CameraStateEnum photoState) { - this.photoState = photoState; - return this; - } - - public Integer getRecordTime() { - return recordTime; - } - - public OsdCamera setRecordTime(Integer recordTime) { - this.recordTime = recordTime; - return this; - } - - public CameraStateEnum getRecordingState() { - return recordingState; - } - - public OsdCamera setRecordingState(CameraStateEnum recordingState) { - this.recordingState = recordingState; - return this; - } - - public Long getRemainPhotoNum() { - return remainPhotoNum; - } - - public OsdCamera setRemainPhotoNum(Long remainPhotoNum) { - this.remainPhotoNum = remainPhotoNum; - return this; - } - - public Integer getRemainRecordDuration() { - return remainRecordDuration; - } - - public OsdCamera setRemainRecordDuration(Integer remainRecordDuration) { - this.remainRecordDuration = remainRecordDuration; - return this; - } - - public Float getZoomFactor() { - return zoomFactor; - } - - public OsdCamera setZoomFactor(Float zoomFactor) { - this.zoomFactor = zoomFactor; - return this; - } - - public Float getIrZoomFactor() { - return irZoomFactor; - } - - public OsdCamera setIrZoomFactor(Float irZoomFactor) { - this.irZoomFactor = irZoomFactor; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/OsdDock.java b/src/main/java/com/dji/sdk/cloudapi/device/OsdDock.java deleted file mode 100644 index 1ea119b..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/OsdDock.java +++ /dev/null @@ -1,474 +0,0 @@ -package com.dji.sdk.cloudapi.device; - -/** - * @author sean - * @version 1.3 - * @date 2022/11/3 - */ -public class OsdDock { - - private NetworkState networkState; - - private Boolean droneInDock; - - private DroneChargeState droneChargeState; - - private RainfallEnum rainfall; - - private Float windSpeed; - - private Float environmentTemperature; - - private Float temperature; - - private Integer humidity; - - private Float latitude; - - private Float longitude; - - private Float height; - - private AlternateLandPoint alternateLandPoint; - - private Long firstPowerOn; - - private DockPositionState positionState; - - private Storage storage; - - private DockModeCodeEnum modeCode; - - private CoverStateEnum coverState; - - private Boolean supplementLightState; - - private Boolean emergencyStopState; - - private AirConditioner airConditioner; - - private BatteryStoreModeEnum batteryStoreMode; - - private Boolean alarmState; - - private PutterStateEnum putterState; - - private DockSubDevice subDevice; - - private Integer jobNumber; - - private Long accTime; - - private Long activationTime; - - private OsdDockMaintainStatus maintainStatus; - - private Integer electricSupplyVoltage; - - private Integer workingVoltage; - - private Integer workingCurrent; - - private BackupBattery backupBattery; - - private DroneBatteryMaintenanceInfo droneBatteryMaintenanceInfo; - - private FlighttaskStepCodeEnum flighttaskStepCode; - - private Integer flighttaskPrepareCapacity; - - private MediaFileDetail mediaFileDetail; - - private WirelessLink wirelessLink; - - private DrcStateEnum drcState; - - public OsdDock() { - } - - @Override - public String toString() { - return "OsdDock{" + - "networkState=" + networkState + - ", droneInDock=" + droneInDock + - ", droneChargeState=" + droneChargeState + - ", rainfall=" + rainfall + - ", windSpeed=" + windSpeed + - ", environmentTemperature=" + environmentTemperature + - ", temperature=" + temperature + - ", humidity=" + humidity + - ", latitude=" + latitude + - ", longitude=" + longitude + - ", height=" + height + - ", alternateLandPoint=" + alternateLandPoint + - ", firstPowerOn=" + firstPowerOn + - ", positionState=" + positionState + - ", storage=" + storage + - ", modeCode=" + modeCode + - ", coverState=" + coverState + - ", supplementLightState=" + supplementLightState + - ", emergencyStopState=" + emergencyStopState + - ", airConditioner=" + airConditioner + - ", batteryStoreMode=" + batteryStoreMode + - ", alarmState=" + alarmState + - ", putterState=" + putterState + - ", subDevice=" + subDevice + - ", jobNumber=" + jobNumber + - ", accTime=" + accTime + - ", activationTime=" + activationTime + - ", maintainStatus=" + maintainStatus + - ", electricSupplyVoltage=" + electricSupplyVoltage + - ", workingVoltage=" + workingVoltage + - ", workingCurrent=" + workingCurrent + - ", backupBattery=" + backupBattery + - ", droneBatteryMaintenanceInfo=" + droneBatteryMaintenanceInfo + - ", flighttaskStepCode=" + flighttaskStepCode + - ", flighttaskPrepareCapacity=" + flighttaskPrepareCapacity + - ", mediaFileDetail=" + mediaFileDetail + - ", wirelessLink=" + wirelessLink + - ", drcState=" + drcState + - '}'; - } - - public NetworkState getNetworkState() { - return networkState; - } - - public OsdDock setNetworkState(NetworkState networkState) { - this.networkState = networkState; - return this; - } - - public Boolean getDroneInDock() { - return droneInDock; - } - - public OsdDock setDroneInDock(Boolean droneInDock) { - this.droneInDock = droneInDock; - return this; - } - - public DroneChargeState getDroneChargeState() { - return droneChargeState; - } - - public OsdDock setDroneChargeState(DroneChargeState droneChargeState) { - this.droneChargeState = droneChargeState; - return this; - } - - public RainfallEnum getRainfall() { - return rainfall; - } - - public OsdDock setRainfall(RainfallEnum rainfall) { - this.rainfall = rainfall; - return this; - } - - public Float getWindSpeed() { - return windSpeed; - } - - public OsdDock setWindSpeed(Float windSpeed) { - this.windSpeed = windSpeed; - return this; - } - - public Float getEnvironmentTemperature() { - return environmentTemperature; - } - - public OsdDock setEnvironmentTemperature(Float environmentTemperature) { - this.environmentTemperature = environmentTemperature; - return this; - } - - public Float getTemperature() { - return temperature; - } - - public OsdDock setTemperature(Float temperature) { - this.temperature = temperature; - return this; - } - - public Integer getHumidity() { - return humidity; - } - - public OsdDock setHumidity(Integer humidity) { - this.humidity = humidity; - return this; - } - - public Float getLatitude() { - return latitude; - } - - public OsdDock setLatitude(Float latitude) { - this.latitude = latitude; - return this; - } - - public Float getLongitude() { - return longitude; - } - - public OsdDock setLongitude(Float longitude) { - this.longitude = longitude; - return this; - } - - public Float getHeight() { - return height; - } - - public OsdDock setHeight(Float height) { - this.height = height; - return this; - } - - public AlternateLandPoint getAlternateLandPoint() { - return alternateLandPoint; - } - - public OsdDock setAlternateLandPoint(AlternateLandPoint alternateLandPoint) { - this.alternateLandPoint = alternateLandPoint; - return this; - } - - public Long getFirstPowerOn() { - return firstPowerOn; - } - - public OsdDock setFirstPowerOn(Long firstPowerOn) { - this.firstPowerOn = firstPowerOn; - return this; - } - - public DockPositionState getPositionState() { - return positionState; - } - - public OsdDock setPositionState(DockPositionState positionState) { - this.positionState = positionState; - return this; - } - - public Storage getStorage() { - return storage; - } - - public OsdDock setStorage(Storage storage) { - this.storage = storage; - return this; - } - - public DockModeCodeEnum getModeCode() { - return modeCode; - } - - public OsdDock setModeCode(DockModeCodeEnum modeCode) { - this.modeCode = modeCode; - return this; - } - - public CoverStateEnum getCoverState() { - return coverState; - } - - public OsdDock setCoverState(CoverStateEnum coverState) { - this.coverState = coverState; - return this; - } - - public Boolean getSupplementLightState() { - return supplementLightState; - } - - public OsdDock setSupplementLightState(Boolean supplementLightState) { - this.supplementLightState = supplementLightState; - return this; - } - - public Boolean getEmergencyStopState() { - return emergencyStopState; - } - - public OsdDock setEmergencyStopState(Boolean emergencyStopState) { - this.emergencyStopState = emergencyStopState; - return this; - } - - public AirConditioner getAirConditioner() { - return airConditioner; - } - - public OsdDock setAirConditioner(AirConditioner airConditioner) { - this.airConditioner = airConditioner; - return this; - } - - public BatteryStoreModeEnum getBatteryStoreMode() { - return batteryStoreMode; - } - - public OsdDock setBatteryStoreMode(BatteryStoreModeEnum batteryStoreMode) { - this.batteryStoreMode = batteryStoreMode; - return this; - } - - public Boolean getAlarmState() { - return alarmState; - } - - public OsdDock setAlarmState(Boolean alarmState) { - this.alarmState = alarmState; - return this; - } - - public PutterStateEnum getPutterState() { - return putterState; - } - - public OsdDock setPutterState(PutterStateEnum putterState) { - this.putterState = putterState; - return this; - } - - public DockSubDevice getSubDevice() { - return subDevice; - } - - public OsdDock setSubDevice(DockSubDevice subDevice) { - this.subDevice = subDevice; - return this; - } - - public Integer getJobNumber() { - return jobNumber; - } - - public OsdDock setJobNumber(Integer jobNumber) { - this.jobNumber = jobNumber; - return this; - } - - public Long getAccTime() { - return accTime; - } - - public OsdDock setAccTime(Long accTime) { - this.accTime = accTime; - return this; - } - - public Long getActivationTime() { - return activationTime; - } - - public OsdDock setActivationTime(Long activationTime) { - this.activationTime = activationTime; - return this; - } - - public OsdDockMaintainStatus getMaintainStatus() { - return maintainStatus; - } - - public OsdDock setMaintainStatus(OsdDockMaintainStatus maintainStatus) { - this.maintainStatus = maintainStatus; - return this; - } - - public Integer getElectricSupplyVoltage() { - return electricSupplyVoltage; - } - - public OsdDock setElectricSupplyVoltage(Integer electricSupplyVoltage) { - this.electricSupplyVoltage = electricSupplyVoltage; - return this; - } - - public Integer getWorkingVoltage() { - return workingVoltage; - } - - public OsdDock setWorkingVoltage(Integer workingVoltage) { - this.workingVoltage = workingVoltage; - return this; - } - - public Integer getWorkingCurrent() { - return workingCurrent; - } - - public OsdDock setWorkingCurrent(Integer workingCurrent) { - this.workingCurrent = workingCurrent; - return this; - } - - public BackupBattery getBackupBattery() { - return backupBattery; - } - - public OsdDock setBackupBattery(BackupBattery backupBattery) { - this.backupBattery = backupBattery; - return this; - } - - public DroneBatteryMaintenanceInfo getDroneBatteryMaintenanceInfo() { - return droneBatteryMaintenanceInfo; - } - - public OsdDock setDroneBatteryMaintenanceInfo(DroneBatteryMaintenanceInfo droneBatteryMaintenanceInfo) { - this.droneBatteryMaintenanceInfo = droneBatteryMaintenanceInfo; - return this; - } - - public FlighttaskStepCodeEnum getFlighttaskStepCode() { - return flighttaskStepCode; - } - - public OsdDock setFlighttaskStepCode(FlighttaskStepCodeEnum flighttaskStepCode) { - this.flighttaskStepCode = flighttaskStepCode; - return this; - } - - public Integer getFlighttaskPrepareCapacity() { - return flighttaskPrepareCapacity; - } - - public OsdDock setFlighttaskPrepareCapacity(Integer flighttaskPrepareCapacity) { - this.flighttaskPrepareCapacity = flighttaskPrepareCapacity; - return this; - } - - public MediaFileDetail getMediaFileDetail() { - return mediaFileDetail; - } - - public OsdDock setMediaFileDetail(MediaFileDetail mediaFileDetail) { - this.mediaFileDetail = mediaFileDetail; - return this; - } - - public WirelessLink getWirelessLink() { - return wirelessLink; - } - - public OsdDock setWirelessLink(WirelessLink wirelessLink) { - this.wirelessLink = wirelessLink; - return this; - } - - public DrcStateEnum getDrcState() { - return drcState; - } - - public OsdDock setDrcState(DrcStateEnum drcState) { - this.drcState = drcState; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/OsdDockDrone.java b/src/main/java/com/dji/sdk/cloudapi/device/OsdDockDrone.java deleted file mode 100644 index adc58d0..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/OsdDockDrone.java +++ /dev/null @@ -1,469 +0,0 @@ -package com.dji.sdk.cloudapi.device; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * @author sean.zhou - * @version 0.1 - * @date 2021/11/23 - */ -public class OsdDockDrone { - - private Float attitudeHead; - - private Double attitudePitch; - - private Double attitudeRoll; - - private Float elevation; - - private DroneBattery battery; - - private String firmwareVersion; - - private GearEnum gear; - - private Float height; - - private Float homeDistance; - - private Float horizontalSpeed; - - private Float latitude; - - private Float longitude; - - private DroneModeCodeEnum modeCode; - - private Double totalFlightDistance; - - private Float totalFlightTime; - - private Float verticalSpeed; - - private WindDirectionEnum windDirection; - - private Float windSpeed; - - private DronePositionState positionState; - - @JsonProperty(PayloadModelConst.PAYLOAD_KEY) - private List payloads; - - private Storage storage; - - private SwitchActionEnum nightLightsState; - - private Integer heightLimit; - - private DockDistanceLimitStatus distanceLimitStatus; - - private ObstacleAvoidance obstacleAvoidance; - - private Long activationTime; - - private List cameras; - - private RcLostActionEnum rcLostAction; - - private Integer rthAltitude; - - private Integer totalFlightSorties; - - private ExitWaylineWhenRcLostEnum exitWaylineWhenRcLost; - - private String country; - - private Boolean ridState; - - @JsonProperty("is_near_area_limit") - private Boolean nearAreaLimit; - - @JsonProperty("is_near_height_limit") - private Boolean nearHeightLimit; - - private OsdDroneMaintainStatus maintainStatus; - - private String trackId; - - public OsdDockDrone() { - } - - @Override - public String toString() { - return "OsdDockDrone{" + - "attitudeHead=" + attitudeHead + - ", attitudePitch=" + attitudePitch + - ", attitudeRoll=" + attitudeRoll + - ", elevation=" + elevation + - ", battery=" + battery + - ", firmwareVersion='" + firmwareVersion + '\'' + - ", gear=" + gear + - ", height=" + height + - ", homeDistance=" + homeDistance + - ", horizontalSpeed=" + horizontalSpeed + - ", latitude=" + latitude + - ", longitude=" + longitude + - ", modeCode=" + modeCode + - ", totalFlightDistance=" + totalFlightDistance + - ", totalFlightTime=" + totalFlightTime + - ", verticalSpeed=" + verticalSpeed + - ", windDirection=" + windDirection + - ", windSpeed=" + windSpeed + - ", positionState=" + positionState + - ", payloads=" + payloads + - ", storage=" + storage + - ", nightLightsState=" + nightLightsState + - ", heightLimit=" + heightLimit + - ", distanceLimitStatus=" + distanceLimitStatus + - ", obstacleAvoidance=" + obstacleAvoidance + - ", activationTime=" + activationTime + - ", cameras=" + cameras + - ", rcLostAction=" + rcLostAction + - ", rthAltitude=" + rthAltitude + - ", totalFlightSorties=" + totalFlightSorties + - ", exitWaylineWhenRcLost=" + exitWaylineWhenRcLost + - ", country='" + country + '\'' + - ", ridState=" + ridState + - ", nearAreaLimit=" + nearAreaLimit + - ", nearHeightLimit=" + nearHeightLimit + - ", maintainStatus=" + maintainStatus + - ", trackId='" + trackId + '\'' + - '}'; - } - - public Float getAttitudeHead() { - return attitudeHead; - } - - public OsdDockDrone setAttitudeHead(Float attitudeHead) { - this.attitudeHead = attitudeHead; - return this; - } - - public Double getAttitudePitch() { - return attitudePitch; - } - - public OsdDockDrone setAttitudePitch(Double attitudePitch) { - this.attitudePitch = attitudePitch; - return this; - } - - public Double getAttitudeRoll() { - return attitudeRoll; - } - - public OsdDockDrone setAttitudeRoll(Double attitudeRoll) { - this.attitudeRoll = attitudeRoll; - return this; - } - - public Float getElevation() { - return elevation; - } - - public OsdDockDrone setElevation(Float elevation) { - this.elevation = elevation; - return this; - } - - public DroneBattery getBattery() { - return battery; - } - - public OsdDockDrone setBattery(DroneBattery battery) { - this.battery = battery; - return this; - } - - public String getFirmwareVersion() { - return firmwareVersion; - } - - public OsdDockDrone setFirmwareVersion(String firmwareVersion) { - this.firmwareVersion = firmwareVersion; - return this; - } - - public GearEnum getGear() { - return gear; - } - - public OsdDockDrone setGear(GearEnum gear) { - this.gear = gear; - return this; - } - - public Float getHeight() { - return height; - } - - public OsdDockDrone setHeight(Float height) { - this.height = height; - return this; - } - - public Float getHomeDistance() { - return homeDistance; - } - - public OsdDockDrone setHomeDistance(Float homeDistance) { - this.homeDistance = homeDistance; - return this; - } - - public Float getHorizontalSpeed() { - return horizontalSpeed; - } - - public OsdDockDrone setHorizontalSpeed(Float horizontalSpeed) { - this.horizontalSpeed = horizontalSpeed; - return this; - } - - public Float getLatitude() { - return latitude; - } - - public OsdDockDrone setLatitude(Float latitude) { - this.latitude = latitude; - return this; - } - - public Float getLongitude() { - return longitude; - } - - public OsdDockDrone setLongitude(Float longitude) { - this.longitude = longitude; - return this; - } - - public DroneModeCodeEnum getModeCode() { - return modeCode; - } - - public OsdDockDrone setModeCode(DroneModeCodeEnum modeCode) { - this.modeCode = modeCode; - return this; - } - - public Double getTotalFlightDistance() { - return totalFlightDistance; - } - - public OsdDockDrone setTotalFlightDistance(Double totalFlightDistance) { - this.totalFlightDistance = totalFlightDistance; - return this; - } - - public Float getTotalFlightTime() { - return totalFlightTime; - } - - public OsdDockDrone setTotalFlightTime(Float totalFlightTime) { - this.totalFlightTime = totalFlightTime; - return this; - } - - public Float getVerticalSpeed() { - return verticalSpeed; - } - - public OsdDockDrone setVerticalSpeed(Float verticalSpeed) { - this.verticalSpeed = verticalSpeed; - return this; - } - - public WindDirectionEnum getWindDirection() { - return windDirection; - } - - public OsdDockDrone setWindDirection(WindDirectionEnum windDirection) { - this.windDirection = windDirection; - return this; - } - - public Float getWindSpeed() { - return windSpeed; - } - - public OsdDockDrone setWindSpeed(Float windSpeed) { - this.windSpeed = windSpeed; - return this; - } - - public DronePositionState getPositionState() { - return positionState; - } - - public OsdDockDrone setPositionState(DronePositionState positionState) { - this.positionState = positionState; - return this; - } - - public List getPayloads() { - return payloads; - } - - public OsdDockDrone setPayloads(List payloads) { - this.payloads = payloads; - return this; - } - - public Storage getStorage() { - return storage; - } - - public OsdDockDrone setStorage(Storage storage) { - this.storage = storage; - return this; - } - - public SwitchActionEnum getNightLightsState() { - return nightLightsState; - } - - public OsdDockDrone setNightLightsState(SwitchActionEnum nightLightsState) { - this.nightLightsState = nightLightsState; - return this; - } - - public Integer getHeightLimit() { - return heightLimit; - } - - public OsdDockDrone setHeightLimit(Integer heightLimit) { - this.heightLimit = heightLimit; - return this; - } - - public DockDistanceLimitStatus getDistanceLimitStatus() { - return distanceLimitStatus; - } - - public OsdDockDrone setDistanceLimitStatus(DockDistanceLimitStatus distanceLimitStatus) { - this.distanceLimitStatus = distanceLimitStatus; - return this; - } - - public ObstacleAvoidance getObstacleAvoidance() { - return obstacleAvoidance; - } - - public OsdDockDrone setObstacleAvoidance(ObstacleAvoidance obstacleAvoidance) { - this.obstacleAvoidance = obstacleAvoidance; - return this; - } - - public Long getActivationTime() { - return activationTime; - } - - public OsdDockDrone setActivationTime(Long activationTime) { - this.activationTime = activationTime; - return this; - } - - public List getCameras() { - return cameras; - } - - public OsdDockDrone setCameras(List cameras) { - this.cameras = cameras; - return this; - } - - public RcLostActionEnum getRcLostAction() { - return rcLostAction; - } - - public OsdDockDrone setRcLostAction(RcLostActionEnum rcLostAction) { - this.rcLostAction = rcLostAction; - return this; - } - - public Integer getRthAltitude() { - return rthAltitude; - } - - public OsdDockDrone setRthAltitude(Integer rthAltitude) { - this.rthAltitude = rthAltitude; - return this; - } - - public Integer getTotalFlightSorties() { - return totalFlightSorties; - } - - public OsdDockDrone setTotalFlightSorties(Integer totalFlightSorties) { - this.totalFlightSorties = totalFlightSorties; - return this; - } - - public ExitWaylineWhenRcLostEnum getExitWaylineWhenRcLost() { - return exitWaylineWhenRcLost; - } - - public OsdDockDrone setExitWaylineWhenRcLost(ExitWaylineWhenRcLostEnum exitWaylineWhenRcLost) { - this.exitWaylineWhenRcLost = exitWaylineWhenRcLost; - return this; - } - - public String getCountry() { - return country; - } - - public OsdDockDrone setCountry(String country) { - this.country = country; - return this; - } - - public Boolean getRidState() { - return ridState; - } - - public OsdDockDrone setRidState(Boolean ridState) { - this.ridState = ridState; - return this; - } - - public Boolean getNearAreaLimit() { - return nearAreaLimit; - } - - public OsdDockDrone setNearAreaLimit(Boolean nearAreaLimit) { - this.nearAreaLimit = nearAreaLimit; - return this; - } - - public Boolean getNearHeightLimit() { - return nearHeightLimit; - } - - public OsdDockDrone setNearHeightLimit(Boolean nearHeightLimit) { - this.nearHeightLimit = nearHeightLimit; - return this; - } - - public OsdDroneMaintainStatus getMaintainStatus() { - return maintainStatus; - } - - public OsdDockDrone setMaintainStatus(OsdDroneMaintainStatus maintainStatus) { - this.maintainStatus = maintainStatus; - return this; - } - - public String getTrackId() { - return trackId; - } - - public OsdDockDrone setTrackId(String trackId) { - this.trackId = trackId; - return this; - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/cloudapi/device/PayloadModelConst.java b/src/main/java/com/dji/sdk/cloudapi/device/PayloadModelConst.java deleted file mode 100644 index a464b72..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/PayloadModelConst.java +++ /dev/null @@ -1,38 +0,0 @@ -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 getAllModelWithPosition() { - Set 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 getAllIndexWithPosition() { - Set 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()); - } - -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/RcFirmwareVersion.java b/src/main/java/com/dji/sdk/cloudapi/device/RcFirmwareVersion.java deleted file mode 100644 index f9f3a19..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/RcFirmwareVersion.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.dji.sdk.cloudapi.device; - -/** - * @author sean - * @version 1.0 - * @date 2022/4/28 - */ -public class RcFirmwareVersion { - - private String firmwareVersion; - - public RcFirmwareVersion() { - } - - @Override - public String toString() { - return "RcFirmwareVersion{" + - "firmwareVersion='" + firmwareVersion + '\'' + - '}'; - } - - public String getFirmwareVersion() { - return firmwareVersion; - } - - public RcFirmwareVersion setFirmwareVersion(String firmwareVersion) { - this.firmwareVersion = firmwareVersion; - return this; - } - -} diff --git a/src/main/java/com/dji/sdk/cloudapi/device/api/AbstractDeviceService.java b/src/main/java/com/dji/sdk/cloudapi/device/api/AbstractDeviceService.java deleted file mode 100644 index 5db7a9d..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/device/api/AbstractDeviceService.java +++ /dev/null @@ -1,177 +0,0 @@ -package com.dji.sdk.cloudapi.device.api; - -import com.dji.sdk.cloudapi.device.*; -import com.dji.sdk.mqtt.ChannelName; -import com.dji.sdk.mqtt.MqttReply; -import com.dji.sdk.mqtt.osd.TopicOsdRequest; -import com.dji.sdk.mqtt.state.TopicStateRequest; -import com.dji.sdk.mqtt.status.TopicStatusRequest; -import com.dji.sdk.mqtt.status.TopicStatusResponse; -import org.springframework.integration.annotation.ServiceActivator; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageHeaders; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/30 - */ -public class AbstractDeviceService { - - /** - * osd dock - * @param request data - * @param headers The headers for a {@link Message}. - * @return status_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_OSD_DOCK) - public void osdDock(TopicOsdRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("osdDock not implemented"); - } - - /** - * osd dock drone - * @param request data - * @param headers The headers for a {@link Message}. - * @return status_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_OSD_DOCK_DRONE) - public void osdDockDrone(TopicOsdRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("osdDockDrone not implemented"); - } - - /** - * osd remote control - * @param request data - * @param headers The headers for a {@link Message}. - * @return status_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_OSD_RC) - public void osdRemoteControl(TopicOsdRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("osdRemoteControl not implemented"); - } - - /** - * osd remote control drone - * @param request data - * @param headers The headers for a {@link Message}. - * @return status_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_OSD_RC_DRONE) - public void osdRcDrone(TopicOsdRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("osdRcDrone not implemented"); - } - - /** - * Gateway device + sub device online - * @param request data - * @param headers The headers for a {@link Message}. - * @return status_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATUS_ONLINE, outputChannel = ChannelName.OUTBOUND_STATUS) - public TopicStatusResponse updateTopoOnline(TopicStatusRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("updateTopoOnline not implemented"); - } - - /** - * Sub device offline - * @param request data - * @param headers The headers for a {@link Message}. - * @return status_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATUS_OFFLINE, outputChannel = ChannelName.OUTBOUND_STATUS) - public TopicStatusResponse updateTopoOffline(TopicStatusRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("updateTopoOffline not implemented"); - } - - /** - * Firmware version update for dock and drone - * @param request data - * @param headers The headers for a {@link Message}. - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_FIRMWARE_VERSION) - public void dockFirmwareVersionUpdate(TopicStateRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("dockFirmwareVersionUpdate not implemented"); - } - - /** - * Firmware version update for remote control and drone - * @param request data - * @param headers The headers for a {@link Message}. - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_RC_FIRMWARE_VERSION) - public void rcFirmwareVersionUpdate(TopicStateRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("rcFirmwareVersionUpdate not implemented"); - } - - /** - * Drone control source update for dock and drone - * @param request data - * @param headers The headers for a {@link Message}. - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_CONTROL_SOURCE) - public void dockControlSourceUpdate(TopicStateRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("dockControlSourceUpdate not implemented"); - } - - /** - * Drone control source update for remote control and drone - * @param request data - * @param headers The headers for a {@link Message}. - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_RC_CONTROL_SOURCE) - public void rcControlSourceUpdate(TopicStateRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("rcControlSourceUpdate not implemented"); - } - - /** - * Live status update for dock and drone - * @param request data - * @param headers The headers for a {@link Message}. - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_LIVE_STATUS) - public void dockLiveStatusUpdate(TopicStateRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("dockLiveStatusUpdate not implemented"); - } - - /** - * Live status source update for remote control and drone - * @param request data - * @param headers The headers for a {@link Message}. - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_RC_LIVE_STATUS) - public void rcLiveStatusUpdate(TopicStateRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("rcLiveStatusUpdate not implemented"); - } - - /** - * Payload firmware version update for remote control and drone - * @param request data - * @param headers The headers for a {@link Message}. - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_RC_PAYLOAD_FIRMWARE) - public void rcPayloadFirmwareVersionUpdate(TopicStateRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("rcPayloadFirmwareVersionUpdate not implemented"); - } - - /** - * Wpmz firmware version update for drone - * @param request data - * @param headers The headers for a {@link Message}. - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_WPMZ_VERSION) - public void dockWpmzVersionUpdate(TopicStateRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("dockWpmzVersionUpdate not implemented"); - } - - /** - * Styles supported by the IR palette - * @param request data - * @param headers The headers for a {@link Message}. - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_DOCK_PAYLOAD) - public void dockPayload(TopicStateRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("dockPayload not implemented"); - } - -} diff --git a/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateRequest.java b/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateRequest.java deleted file mode 100644 index 1c43792..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/firmware/OtaCreateRequest.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.dji.sdk.cloudapi.firmware; - -import com.dji.sdk.common.BaseModel; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.List; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/28 - */ -public class OtaCreateRequest extends BaseModel { - - @Size(min = 1, max = 2) - @NotNull - @Valid - private List devices; - - public OtaCreateRequest() { - } - - @Override - public String toString() { - return "OtaCreateRequest{" + - "devices=" + devices + - '}'; - } - - public List getDevices() { - return devices; - } - - public OtaCreateRequest setDevices(List devices) { - this.devices = devices; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStartPushRequest.java b/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStartPushRequest.java deleted file mode 100644 index 8748869..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/livestream/LiveStartPushRequest.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.dji.sdk.cloudapi.livestream; - -import com.dji.sdk.cloudapi.device.VideoId; -import com.dji.sdk.common.BaseModel; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** - * @author sean - * @version 1.7 - * @date 2023/5/23 - */ -public class LiveStartPushRequest extends BaseModel { - - @NotNull - private UrlTypeEnum urlType; - - /** - * RTMP: (rtmp://xxxxxxx) Example: rtmp://192.168.1.1:8080/live - * RTSP:(uerName&password&port) Example: userName=dji-cloud-api&password=123456&port=8080 - * GB28181:(serverIP&serverPort&serverID&agentID&agentPassword&localPort&channel) - * Example: serverIP=192.168.1.1&serverPort=8080&serverID=34000000000000000000&agentID= - * 300000000010000000000&agentPassword=0000000&localPort=7060&channel=340000000000000000000 - * AGORA:(channel&sn&token&uid) - * Example: channel=1ZNDH360010162_39-0-7&sn=1ZNDH360010162&token=006dca67721582a48768ec4d8 - * 17b7b25a86IAB4cw2JgN6iX8BpTPdc3e4S1Iendz94IFJ56aSXKvzAJei27MqF2zyCIgCLIIoBt41+YAQAAQC3jX - * 5gAgC3jX5gAwC3jX5gBAC3jX5g&uid=50000 - * Notice: The token generated by Shengwang may have special characters such as '+' ' ', - * and need to do url encode, otherwise there will be a parsing error on the PILOT side - */ - @NotBlank - private String url; - - /** - * The format is #{uav_sn}/#{camera_id}/#{video_index}, - * drone serial number/payload and mounted location enumeration value/payload lens numbering - */ - @NotNull - private VideoId videoId; - - @NotNull - private VideoQualityEnum videoQuality; - - public LiveStartPushRequest() { - } - - @Override - public String toString() { - return "LiveStartPushRequest{" + - "urlType=" + urlType + - ", url='" + url + '\'' + - ", videoId=" + videoId + - ", videoQuality=" + videoQuality + - '}'; - } - - public UrlTypeEnum getUrlType() { - return urlType; - } - - public LiveStartPushRequest setUrlType(UrlTypeEnum urlType) { - this.urlType = urlType; - return this; - } - - public String getUrl() { - return url; - } - - public LiveStartPushRequest setUrl(String url) { - this.url = url; - return this; - } - - public VideoId getVideoId() { - return videoId; - } - - public LiveStartPushRequest setVideoId(VideoId videoId) { - this.videoId = videoId; - return this; - } - - public VideoQualityEnum getVideoQuality() { - return videoQuality; - } - - public LiveStartPushRequest setVideoQuality(VideoQualityEnum videoQuality) { - this.videoQuality = videoQuality; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityCamera.java b/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityCamera.java deleted file mode 100644 index 7ca3b66..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityCamera.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.dji.sdk.cloudapi.livestream; - -import com.dji.sdk.cloudapi.device.PayloadIndex; - -import java.util.List; - -/** - * @author sean.zhou - * @date 2021/11/18 - * @version 0.1 - */ -public class RcLiveCapacityCamera { - - /** - * Total number of video streams that can be used for livestreaming - * Total number of video streams that the camera can live stream - */ - private Integer availableVideoNumber; - - /** - * Maximum number of video streams that the camera can live stream at the same time. - */ - private Integer coexistVideoNumberMax; - - /** - * Camera index, composed of product type enumeration and gimbal index. - */ - private PayloadIndex cameraIndex; - - private List videoList; - - public RcLiveCapacityCamera() { - } - - @Override - public String toString() { - return "CapacityCameraReceiver{" + - "availableVideoNumber=" + availableVideoNumber + - ", coexistVideoNumberMax=" + coexistVideoNumberMax + - ", cameraIndex=" + cameraIndex + - ", videoList=" + videoList + - '}'; - } - - public Integer getAvailableVideoNumber() { - return availableVideoNumber; - } - - public RcLiveCapacityCamera setAvailableVideoNumber(Integer availableVideoNumber) { - this.availableVideoNumber = availableVideoNumber; - return this; - } - - public Integer getCoexistVideoNumberMax() { - return coexistVideoNumberMax; - } - - public RcLiveCapacityCamera setCoexistVideoNumberMax(Integer coexistVideoNumberMax) { - this.coexistVideoNumberMax = coexistVideoNumberMax; - return this; - } - - public PayloadIndex getCameraIndex() { - return cameraIndex; - } - - public RcLiveCapacityCamera setCameraIndex(PayloadIndex cameraIndex) { - this.cameraIndex = cameraIndex; - return this; - } - - public List getVideoList() { - return videoList; - } - - public RcLiveCapacityCamera setVideoList(List videoList) { - this.videoList = videoList; - return this; - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityDevice.java b/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityDevice.java deleted file mode 100644 index 831bfc4..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityDevice.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.dji.sdk.cloudapi.livestream; - -import java.util.List; - -/** - * @author sean.zhou - * @date 2021/11/18 - * @version 0.1 - */ -public class RcLiveCapacityDevice { - - /** - * Device serial number - */ - private String sn; - - /** - * Total number of video streams that can be used for livestreaming - * Total number of video streams used for livestreaming that belongs to devices. - */ - private Integer availableVideoNumber; - - /** - * Maximum number of video streams that can be used for livestreaming at the same time - */ - private Integer coexistVideoNumberMax; - - /** - * Camera list on the device - */ - private List cameraList; - - public RcLiveCapacityDevice() { - } - - @Override - public String toString() { - return "CapacityDeviceReceiver{" + - "sn='" + sn + '\'' + - ", availableVideoNumber=" + availableVideoNumber + - ", coexistVideoNumberMax=" + coexistVideoNumberMax + - ", cameraList=" + cameraList + - '}'; - } - - public String getSn() { - return sn; - } - - public RcLiveCapacityDevice setSn(String sn) { - this.sn = sn; - return this; - } - - public Integer getAvailableVideoNumber() { - return availableVideoNumber; - } - - public RcLiveCapacityDevice setAvailableVideoNumber(Integer availableVideoNumber) { - this.availableVideoNumber = availableVideoNumber; - return this; - } - - public Integer getCoexistVideoNumberMax() { - return coexistVideoNumberMax; - } - - public RcLiveCapacityDevice setCoexistVideoNumberMax(Integer coexistVideoNumberMax) { - this.coexistVideoNumberMax = coexistVideoNumberMax; - return this; - } - - public List getCameraList() { - return cameraList; - } - - public RcLiveCapacityDevice setCameraList(List cameraList) { - this.cameraList = cameraList; - return this; - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityVideo.java b/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityVideo.java deleted file mode 100644 index 640a631..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/livestream/RcLiveCapacityVideo.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.dji.sdk.cloudapi.livestream; - -/** - * @author sean.zhou - * @date 2021/11/18 - * @version 0.1 - */ -public class RcLiveCapacityVideo { - - private String videoIndex; - - private VideoTypeEnum videoType; - - public RcLiveCapacityVideo() { - } - - @Override - public String toString() { - return "CapacityVideoReceiver{" + - "videoIndex='" + videoIndex + '\'' + - ", videoType=" + videoType + - '}'; - } - - public String getVideoIndex() { - return videoIndex; - } - - public RcLiveCapacityVideo setVideoIndex(String videoIndex) { - this.videoIndex = videoIndex; - return this; - } - - public VideoTypeEnum getVideoType() { - return videoType; - } - - public RcLiveCapacityVideo setVideoType(VideoTypeEnum videoType) { - this.videoType = videoType; - return this; - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/cloudapi/livestream/UrlTypeEnum.java b/src/main/java/com/dji/sdk/cloudapi/livestream/UrlTypeEnum.java deleted file mode 100644 index dc59a10..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/livestream/UrlTypeEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.dji.sdk.cloudapi.livestream; - -import com.dji.sdk.exception.CloudSDKException; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -import java.util.Arrays; - -/** - * @author sean.zhou - * @version 0.1 - * @date 2021/11/22 - */ -public enum UrlTypeEnum { - - AGORA(0), - - RTMP(1), - - RTSP(2), - - GB28181(3); - - private final int type; - - UrlTypeEnum(int type) { - this.type = type; - } - - @JsonValue - public int getType() { - return type; - } - - @JsonCreator - public static UrlTypeEnum find(int type) { - return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny() - .orElseThrow(() -> new CloudSDKException(UrlTypeEnum.class, type)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListRequest.java b/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListRequest.java deleted file mode 100644 index 229fd4c..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadListRequest.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.dji.sdk.cloudapi.log; - -import com.dji.sdk.common.BaseModel; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.List; - -/** - * @author sean - * @version 1.7 - * @date 2023/5/23 - */ -public class FileUploadListRequest extends BaseModel { - - /** - * Filter list of file - **/ - @NotNull - @Valid - @Size(min = 1, max = 2) - private List moduleList; - - public FileUploadListRequest() { - } - - @Override - public String toString() { - return "FileUploadListRequest{" + - "moduleList=" + moduleList + - '}'; - } - - public List getModuleList() { - return moduleList; - } - - public FileUploadListRequest setModuleList(List moduleList) { - this.moduleList = moduleList; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartFile.java b/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartFile.java deleted file mode 100644 index 751e38f..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartFile.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.dji.sdk.cloudapi.log; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * @author sean - * @version 1.2 - * @date 2022/9/7 - */ -public class FileUploadStartFile { - - @NotNull - private String deviceSn; - - @NotNull - @Valid - private List list; - - @NotNull - private LogModuleEnum module; - - @NotNull - private String objectKey; - - public FileUploadStartFile() { - } - - @Override - public String toString() { - return "FileUploadStartFile{" + - "deviceSn='" + deviceSn + '\'' + - ", list=" + list + - ", module=" + module + - ", objectKey='" + objectKey + '\'' + - '}'; - } - - public String getDeviceSn() { - return deviceSn; - } - - public FileUploadStartFile setDeviceSn(String deviceSn) { - this.deviceSn = deviceSn; - return this; - } - - public List getList() { - return list; - } - - public FileUploadStartFile setList(List list) { - this.list = list; - return this; - } - - public LogModuleEnum getModule() { - return module; - } - - public FileUploadStartFile setModule(LogModuleEnum module) { - this.module = module; - return this; - } - - public String getObjectKey() { - return objectKey; - } - - public FileUploadStartFile setObjectKey(String objectKey) { - this.objectKey = objectKey; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartParam.java b/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartParam.java deleted file mode 100644 index df0e6af..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadStartParam.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.dji.sdk.cloudapi.log; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.List; - -/** - * @author sean - * @version 1.2 - * @date 2022/9/7 - */ -public class FileUploadStartParam { - - @NotNull - @Size(min = 1, max = 2) - @Valid - private List files; - - public FileUploadStartParam() { - } - - @Override - public String toString() { - return "FileUploadStartParam{" + - "files=" + files + - '}'; - } - - public List getFiles() { - return files; - } - - public FileUploadStartParam setFiles(List files) { - this.files = files; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateRequest.java b/src/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateRequest.java deleted file mode 100644 index ce62daf..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/log/FileUploadUpdateRequest.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.dji.sdk.cloudapi.log; - -import com.dji.sdk.common.BaseModel; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.List; - -/** - * @author sean - * @version 1.7 - * @date 2023/5/23 - */ -public class FileUploadUpdateRequest extends BaseModel { - - /** - * Filter list of file - **/ - @NotNull - @Valid - @Size(min = 1, max = 2) - private List moduleList; - - @NotNull - private FileUploadUpdateStatusEnum status; - - public FileUploadUpdateRequest() { - } - - @Override - public String toString() { - return "FileUploadUpdateRequest{" + - "moduleList=" + moduleList + - ", status=" + status + - '}'; - } - - public List getModuleList() { - return moduleList; - } - - public FileUploadUpdateRequest setModuleList(List moduleList) { - this.moduleList = moduleList; - return this; - } - - public FileUploadUpdateStatusEnum getStatus() { - return status; - } - - public FileUploadUpdateRequest setStatus(FileUploadUpdateStatusEnum status) { - this.status = status; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/ElementContent.java b/src/main/java/com/dji/sdk/cloudapi/map/ElementContent.java deleted file mode 100644 index b6aefbe..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/map/ElementContent.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.dji.sdk.cloudapi.map; - -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/30 - */ -@Schema(description = "element content") -public class ElementContent { - - @Schema(defaultValue = "Feature", allowableValues = "Feature") - @NotNull - private String type = "Feature"; - - @NotNull - @Valid - private ElementProperty properties; - - @Valid - @NotNull - private ElementGeometryType geometry; - - public ElementContent() { - } - - @Override - public String toString() { - return "ElementContent{" + - "type='" + type + '\'' + - ", properties=" + properties + - ", geometry=" + geometry + - '}'; - } - - public String getType() { - return type; - } - - public ElementContent setType(String type) { - this.type = type; - return this; - } - - public ElementProperty getProperties() { - return properties; - } - - public ElementContent setProperties(ElementProperty properties) { - this.properties = properties; - return this; - } - - public ElementGeometryType getGeometry() { - return geometry; - } - - public ElementContent setGeometry(ElementGeometryType geometry) { - this.geometry = geometry; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/ElementCoordinate.java b/src/main/java/com/dji/sdk/cloudapi/map/ElementCoordinate.java deleted file mode 100644 index 8932943..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/map/ElementCoordinate.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.dji.sdk.cloudapi.map; - -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.NotNull; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/30 - */ -@Schema(description = "The coordinates of the element, the coordinate system is WGS84") -public class ElementCoordinate { - - @Schema(description = "longitude") - @NotNull - private Double longitude; - - @Schema(description = "latitude") - @NotNull - private Double latitude; - - @Schema(description = "altitude") - private Double altitude; - - public ElementCoordinate() { - } - - @Override - public String toString() { - return "ElementCoordinate{" + - "longitude=" + longitude + - ", latitude=" + latitude + - ", altitude=" + altitude + - '}'; - } - - public Double getLongitude() { - return longitude; - } - - public ElementCoordinate setLongitude(Double longitude) { - this.longitude = longitude; - return this; - } - - public Double getLatitude() { - return latitude; - } - - public ElementCoordinate setLatitude(Double latitude) { - this.latitude = latitude; - return this; - } - - public Double getAltitude() { - return altitude; - } - - public ElementCoordinate setAltitude(Double altitude) { - this.altitude = altitude; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/ElementGeometryType.java b/src/main/java/com/dji/sdk/cloudapi/map/ElementGeometryType.java deleted file mode 100644 index 0086762..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/map/ElementGeometryType.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.dji.sdk.cloudapi.map; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import io.swagger.v3.oas.annotations.media.Schema; - -import java.util.List; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/30 - */ -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", - include = JsonTypeInfo.As.EXISTING_PROPERTY, defaultImpl = ElementGeometryType.class) -@JsonSubTypes({ - @JsonSubTypes.Type(value = ElementPointGeometry.class, name = "Point"), - @JsonSubTypes.Type(value = ElementLineStringGeometry.class, name = "LineString"), - @JsonSubTypes.Type(value = ElementPolygonGeometry.class, name = "Polygon") -}) -@Schema(oneOf = {ElementPointGeometry.class, ElementLineStringGeometry.class, ElementPolygonGeometry.class}) -public abstract class ElementGeometryType { - - private String type; - - ElementGeometryType(String type) { - this.type = type; - } - - public ElementGeometryType() { - } - - public String getType() { - return type; - } - - public ElementGeometryType setType(String type) { - this.type = type; - return this; - } - - /** - * Convert coordinate data into objects and then add them to the collection. - * @return - */ - public abstract List convertToList(); - - /** - * Converts coordinates in a collection of objects to a specific type. - * @param coordinateList - */ - public abstract void adapterCoordinateType(List coordinateList); -} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/ElementLineStringGeometry.java b/src/main/java/com/dji/sdk/cloudapi/map/ElementLineStringGeometry.java deleted file mode 100644 index 5aef1cf..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/map/ElementLineStringGeometry.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.dji.sdk.cloudapi.map; - -import com.dji.sdk.exception.CloudSDKErrorEnum; -import com.dji.sdk.exception.CloudSDKException; -import io.swagger.v3.oas.annotations.media.Schema; -import org.springframework.util.CollectionUtils; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/30 - */ -@Schema(description = "line geometry") -public class ElementLineStringGeometry extends ElementGeometryType { - - @Schema(example = "LineString") - @NotNull - private String type = ElementResourceTypeEnum.LINE_STRING.getTypeName(); - - @Schema(example = "[[113.943109, 22.577378]]") - @NotNull - @Size(min = 2) - private Double[][] coordinates; - - public ElementLineStringGeometry() { - super(); - } - - @Override - public List convertToList() { - if (this.coordinates.length < 2) { - throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER); - } - List coordinateList = new ArrayList<>(); - for (Double[] coordinate : this.coordinates) { - coordinateList.add(new ElementCoordinate() - .setLongitude(coordinate[0]) - .setLatitude(coordinate[1])); - } - return coordinateList; - } - - @Override - public void adapterCoordinateType(List coordinateList) { - if (CollectionUtils.isEmpty(coordinateList) || coordinateList.size() < 2) { - throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER); - } - this.coordinates = new Double[coordinateList.size()][2]; - for (int i = 0; i < this.coordinates.length; i++) { - this.coordinates[i][0] = coordinateList.get(i).getLongitude(); - this.coordinates[i][1] = coordinateList.get(i).getLatitude(); - } - } - - @Override - public String toString() { - return "ElementLineStringGeometry{" + - "coordinates=" + Arrays.toString(coordinates) + - '}'; - } - - public Double[][] getCoordinates() { - return coordinates; - } - - public ElementLineStringGeometry setCoordinates(Double[][] coordinates) { - this.coordinates = coordinates; - return this; - } - - @Override - public String getType() { - return type; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/ElementPointGeometry.java b/src/main/java/com/dji/sdk/cloudapi/map/ElementPointGeometry.java deleted file mode 100644 index 5bed461..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/map/ElementPointGeometry.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.dji.sdk.cloudapi.map; - -import com.dji.sdk.exception.CloudSDKErrorEnum; -import com.dji.sdk.exception.CloudSDKException; -import io.swagger.v3.oas.annotations.media.Schema; -import org.springframework.util.CollectionUtils; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/30 - */ -@Schema(description = "point geometry") -public class ElementPointGeometry extends ElementGeometryType { - - @Schema(example = "Point") - @NotNull - private String type = ElementResourceTypeEnum.POINT.getTypeName(); - - @Schema(example = "[113.943109, 22.577378]") - @NotNull - @Size(min = 2, max = 3) - private Double[] coordinates; - - public ElementPointGeometry() { - super(); - } - - @Override - public List convertToList() { - List coordinateList = new ArrayList<>(); - coordinateList.add(new ElementCoordinate() - .setLongitude(this.coordinates[0]) - .setLatitude(this.coordinates[1]) - .setAltitude(this.coordinates.length == 3 ? this.coordinates[2] : null)); - return coordinateList; - } - - @Override - public void adapterCoordinateType(List coordinateList) { - if (CollectionUtils.isEmpty(coordinateList)) { - throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER); - } - this.coordinates = new Double[]{ - coordinateList.get(0).getLongitude(), - coordinateList.get(0).getLatitude(), - coordinateList.get(0).getAltitude() - }; - } - - @Override - public String toString() { - return "ElementPointGeometry{" + - "coordinates=" + Arrays.toString(coordinates) + - '}'; - } - - public Double[] getCoordinates() { - return coordinates; - } - - public ElementPointGeometry setCoordinates(Double[] coordinates) { - this.coordinates = coordinates; - return this; - } - - @Override - public String getType() { - return type; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/ElementPolygonGeometry.java b/src/main/java/com/dji/sdk/cloudapi/map/ElementPolygonGeometry.java deleted file mode 100644 index 7068c9d..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/map/ElementPolygonGeometry.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.dji.sdk.cloudapi.map; - -import com.dji.sample.map.model.enums.ElementTypeEnum; -import com.dji.sdk.exception.CloudSDKErrorEnum; -import com.dji.sdk.exception.CloudSDKException; -import io.swagger.v3.oas.annotations.media.Schema; -import org.springframework.util.CollectionUtils; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/30 - */ -@Schema(description = "polygon geometry") -public class ElementPolygonGeometry extends ElementGeometryType { - - @Schema(example = "Polygon") - @NotNull - private String type = ElementTypeEnum.POLYGON.getDesc(); - - @Schema(example = "[[[113.943109, 22.577378]]]") - @NotNull - @Size(min = 1, max = 1) - private Double[][][] coordinates; - - public ElementPolygonGeometry() { - super(); - } - - @Override - public List convertToList() { - if (this.coordinates[0].length < 3) { - throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER); - } - List coordinateList = new ArrayList<>(); - for (Double[] coordinate : this.coordinates[0]) { - coordinateList.add(new ElementCoordinate() - .setLongitude(coordinate[0]) - .setLatitude(coordinate[1])); - } - return coordinateList; - } - - @Override - public void adapterCoordinateType(List coordinateList) { - if (CollectionUtils.isEmpty(coordinateList) || coordinateList.size() < 3) { - throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER); - } - this.coordinates = new Double[1][coordinateList.size()][2]; - for (int i = 0; i < this.coordinates[0].length; i++) { - this.coordinates[0][i][0] = coordinateList.get(i).getLongitude(); - this.coordinates[0][i][1] = coordinateList.get(i).getLatitude(); - } - } - - @Override - public String toString() { - return "ElementPolygonGeometry{" + - "coordinates=" + Arrays.toString(coordinates) + - '}'; - } - - public Double[][][] getCoordinates() { - return coordinates; - } - - public ElementPolygonGeometry setCoordinates(Double[][][] coordinates) { - this.coordinates = coordinates; - return this; - } - - @Override - public String getType() { - return type; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/ElementResourceTypeEnum.java b/src/main/java/com/dji/sdk/cloudapi/map/ElementResourceTypeEnum.java deleted file mode 100644 index 423be37..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/map/ElementResourceTypeEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.dji.sdk.cloudapi.map; - -import com.dji.sdk.exception.CloudSDKException; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; - -import java.util.Arrays; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/30 - */ -@Schema(enumAsRef = true, description = "

0: Point

1: LineString

2: Polygon

", allowableValues = {"0", "1", "2"}) -public enum ElementResourceTypeEnum { - - POINT(0, "Point"), - - LINE_STRING(1, "LineString"), - - POLYGON(2, "Polygon"); - - private final int type; - - private final String typeName; - - ElementResourceTypeEnum(int type, String typeName) { - this.type = type; - this.typeName = typeName; - } - - public String getTypeName() { - return typeName; - } - - @JsonValue - public int getType() { - return type; - } - - @JsonCreator - public static ElementResourceTypeEnum find(int type) { - return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny() - .orElseThrow(() -> new CloudSDKException(ElementResourceTypeEnum.class, type)); - } - -} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/GetMapElementsResponse.java b/src/main/java/com/dji/sdk/cloudapi/map/GetMapElementsResponse.java deleted file mode 100644 index d2b0c71..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/map/GetMapElementsResponse.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.dji.sdk.cloudapi.map; - -import com.dji.sdk.common.BaseModel; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import java.util.List; - -/** - * @author sean - * @version 0.2 - * @date 2021/11/29 - */ -@Schema(description = "element group data") -public class GetMapElementsResponse extends BaseModel { - - @NotNull - @Pattern(regexp = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") - @Schema(description = "group id", format = "uuid") - private String id; - - @NotNull - @Schema(description = "group name", example = "Pilot Share Layer") - private String name; - - @NotNull - private GroupTypeEnum type; - - @NotNull - @Valid - @Schema(description = "data collection of elements") - private List elements; - - @JsonProperty(value = "is_lock") - @NotNull - @Schema(description = "Whether the element group is locked.") - private Boolean lock; - - public GetMapElementsResponse() { - } - - @Override - public String toString() { - return "GetMapElementsResponse{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", type=" + type + - ", elements=" + elements + - ", lock=" + lock + - '}'; - } - - public String getId() { - return id; - } - - public GetMapElementsResponse setId(String id) { - this.id = id; - return this; - } - - public String getName() { - return name; - } - - public GetMapElementsResponse setName(String name) { - this.name = name; - return this; - } - - public GroupTypeEnum getType() { - return type; - } - - public GetMapElementsResponse setType(GroupTypeEnum type) { - this.type = type; - return this; - } - - public List getElements() { - return elements; - } - - public GetMapElementsResponse setElements(List elements) { - this.elements = elements; - return this; - } - - public Boolean getLock() { - return lock; - } - - public GetMapElementsResponse setLock(Boolean lock) { - this.lock = lock; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/map/GroupTypeEnum.java b/src/main/java/com/dji/sdk/cloudapi/map/GroupTypeEnum.java deleted file mode 100644 index 1319a57..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/map/GroupTypeEnum.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.dji.sdk.cloudapi.map; - -import com.dji.sdk.exception.CloudSDKException; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; - -import java.util.Arrays; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/15 - */ -@Schema(description = "

0: custom element group

1: default element group

2: APP shared element group " + - "(type=2 is an APP element group, PILOT will add map elements to this element group by default, " + - "and there must be an APP shared element group. " + - "It is recommended that in the same workspace, there are And there is only one APP shared element group)

", - enumAsRef = true, type = "int", allowableValues = {"0", "1", "2"}) -public enum GroupTypeEnum { - - NORMAL(0), - - DEFAULT(1), - - SHARED(2); - - private final int type; - - GroupTypeEnum(int type) { - this.type = type; - } - - @JsonValue - public int getType() { - return type; - } - - @JsonCreator - public static GroupTypeEnum find(int type) { - return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny() - .orElseThrow(() -> new CloudSDKException(GroupTypeEnum.class, type)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/media/UploadFlighttaskMediaPrioritize.java b/src/main/java/com/dji/sdk/cloudapi/media/UploadFlighttaskMediaPrioritize.java deleted file mode 100644 index 59c197f..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/media/UploadFlighttaskMediaPrioritize.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.dji.sdk.cloudapi.media; - -import com.dji.sdk.common.BaseModel; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/27 - */ -public class UploadFlighttaskMediaPrioritize extends BaseModel { - - @NotNull - @Pattern(regexp = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") - private String flightId; - - public UploadFlighttaskMediaPrioritize() { - } - - @Override - public String toString() { - return "UploadFlighttaskMediaPrioritize{" + - "flightId='" + flightId + '\'' + - '}'; - } - - public String getFlightId() { - return flightId; - } - - public UploadFlighttaskMediaPrioritize setFlightId(String flightId) { - this.flightId = flightId; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusResponse.java b/src/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusResponse.java deleted file mode 100644 index 9928c5c..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/organization/AirportBindStatusResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.dji.sdk.cloudapi.organization; - -import com.dji.sdk.common.BaseModel; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.List; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/30 - */ -public class AirportBindStatusResponse extends BaseModel { - - @NotNull - @Valid - @Size(min = 1, max = 2) - private List bindStatus; - - public AirportBindStatusResponse() { - } - - @Override - public String toString() { - return "AirportBindStatusResponse{" + - "bindStatus=" + bindStatus + - '}'; - } - - public List getBindStatus() { - return bindStatus; - } - - public AirportBindStatusResponse setBindStatus(List bindStatus) { - this.bindStatus = bindStatus; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindResponse.java b/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindResponse.java deleted file mode 100644 index 8155091..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/organization/AirportOrganizationBindResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.dji.sdk.cloudapi.organization; - -import com.dji.sdk.common.BaseModel; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.List; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/30 - */ -public class AirportOrganizationBindResponse extends BaseModel { - - @NotNull - @Valid - @Size(min = 1, max = 2) - private List errInfos; - - public AirportOrganizationBindResponse() { - } - - @Override - public String toString() { - return "AirportOrganizationBindResponse{" + - "errInfos=" + errInfos + - '}'; - } - - public List getErrInfos() { - return errInfos; - } - - public AirportOrganizationBindResponse setErrInfos(List errInfos) { - this.errInfos = errInfos; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/property/PropertySetEnum.java b/src/main/java/com/dji/sdk/cloudapi/property/PropertySetEnum.java deleted file mode 100644 index 549c6fd..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/property/PropertySetEnum.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.dji.sdk.cloudapi.property; - -import com.dji.sdk.common.BaseModel; -import com.dji.sdk.exception.CloudSDKException; - -import java.util.Arrays; - -/** - * @author sean - * @version 1.3 - * @date 2022/10/27 - */ -public enum PropertySetEnum { - - NIGHT_LIGHTS_STATE("night_lights_state", NightLightsStateSet.class), - - HEIGHT_LIMIT("height_limit", HeightLimitSet.class), - - DISTANCE_LIMIT_STATUS("distance_limit_status", DistanceLimitStatusSet.class), - - OBSTACLE_AVOIDANCE("obstacle_avoidance", ObstacleAvoidanceSet.class), - - RTH_ALTITUDE("rth_altitude", RthAltitudeSet.class), - - OUT_OF_CONTROL_ACTION("rc_lost_action", RcLostActionSet.class), - - EXIT_WAYLINE_WHEN_RC_LOST("exit_wayline_when_rc_lost", ExitWaylineWhenRcLostSet.class), - - THERMAL_CURRENT_PALETTE_STYLE("thermal_current_palette_style", ThermalCurrentPaletteStyleSet.class), - - THERMAL_GAIN_MODE("thermal_gain_mode", ThermalGainModeSet.class), - - THERMAL_ISOTHERM_STATE("thermal_isotherm_state", ThermalIsothermStateSet.class), - - THERMAL_ISOTHERM_UPPER_LIMIT("thermal_isotherm_upper_limit", ThermalIsothermUpperLimitSet.class), - - THERMAL_ISOTHERM_LOWER_LIMIT("thermal_isotherm_lower_limit", ThermalIsothermLowerLimitSet.class), - - ; - - private final String property; - - private final Class clazz; - - PropertySetEnum(String property, Class clazz) { - this.property = property; - this.clazz = clazz; - } - - public String getProperty() { - return property; - } - - public Class getClazz() { - return clazz; - } - - public static PropertySetEnum find(String property) { - return Arrays.stream(values()).filter(propertyEnum -> propertyEnum.property.equals(property)).findAny() - .orElseThrow(() -> new CloudSDKException(PropertySetEnum.class, property)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/property/api/AbstractPropertyService.java b/src/main/java/com/dji/sdk/cloudapi/property/api/AbstractPropertyService.java deleted file mode 100644 index 8d5c814..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/property/api/AbstractPropertyService.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.dji.sdk.cloudapi.property.api; - -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.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; -import com.dji.sdk.mqtt.property.PropertySetReplyResultEnum; -import com.fasterxml.jackson.annotation.JsonProperty; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/30 - */ -public abstract class AbstractPropertyService { - - @Resource - private PropertySetPublish propertySetPublish; - - /** - * Device property set - * @param gateway - * @param propertyEnum - * @param request - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public PropertySetReplyResultEnum propertySet(GatewayManager gateway, PropertySetEnum propertyEnum, BaseModel request) { - if (Objects.isNull(request) || propertyEnum.getClazz() != request.getClass()) { - throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER); - } - Common.validateModel(request); - Field[] fields = request.getClass().getDeclaredFields(); - if (fields.length > 1 || null == fields[0].getDeclaredAnnotation(Valid.class)) { - return propertySetPublish.publish(gateway.getGatewaySn(), request); - } - - try { - Map map = new HashMap<>(); - fields[0].setAccessible(true); - Object child = fields[0].get(request); - for (Field field : ((Class) fields[0].getGenericType()).getDeclaredFields()) { - field.setAccessible(true); - Object value = field.get(child); - if (Objects.isNull(value)) { - continue; - } - map.put(Optional.ofNullable(field.getDeclaredAnnotation(JsonProperty.class)) - .map(JsonProperty::value).orElse(field.getName()), value); - field.setAccessible(false); - PropertySetReplyResultEnum result = propertySetPublish.publish( - gateway.getGatewaySn(), Map.of(propertyEnum.getProperty(), map)); - if (PropertySetReplyResultEnum.SUCCESS != result) { - return result; - } - map.clear(); - } - fields[0].setAccessible(false); - - } catch (IllegalAccessException e) { - throw new CloudSDKException(e); - } - return PropertySetReplyResultEnum.SUCCESS; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/storage/CredentialsToken.java b/src/main/java/com/dji/sdk/cloudapi/storage/CredentialsToken.java deleted file mode 100644 index 93317b4..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/storage/CredentialsToken.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.dji.sdk.cloudapi.storage; - -import com.aliyuncs.sts.model.v20150401.AssumeRoleResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.minio.credentials.Credentials; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - - -/** - * @author sean - * @version 0.2 - * @date 2021/12/7 - */ -@Schema(description = "The token data of the temporary credential") -public class CredentialsToken { - - private static final int DELAY = 300; - - @NotNull - @Schema(description = "access key id", example = "3POX6W77L1EF4C86L2RE") - @JsonProperty("access_key_id") - private String accessKeyId; - - @NotNull - @Schema(description = "access key secret", example = "9NG2P2yJaUrck576CkdRoRbchKssJiZygi5D93CBsduY") - @JsonProperty("access_key_secret") - private String accessKeySecret; - - @NotNull - @Min(1) - @Schema(description = "The valid time of the token, in seconds.", example = "3600") - private Long expire; - - @NotNull - @JsonProperty("security_token") - @Schema(description = "security token", example = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiIzUE9YNlc3N0wxRUY0Qzg2TDJSRSIsImV4cCI6MTY4NjgxOTgyOSwicGFyZW50IjoibWluaW8ifQ.cWJXI90UidrBOTD0gWxKt8PT5Qp_6dEK5wNfJuE6lR9dH6Us7jtSB8vcttRDwPhpCNrAGsv91ydw6NLMyjqAOw") - private String securityToken; - - public CredentialsToken(Credentials credentials, long expire) { - this.accessKeyId = credentials.accessKey(); - this.accessKeySecret = credentials.secretKey(); - this.securityToken = credentials.sessionToken(); - this.expire = expire - DELAY; - } - - public CredentialsToken(AssumeRoleResponse.Credentials credentials, long expire) { - this.accessKeyId = credentials.getAccessKeyId(); - this.accessKeySecret = credentials.getAccessKeySecret(); - this.securityToken = credentials.getSecurityToken(); - this.expire = expire - DELAY; - } - - public CredentialsToken(com.amazonaws.services.securitytoken.model.Credentials credentials) { - this.accessKeyId = credentials.getAccessKeyId(); - this.accessKeySecret = credentials.getSecretAccessKey(); - this.securityToken = credentials.getSessionToken(); - this.expire = (credentials.getExpiration().getTime() - System.currentTimeMillis()) / 1000 - DELAY; - } - - public CredentialsToken() { - } - - @Override - public String toString() { - return "CredentialsToken{" + - "accessKeyId='" + accessKeyId + '\'' + - ", accessKeySecret='" + accessKeySecret + '\'' + - ", expire=" + expire + - ", securityToken='" + securityToken + '\'' + - '}'; - } - - public String getAccessKeyId() { - return accessKeyId; - } - - public CredentialsToken setAccessKeyId(String accessKeyId) { - this.accessKeyId = accessKeyId; - return this; - } - - public String getAccessKeySecret() { - return accessKeySecret; - } - - public CredentialsToken setAccessKeySecret(String accessKeySecret) { - this.accessKeySecret = accessKeySecret; - return this; - } - - public Long getExpire() { - return expire; - } - - public CredentialsToken setExpire(Long expire) { - this.expire = expire; - return this; - } - - public String getSecurityToken() { - return securityToken; - } - - public CredentialsToken setSecurityToken(String securityToken) { - this.securityToken = securityToken; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyList.java b/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyList.java deleted file mode 100644 index 4f41c57..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyList.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.dji.sdk.cloudapi.tsa; - -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * @author sean - * @version 0.2 - * @date 2021/12/8 - */ -@Schema(description = "device topology list") -public class TopologyList { - - @Valid - @Schema(description = "drone device topology collection") - @NotNull - private List hosts; - - @Valid - @Schema(description = "gateway device topology collection") - @NotNull - private List parents; - - public TopologyList() { - } - - @Override - public String toString() { - return "TopologyList{" + - "hosts=" + hosts + - ", parents=" + parents + - '}'; - } - - public List getHosts() { - return hosts; - } - - public TopologyList setHosts(List hosts) { - this.hosts = hosts; - return this; - } - - public List getParents() { - return parents; - } - - public TopologyList setParents(List parents) { - this.parents = parents; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyResponse.java b/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyResponse.java deleted file mode 100644 index b3a2216..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/tsa/TopologyResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.dji.sdk.cloudapi.tsa; - -import com.dji.sdk.common.BaseModel; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/16 - */ -@Schema(description = "topology response data") -public class TopologyResponse extends BaseModel { - - @Valid - @NotNull - private List list; - - public TopologyResponse() { - } - - @Override - public String toString() { - return "TopologyResponse{" + - "list=" + list + - '}'; - } - - public List getList() { - return list; - } - - public TopologyResponse setList(List list) { - this.list = list; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/BreakpointStateEnum.java b/src/main/java/com/dji/sdk/cloudapi/wayline/BreakpointStateEnum.java deleted file mode 100644 index ec958ee..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/BreakpointStateEnum.java +++ /dev/null @@ -1,43 +0,0 @@ -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 - * @date 2023/6/6 - */ -public enum BreakpointStateEnum { - - WAYLINE_SEGMENT(0, "On the wayline segment"), - - WAYPOINT(1, "On the waypoint"); - - private final int state; - - private final String msg; - - BreakpointStateEnum(int state, String msg) { - this.state = state; - this.msg = msg; - } - - public int getState() { - return state; - } - - @JsonValue - public String getMsg() { - return msg; - } - - @JsonCreator - public static BreakpointStateEnum find(int state) { - return Arrays.stream(values()).filter(stateEnum -> stateEnum.state == state).findAny() - .orElseThrow(() -> new CloudSDKException(BreakpointStateEnum.class, state)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/ExecutionStepEnum.java b/src/main/java/com/dji/sdk/cloudapi/wayline/ExecutionStepEnum.java deleted file mode 100644 index f142ce6..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/ExecutionStepEnum.java +++ /dev/null @@ -1,66 +0,0 @@ -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 - * @date 2023/6/6 - */ -public enum ExecutionStepEnum { - - STARTING(0, 4, "MissionCenter starting, checking and resuming"), - - WAITING_STATE(5, 18, "Waiting state"), - - EXECUTING(19, 20, "Task executing"), - - RTH(21, 29, "Returning to home"), - - PULLING_LOGS(30, 39, "Pulling logs"), - - COMPLETE(40, 65534, "Interaction completed"), - - UNKNOWN(65535, 65535, "Unknown"); - - private final int min; - - private final int max; - - private final String msg; - - ExecutionStepEnum(int min, int max, String msg) { - this.min = min; - this.max = max; - this.msg = msg; - } - - @JsonValue - public int getMin() { - return min; - } - - public int getMax() { - return max; - } - - public String getMsg() { - return msg; - } - - @JsonCreator - public static ExecutionStepEnum find(int step) { - return Arrays.stream(values()).filter(stepEnum -> stepEnum.min <= step && stepEnum.max >= step).findAny() - .orElseThrow(() -> new CloudSDKException(ExecutionStepEnum.class, step)); - } - - @JsonCreator - public static ExecutionStepEnum find(String msg) { - return Arrays.stream(values()).filter(stepEnum -> stepEnum.msg.equals(msg)).findAny() - .orElseThrow(() -> new CloudSDKException(ExecutionStepEnum.class, msg)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHActionEnum.java b/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHActionEnum.java deleted file mode 100644 index 402cfa1..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHActionEnum.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.dji.sdk.cloudapi.wayline; - -import com.dji.sdk.cloudapi.device.ExitWaylineWhenRcLostEnum; -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 - * @date 2023/6/6 - */ -public enum ExitingRTHActionEnum { - - EXIT(0, "Exit exiting RTH state"), - - Enter(1, "Enter exiting RTH state"); - - private final int action; - - private final String msg; - - ExitingRTHActionEnum(int action, String msg) { - this.action = action; - this.msg = msg; - } - - public int getAction() { - return action; - } - - @JsonValue - public String getMsg() { - return msg; - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static ExitingRTHActionEnum find(int action) { - return Arrays.stream(values()).filter(actionEnum -> actionEnum.action == action).findAny() - .orElseThrow(() -> new CloudSDKException(ExitWaylineWhenRcLostEnum.class, action)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHReasonEnum.java b/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHReasonEnum.java deleted file mode 100644 index 63b407d..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/ExitingRTHReasonEnum.java +++ /dev/null @@ -1,61 +0,0 @@ -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 - * @date 2023/6/6 - */ -public enum ExitingRTHReasonEnum { - - ADD_JOYSTICK_THROTTLE(0, "Add joystick throttle"), - - ADD_JOYSTICK_PITCH(1, "Add joystick pitch"), - - INITIALIZATION_FAILED(2, "The initialization of behavior tree is failed"), - - SURROUNDED_BY_OBSTACLES(3, "Surrounded by obstacles"), - - FLIGHT_RESTRICTION(4, "Flight restriction is triggered"), - - OBSTACLE_IS_TOO_CLOSED(5, "Obstacle is too closed"), - - NO_GPS(6, "No GPS signal"), - - GPS_AND_VIO_ARE_FALSE(7, "The output flag of GPS and VIO location is false"), - - ERROR_OF_GPS_AND_VIO(8, "The error of GPS and VIO fusion position is too large"), - - SHORT_DISTANCE_BACKTRACKING(9, "Backtrack in a short distance"), - - TRIGGER_RTH(10, "Trigger the RTH in a short distanc"); - - private final int reason; - - private final String msg; - - ExitingRTHReasonEnum(int reason, String msg) { - this.reason = reason; - this.msg = msg; - } - - public int getReason() { - return reason; - } - - @JsonValue - public String getMsg() { - return msg; - } - - @JsonCreator - public static ExitingRTHReasonEnum find(int reason) { - return Arrays.stream(values()).filter(reasonEnum -> reasonEnum.reason == reason).findAny() - .orElseThrow(() -> new CloudSDKException(ExitingRTHReasonEnum.class, reason)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakReasonEnum.java b/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakReasonEnum.java deleted file mode 100644 index 38fbc58..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskBreakReasonEnum.java +++ /dev/null @@ -1,201 +0,0 @@ -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 - * @date 2023/6/6 - */ -public enum FlighttaskBreakReasonEnum { - - 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)); - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskExecuteRequest.java b/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskExecuteRequest.java deleted file mode 100644 index 451b784..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskExecuteRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.dji.sdk.cloudapi.wayline; - -import com.dji.sdk.common.BaseModel; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - -/** - * @author sean - * @version 1.1 - * @date 2022/6/1 - */ -public class FlighttaskExecuteRequest extends BaseModel { - - @NotNull - @Pattern(regexp = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") - private String flightId; - - public FlighttaskExecuteRequest() { - } - - @Override - public String toString() { - return "FlighttaskExecuteRequest{" + - "flightId='" + flightId + '\'' + - '}'; - } - - public String getFlightId() { - return flightId; - } - - public FlighttaskExecuteRequest setFlightId(String flightId) { - this.flightId = flightId; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskPrepareRequest.java b/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskPrepareRequest.java deleted file mode 100755 index 3a02541..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskPrepareRequest.java +++ /dev/null @@ -1,245 +0,0 @@ -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.config.version.CloudSDKVersionEnum; - -import javax.validation.Valid; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/6 - */ -public class FlighttaskPrepareRequest extends BaseModel { - - /** - * Task ID - */ - @NotNull - @Pattern(regexp = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") - private String flightId; - - /** - * Time to execute - * Millisecond timestamp of task execution time. Optional field. - * When the `task_type` is 0 or 1, it is required. When the `task_type` is 2, it is not required. - */ - @Min(123456789012L) - private Long executeTime; - - /** - * Task type - * The execution time of immediate task and timed task are defined by `execute_time`. - * The conditional task supports the task readiness condition defined by `ready_conditions`. - * The task can be executed if conditions are satisfied within a specified period. - * Immediate task has the highest priority. Timed task and conditional task have the same priority. - */ - @NotNull - private TaskTypeEnum taskType; - - /** - * Wayline type - */ - @NotNull - private WaylineTypeEnum waylineType; - - /** - * Wayline file object - */ - @NotNull - @Valid - private FlighttaskFile file; - - /** - * Task readiness condition - */ - @Valid - private ReadyConditions readyConditions; - - /** - * Task executable condition - */ - @Valid - private ExecutableConditions executableConditions; - - /** - * Wayline breakpoint information - */ - @Valid - private FlighttaskBreakPoint breakPoint; - - /** - * Height for RTH - */ - @NotNull - @Min(20) - @Max(1500) - private Integer rthAltitude; - - /** - * Remote controller out of control action - * Out of control action: the current fixed transmitted value is 0, meaning Return-to-Home (RTH). - * Note that this enumeration value definition is inconsistent with the flight control and dock definitions, - * and a conversion exists at the dock end. - */ - @NotNull - private OutOfControlActionEnum outOfControlAction; - - /** - * wayline out of control action - * consistent with the KMZ file - */ - @NotNull - private ExitWaylineWhenRcLostEnum exitWaylineWhenRcLost; - - @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) - private RthModeEnum rthMode = RthModeEnum.SETTING_HEIGHT; - - @Valid - @CloudSDKVersion(since = CloudSDKVersionEnum.V1_0_0) - private SimulateMission simulateMission; - - public FlighttaskPrepareRequest() {} - - @Override - public String toString() { - return "FlighttaskPrepareRequest{" + - "flightId='" + flightId + '\'' + - ", executeTime=" + executeTime + - ", taskType=" + taskType + - ", waylineType=" + waylineType + - ", file=" + file + - ", readyConditions=" + readyConditions + - ", executableConditions=" + executableConditions + - ", breakPoint=" + breakPoint + - ", rthAltitude=" + rthAltitude + - ", outOfControlAction=" + outOfControlAction + - ", exitWaylineWhenRcLost=" + exitWaylineWhenRcLost + - ", rthMode=" + rthMode + - ", simulateMission=" + simulateMission + - '}'; - } - - public String getFlightId() { - return flightId; - } - - public FlighttaskPrepareRequest setFlightId(String flightId) { - this.flightId = flightId; - return this; - } - - public Long getExecuteTime() { - return executeTime; - } - - public FlighttaskPrepareRequest setExecuteTime(Long executeTime) { - this.executeTime = executeTime; - return this; - } - - public TaskTypeEnum getTaskType() { - return taskType; - } - - public FlighttaskPrepareRequest setTaskType(TaskTypeEnum taskType) { - this.taskType = taskType; - return this; - } - - public WaylineTypeEnum getWaylineType() { - return waylineType; - } - - public FlighttaskPrepareRequest setWaylineType(WaylineTypeEnum waylineType) { - this.waylineType = waylineType; - return this; - } - - public FlighttaskFile getFile() { - return file; - } - - public FlighttaskPrepareRequest setFile(FlighttaskFile file) { - this.file = file; - return this; - } - - public ReadyConditions getReadyConditions() { - return readyConditions; - } - - public FlighttaskPrepareRequest setReadyConditions(ReadyConditions readyConditions) { - this.readyConditions = readyConditions; - return this; - } - - public ExecutableConditions getExecutableConditions() { - return executableConditions; - } - - public FlighttaskPrepareRequest setExecutableConditions(ExecutableConditions executableConditions) { - this.executableConditions = executableConditions; - return this; - } - - public FlighttaskBreakPoint getBreakPoint() { - return breakPoint; - } - - public FlighttaskPrepareRequest setBreakPoint(FlighttaskBreakPoint breakPoint) { - this.breakPoint = breakPoint; - return this; - } - - public Integer getRthAltitude() { - return rthAltitude; - } - - public FlighttaskPrepareRequest setRthAltitude(Integer rthAltitude) { - this.rthAltitude = rthAltitude; - return this; - } - - public OutOfControlActionEnum getOutOfControlAction() { - return outOfControlAction; - } - - public FlighttaskPrepareRequest setOutOfControlAction(OutOfControlActionEnum outOfControlAction) { - this.outOfControlAction = outOfControlAction; - return this; - } - - public ExitWaylineWhenRcLostEnum getExitWaylineWhenRcLost() { - return exitWaylineWhenRcLost; - } - - public FlighttaskPrepareRequest setExitWaylineWhenRcLost(ExitWaylineWhenRcLostEnum exitWaylineWhenRcLost) { - this.exitWaylineWhenRcLost = exitWaylineWhenRcLost; - return this; - } - - public RthModeEnum getRthMode() { - return rthMode; - } - - public FlighttaskPrepareRequest setRthMode(RthModeEnum rthMode) { - this.rthMode = rthMode; - return this; - } - - public SimulateMission getSimulateMission() { - return simulateMission; - } - - public FlighttaskPrepareRequest setSimulateMission(SimulateMission simulateMission) { - this.simulateMission = simulateMission; - return this; - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressExt.java b/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressExt.java deleted file mode 100644 index 7a3c61b..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskProgressExt.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.dji.sdk.cloudapi.wayline; - -/** - * @author sean - * @version 1.1 - * @date 2022/6/9 - */ -public class FlighttaskProgressExt { - - private Integer currentWaypointIndex; - - private Integer mediaCount; - - private String flightId; - - private String trackId; - - private ProgressExtBreakPoint breakPoint; - - public FlighttaskProgressExt() { - } - - @Override - public String toString() { - return "FlighttaskProgressExt{" + - "currentWaypointIndex=" + currentWaypointIndex + - ", mediaCount=" + mediaCount + - ", flightId='" + flightId + '\'' + - ", trackId='" + trackId + '\'' + - ", breakPoint=" + breakPoint + - '}'; - } - - public Integer getCurrentWaypointIndex() { - return currentWaypointIndex; - } - - public FlighttaskProgressExt setCurrentWaypointIndex(Integer currentWaypointIndex) { - this.currentWaypointIndex = currentWaypointIndex; - return this; - } - - public Integer getMediaCount() { - return mediaCount; - } - - public FlighttaskProgressExt setMediaCount(Integer mediaCount) { - this.mediaCount = mediaCount; - return this; - } - - public String getFlightId() { - return flightId; - } - - public FlighttaskProgressExt setFlightId(String flightId) { - this.flightId = flightId; - return this; - } - - public String getTrackId() { - return trackId; - } - - public FlighttaskProgressExt setTrackId(String trackId) { - this.trackId = trackId; - return this; - } - - public ProgressExtBreakPoint getBreakPoint() { - return breakPoint; - } - - public FlighttaskProgressExt setBreakPoint(ProgressExtBreakPoint breakPoint) { - this.breakPoint = breakPoint; - return this; - } -} - - diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskUndoRequest.java b/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskUndoRequest.java deleted file mode 100644 index a38af28..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/FlighttaskUndoRequest.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.dji.sdk.cloudapi.wayline; - -import com.dji.sdk.common.BaseModel; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; -import java.util.List; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/7 - */ -public class FlighttaskUndoRequest extends BaseModel { - - @NotNull - @Size(min = 1) - private List<@Pattern(regexp = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") String> flightIds; - - public FlighttaskUndoRequest() { - } - - @Override - public String toString() { - return "FlighttaskUndoRequest{" + - "flightIds=" + flightIds + - '}'; - } - - public List getFlightIds() { - return flightIds; - } - - public FlighttaskUndoRequest setFlightIds(List flightIds) { - this.flightIds = flightIds; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListRequest.java b/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListRequest.java deleted file mode 100644 index 8ea9c41..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListRequest.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.dji.sdk.cloudapi.wayline; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.List; - -/** - * @author sean - * @version 1.7 - * @date 2023/6/8 - */ -@Schema(description = "Query parameter to get list of wayline files") -public class GetWaylineListRequest { - - /** - * Is the wayline file favorited? - */ - @Parameter(name = "favorited", description = "Is the wayline file favorited?") - private Boolean favorited; - - /** - * order(xxx_column desc or xxx_column asc) - * Pilot2 optional value: nameupdate_time desc - */ - @NotNull - @JsonProperty("order_by") - @Parameter(name = "order_by", description = "sort field name", example = "update_time desc", schema = @Schema(allowableValues = {"name", "update_time desc"})) - private String orderBy; - - /** - * current page - */ - @Min(1) - @Parameter(name = "page", description = "current page", schema = @Schema(defaultValue = "1", type = "int")) - private int page = 1; - - /** - * page size - */ - @Min(1) - @JsonProperty("page_size") - @Parameter(name = "page_size", description = "page size", schema = @Schema(defaultValue = "10", type = "int")) - private int pageSize = 10; - - /** - * wayline template type collection - */ - @Size(min = 1) - @JsonProperty("template_type") - @Parameter(name = "template_type", description = "wayline template type collection", example = "[0]") - private List templateType; - - public GetWaylineListRequest() { - } - - @Override - public String toString() { - return "GetWaylineListRequest{" + - "favorited=" + favorited + - ", orderBy='" + orderBy + '\'' + - ", page=" + page + - ", pageSize=" + pageSize + - ", templateType=" + templateType + - '}'; - } - - public Boolean getFavorited() { - return favorited; - } - - public GetWaylineListRequest setFavorited(Boolean favorited) { - this.favorited = favorited; - return this; - } - - public String getOrderBy() { - return orderBy; - } - - public GetWaylineListRequest setOrderBy(String orderBy) { - this.orderBy = orderBy; - return this; - } - - public int getPage() { - return page; - } - - public GetWaylineListRequest setPage(int page) { - this.page = page; - return this; - } - - public int getPageSize() { - return pageSize; - } - - public GetWaylineListRequest setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - public List getTemplateType() { - return templateType; - } - - public GetWaylineListRequest setTemplateType(List templateType) { - this.templateType = templateType; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListResponse.java b/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListResponse.java deleted file mode 100644 index 8e856da..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/GetWaylineListResponse.java +++ /dev/null @@ -1,203 +0,0 @@ -package com.dji.sdk.cloudapi.wayline; - -import com.dji.sdk.cloudapi.device.DeviceEnum; -import com.dji.sdk.common.BaseModel; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; -import java.util.List; - -/** - * @author sean - * @version 0.3 - * @date 2021/12/22 - */ -@Schema(description = "The data of the wayline file.") -public class GetWaylineListResponse extends BaseModel { - - /** - * wayline file name - */ - @NotNull - @Schema(description = "wayline file name", example = "waylineFile") - // TODO 排除特殊字符 - private String name; - - /** - * wayline file id - */ - @NotNull - @Pattern(regexp = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") - @Schema(description = "wayline file id", format = "uuid") - private String id; - - /** - * drone device product enum - */ - @NotNull - @JsonProperty("drone_model_key") - @Schema(description = "drone device product enum", example = "0-67-0") - private DeviceEnum droneModelKey; - - private String sign; - - /** - * payload device product enum - */ - @NotNull - @Size(min = 1) - @JsonProperty("payload_model_keys") - @Schema(description = "payload device product enum", example = "[\"1-53-0\"]") - private List payloadModelKeys; - - /** - * Is the wayline file favorited? - */ - @NotNull - @Schema(description = "Is the wayline file favorited?") - private Boolean favorited; - - /** - * wayline template collection - */ - @NotNull - @Size(min = 1) - @Schema(description = "wayline template collection", example = "[0]") - @JsonProperty("template_types") - private List templateTypes; - - @NotNull - @Schema(description = "The key of the object in the bucket", example = "wayline/waylineFile.kmz") - @JsonProperty("object_key") - private String objectKey; - - /** - * uploader - */ - @NotNull - @JsonProperty("user_name") - @Schema(description = "uploader's username", example = "admin") - private String username; - - /** - * update time (millisecond) - */ - @NotNull - @Min(123456789012L) - @Schema(description = "update time (millisecond). The field named `update time` must exist in the table.", example = "123456789012") - @JsonProperty("update_time") - private Long updateTime; - - public GetWaylineListResponse() { - } - - @Override - public String toString() { - return "GetWaylineListResponse{" + - "name='" + name + '\'' + - ", id='" + id + '\'' + - ", droneModelKey=" + droneModelKey + - ", sign='" + sign + '\'' + - ", payloadModelKeys=" + payloadModelKeys + - ", favorited=" + favorited + - ", templateTypes=" + templateTypes + - ", objectKey='" + objectKey + '\'' + - ", username='" + username + '\'' + - ", updateTime=" + updateTime + - '}'; - } - - public String getName() { - return name; - } - - public GetWaylineListResponse setName(String name) { - this.name = name; - return this; - } - - public String getId() { - return id; - } - - public GetWaylineListResponse setId(String id) { - this.id = id; - return this; - } - - public DeviceEnum getDroneModelKey() { - return droneModelKey; - } - - public GetWaylineListResponse setDroneModelKey(DeviceEnum droneModelKey) { - this.droneModelKey = droneModelKey; - return this; - } - - public String getSign() { - return sign; - } - - public GetWaylineListResponse setSign(String sign) { - this.sign = sign; - return this; - } - - public List getPayloadModelKeys() { - return payloadModelKeys; - } - - public GetWaylineListResponse setPayloadModelKeys(List payloadModelKeys) { - this.payloadModelKeys = payloadModelKeys; - return this; - } - - public Boolean getFavorited() { - return favorited; - } - - public GetWaylineListResponse setFavorited(Boolean favorited) { - this.favorited = favorited; - return this; - } - - public List getTemplateTypes() { - return templateTypes; - } - - public GetWaylineListResponse setTemplateTypes(List templateTypes) { - this.templateTypes = templateTypes; - return this; - } - - public String getObjectKey() { - return objectKey; - } - - public GetWaylineListResponse setObjectKey(String objectKey) { - this.objectKey = objectKey; - return this; - } - - public String getUsername() { - return username; - } - - public GetWaylineListResponse setUsername(String username) { - this.username = username; - return this; - } - - public Long getUpdateTime() { - return updateTime; - } - - public GetWaylineListResponse setUpdateTime(Long updateTime) { - this.updateTime = updateTime; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/ReadyConditions.java b/src/main/java/com/dji/sdk/cloudapi/wayline/ReadyConditions.java deleted file mode 100755 index 6194e8d..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/ReadyConditions.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.dji.sdk.cloudapi.wayline; - -import com.dji.sdk.common.BaseModel; - -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -/** - * @author sean - * @version 1.7 - * @date 2023/5/23 - */ -public class ReadyConditions extends BaseModel { - - /** - * Battery capacity - * The aircraft battery percentage threshold of the executable task. - * The aircraft battery must be greater than the `battery_capacity` when the task starts. - */ - @NotNull - @Min(0) - @Max(1) - private Integer batteryCapacity; - - /** - * Start time of the task executable period - * Start millisecond timestamp of the task executable period. The task execution time should be later than the `begin_time`. - */ - @NotNull - private Long beginTime; - - /** - * End time of the task executable period - * End millisecond timestamp of the task executable period. The task execution time should be earlier than the `end_time`. - */ - @NotNull - private Long endTime; - - public ReadyConditions() {} - - @Override - public String toString() { - return "ReadyConditions{" + - "batteryCapacity=" + batteryCapacity + - ", beginTime=" + beginTime + - ", endTime=" + endTime + - '}'; - } - - public Integer getBatteryCapacity() { - return batteryCapacity; - } - - public ReadyConditions setBatteryCapacity(Integer batteryCapacity) { - this.batteryCapacity = batteryCapacity; - return this; - } - - public Long getBeginTime() { - return beginTime; - } - - public ReadyConditions setBeginTime(Long beginTime) { - this.beginTime = beginTime; - return this; - } - - public Long getEndTime() { - return endTime; - } - - public ReadyConditions setEndTime(Long endTime) { - this.endTime = endTime; - return this; - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/RthModeEnum.java b/src/main/java/com/dji/sdk/cloudapi/wayline/RthModeEnum.java deleted file mode 100644 index 2d4713d..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/RthModeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -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 - * @date 2023/8/4 - */ -public enum RthModeEnum { - - SMART_HEIGHT(0), - - SETTING_HEIGHT(1); - - private final int rthMode; - - RthModeEnum(int rthMode) { - this.rthMode = rthMode; - } - - @JsonValue - public int getRthMode() { - return rthMode; - } - - @JsonCreator - public static RthModeEnum find(int rthMode) { - return Arrays.stream(values()).filter(rthModeEnum -> rthModeEnum.rthMode == rthMode).findAny() - .orElseThrow(() -> new CloudSDKException(RthModeEnum.class, rthMode)); - } - -} diff --git a/src/main/java/com/dji/sdk/cloudapi/wayline/api/AbstractWaylineService.java b/src/main/java/com/dji/sdk/cloudapi/wayline/api/AbstractWaylineService.java deleted file mode 100644 index de59f19..0000000 --- a/src/main/java/com/dji/sdk/cloudapi/wayline/api/AbstractWaylineService.java +++ /dev/null @@ -1,195 +0,0 @@ -package com.dji.sdk.cloudapi.wayline.api; - -import com.dji.sdk.annotations.CloudSDKVersion; -import com.dji.sdk.cloudapi.wayline.*; -import com.dji.sdk.config.version.CloudSDKVersionEnum; -import com.dji.sdk.common.Common; -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; -import com.dji.sdk.mqtt.MqttReply; -import com.dji.sdk.mqtt.events.EventsDataRequest; -import com.dji.sdk.mqtt.events.TopicEventsRequest; -import com.dji.sdk.mqtt.events.TopicEventsResponse; -import com.dji.sdk.mqtt.requests.TopicRequestsRequest; -import com.dji.sdk.mqtt.requests.TopicRequestsResponse; -import com.dji.sdk.mqtt.services.ServicesPublish; -import com.dji.sdk.mqtt.services.ServicesReplyData; -import com.dji.sdk.mqtt.services.TopicServicesResponse; -import org.springframework.integration.annotation.ServiceActivator; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageHeaders; - -import javax.annotation.Resource; - -/** - * @author sean - * @version 1.7 - * @date 2023/5/19 - */ -public abstract class AbstractWaylineService { - - @Resource - private ServicesPublish servicesPublish; - - /** - * Notification of device exits the Return to Home (RTH) state - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_DEVICE_EXIT_HOMING_NOTIFY, outputChannel = ChannelName.OUTBOUND_EVENTS) - public TopicEventsResponse deviceExitHomingNotify(TopicEventsRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("deviceExitHomingNotify not implemented"); - } - - /** - * Report wayline task progress - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_FLIGHTTASK_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS) - public TopicEventsResponse flighttaskProgress(TopicEventsRequest> request, MessageHeaders headers) { - throw new UnsupportedOperationException("flighttaskProgress not implemented"); - } - - /** - * Notification of task readiness - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_FLIGHTTASK_READY, outputChannel = ChannelName.OUTBOUND_EVENTS) - public TopicEventsResponse flighttaskReady(TopicEventsRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("flighttaskReady not implemented"); - } - - /** - * Create wayline task (Deprecated) - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(deprecated = CloudSDKVersionEnum.V0_0_1, exclude = GatewayTypeEnum.RC) - public TopicServicesResponse flighttaskCreate(GatewayManager gateway, FlighttaskCreateRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - WaylineMethodEnum.FLIGHTTASK_CREATE.getMethod(), - request); - } - - /** - * Issue wayline task - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse flighttaskPrepare(GatewayManager gateway, FlighttaskPrepareRequest request) { - validPrepareParam(request); - return servicesPublish.publish( - gateway.getGatewaySn(), - WaylineMethodEnum.FLIGHTTASK_PREPARE.getMethod(), - request, - request.getFlightId()); - } - - /** - * Execute wayline task - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse flighttaskExecute(GatewayManager gateway, FlighttaskExecuteRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - WaylineMethodEnum.FLIGHTTASK_EXECUTE.getMethod(), - request, - request.getFlightId()); - } - - /** - * Cancel wayline task - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse flighttaskUndo(GatewayManager gateway, FlighttaskUndoRequest request) { - return servicesPublish.publish( - gateway.getGatewaySn(), - WaylineMethodEnum.FLIGHTTASK_UNDO.getMethod(), - request); - } - - /** - * Pause wayline task - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse flighttaskPause(GatewayManager gateway) { - return servicesPublish.publish( - gateway.getGatewaySn(), - WaylineMethodEnum.FLIGHTTASK_PAUSE.getMethod()); - } - - /** - * Resume wayline task - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse flighttaskRecovery(GatewayManager gateway) { - return servicesPublish.publish( - gateway.getGatewaySn(), - WaylineMethodEnum.FLIGHTTASK_RECOVERY.getMethod()); - } - - /** - * Return to Home (RTH) - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse returnHome(GatewayManager gateway) { - return servicesPublish.publish( - gateway.getGatewaySn(), - WaylineMethodEnum.RETURN_HOME.getMethod()); - } - - /** - * Cancel return to home - * @param gateway - * @return services_reply - */ - @CloudSDKVersion(exclude = GatewayTypeEnum.RC) - public TopicServicesResponse returnHomeCancel(GatewayManager gateway) { - return servicesPublish.publish( - gateway.getGatewaySn(), - WaylineMethodEnum.RETURN_HOME_CANCEL.getMethod()); - } - - /** - * Get the wayline task resource - * @param request data - * @param headers The headers for a {@link Message}. - * @return events_reply - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_REQUESTS_FLIGHTTASK_RESOURCE_GET, outputChannel = ChannelName.OUTBOUND_REQUESTS) - public TopicRequestsResponse> flighttaskResourceGet(TopicRequestsRequest request, MessageHeaders headers) { - throw new UnsupportedOperationException("flighttaskResourceGet not implemented"); - } - - - private void validPrepareParam(FlighttaskPrepareRequest request) { - if (null == request.getExecuteTime() - && (TaskTypeEnum.IMMEDIATE == request.getTaskType() || TaskTypeEnum.TIMED == request.getTaskType())) { - throw new CloudSDKException(CloudSDKErrorEnum.INVALID_PARAMETER, "Execute time must not be null."); - } - if (TaskTypeEnum.CONDITIONAL == request.getTaskType()) { - Common.validateModel(request.getReadyConditions()); - } - } - -} diff --git a/src/main/java/com/dji/sdk/common/Pagination.java b/src/main/java/com/dji/sdk/common/Pagination.java deleted file mode 100644 index 7a025d3..0000000 --- a/src/main/java/com/dji/sdk/common/Pagination.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.dji.sdk.common; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * Used for paging display. These field names cannot be changed. - * Because they need to be the same as the pilot. - * @author sean - * @version 0.3 - * @date 2021/12/22 - */ -@Schema(description = "Used for paging display") -public class Pagination { - - /** - * The current page number. - */ - @Schema(description = "The current page number.", example = "1") - private long page; - - /** - * The amount of data displayed per page. - */ - @Schema(description = "The amount of data displayed per page.", example = "10") - @JsonProperty("page_size") - private long pageSize; - - /** - * The total amount of all data. - */ - @Schema(description = "The total amount of all data.", example = "10") - private long total; - - public Pagination() { - } - - public Pagination(Page page) { - this.page = page.getCurrent(); - this.pageSize = page.getSize(); - this.total = page.getTotal(); - } - - @Override - public String toString() { - return "Pagination{" + - "page=" + page + - ", pageSize=" + pageSize + - ", total=" + total + - '}'; - } - - public long getPage() { - return page; - } - - public Pagination setPage(long page) { - this.page = page; - return this; - } - - public long getPageSize() { - return pageSize; - } - - public Pagination setPageSize(long pageSize) { - this.pageSize = pageSize; - return this; - } - - public long getTotal() { - return total; - } - - public Pagination setTotal(long total) { - this.total = total; - return this; - } -} diff --git a/src/main/java/com/dji/sdk/config/GetSnakeDataBinder.java b/src/main/java/com/dji/sdk/config/GetSnakeDataBinder.java deleted file mode 100644 index b14ab6b..0000000 --- a/src/main/java/com/dji/sdk/config/GetSnakeDataBinder.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.dji.sdk.config; - -import com.dji.sdk.common.Common; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.springframework.beans.MutablePropertyValues; -import org.springframework.beans.PropertyValue; -import org.springframework.web.servlet.mvc.method.annotation.ExtendedServletRequestDataBinder; - -import javax.servlet.ServletRequest; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author sean - * @version 1.2 - * @date 2022/9/9 - */ -public class GetSnakeDataBinder extends ExtendedServletRequestDataBinder { - - public GetSnakeDataBinder(Object target, String objectName) { - super(target, objectName); - } - - @Override - protected void addBindValues(MutablePropertyValues mpvs, ServletRequest request) { - List propertyValueList = mpvs.getPropertyValueList(); - List values = new ArrayList<>(propertyValueList); - Field[] fields = this.getTarget().getClass().getDeclaredFields(); - Map fieldMap = Arrays.stream(fields).collect(Collectors.toMap(Field::getName, field -> field)); - fieldMap.putAll(Arrays.stream(fields).filter(field -> null != field.getAnnotation(JsonProperty.class)) - .collect(Collectors.toMap(field -> field.getAnnotation(JsonProperty.class).value(), field -> field))); - - for (PropertyValue property : values) { - if (!fieldMap.containsKey(property.getName())) { - continue; - } - - Field field = fieldMap.get(property.getName()); - List list = (List) Objects.requireNonNullElse(property.getConvertedValue(), new ArrayList<>()); - list.addAll((List) convertValue(field, this.getTarget(), property.getValue())); - if (!list.isEmpty()) { - property.setConvertedValue(list); - } - - String fieldName = field.getName(); - if (fieldName.equals(property.getName())) { - continue; - } - if (mpvs.contains(fieldName)) { - PropertyValue propertyValue = mpvs.getPropertyValue(fieldName); - if (null != propertyValue.getConvertedValue()) { - ((List) propertyValue.getConvertedValue()).addAll((List) property.getConvertedValue()); - } - } else { - mpvs.addPropertyValue(new PropertyValue(fieldName, Objects.requireNonNullElse(property.getConvertedValue(), property.getValue()))); - } - mpvs.removePropertyValue(property); - } - - super.addBindValues(mpvs, request); - } - - private Object convertValue(Field field, Object object, Object value) { - List convertedValue = new ArrayList(); - if (Enum.class.isAssignableFrom(field.getType())) { - convertedValue.add(getRealEnumValue(field.getType(), object, value)); - } - if (field.getType() == field.getGenericType()) { - return convertedValue; - } - if (List.class.isAssignableFrom(field.getType())) { - if (!value.getClass().isArray()) { - value = String.valueOf(value).split(","); - } - for (String v : (String[]) value) { - if ("".equals(v)) { - continue; - } - convertedValue.add(getRealEnumValue((Class) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0], object, v)); - } - } - - return convertedValue; - } - - private Object getRealEnumValue(Class type, Object object, Object... value) { - if (!type.isEnum()) { - return value; - } - Set methods = Arrays.stream(type.getDeclaredMethods()) - .filter(m -> null != m.getAnnotation(JsonCreator.class)) - .filter(m -> m.getParameterTypes().length == value.length).collect(Collectors.toSet()); - for (Method m : methods) { - try { - Class[] parameterTypes = m.getParameterTypes(); - for (int i = 0; i < value.length; i++) { - value[i] = Common.getObjectMapper().convertValue(value[i], parameterTypes[i]); - } - return m.invoke(object, value); - } catch (IllegalAccessException | InvocationTargetException ignored) { - } - } - return value; - } -} diff --git a/src/main/java/com/dji/sdk/config/version/CloudSDKVersionEnum.java b/src/main/java/com/dji/sdk/config/version/CloudSDKVersionEnum.java deleted file mode 100644 index 69bdcab..0000000 --- a/src/main/java/com/dji/sdk/config/version/CloudSDKVersionEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.dji.sdk.config.version; - -/** - * @author sean - * @version 1.7 - * @date 2023/5/22 - */ -public enum CloudSDKVersionEnum { - - V0_0_1("0.0.1"), - - V1_0_0("1.0.0"), - - V1_0_1("1.0.1"), - - DEFAULT("1.0.1"), - - V99("99"); - - private final String version; - - CloudSDKVersionEnum(String version) { - this.version = version; - } - - public String getVersion() { - return version; - } - - public boolean isSupported(CloudSDKVersionEnum version) { - return this.version.compareTo(version.getVersion()) >= 0; - } - - public boolean isDeprecated(CloudSDKVersionEnum version) { - return this.version.compareTo(version.getVersion()) >= 0; - } -} diff --git a/src/main/java/com/dji/sdk/config/version/DockThingVersionEnum.java b/src/main/java/com/dji/sdk/config/version/DockThingVersionEnum.java deleted file mode 100644 index 01b0f3b..0000000 --- a/src/main/java/com/dji/sdk/config/version/DockThingVersionEnum.java +++ /dev/null @@ -1,45 +0,0 @@ -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/5/19 - */ -public enum DockThingVersionEnum implements IThingVersion { - - V1_0_0("1.0.0", CloudSDKVersionEnum.V0_0_1), - - V1_1_0("1.1.0", CloudSDKVersionEnum.V0_0_1), - - V1_1_2("1.1.2", CloudSDKVersionEnum.V1_0_0), - - ; - - private final String thingVersion; - - private final CloudSDKVersionEnum cloudSDKVersion; - - DockThingVersionEnum(String thingVersion, CloudSDKVersionEnum cloudSDKVersion) { - this.thingVersion = thingVersion; - this.cloudSDKVersion = cloudSDKVersion; - } - - @JsonValue - public String getThingVersion() { - return thingVersion; - } - - public CloudSDKVersionEnum getCloudSDKVersion() { - return cloudSDKVersion; - } - - public static DockThingVersionEnum find(String thingVersion) { - return Arrays.stream(values()).filter(thingVersionEnum -> thingVersionEnum.thingVersion.equals(thingVersion)) - .findAny().orElseThrow(() -> new CloudSDKVersionException(thingVersion)); - } -} diff --git a/src/main/java/com/dji/sdk/config/version/DroneThingVersionEnum.java b/src/main/java/com/dji/sdk/config/version/DroneThingVersionEnum.java deleted file mode 100644 index 8f41853..0000000 --- a/src/main/java/com/dji/sdk/config/version/DroneThingVersionEnum.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.dji.sdk.config.version; - -import com.dji.sdk.exception.CloudSDKVersionException; -import com.fasterxml.jackson.annotation.JsonValue; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; -import java.util.Optional; - -/** - * @author sean - * @version 1.7 - * @date 2023/5/19 - */ -public enum DroneThingVersionEnum implements IThingVersion { - - V1_0_0("1.0.0", CloudSDKVersionEnum.V0_0_1), - - V1_1_0("1.1.0", CloudSDKVersionEnum.V1_0_0), - - V1_1_2("1.1.2", CloudSDKVersionEnum.V1_0_0), - - ; - - private static final Logger log = LoggerFactory.getLogger(DroneThingVersionEnum.class); - - private final String thingVersion; - - private final CloudSDKVersionEnum cloudSDKVersion; - - DroneThingVersionEnum(String thingVersion, CloudSDKVersionEnum cloudSDKVersion) { - this.thingVersion = thingVersion; - this.cloudSDKVersion = cloudSDKVersion; - } - - @JsonValue - public String getThingVersion() { - return thingVersion; - } - - public CloudSDKVersionEnum getCloudSDKVersion() { - return cloudSDKVersion; - } - - public static DroneThingVersionEnum find(String thingVersion) { - Optional opt = Arrays.stream(values()) - .filter(thingVersionEnum -> thingVersionEnum.thingVersion.equals(thingVersion)).findAny(); - if (opt.isPresent()) { - return opt.get(); - } - throw new CloudSDKVersionException(thingVersion); - } -} diff --git a/src/main/java/com/dji/sdk/mqtt/ChannelName.java b/src/main/java/com/dji/sdk/mqtt/ChannelName.java deleted file mode 100644 index 1fb7c82..0000000 --- a/src/main/java/com/dji/sdk/mqtt/ChannelName.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.dji.sdk.mqtt; - -/** - * The name of all channels. - * - * @author sean.zhou - * @date 2021/11/10 - * @version 0.1 - */ -public class ChannelName { - - public static final String INBOUND = "inbound"; - public static final String DEFAULT = "default"; - public static final String OUTBOUND = "outbound"; - - // status - public static final String INBOUND_STATUS = "inboundStatus"; - - public static final String OUTBOUND_STATUS = "outboundStatus"; - - public static final String INBOUND_STATUS_ONLINE = "inboundStatusOnline"; - - public static final String INBOUND_STATUS_OFFLINE = "inboundStatusOffline"; - - - // state - public static final String INBOUND_STATE = "inboundState"; - - public static final String INBOUND_STATE_RC_CONTROL_SOURCE = "inboundStateRcControlSource"; - - public static final String INBOUND_STATE_DOCK_CONTROL_SOURCE = "inboundStateDockControlSource"; - - public static final String INBOUND_STATE_RC_LIVESTREAM_ABILITY_UPDATE = "inboundStateRcLiveCapacity"; - - public static final String INBOUND_STATE_DOCK_LIVESTREAM_ABILITY_UPDATE = "inboundStateDockLiveCapacity"; - - public static final String INBOUND_STATE_RC_LIVE_STATUS = "inboundStateRcLiveStatus"; - - public static final String INBOUND_STATE_DOCK_LIVE_STATUS = "inboundStateDockLiveStatus"; - - public static final String INBOUND_STATE_RC_FIRMWARE_VERSION = "inboundStateRcFirmwareVersion"; - - public static final String INBOUND_STATE_DOCK_FIRMWARE_VERSION = "inboundStateDockFirmwareVersion"; - - public static final String INBOUND_STATE_RC_PAYLOAD_FIRMWARE = "inboundStateRcPayloadFirmware"; - - public static final String INBOUND_STATE_DOCK_WPMZ_VERSION = "inboundStateDockWpmzVersion"; - - public static final String INBOUND_STATE_DOCK_PAYLOAD = "inboundStateDockPayload"; - - - // services_reply - public static final String INBOUND_SERVICES_REPLY = "inboundServicesReply"; - - - // osd - public static final String INBOUND_OSD = "inboundOsd"; - - public static final String INBOUND_OSD_RC = "inboundOsdRc"; - - public static final String INBOUND_OSD_DOCK = "inboundOsdDock"; - - public static final String INBOUND_OSD_RC_DRONE = "inboundOsdRcDrone"; - - public static final String INBOUND_OSD_DOCK_DRONE = "inboundOsdDockDrone"; - - - // requests - public static final String INBOUND_REQUESTS = "inboundRequests"; - - public static final String INBOUND_REQUESTS_STORAGE_CONFIG_GET = "inboundRequestsStorageConfigGet"; - - public static final String INBOUND_REQUESTS_AIRPORT_BIND_STATUS = "inboundRequestsAirportBindStatus"; - - public static final String INBOUND_REQUESTS_AIRPORT_ORGANIZATION_GET = "inboundRequestsAirportOrganizationGet"; - - public static final String INBOUND_REQUESTS_AIRPORT_ORGANIZATION_BIND = "inboundRequestsAirportOrganizationBind"; - - public static final String INBOUND_REQUESTS_CONFIG = "inboundRequestsConfig"; - - public static final String INBOUND_REQUESTS_FLIGHTTASK_RESOURCE_GET = "inboundEventsFlightTaskResourceGet"; - - public static final String OUTBOUND_REQUESTS = "outboundRequests"; - - - // events - public static final String INBOUND_EVENTS = "inboundEvents"; - - public static final String OUTBOUND_EVENTS = "outboundEvents"; - - public static final String INBOUND_EVENTS_DEVICE_EXIT_HOMING_NOTIFY = "inboundEventsDeviceExitHomingNotify"; - - public static final String INBOUND_EVENTS_FLIGHTTASK_PROGRESS = "inboundEventsFlighttaskProgress"; - - public static final String INBOUND_EVENTS_FLIGHTTASK_READY = "inboundEventsFlighttaskReady"; - - public static final String INBOUND_EVENTS_FILE_UPLOAD_CALLBACK = "inboundEventsFileUploadCallback"; - - public static final String INBOUND_EVENTS_HMS = "inboundEventsHms"; - - public static final String INBOUND_EVENTS_CONTROL_PROGRESS = "inboundEventsControlProgress"; - - public static final String INBOUND_EVENTS_OTA_PROGRESS = "inboundEventsOtaProgress"; - - public static final String INBOUND_EVENTS_FILEUPLOAD_PROGRESS = "inboundEventsFileUploadProgress"; - - public static final String INBOUND_EVENTS_FLY_TO_POINT_PROGRESS = "inboundEventsFlyToPointProgress"; - - public static final String INBOUND_EVENTS_TAKEOFF_TO_POINT_PROGRESS = "inboundEventsTakeoffToPointProgress"; - - public static final String INBOUND_EVENTS_DRC_STATUS_NOTIFY = "inboundEventsDrcStatusNotify"; - - public static final String INBOUND_EVENTS_JOYSTICK_INVALID_NOTIFY = "inboundEventsJoystickInvalidNotify"; - - public static final String INBOUND_EVENTS_HIGHEST_PRIORITY_UPLOAD_FLIGHT_TASK_MEDIA = "inboundEventsHighestPriorityUploadFlightTaskMedia"; - - - // property - public static final String INBOUND_PROPERTY_SET_REPLY = "inboundPropertySetReply"; - - - // drc/up - public static final String INBOUND_DRC_UP = "inboundDrcUp"; - - public static final String INBOUND_DRC_UP_DRONE_CONTROL = "inboundDrcUpDroneControl"; - - public static final String INBOUND_DRC_UP_DRONE_EMERGENCY_STOP = "inboundDrcUpDroneEmergencyStop"; - - public static final String INBOUND_DRC_UP_HEART_BEAT = "inboundDrcUpHeartBeat"; - - public static final String INBOUND_DRC_UP_HSI_INFO_PUSH = "inboundDrcUpHsiInfoPush"; - - public static final String INBOUND_DRC_UP_DELAY_INFO_PUSH = "inboundDrcUpDelayInfoPush"; - - public static final String INBOUND_DRC_UP_OSD_INFO_PUSH = "inboundDrcUpOsdInfoPush"; - -} diff --git a/src/main/java/com/dji/sdk/mqtt/MqttGatewayPublish.java b/src/main/java/com/dji/sdk/mqtt/MqttGatewayPublish.java deleted file mode 100644 index 8d60425..0000000 --- a/src/main/java/com/dji/sdk/mqtt/MqttGatewayPublish.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.dji.sdk.mqtt; - -import com.dji.sdk.common.Common; -import com.dji.sdk.exception.CloudSDKErrorEnum; -import com.dji.sdk.exception.CloudSDKException; -import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.TypeMismatchException; -import org.springframework.integration.mqtt.support.MqttHeaders; -import org.springframework.messaging.MessageHeaders; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; - -import javax.annotation.Resource; -import java.util.Objects; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * @author sean.zhou - * @date 2021/11/16 - * @version 0.1 - */ -@Component -@Slf4j -public class MqttGatewayPublish { - - private static final int DEFAULT_QOS = 0; - public static final int DEFAULT_RETRY_COUNT = 2; - public static final int DEFAULT_RETRY_TIMEOUT = 3000; - - @Resource - private IMqttMessageGateway messageGateway; - - public void publish(String topic, int qos, CommonTopicRequest request) { - try { - log.debug("send topic: {}, payload: {}", topic, request.toString()); - byte[] payload = Common.getObjectMapper().writeValueAsBytes(request); - messageGateway.publish(topic, payload, qos); - } catch (JsonProcessingException e) { - log.error("Failed to publish the message. {}", request.toString()); - e.printStackTrace(); - } - } - - public void publish(String topic, int qos, CommonTopicResponse response) { - try { - log.debug("send topic: {}, payload: {}", topic, response.toString()); - byte[] payload = Common.getObjectMapper().writeValueAsBytes(response); - messageGateway.publish(topic, payload, qos); - } catch (JsonProcessingException e) { - log.error("Failed to publish the message. {}", response.toString()); - e.printStackTrace(); - } - } - - public void publish(String topic, CommonTopicRequest request, int publishCount) { - AtomicInteger time = new AtomicInteger(0); - while (time.getAndIncrement() < publishCount) { - this.publish(topic, DEFAULT_QOS, request); - } - } - - public void publish(String topic, CommonTopicRequest request) { - this.publish(topic, DEFAULT_QOS, request); - } - - public void publishReply(CommonTopicResponse response, MessageHeaders headers) { - this.publish(headers.get(MqttHeaders.RECEIVED_TOPIC) + TopicConst._REPLY_SUF, 2, response); - } - - public CommonTopicResponse publishWithReply(Class clazz, String topic, CommonTopicRequest request, int retryCount, long timeout) { - AtomicInteger time = new AtomicInteger(0); - boolean hasBid = StringUtils.hasText(request.getBid()); - request.setBid(hasBid ? request.getBid() : UUID.randomUUID().toString()); - // Retry - while (time.getAndIncrement() <= retryCount) { - this.publish(topic, request); - - // If the message is not received in 3 seconds then resend it again. - CommonTopicResponse receiver = Chan.getInstance(request.getTid(), true).get(request.getTid(), timeout); - // Need to match tid and bid. - if (Objects.nonNull(receiver) - && receiver.getTid().equals(request.getTid()) - && receiver.getBid().equals(request.getBid())) { - if (clazz.isAssignableFrom(receiver.getData().getClass())) { - return receiver; - } - throw new TypeMismatchException(receiver.getData(), clazz); - } - // It must be guaranteed that the tid and bid of each message are different. - if (!hasBid) { - request.setBid(UUID.randomUUID().toString()); - } - request.setTid(UUID.randomUUID().toString()); - } - throw new CloudSDKException(CloudSDKErrorEnum.MQTT_PUBLISH_ABNORMAL, "No message reply received."); - } - - -} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/mqtt/MqttReplyHandler.java b/src/main/java/com/dji/sdk/mqtt/MqttReplyHandler.java deleted file mode 100644 index f0e3a27..0000000 --- a/src/main/java/com/dji/sdk/mqtt/MqttReplyHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.dji.sdk.mqtt; - -import com.dji.sdk.common.BaseModel; -import com.dji.sdk.common.Common; -import com.dji.sdk.mqtt.events.TopicEventsRequest; -import com.dji.sdk.mqtt.events.TopicEventsResponse; -import com.dji.sdk.mqtt.requests.TopicRequestsRequest; -import com.dji.sdk.mqtt.requests.TopicRequestsResponse; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.Aspect; -import org.springframework.stereotype.Component; - -import java.util.Objects; - -/** - * @author sean - * @version 1.7 - * @date 2023/5/22 - */ -@Aspect -@Component -public class MqttReplyHandler { - - @AfterReturning(value = "execution(public com.dji.sdk.mqtt.CommonTopicResponse+ com.dji.sdk.cloudapi.*.api.*.*(com.dji.sdk.mqtt.CommonTopicRequest+, org.springframework.messaging.MessageHeaders))", returning = "result") - public Object validateReturnValue(JoinPoint point, CommonTopicResponse result) { - if (Objects.isNull(result)) { - return null; - } - CommonTopicRequest request = (CommonTopicRequest) point.getArgs()[0]; - result.setBid(request.getBid()).setTid(request.getTid()).setTimestamp(System.currentTimeMillis()); - if (result instanceof TopicEventsResponse) { - fillEvents((TopicEventsResponse) result, (TopicEventsRequest) request); - } else if (result instanceof TopicRequestsResponse) { - validateRequests((TopicRequestsResponse) result, (TopicRequestsRequest) request); - } - return result; - } - - private void fillEvents(TopicEventsResponse response, TopicEventsRequest request) { - if (!request.isNeedReply()) { - response.setData(null); - return; - } - response.setMethod(request.getMethod()).setData(MqttReply.success()); - } - - private void validateRequests(TopicRequestsResponse response, TopicRequestsRequest request) { - response.setMethod(request.getMethod()); - Object data = response.getData(); - if (data instanceof MqttReply) { - MqttReply mqttData = (MqttReply) data; - if (MqttReply.CODE_SUCCESS != mqttData.getResult()) { - return; - } - data = mqttData.getOutput(); - } - Common.validateModel((BaseModel) data); - } -} diff --git a/src/main/java/com/dji/sdk/mqtt/events/EventsMethodEnum.java b/src/main/java/com/dji/sdk/mqtt/events/EventsMethodEnum.java deleted file mode 100644 index 92ca2d8..0000000 --- a/src/main/java/com/dji/sdk/mqtt/events/EventsMethodEnum.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.dji.sdk.mqtt.events; - -import com.dji.sdk.cloudapi.control.DrcStatusNotify; -import com.dji.sdk.cloudapi.control.FlyToPointProgress; -import com.dji.sdk.cloudapi.control.JoystickInvalidNotify; -import com.dji.sdk.cloudapi.control.TakeoffToPointProgress; -import com.dji.sdk.cloudapi.debug.RemoteDebugProgress; -import com.dji.sdk.cloudapi.firmware.OtaProgress; -import com.dji.sdk.cloudapi.hms.Hms; -import com.dji.sdk.cloudapi.log.FileUploadProgress; -import com.dji.sdk.cloudapi.media.FileUploadCallback; -import com.dji.sdk.cloudapi.media.HighestPriorityUploadFlightTaskMedia; -import com.dji.sdk.cloudapi.wayline.DeviceExitHomingNotify; -import com.dji.sdk.cloudapi.wayline.FlighttaskProgress; -import com.dji.sdk.cloudapi.wayline.FlighttaskReady; -import com.dji.sdk.mqtt.ChannelName; -import com.fasterxml.jackson.core.type.TypeReference; - -import java.util.Arrays; - -/** - * @author sean - * @version 1.1 - * @date 2022/6/1 - */ -public enum EventsMethodEnum { - - FLIGHTTASK_PROGRESS("flighttask_progress", ChannelName.INBOUND_EVENTS_FLIGHTTASK_PROGRESS, new TypeReference>() {}), - - DEVICE_EXIT_HOMING_NOTIFY("device_exit_homing_notify", ChannelName.INBOUND_EVENTS_DEVICE_EXIT_HOMING_NOTIFY, new TypeReference() {}), - - FILE_UPLOAD_CALLBACK("file_upload_callback", ChannelName.INBOUND_EVENTS_FILE_UPLOAD_CALLBACK, new TypeReference() {}), - - HMS("hms", ChannelName.INBOUND_EVENTS_HMS, new TypeReference() {}), - - DEVICE_REBOOT("device_reboot", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), - - DRONE_OPEN("drone_open", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), - - DRONE_CLOSE("drone_close", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), - - DRONE_FORMAT("drone_format", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), - - DEVICE_FORMAT("device_format", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), - - COVER_OPEN("cover_open", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), - - COVER_CLOSE("cover_close", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), - - PUTTER_OPEN("putter_open", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), - - PUTTER_CLOSE("putter_close", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), - - CHARGE_OPEN("charge_open", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), - - CHARGE_CLOSE("charge_close", ChannelName.INBOUND_EVENTS_CONTROL_PROGRESS, new TypeReference>() {}), - - OTA_PROGRESS("ota_progress", ChannelName.INBOUND_EVENTS_OTA_PROGRESS, new TypeReference>() {}), - - FILE_UPLOAD_PROGRESS("fileupload_progress", ChannelName.INBOUND_EVENTS_FILEUPLOAD_PROGRESS, new TypeReference>() {}), - - HIGHEST_PRIORITY_UPLOAD_FLIGHT_TASK_MEDIA("highest_priority_upload_flighttask_media", ChannelName.INBOUND_EVENTS_HIGHEST_PRIORITY_UPLOAD_FLIGHT_TASK_MEDIA, new TypeReference() {}), - - FLIGHT_TASK_READY("flighttask_ready", ChannelName.INBOUND_EVENTS_FLIGHTTASK_READY, new TypeReference() {}), - - FLY_TO_POINT_PROGRESS("fly_to_point_progress", ChannelName.INBOUND_EVENTS_FLY_TO_POINT_PROGRESS, new TypeReference() {}), - - TAKE_OFF_TO_POINT_PROGRESS("takeoff_to_point_progress", ChannelName.INBOUND_EVENTS_TAKEOFF_TO_POINT_PROGRESS, new TypeReference() {}), - - DRC_STATUS_NOTIFY("drc_status_notify", ChannelName.INBOUND_EVENTS_DRC_STATUS_NOTIFY, new TypeReference() {}), - - JOYSTICK_INVALID_NOTIFY("joystick_invalid_notify", ChannelName.INBOUND_EVENTS_JOYSTICK_INVALID_NOTIFY, new TypeReference() {}), - - UNKNOWN("", ChannelName.DEFAULT, new TypeReference<>() {}); - - private final String method; - - private final String channelName; - - private final TypeReference classType; - - EventsMethodEnum(String method, String channelName, TypeReference classType) { - this.method = method; - this.channelName = channelName; - this.classType = classType; - } - - public String getMethod() { - return method; - } - - public String getChannelName() { - return channelName; - } - - public TypeReference getClassType() { - return classType; - } - - public static EventsMethodEnum find(String method) { - return Arrays.stream(EventsMethodEnum.values()) - .filter(methodEnum -> methodEnum.method.equals(method)) - .findAny().orElse(UNKNOWN); - } -} diff --git a/src/main/java/com/dji/sdk/mqtt/requests/RequestsMethodEnum.java b/src/main/java/com/dji/sdk/mqtt/requests/RequestsMethodEnum.java deleted file mode 100644 index 40e79a4..0000000 --- a/src/main/java/com/dji/sdk/mqtt/requests/RequestsMethodEnum.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.dji.sdk.mqtt.requests; - -import com.dji.sdk.cloudapi.config.RequestsConfigRequest; -import com.dji.sdk.cloudapi.media.StorageConfigGet; -import com.dji.sdk.cloudapi.organization.AirportBindStatusRequest; -import com.dji.sdk.cloudapi.organization.AirportOrganizationBindRequest; -import com.dji.sdk.cloudapi.organization.AirportOrganizationGetRequest; -import com.dji.sdk.cloudapi.wayline.FlighttaskResourceGetRequest; -import com.dji.sdk.mqtt.ChannelName; - -import java.util.Arrays; - -/** - * @author sean - * @version 1.0 - * @date 2022/5/25 - */ -public enum RequestsMethodEnum { - - STORAGE_CONFIG_GET("storage_config_get", ChannelName.INBOUND_REQUESTS_STORAGE_CONFIG_GET, StorageConfigGet.class), - - AIRPORT_BIND_STATUS("airport_bind_status", ChannelName.INBOUND_REQUESTS_AIRPORT_BIND_STATUS, AirportBindStatusRequest.class), - - AIRPORT_ORGANIZATION_BIND("airport_organization_bind", ChannelName.INBOUND_REQUESTS_AIRPORT_ORGANIZATION_BIND, AirportOrganizationBindRequest.class), - - AIRPORT_ORGANIZATION_GET("airport_organization_get", ChannelName.INBOUND_REQUESTS_AIRPORT_ORGANIZATION_GET, AirportOrganizationGetRequest.class), - - FLIGHT_TASK_RESOURCE_GET("flighttask_resource_get", ChannelName.INBOUND_REQUESTS_FLIGHTTASK_RESOURCE_GET, FlighttaskResourceGetRequest.class), - - CONFIG("config", ChannelName.INBOUND_REQUESTS_CONFIG, RequestsConfigRequest.class), - - UNKNOWN("", ChannelName.DEFAULT, Object.class); - - private final String method; - - private final String channelName; - - private final Class classType; - - RequestsMethodEnum(String method, String channelName, Class classType) { - this.method = method; - this.channelName = channelName; - this.classType = classType; - } - - public String getMethod() { - return method; - } - - public String getChannelName() { - return channelName; - } - - public Class getClassType() { - return classType; - } - - public static RequestsMethodEnum find(String method) { - return Arrays.stream(RequestsMethodEnum.values()) - .filter(methodEnum -> methodEnum.method.equals(method)) - .findAny().orElse(UNKNOWN); - } -} diff --git a/src/main/java/com/dji/sdk/mqtt/state/DockStateDataKeyEnum.java b/src/main/java/com/dji/sdk/mqtt/state/DockStateDataKeyEnum.java deleted file mode 100644 index 3cff877..0000000 --- a/src/main/java/com/dji/sdk/mqtt/state/DockStateDataKeyEnum.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.dji.sdk.mqtt.state; - -import com.dji.sdk.cloudapi.device.*; -import com.dji.sdk.cloudapi.livestream.DockLivestreamAbilityUpdate; -import com.dji.sdk.exception.CloudSDKException; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Set; - -/** - * - * @author sean.zhou - * @date 2021/11/18 - * @version 0.1 - */ -public enum DockStateDataKeyEnum { - - FIRMWARE_VERSION(Set.of("firmware_version"), DockFirmwareVersion.class), - - LIVE_CAPACITY(Set.of("live_capacity"), DockLivestreamAbilityUpdate.class), - - CONTROL_SOURCE(Set.of("control_source"), DockDroneControlSource.class), - - LIVE_STATUS(Set.of("live_status"), DockLiveStatus.class), - - WPMZ_VERSION(Set.of("wpmz_version"), DockWpmzVersion.class), - - PAYLOAD(PayloadModelConst.getAllIndexWithPosition(), DockPayload.class) - ; - - private final Set keys; - - private final Class classType; - - - DockStateDataKeyEnum(Set keys, Class classType) { - this.keys = keys; - this.classType = classType; - } - - public Class getClassType() { - return classType; - } - - public Set getKeys() { - return keys; - } - - public static DockStateDataKeyEnum find(Set keys) { - return Arrays.stream(values()).filter(keyEnum -> !Collections.disjoint(keys, keyEnum.keys)).findAny() - .orElseThrow(() -> new CloudSDKException(DockStateDataKeyEnum.class, keys)); - } - -} diff --git a/src/main/java/com/dji/sdk/mqtt/state/RcStateDataKeyEnum.java b/src/main/java/com/dji/sdk/mqtt/state/RcStateDataKeyEnum.java deleted file mode 100644 index 522cbc9..0000000 --- a/src/main/java/com/dji/sdk/mqtt/state/RcStateDataKeyEnum.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.dji.sdk.mqtt.state; - -import com.dji.sdk.cloudapi.device.*; -import com.dji.sdk.cloudapi.livestream.DockLivestreamAbilityUpdate; -import com.dji.sdk.exception.CloudSDKException; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Set; - -/** - * - * @author sean.zhou - * @date 2021/11/18 - * @version 0.1 - */ -public enum RcStateDataKeyEnum { - - FIRMWARE_VERSION(Set.of("firmware_version"), RcFirmwareVersion.class), - - LIVE_CAPACITY(Set.of("live_capacity"), DockLivestreamAbilityUpdate.class), - - CONTROL_SOURCE(Set.of("control_source"), RcDroneControlSource.class), - - LIVE_STATUS(Set.of("live_status"), RcLiveStatus.class), - - PAYLOAD_FIRMWARE(PayloadModelConst.getAllModelWithPosition(), PayloadFirmwareVersion.class), - ; - - private final Set keys; - - private final Class classType; - - - RcStateDataKeyEnum(Set keys, Class classType) { - this.keys = keys; - this.classType = classType; - } - - public Class getClassType() { - return classType; - } - - public Set getKeys() { - return keys; - } - - public static RcStateDataKeyEnum find(Set keys) { - return Arrays.stream(values()).filter(keyEnum -> !Collections.disjoint(keys, keyEnum.keys)).findAny() - .orElseThrow(() -> new CloudSDKException(RcStateDataKeyEnum.class, keys)); - } - -} diff --git a/src/main/java/com/dji/sdk/mqtt/state/StateDataKeyEnum.java b/src/main/java/com/dji/sdk/mqtt/state/StateDataKeyEnum.java deleted file mode 100644 index 12fcdff..0000000 --- a/src/main/java/com/dji/sdk/mqtt/state/StateDataKeyEnum.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.dji.sdk.mqtt.state; - -import com.dji.sdk.cloudapi.device.*; -import com.dji.sdk.cloudapi.livestream.DockLivestreamAbilityUpdate; -import com.dji.sdk.cloudapi.livestream.RcLivestreamAbilityUpdate; -import com.dji.sdk.mqtt.ChannelName; - -import java.util.Arrays; - -/** - * - * @author sean.zhou - * @date 2021/11/18 - * @version 0.1 - */ -public enum StateDataKeyEnum { - - RC_FIRMWARE_VERSION(ChannelName.INBOUND_STATE_RC_FIRMWARE_VERSION, RcFirmwareVersion.class), - - RC_LIVE_CAPACITY(ChannelName.INBOUND_STATE_RC_LIVESTREAM_ABILITY_UPDATE, RcLivestreamAbilityUpdate.class), - - RC_CONTROL_SOURCE(ChannelName.INBOUND_STATE_RC_CONTROL_SOURCE, RcDroneControlSource.class), - - RC_LIVE_STATUS(ChannelName.INBOUND_STATE_RC_LIVE_STATUS, RcLiveStatus.class), - - RC_PAYLOAD_FIRMWARE(ChannelName.INBOUND_STATE_RC_PAYLOAD_FIRMWARE, PayloadFirmwareVersion.class), - - DOCK_FIRMWARE_VERSION(ChannelName.INBOUND_STATE_DOCK_FIRMWARE_VERSION, DockFirmwareVersion.class), - - DOCK_LIVE_CAPACITY(ChannelName.INBOUND_STATE_DOCK_LIVESTREAM_ABILITY_UPDATE, DockLivestreamAbilityUpdate.class), - - DOCK_CONTROL_SOURCE(ChannelName.INBOUND_STATE_DOCK_CONTROL_SOURCE, DockDroneControlSource.class), - - DOCK_LIVE_STATUS(ChannelName.INBOUND_STATE_DOCK_LIVE_STATUS, DockLiveStatus.class), - - WPMZ_VERSION(ChannelName.INBOUND_STATE_DOCK_WPMZ_VERSION, DockWpmzVersion.class), - - DOCK_PAYLOAD(ChannelName.INBOUND_STATE_DOCK_PAYLOAD, DockPayload.class), - - UNKNOWN(ChannelName.DEFAULT, Object.class); - - private final String channelName; - - private final Class classType; - - StateDataKeyEnum(String channelName, Class classType) { - this.channelName = channelName; - this.classType = classType; - } - - public Class getClassType() { - return classType; - } - - public String getChannelName() { - return channelName; - } - - public static StateDataKeyEnum find(Class clazz) { - return Arrays.stream(values()).filter(keyEnum -> keyEnum.classType == clazz).findAny() - .orElse(UNKNOWN); - } - -} diff --git a/src/main/java/com/dji/sdk/mqtt/state/StateRouter.java b/src/main/java/com/dji/sdk/mqtt/state/StateRouter.java deleted file mode 100644 index 22425ff..0000000 --- a/src/main/java/com/dji/sdk/mqtt/state/StateRouter.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.dji.sdk.mqtt.state; - -import com.dji.sdk.common.Common; -import com.dji.sdk.common.SDKManager; -import com.dji.sdk.exception.CloudSDKErrorEnum; -import com.dji.sdk.exception.CloudSDKException; -import com.dji.sdk.mqtt.ChannelName; -import com.fasterxml.jackson.core.type.TypeReference; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; -import org.springframework.integration.mqtt.support.MqttHeaders; -import org.springframework.messaging.Message; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Map; -import java.util.Set; - -import static com.dji.sdk.mqtt.TopicConst.*; - -/** - * - * @author sean.zhou - * @date 2021/11/17 - * @version 0.1 - */ -@Configuration -public class StateRouter { - - @Bean - public IntegrationFlow stateDataRouterFlow() { - return IntegrationFlows - .from(ChannelName.INBOUND_STATE) - .transform(Message.class, source -> { - try { - TopicStateRequest response = Common.getObjectMapper().readValue((byte[]) source.getPayload(), new TypeReference() {}); - String topic = String.valueOf(source.getHeaders().get(MqttHeaders.RECEIVED_TOPIC)); - String from = topic.substring((THING_MODEL_PRE + PRODUCT).length(), topic.indexOf(STATE_SUF)); - return response.setFrom(from) - .setData(Common.getObjectMapper().convertValue(response.getData(), getTypeReference(response.getGateway(), response.getData()))); - } catch (IOException e) { - throw new CloudSDKException(e); - } - }, null) - .route(response -> StateDataKeyEnum.find(response.getData().getClass()), - mapping -> Arrays.stream(StateDataKeyEnum.values()).forEach(key -> mapping.channelMapping(key, key.getChannelName()))) - .get(); - } - - private Class getTypeReference(String gatewaySn, Object data) { - Set keys = ((Map) data).keySet(); - switch (SDKManager.getDeviceSDK(gatewaySn).getType()) { - 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()); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sdk/mqtt/state/TopicStateRequest.java b/src/main/java/com/dji/sdk/mqtt/state/TopicStateRequest.java deleted file mode 100644 index 555772c..0000000 --- a/src/main/java/com/dji/sdk/mqtt/state/TopicStateRequest.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.dji.sdk.mqtt.state; - -import com.dji.sdk.mqtt.CommonTopicRequest; - -/** - * @author sean - * @version 1.7 - * @date 2023/5/24 - */ -public class TopicStateRequest extends CommonTopicRequest { - - private String gateway; - - private String from; - - public TopicStateRequest() { - } - - @Override - public String toString() { - return "TopicStateRequest{" + - "gateway='" + gateway + '\'' + - ", from='" + from + '\'' + - ", tid='" + tid + '\'' + - ", bid='" + bid + '\'' + - ", timestamp=" + timestamp + - ", data=" + data + - '}'; - } - public String getTid() { - return tid; - } - - public TopicStateRequest setTid(String tid) { - this.tid = tid; - return this; - } - - public String getBid() { - return bid; - } - - public TopicStateRequest setBid(String bid) { - this.bid = bid; - return this; - } - - public Long getTimestamp() { - return timestamp; - } - - public TopicStateRequest setTimestamp(Long timestamp) { - this.timestamp = timestamp; - return this; - } - - public T getData() { - return data; - } - - public TopicStateRequest setData(T data) { - this.data = data; - return this; - } - - public String getGateway() { - return gateway; - } - - public TopicStateRequest setGateway(String gateway) { - this.gateway = gateway; - return this; - } - - public String getFrom() { - return from; - } - - public TopicStateRequest setFrom(String from) { - this.from = from; - return this; - } -} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml deleted file mode 100644 index 07752bf..0000000 --- a/src/main/resources/application.yml +++ /dev/null @@ -1,141 +0,0 @@ -server: - port: 6789 -spring: - main: - allow-bean-definition-overriding: true - application: - name: cloud-api-sample - datasource: - druid: - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://cloud_api_sample_mysql:3306/cloud_sample?useSSL=false&allowPublicKeyRetrieval=true - username: root - password: root - initial-size: 10 - min-idle: 10 - max-active: 20 - max-wait: 60000 - - redis: - host: cloud_api_sample_redis - port: 6379 - database: 0 - username: # if you enable - password: - lettuce: - pool: - max-active: 8 - max-idle: 8 - min-idle: 0 - - servlet: - multipart: - max-file-size: 2GB - max-request-size: 2GB - -jwt: - issuer: DJI - subject: CloudApiSample - secret: CloudApiSample - age: 86400 - -mqtt: - # @see com.dji.sample.component.mqtt.model.MqttUseEnum - # BASIC parameters are required. - BASIC: - protocol: MQTT # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum - host: Please enter your ip. - port: 1883 - username: JavaServer - password: 123456 - client-id: 123456 - # If the protocol is ws/wss, this value is required. - path: - DRC: - protocol: WS # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum - host: Please enter your ip. - port: 8083 - path: /mqtt - username: JavaServer - password: 123456 - -cloud-sdk: - mqtt: - # Topics that need to be subscribed when initially connecting to mqtt, multiple topics are divided by ",". - inbound-topic: sys/product/+/status,thing/product/+/requests - -url: - manage: - prefix: manage - version: /api/v1 - map: - prefix: map - version: /api/v1 - media: - prefix: media - version: /api/v1 - wayline: - prefix: wayline - version: /api/v1 - storage: - prefix: storage - version: /api/v1 - control: - prefix: control - version: /api/v1 - -# Tutorial: https://www.alibabacloud.com/help/en/object-storage-service/latest/use-a-temporary-credential-provided-by-sts-to-access-oss -oss: - enable: false - provider: ALIYUN # @see com.dji.sample.component.OssConfiguration.model.enums.OssTypeEnum - endpoint: https://oss-cn-hangzhou.aliyuncs.com - access-key: Please enter your access key. - secret-key: Please enter your secret key. - expire: 3600 - region: Please enter your oss region. # cn-hangzhou - role-session-name: cloudApi - role-arn: Please enter your role arn. # acs:ram::123456789:role/stsrole - bucket: Please enter your bucket name. - object-dir-prefix: Please enter a folder name. - -#oss: -# enable: true -# provider: aws -# endpoint: https://s3.us-east-1.amazonaws.com -# access-key: -# secret-key: -# expire: 3600 -# region: us-east-1 -# role-session-name: cloudApi -# role-arn: -# bucket: cloudapi-bucket -# object-dir-prefix: wayline - -#oss: -# enable: true -# provider: minio -# endpoint: http://192.168.1.1:9000 -# access-key: minioadmin -# secret-key: minioadmin -# bucket: cloud-bucket -# expire: 3600 -# region: us-east-1 -# object-dir-prefix: wayline - -logging: - level: - com.dji: debug - file: - name: logs/cloud-api-sample.log - -ntp: - server: - host: Google.mzr.me - -# To create a license for an application: https://developer.dji.com/user/apps/#all -cloud-api: - app: - id: Please enter the app id. - key: Please enter the app key. - license: Please enter the app license. \ No newline at end of file