ws disconnect 这个对于前后端数据通信是否有影响
Completed先说一下我的运行环境:
M300 RTK(固件版本V5.1)
Cloud API
使用cloud api提供的前后端代码:
在pc上登录web端,然后显示设备 disconnected, 我在MQTTX
订阅飞行器的主题:Topic: thing/product/1ZNDH6W00AJ208/osd
飞行器负载:
mode_code: {"0":"待机","1":"起飞准备","2":"起飞准备完毕","3":"手动飞行","4":"自动起飞","5":"航线飞行","6":"全景拍照","7":"智能跟随","8":"ADS-B 躲避","9":"自动返航","10":"自动降落","11":"强制降落","12":"三桨叶降落","13":"升级中","14":"未连接"}
mode_code: 0, 待机状态, 在Web页面 http://localhost:8080/tsa 显示的就是 红色Disconnected 状态, (这个是否和飞机没有展开有关,因为调试空间有限,就把四个旋翼折叠起来了,还是因为 ws 模块Disconnect有关,造成websocket的通信前后端不能正常通信,因为)
web端界面显示
前端workspace.vue代码:(是否遥控器上显示websocket disconnected这部分代码就不会响应了, 我加入调试断点,messageHandler 没有触发,没有触发的场景说明:比如DeviceOsd不知道是不是0.5Hz就触发一次嘛以及我关掉无人机都没有触发这个函数入口处)
const messageHandler = async (payload: any) => {
if (!payload) {
return
}
switch (payload.biz_code) {
case EBizCode.GatewayOsd: {
store.commit('SET_GATEWAY_INFO', payload.data)
break
}
case EBizCode.DeviceOsd: {
store.commit('SET_DEVICE_INFO', payload.data)
break
}
case EBizCode.DockOsd: {
store.commit('SET_DOCK_INFO', payload.data)
break
}
case EBizCode.MapElementCreate: {
store.commit('SET_MAP_ELEMENT_CREATE', payload.data)
break
}
case EBizCode.MapElementUpdate: {
store.commit('SET_MAP_ELEMENT_UPDATE', payload.data)
break
}
case EBizCode.MapElementDelete: {
store.commit('SET_MAP_ELEMENT_DELETE', payload.data)
break
}
case EBizCode.DeviceOnline: {
store.commit('SET_DEVICE_ONLINE', payload.data)
break
}
case EBizCode.DeviceOffline: {
store.commit('SET_DEVICE_OFFLINE', payload.data)
break
}
case EBizCode.FlightTaskProgress:
case EBizCode.FlightTaskMediaProgress:
case EBizCode.FlightTaskMediaHighestPriority: {
EventBus.emit('flightTaskWs', payload)
break
}
case EBizCode.DeviceHms: {
store.commit('SET_DEVICE_HMS_INFO', payload.data)
break
}
case EBizCode.DeviceReboot:
case EBizCode.DroneOpen:
case EBizCode.DroneClose:
case EBizCode.CoverOpen:
case EBizCode.CoverClose:
case EBizCode.PutterOpen:
case EBizCode.PutterClose:
case EBizCode.ChargeOpen:
case EBizCode.ChargeClose:
case EBizCode.DeviceFormat:
case EBizCode.DroneFormat:
{
store.commit('SET_DEVICES_CMD_EXECUTE_INFO', {
biz_code: payload.biz_code,
timestamp: payload.timestamp,
...payload.data,
})
break
}
default:
break
}
}
// 监听ws 消息
useConnectWebSocket(messageHandler)
Please sign in to leave a comment.
Comments
4 comments