| | |
| | | <span style="color: #737373">{{ device.data.gateway_sn }}</span> |
| | | </a-col> |
| | | </a-row> |
| | | <a-row style="border-bottom: 1px solid #f4f8f9; height: 45px;" align="middle" v-if="device.data.online_status"> |
| | | <a-row style="border-bottom: 1px solid #f4f8f9; height: 45px;" align="middle" v-if="device.data.online_status && device.data.sn"> |
| | | <a-col :span="1"></a-col> |
| | | <a-col :span="9">Aircraft Sn</a-col> |
| | | <a-col :span="13" class="flex-align-end flex-column" > |
| | |
| | | <span class="ml5" style="color: #939393;">Settings</span> |
| | | </div> |
| | | <div class="fz16" style="background-color: white; border-radius: 4px;"> |
| | | <a-row v-if="device.data.online_status" style="border-bottom: 1px solid #f4f8f9; height: 45px;" align="middle" @click="bindingDevice"> |
| | | <a-row v-if="device.data.online_status && device.data.sn" style="border-bottom: 1px solid #f4f8f9; height: 45px;" align="middle" @click="bindingDevice"> |
| | | <a-col :span="1"></a-col> |
| | | <a-col :span="11"> |
| | | Device Binding |
| | |
| | | import cloudapi from '/@/assets/icons/cloudapi.png' |
| | | import { RightOutlined, CloudOutlined, CloudSyncOutlined, SyncOutlined } from '@ant-design/icons-vue' |
| | | import { useMyStore } from '/@/store' |
| | | import ReconnectingWebSocket from 'reconnecting-websocket' |
| | | import websocket from '/@/api/websocket' |
| | | import { DeviceStatus } from '/@/types/device' |
| | | import { useConnectWebSocket } from '/@/hooks/use-connect-websocket' |
| | | |
| | | const root = getRoot() |
| | | const gatewayState = ref<boolean>(localStorage.getItem(ELocalStorageKey.GatewayOnline) === 'true') |
| | |
| | | const components = apiPilot.init() |
| | | const exitVisible = ref(false) |
| | | const drawerVisible = ref(false) |
| | | let minitor = -1 |
| | | let minitor: any |
| | | |
| | | interface DeviceInfoData { |
| | | data: DeviceStatus |
| | |
| | | bound_status: false, |
| | | model: '', |
| | | gateway_sn: EStatusValue.DISCONNECT, |
| | | domain: '' |
| | | domain: -1 |
| | | } |
| | | }) |
| | | const bindParam: BindBody = { |
| | |
| | | |
| | | const store = useMyStore() |
| | | |
| | | const wsGetMsg = async (res: any) => { |
| | | const payload = JSON.parse(res.data) |
| | | const messageHandler = async (payload: any) => { |
| | | if (!payload) { |
| | | return |
| | | } |
| | | switch (payload.biz_code) { |
| | | case EBizCode.DeviceOnline: { |
| | | console.info('online: ', payload) |
| | |
| | | break |
| | | } |
| | | } |
| | | let bindNum: number |
| | | let socket: ReconnectingWebSocket |
| | | |
| | | // 监听ws 消息 |
| | | useConnectWebSocket(messageHandler) |
| | | |
| | | let bindNum: any |
| | | |
| | | onMounted(() => { |
| | | apiPilot.onBackClickReg() |
| | | apiPilot.onStopPlatform() |
| | | const oldDevice = localStorage.getItem(ELocalStorageKey.Device) |
| | | if (oldDevice) { |
| | | device.data = JSON.parse(oldDevice) |
| | | } |
| | | |
| | | window.connectCallback = (arg: any) => { |
| | | connectCallback(arg) |
| | | } |
| | | window.wsConnectCallback = (arg: any) => { |
| | | wsConnectCallback(arg) |
| | | } |
| | | device.data.gateway_sn = apiPilot.getRemoteControllerSN() |
| | | if (device.data.gateway_sn === EStatusValue.DISCONNECT.toString()) { |
| | | message.warn('Data is not available, please restart the remote control.') |
| | | return |
| | | } |
| | | const oldDevice = localStorage.getItem(ELocalStorageKey.Device) |
| | | if (oldDevice) { |
| | | device.data = JSON.parse(oldDevice) |
| | | } |
| | | |
| | | device.data.sn = apiPilot.getAircraftSN() |
| | | getDeviceInfo() |
| | | |
| | | socket = websocket.init(wsGetMsg) |
| | | |
| | | const isLoaded = apiPilot.isComponentLoaded(EComponentName.Thing) |
| | | if (isLoaded) { |
| | |
| | | // thing |
| | | const param: ThingParam = { |
| | | host: res.data.mqtt_addr, |
| | | username: username.value, |
| | | username: res.data.mqtt_username, |
| | | password: res.data.mqtt_password, |
| | | connectCallback: 'connectCallback' |
| | | } |
| | |
| | | bindParam.user_id = res.data.user_id |
| | | bindParam.workspace_id = res.data.workspace_id |
| | | }) |
| | | window.connectCallback = arg => { |
| | | connectCallback(arg) |
| | | } |
| | | window.wsConnectCallback = arg => { |
| | | wsConnectCallback(arg) |
| | | } |
| | | }) |
| | | |
| | | onUnmounted(() => { |
| | | socket.close() |
| | | }) |
| | | |
| | | const connectCallback = async (arg: any) => { |
| | |
| | | apiPilot.loadComponent(EComponentName.Mission, {}) |
| | | |
| | | bindNum = setInterval(() => { |
| | | if (!bindParam.device_sn) { |
| | | device.data.gateway_sn = apiPilot.getRemoteControllerSN() |
| | | bindParam.device_sn = device.data.gateway_sn |
| | | return |
| | | } |
| | | bindDevice(bindParam).then(bindRes => { |
| | | if (bindRes.code !== 0) { |
| | | message.error(bindRes.message) |
| | |
| | | } |
| | | |
| | | function getDeviceInfo () { |
| | | if (device.data.sn === EStatusValue.DISCONNECT) { |
| | | if (!device.data.sn || device.data.sn === EStatusValue.DISCONNECT) { |
| | | return |
| | | } |
| | | getDeviceBySn(bindParam.workspace_id, device.data.sn).then(res => { |