diff --git a/src/components/Controls/SendDiagnosticCommand/index.jsx b/src/components/Controls/SendDiagnosticCommand/index.jsx index 83e9dc7..307d8ba 100644 --- a/src/components/Controls/SendDiagnosticCommand/index.jsx +++ b/src/components/Controls/SendDiagnosticCommand/index.jsx @@ -6,6 +6,7 @@ import { useStatusContext } from "../../Contexts/StatusContext"; import { logger } from "../../../services/monitoring"; import smsAPI from "../../../services/smsAPI"; import cmp from "semver-compare"; +import PropTypes from 'prop-types'; import { @@ -17,6 +18,7 @@ const commands = [ { displayname: "Set CAN Network State", val: "can_network" }, { displayname: "Set Remote Ignition", val: "remote_ignition" }, { displayname: "Send Wake Up SMS", val: "sms" }, + { displayname: "Read ECU versions", val: "read_ecu_versions" }, ] const SendDiagnosticCommand = ({ vin, token, classes }) => { @@ -102,6 +104,8 @@ const SendDiagnosticCommand = ({ vin, token, classes }) => { setMessage(`Failed to wake up the car: ${res.error}`) return; } + } else if (currentCommand === "read_ecu_versions") { + await sendDiagnosticCommand([vin], { command: currentCommand, ecu_name: currentECU }, token); } setMessage(`Sent diagnostic command to ${vin}`); } catch (error) { @@ -115,14 +119,17 @@ const SendDiagnosticCommand = ({ vin, token, classes }) => { { currentCommand === "remote_reset" ? - + : currentCommand === "can_network" ? : currentCommand === "remote_ignition" ? - : null + : currentCommand === "read_ecu_versions" + ? + + : null }

@@ -179,7 +186,7 @@ const SendDiagnosticCommand = ({ vin, token, classes }) => { ); }; -const ResetCommand = ({ classes, ecus, currentECU, setCurrentECU }) => { +const AllECUsCommand = ({ classes, ecus, currentECU, setCurrentECU }) => { return ( { ) } +AllECUsCommand.propTypes = { + classes: PropTypes.object.isRequired, + ecus: PropTypes.array.isRequired, + currentECU: PropTypes.string.isRequired, + setCurrentECU: PropTypes.func.isRequired, +}; const CanNetCommand = ({ canNetState, setCanNetState, seconds, setSeconds }) => { return ( @@ -239,6 +252,11 @@ const CanNetCommand = ({ canNetState, setCanNetState, seconds, setSeconds }) => ) } +CanNetCommand.propTypes = { + setCanNetState: PropTypes.func.isRequired, + seconds: PropTypes.number.isRequired, + setSeconds: PropTypes.func.isRequired, +}; const RemoteIgnitionCommand = ({ ignitionState, setIgnitionState, setSeconds, seconds }) => { return ( @@ -272,5 +290,11 @@ const RemoteIgnitionCommand = ({ ignitionState, setIgnitionState, setSeconds, se ) } +RemoteIgnitionCommand.propTypes = { + ignitionState: PropTypes.bool.isRequired, + setIgnitionState: PropTypes.func.isRequired, + setSeconds: PropTypes.func.isRequired, + seconds: PropTypes.number.isRequired, +}; export default SendDiagnosticCommand;