@@ -23,73 +23,74 @@ export class FrontendRovMsgHandlerClass {
23
23
let rawData = new Uint8Array ( msgBytes )
24
24
if ( ! rawData || rawData . length === 0 ) return ;
25
25
const msgData = rov_actions_proto . RovResponse . decode ( new Uint8Array ( msgBytes ) ) ;
26
+ const ExchangeId = msgData . ExchangeId ;
26
27
27
- this . runExchangeCallback ( msgData . ExchangeId , msgData ) ;
28
+ this . runExchangeCallback ( msgData , ExchangeId ) ;
28
29
if ( msgData . Done ) {
29
- return this . handleDoneMsgRecived ( msgData . ExchangeId , msgData . Done ) ;
30
+ return this . handleDoneMsgRecived ( msgData . Done , ExchangeId ) ;
30
31
} else if ( msgData . Error ) {
31
- return this . handleErrorMsgRecived ( msgData . ExchangeId , msgData . Error ) ;
32
+ return this . handleErrorMsgRecived ( msgData . Error , ExchangeId ) ;
32
33
} else if ( msgData . Pong ) {
33
- return this . handlePongMsgRecived ( msgData . ExchangeId , msgData . Pong ) ;
34
+ return this . handlePongMsgRecived ( msgData . Pong , ExchangeId ) ;
34
35
} else if ( msgData . ContinuedOutput ) {
35
- return this . handleContinuedOutputMsgRecived ( msgData . ExchangeId , msgData . ContinuedOutput ) ;
36
+ return this . handleContinuedOutputMsgRecived ( msgData . ContinuedOutput , ExchangeId ) ;
36
37
} else if ( msgData . SensorUpdates ) {
37
- return this . handleSensorUpdatesMsgRecived ( msgData . ExchangeId , msgData . SensorUpdates ) ;
38
+ return this . handleSensorUpdatesMsgRecived ( msgData . SensorUpdates , ExchangeId ) ;
38
39
} else if ( msgData . PasswordRequired ) {
39
- return this . handlePasswordRequiredMsgRecived ( msgData . ExchangeId , msgData . PasswordRequired ) ;
40
+ return this . handlePasswordRequiredMsgRecived ( msgData . PasswordRequired , ExchangeId ) ;
40
41
} else if ( msgData . PasswordAccepted ) {
41
- return this . handlePasswordAcceptedMsgRecived ( msgData . ExchangeId , msgData . PasswordAccepted ) ;
42
+ return this . handlePasswordAcceptedMsgRecived ( msgData . PasswordAccepted , ExchangeId ) ;
42
43
} else if ( msgData . PasswordInvalid ) {
43
- return this . handlePasswordInvalidMsgRecived ( msgData . ExchangeId , msgData . PasswordInvalid ) ;
44
+ return this . handlePasswordInvalidMsgRecived ( msgData . PasswordInvalid , ExchangeId ) ;
44
45
} else if ( msgData . DriverChanged ) {
45
- return this . handleDriverChangedMsgRecived ( msgData . ExchangeId , msgData . DriverChanged ) ;
46
+ return this . handleDriverChangedMsgRecived ( msgData . DriverChanged , ExchangeId ) ;
46
47
} else if ( msgData . ClientConnected ) {
47
- return this . handleClientConnectedMsgRecived ( msgData . ExchangeId , msgData . ClientConnected ) ;
48
+ return this . handleClientConnectedMsgRecived ( msgData . ClientConnected , ExchangeId ) ;
48
49
} else if ( msgData . ClientDisconnected ) {
49
- return this . handleClientDisconnectedMsgRecived ( msgData . ExchangeId , msgData . ClientDisconnected ) ;
50
+ return this . handleClientDisconnectedMsgRecived ( msgData . ClientDisconnected , ExchangeId ) ;
50
51
} else if ( msgData . SimplepeerSignal && msgData . SimplepeerSignal . Message ) {
51
52
frontendConnMngr . ingestSimplePeerSignallingMsg ( msgData . SimplepeerSignal . Message ) ;
52
53
} else if ( msgData . Mavlink ) {
53
- return this . handleMavlinkMessageRecived ( msgData . ExchangeId , msgData . Mavlink ) ;
54
+ return this . handleMavlinkMessageRecived ( msgData . Mavlink , ExchangeId ) ;
54
55
} else if ( msgData . SystemMonitor ) {
55
- return this . handleSystemMonitorMsgRecived ( msgData . ExchangeId , msgData . SystemMonitor ) ;
56
+ return this . handleSystemMonitorMsgRecived ( msgData . SystemMonitor , ExchangeId ) ;
56
57
} else if ( msgData . LogMessage ) {
57
- return this . handleLogMsgRecived ( msgData . ExchangeId , msgData . LogMessage ) ;
58
+ return this . handleLogMsgRecived ( msgData . LogMessage , ExchangeId ) ;
58
59
} else {
59
60
console . warn ( "Unhandled ROV message recived: " , msgData ) ;
60
61
}
61
62
}
62
63
63
- handleDoneMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . IDoneResponse ) {
64
+ handleDoneMsgRecived ( msgData : rov_actions_proto . IDoneResponse , ExchangeId : number ) {
64
65
if ( URL_PARAMS . DEBUG_MODE ) console . debug ( "Done: " , msgData ) ;
65
66
}
66
67
67
- handleErrorMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . IErrorResponse ) {
68
+ handleErrorMsgRecived ( msgData : rov_actions_proto . IErrorResponse , ExchangeId : number ) {
68
69
console . warn ( "ROV Error: " , msgData ) ;
69
70
showToastMessage ( "ROV Error: " + msgData . Message , 2000 , null ) ;
70
71
}
71
72
72
- handlePongMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . IPongResponse ) {
73
+ handlePongMsgRecived ( msgData : rov_actions_proto . IPongResponse , ExchangeId : number ) {
73
74
lastTimeRecvdPong = Date . now ( ) ;
74
75
const networkPingDelay = lastTimeRecvdPong - Number . parseFloat ( msgData . Time ) // since the rpi replies with the ms time we sent in the ping in the pong message
75
76
networkLatencyMs . set ( networkPingDelay ) ;
76
77
}
77
78
78
- handleContinuedOutputMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . IContinuedOutputResponse ) {
79
+ handleContinuedOutputMsgRecived ( msgData : rov_actions_proto . IContinuedOutputResponse , ExchangeId : number ) {
79
80
if ( URL_PARAMS . DEBUG_MODE ) console . debug ( "ContinuedOutput: " , ExchangeId , msgData ) ;
80
81
// pass
81
82
}
82
83
83
- handleSensorUpdatesMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . ISensorUpdatesResponse ) {
84
+ handleSensorUpdatesMsgRecived ( msgData : rov_actions_proto . ISensorUpdatesResponse , ExchangeId : number ) {
84
85
if ( URL_PARAMS . DEBUG_MODE ) console . debug ( "SensorUpdates: " , msgData ) ;
85
86
updateSensorValues ( msgData ) ;
86
87
}
87
88
88
- handleSystemMonitorMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . ISystemMonitorResponse ) {
89
+ handleSystemMonitorMsgRecived ( msgData : rov_actions_proto . ISystemMonitorResponse , ExchangeId : number ) {
89
90
updateSystemMonitorDisplay ( msgData . CpuTemp , msgData . CpuUsage , msgData . MemoryUsage , msgData . DiskUsage , msgData . Warnings ) ;
90
91
}
91
92
92
- handlePasswordRequiredMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . IPasswordRequiredResponse ) {
93
+ handlePasswordRequiredMsgRecived ( msgData : rov_actions_proto . IPasswordRequiredResponse , ExchangeId : number ) {
93
94
if ( URL_PARAMS . DEBUG_MODE ) console . debug ( "PasswordRequired for rovId:" , msgData . RovId ) ;
94
95
// TODO: use the rovId to determine if we have authtoken
95
96
modalPasswordPrompt ( "Enter ROV Password" , "" ) . then ( ( password ) => {
@@ -106,17 +107,17 @@ export class FrontendRovMsgHandlerClass {
106
107
} )
107
108
}
108
109
109
- handlePasswordAcceptedMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . IPasswordAcceptedResponse ) {
110
+ handlePasswordAcceptedMsgRecived ( msgData : rov_actions_proto . IPasswordAcceptedResponse , ExchangeId : number ) {
110
111
showToastMessage ( "Password Accepted" , 1000 , null ) ;
111
112
}
112
113
113
- handlePasswordInvalidMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . IPasswordInvalidResponse ) {
114
+ handlePasswordInvalidMsgRecived ( msgData : rov_actions_proto . IPasswordInvalidResponse , ExchangeId : number ) {
114
115
showToastMessage ( "Wrong Password" , 1000 , null ) ;
115
- this . handlePasswordRequiredMsgRecived ( ExchangeId , msgData ) ;
116
+ this . handlePasswordRequiredMsgRecived ( msgData , ExchangeId ) ;
116
117
}
117
118
118
119
// TODO:
119
- handleDriverChangedMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . IDriverChangedResponse ) {
120
+ handleDriverChangedMsgRecived ( msgData : rov_actions_proto . IDriverChangedResponse , ExchangeId : number ) {
120
121
let ourLivekitIdentity = frontendConnMngr . currentLivekitIdentity . get ( ) ;
121
122
if ( msgData . DriverPeerId == ourLivekitIdentity ) {
122
123
showToastMessage ( "You are now the driver" ) ;
@@ -127,7 +128,7 @@ export class FrontendRovMsgHandlerClass {
127
128
}
128
129
}
129
130
130
- handleMavlinkMessageRecived ( ExchangeId : number , msgData : rov_actions_proto . IMavlinkResponse ) {
131
+ handleMavlinkMessageRecived ( msgData : rov_actions_proto . IMavlinkResponse , ExchangeId : number ) {
131
132
if ( ! msgData . Message ) return ;
132
133
const mavMessage = DECODE_TXT ( msgData . Message )
133
134
try {
@@ -138,21 +139,21 @@ export class FrontendRovMsgHandlerClass {
138
139
}
139
140
}
140
141
141
- handleClientConnectedMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . IClientConnectedResponse ) {
142
+ handleClientConnectedMsgRecived ( msgData : rov_actions_proto . IClientConnectedResponse , ExchangeId : number ) {
142
143
showToastMessage ( msgData . ClientPeerId + " Connected to ROV" , 1500 , null ) ;
143
144
}
144
145
145
- handleClientDisconnectedMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . IClientConnectedResponse ) {
146
+ handleClientDisconnectedMsgRecived ( msgData : rov_actions_proto . IClientConnectedResponse , ExchangeId : number ) {
146
147
showToastMessage ( msgData . ClientPeerId + " Disconnected from ROV" , 1500 , null ) ;
147
148
}
148
149
149
- handleLogMsgRecived ( ExchangeId : number , msgData : rov_actions_proto . ILogMessageResponse ) {
150
+ handleLogMsgRecived ( msgData : rov_actions_proto . ILogMessageResponse , ExchangeId : number ) {
150
151
if ( URL_PARAMS . SHOW_REMOTE_LOGS ) {
151
152
let logArgs = JSON . parse ( msgData . Message ) ;
152
153
if ( ! Array . isArray ( logArgs ) ) logArgs = [ logArgs ] ;
153
154
if ( logArgs . length === 0 ) return ;
154
155
if ( typeof logArgs [ 0 ] === 'string' ) logArgs [ 0 ] = "REMOTE LOG: " + logArgs [ 0 ] ;
155
- else logArgs . unshift ( "REMOTE LOG: " ) ;
156
+ else logArgs . unshift ( "REMOTE LOG: " ) ; // add "REMOTE LOG: " to the start of the logArgs
156
157
if ( msgData . Level == rov_actions_proto . LogLevel . Debug ) console . debug ( ...logArgs ) ;
157
158
else if ( msgData . Level == rov_actions_proto . LogLevel . Info ) console . info ( ...logArgs ) ;
158
159
else if ( msgData . Level == rov_actions_proto . LogLevel . Warning ) console . warn ( ...logArgs ) ;
@@ -178,7 +179,7 @@ export class FrontendRovMsgHandlerClass {
178
179
}
179
180
}
180
181
181
- runExchangeCallback ( ExchangeId : number , msgData : rov_actions_proto . RovResponse ) {
182
+ runExchangeCallback ( msgData : rov_actions_proto . RovResponse , ExchangeId : number ) {
182
183
const replyExchageData = this . replyContinuityCallbacks [ ExchangeId ] ;
183
184
if ( replyExchageData ) {
184
185
replyExchageData . callback && replyExchageData . callback ( msgData ) ;
0 commit comments