CEC-222, CEC-214 Send car commands and log filtering (#41)
* Send car commands * Log filter control * Fix message format * Move VehicleContext
This commit is contained in:
@@ -25,6 +25,14 @@ const vehiclesAPI = {
|
||||
data: [2021, 2022],
|
||||
};
|
||||
},
|
||||
sendCommand: async (vin, command, token) => {
|
||||
return {
|
||||
vin, command,
|
||||
}
|
||||
},
|
||||
sendLog: async (vin, filter, token) => {
|
||||
return Object.assign(filter, {vin});
|
||||
},
|
||||
};
|
||||
|
||||
export default vehiclesAPI;
|
||||
|
||||
42
src/services/commands.js
Normal file
42
src/services/commands.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const Commands = [{
|
||||
value: "LFRD",
|
||||
label: "Lock front right door",
|
||||
},{
|
||||
value: "UFRD",
|
||||
label: "Unlock front right door",
|
||||
},{
|
||||
value: "LFLD",
|
||||
label: "Lock front left door",
|
||||
},{
|
||||
value: "UFLD",
|
||||
label: "Unlock front left door",
|
||||
},{
|
||||
value: "LRRD",
|
||||
label: "Lock rear right door",
|
||||
},{
|
||||
value: "URRD",
|
||||
label: "Unlock rear right door",
|
||||
},{
|
||||
value: "LRLD",
|
||||
label: "Lock rear left door",
|
||||
},{
|
||||
value: "URLD",
|
||||
label: "Unlock rear left door",
|
||||
},{
|
||||
value: "LTRK",
|
||||
label: "Lock trunk",
|
||||
},{
|
||||
value: "UTRK",
|
||||
label: "Unlock trunk",
|
||||
},{
|
||||
value: "OWIN",
|
||||
label: "Open Windows",
|
||||
},{
|
||||
value: "CWIN",
|
||||
label: "Close Windows",
|
||||
},{
|
||||
value: "FLASH",
|
||||
label: "Flash headlights",
|
||||
}];
|
||||
|
||||
export default Commands;
|
||||
@@ -30,6 +30,23 @@ const vehiclesAPI = {
|
||||
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
|
||||
})
|
||||
.then(fetchRespHandler),
|
||||
|
||||
sendCommand: async (vin, command, token) => fetch(`${API_ENDPOINT}/vehiclecommand`, {
|
||||
method: "POST",
|
||||
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
|
||||
body: JSON.stringify({
|
||||
vin, command,
|
||||
}),
|
||||
})
|
||||
.then(fetchRespHandler),
|
||||
|
||||
sendLog: async (vin, filter, token) => fetch(`${API_ENDPOINT}/vehiclelog`, {
|
||||
method: "POST",
|
||||
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
|
||||
body: JSON.stringify(Object.assign(filter, {vin})),
|
||||
})
|
||||
.then(fetchRespHandler),
|
||||
|
||||
};
|
||||
|
||||
export default vehiclesAPI;
|
||||
|
||||
Reference in New Issue
Block a user