| | |
| | | import com.dji.sample.component.mqtt.model.ChannelName; |
| | | import com.dji.sample.component.mqtt.model.CommonTopicReceiver; |
| | | import com.dji.sample.component.mqtt.model.CommonTopicResponse; |
| | | import com.dji.sample.droneairport.service.RegistService; |
| | | import com.dji.sample.manage.model.dto.DeviceDTO; |
| | | import com.dji.sample.manage.model.dto.DeviceFirmwareUpgradeDTO; |
| | | import com.dji.sample.manage.model.enums.DeviceSetPropertyEnum; |
| | |
| | | |
| | | @Autowired |
| | | private IDeviceService deviceService; |
| | | @Autowired |
| | | private RegistService registService; |
| | | |
| | | /** |
| | | * Handles the message that the drone goes online. |
| | |
| | | .timestamp(System.currentTimeMillis()) |
| | | .method(receiver.getMethod()) |
| | | .build()); |
| | | } |
| | | if (receiver.getData().getSn().length()==14){ |
| | | registService.Authorization(receiver.getData().getSn()); |
| | | } |
| | | } |
| | | |
| | |
| | | .build()); |
| | | |
| | | } |
| | | if (receiver.getData().getSn().length()==14){ |
| | | registService.noAuthorization(receiver.getData().getSn()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 手动在线 |
| | | * @param workspaceId |
| | | * @param receiver |
| | | * @return |
| | | */ |
| | | @PostMapping("/{workspace_id}/deviceOnline") |
| | | public ResponseResult<List<DeviceDTO>> deviceOnline(@PathVariable("workspace_id") String workspaceId, |
| | | @RequestBody CommonTopicReceiver<StatusGatewayReceiver> receiver) { |
| | | boolean offline = deviceService.deviceOnline(receiver.getData()); |
| | | if (offline) { |
| | | // Notify pilot that the device is offline successfully. |
| | | deviceService.publishStatusReply(receiver.getData().getSn(), |
| | | CommonTopicResponse.builder() |
| | | .tid(receiver.getTid()) |
| | | .bid(receiver.getBid()) |
| | | .timestamp(System.currentTimeMillis()) |
| | | .method(receiver.getMethod()) |
| | | .build()); |
| | | |
| | | } |
| | | return ResponseResult.success(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | @GetMapping("/{workspace_id}/devices") |
| | | public ResponseResult<List<DeviceDTO>> getDevices(@PathVariable("workspace_id") String workspaceId) { |
| | | List<DeviceDTO> devicesList = deviceService.getDevicesTopoForWeb(workspaceId); |
| | | public ResponseResult<List<DeviceDTO>> getDevices(@PathVariable("workspace_id") String workspaceId,String reserveId) { |
| | | List<DeviceDTO> devicesList = deviceService.getDevicesTopoForWeb(workspaceId,reserveId); |
| | | |
| | | return ResponseResult.success(devicesList); |
| | | } |
| | | |
| | | @GetMapping("/{device_sn}/subscribeTopic") |
| | | public ResponseResult<List<DeviceDTO>> testBinding(@PathVariable("device_sn") String deviceSn) { |
| | | deviceService.subscribeTopicOnline(deviceSn); |
| | | |
| | | return ResponseResult.success(); |
| | | } |
| | | |
| | | @GetMapping("/{device_sn}/unsubscribeTopic") |
| | | public ResponseResult<List<DeviceDTO>> testUnBinding(@PathVariable("device_sn") String deviceSn) { |
| | | deviceService.unsubscribeTopicOffline(deviceSn); |
| | | |
| | | return ResponseResult.success(); |
| | | } |
| | | // @GetMapping("/{device_sn}/subscribeTopic2") |
| | | // public ResponseResult<List<DeviceDTO>> testBinding(@PathVariable("device_sn") String deviceSn) { |
| | | // deviceService.subscribeTopicOnline(deviceSn); |
| | | // |
| | | // return ResponseResult.success(); |
| | | // } |
| | | // |
| | | // @GetMapping("/{device_sn}/unsubscribeTopic2") |
| | | // public ResponseResult<List<DeviceDTO>> testUnBinding(@PathVariable("device_sn") String deviceSn) { |
| | | // deviceService.unsubscribeTopicOffline(deviceSn); |
| | | // |
| | | // return ResponseResult.success(); |
| | | // } |
| | | |
| | | /** |
| | | * After binding the device to the workspace, the device data can only be seen on the web. |