CEC-5212 add 'read_ecu_versions' remote command. (#464)
* CEC-5212 add 'read_ecu_versions' remote command. * try to reduce smells. * props smells * one more smells
This commit is contained in:
@@ -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,13 +119,16 @@ const SendDiagnosticCommand = ({ vin, token, classes }) => {
|
||||
{
|
||||
currentCommand === "remote_reset"
|
||||
?
|
||||
<ResetCommand classes={classes} ecus={ecus} currentECU={currentECU} setCurrentECU={setCurrentECU} />
|
||||
<AllECUsCommand classes={classes} ecus={ecus} currentECU={currentECU} setCurrentECU={setCurrentECU} />
|
||||
: currentCommand === "can_network"
|
||||
?
|
||||
<CanNetCommand canNetState={canNetState} setCanNetState={setCanNetState} seconds={seconds} setSeconds={setSeconds} />
|
||||
: currentCommand === "remote_ignition"
|
||||
?
|
||||
<RemoteIgnitionCommand ignitionState={ignitionState} setIgnitionState={setIgnitionState} seconds={seconds} setSeconds={setSeconds} />
|
||||
: currentCommand === "read_ecu_versions"
|
||||
?
|
||||
<AllECUsCommand classes={classes} ecus={ecus} currentECU={currentECU} setCurrentECU={setCurrentECU} />
|
||||
: null
|
||||
}
|
||||
|
||||
@@ -179,7 +186,7 @@ const SendDiagnosticCommand = ({ vin, token, classes }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const ResetCommand = ({ classes, ecus, currentECU, setCurrentECU }) => {
|
||||
const AllECUsCommand = ({ classes, ecus, currentECU, setCurrentECU }) => {
|
||||
return (
|
||||
<FormControl
|
||||
className={classes.formControl}
|
||||
@@ -206,6 +213,12 @@ const ResetCommand = ({ classes, ecus, currentECU, setCurrentECU }) => {
|
||||
</FormControl>
|
||||
)
|
||||
}
|
||||
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 }) =>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
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
|
||||
</div>
|
||||
)
|
||||
}
|
||||
RemoteIgnitionCommand.propTypes = {
|
||||
ignitionState: PropTypes.bool.isRequired,
|
||||
setIgnitionState: PropTypes.func.isRequired,
|
||||
setSeconds: PropTypes.func.isRequired,
|
||||
seconds: PropTypes.number.isRequired,
|
||||
};
|
||||
|
||||
export default SendDiagnosticCommand;
|
||||
|
||||
Reference in New Issue
Block a user