|
8 | 8 | MAV_STATE, |
9 | 9 | } from "../../helpers/mavlinkConstants" |
10 | 10 |
|
| 11 | +const MAV_SYS_STATUS_PREARM_CHECK = 268435456 |
| 12 | + |
11 | 13 | // TODO: Make this configurable in the future? |
12 | 14 | const GPS_TRACK_MAX_LENGTH = 300 |
13 | 15 |
|
@@ -56,6 +58,7 @@ const droneInfoSlice = createSlice({ |
56 | 58 | systemStatus: 0, |
57 | 59 | }, |
58 | 60 | onboardControlSensorsEnabled: 0, |
| 61 | + onboardControlSensorsHealth: 0, |
59 | 62 | gpsRawIntData: { |
60 | 63 | fixType: 0, |
61 | 64 | satellitesVisible: 0, |
@@ -259,6 +262,11 @@ const droneInfoSlice = createSlice({ |
259 | 262 | state.onboardControlSensorsEnabled = action.payload |
260 | 263 | } |
261 | 264 | }, |
| 265 | + setOnboardControlSensorsHealth: (state, action) => { |
| 266 | + if (action.payload !== state.onboardControlSensorsHealth) { |
| 267 | + state.onboardControlSensorsHealth = action.payload |
| 268 | + } |
| 269 | + }, |
262 | 270 | setRSSIData: (state, action) => { |
263 | 271 | if (action.payload !== state.rssi) { |
264 | 272 | state.rssi = action.payload |
@@ -345,8 +353,18 @@ const droneInfoSlice = createSlice({ |
345 | 353 | selectNotificationSound: (state) => state.notificationSound, |
346 | 354 | selectFlightMode: (state) => state.heartbeatData.customMode, |
347 | 355 | selectSystemStatus: (state) => MAV_STATE[state.heartbeatData.systemStatus], |
348 | | - selectPrearmEnabled: (state) => |
349 | | - state.onboardControlSensorsEnabled & 268435456, |
| 356 | + selectReadyToArm: (state) => { |
| 357 | + const isEnabled = !!( |
| 358 | + state.onboardControlSensorsEnabled & MAV_SYS_STATUS_PREARM_CHECK |
| 359 | + ) |
| 360 | + const isHealthy = !!( |
| 361 | + state.onboardControlSensorsHealth & MAV_SYS_STATUS_PREARM_CHECK |
| 362 | + ) |
| 363 | + |
| 364 | + // If pre-arm check is enabled, it must also be healthy |
| 365 | + // If pre-arm check is disabled, just check if it's healthy |
| 366 | + return isEnabled ? isHealthy : isHealthy |
| 367 | + }, |
350 | 368 | selectGPSRawInt: (state) => state.gpsRawIntData, |
351 | 369 | selectGPS2RawInt: (state) => state.gps2RawIntData, |
352 | 370 | selectHasSecondaryGps: (state) => state.hasSecondaryGps, |
@@ -386,6 +404,7 @@ export const { |
386 | 404 | setHasEverHadGpsFix, |
387 | 405 | setBatteryData, |
388 | 406 | setOnboardControlSensorsEnabled, |
| 407 | + setOnboardControlSensorsHealth, |
389 | 408 | setRSSIData, |
390 | 409 | setGraphValues, |
391 | 410 | setLastGraphMessage, |
@@ -498,7 +517,7 @@ export const { |
498 | 517 | selectHeartbeat, |
499 | 518 | selectIsArmed, |
500 | 519 | selectIsFlying, |
501 | | - selectPrearmEnabled, |
| 520 | + selectReadyToArm, |
502 | 521 | selectGPSRawInt, |
503 | 522 | selectGPS2RawInt, |
504 | 523 | selectHasSecondaryGps, |
|
0 commit comments