package com.dji.sample.debug.service.impl;
|
|
import com.dji.sample.debug.model.param.*;
|
import com.dji.sample.debug.service.DebugService;
|
import com.dji.sdk.cloudapi.debug.*;
|
import com.dji.sdk.cloudapi.debug.api.AbstractDebugService;
|
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 com.fasterxml.jackson.databind.ObjectMapper;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
/**
|
* @author wmm
|
* @version 0.1
|
* @date 2024/5/8
|
*/
|
@Service
|
@Slf4j
|
public class DebugServiceImpl implements DebugService {
|
|
|
@Autowired
|
private AbstractDebugService abstractDebugService;
|
|
@Autowired
|
private ObjectMapper mapper;
|
|
@Override
|
public HttpResultResponse coverOpen(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.coverOpen(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The cover failed to open. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse coverClose(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.coverClose(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The cover failed to close. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse debugModeOpen(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.debugModeOpen(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The debug mode failed to open. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse debugModeClose(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.debugModeClose(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The debug mode failed to close. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse supplementLightOpen(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.supplementLightOpen(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The supplementLight failed to open. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse supplementLightClose(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.supplementLightClose(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The supplementLight failed to close. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse chargeOpen(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.chargeOpen(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The charge failed to open. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse chargeClose(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.chargeClose(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The charge failed to close. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse droneOpen(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.droneOpen(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The drone failed to open. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse droneClose(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.droneClose(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The drone failed to close. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse deviceFormat(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.deviceFormat(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The device failed to format. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse droneFormat(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.droneFormat(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The drone failed to format. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse deviceReboot(String sn) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.deviceReboot(SDKManager.getDeviceSDK(sn));
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The device failed to reboot. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse batteryMaintenanceSwitch(String sn, BatteryMaintenanceSwitchParam param) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.batteryMaintenanceSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, BatteryMaintenanceSwitchRequest.class));
|
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The battery maintenance failed to switch. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse airConditionerModeSwitch(String sn, AirConditionerModeSwitchParam param) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.airConditionerModeSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, AirConditionerModeSwitchRequest.class));
|
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The air conditioner mode failed to switch. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse alarmStateSwitch(String sn, AlarmStateSwitchParam param) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.alarmStateSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, AlarmStateSwitchRequest.class));
|
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The alarm state failed to switch. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse batteryStoreModeSwitch(String sn, BatteryStoreModeSwitchParam param) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.batteryStoreModeSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, BatteryStoreModeSwitchRequest.class));
|
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The battery store mode failed to switch. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse sdrWorkmodeSwitch(String sn, SdrWorkmodeSwitchParam param) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.sdrWorkmodeSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, SdrWorkmodeSwitchRequest.class));
|
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The sdr workmode failed to switch. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse esimActivate(String sn, EsimActivateParam param) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.esimActivate(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, EsimActivateRequest.class));
|
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The esim failed to activate. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse simSlotSwitch(String sn, SimSlotSwitchParam param) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.simSlotSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, SimSlotSwitchRequest.class));
|
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The sim slot failed to switch. " + reply.getResult());
|
}
|
|
@Override
|
public HttpResultResponse esimOperatorSwitch(String sn, EsimOperatorSwitchParam param) {
|
|
TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.esimOperatorSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, EsimOperatorSwitchRequest.class));
|
|
ServicesReplyData reply = response.getData();
|
return reply.getResult().isSuccess() ?
|
HttpResultResponse.success()
|
: HttpResultResponse.error("The esim operator failed to switch. " + reply.getResult());
|
}
|
}
|