Skip to content
Snippets Groups Projects
Commit 482654f6 authored by Augustin Jaujay's avatar Augustin Jaujay
Browse files

Enregistrement des erreurs

parent a8f83589
No related branches found
No related tags found
No related merge requests found
......@@ -485,6 +485,12 @@
}
}
},
"cordovarduino": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/cordovarduino/-/cordovarduino-0.0.10.tgz",
"integrity": "sha512-W3wcmuCiDJnUv73y91eEeP1zC+rqzmvgEzlnQ0I4wrX3fJ89VEV7RZzqk9tpcwz1HSOxE2OdIknevPUoaxmbCg==",
"dev": true
},
"cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
......
......@@ -22,7 +22,8 @@
"cordova-plugin-indooratlas": "git+https://github.com/IndoorAtlas/cordova-plugin.git",
"cordova-plugin-magnetometer": "git+https://github.com/sdesalas/cordova-plugin-magnetometer.git",
"cordova-plugin-sensors": "git+https://github.com/fabiorogeriosj/cordova-plugin-sensors.git",
"cordova-plugin-whitelist": "^1.3.4"
"cordova-plugin-whitelist": "^1.3.4",
"cordovarduino": "0.0.10"
},
"cordova": {
"plugins": {
......@@ -33,7 +34,8 @@
"cordova-plugin-magnetometer": {},
"cordova-plugin-indooratlas": {},
"cordova-plugin-sensors": {},
"cordova-plugin-file": {}
"cordova-plugin-file": {},
"cordovarduino": {}
},
"platforms": [
"android",
......
......@@ -44,31 +44,31 @@ function onDeviceReady() {
console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
// Removing file from last session
clearFile('sessionData.csv');
setTimeout(clearFile, 100, 'errors.csv');
// Creating a file to save data
setTimeout(createDataFile, 200);
setTimeout(createErrorsFile, 300);
setTimeout(beginMeasures, 500);
}
function beginMeasures() {
//Add volume buttons events:
document.addEventListener("volumeupbutton", handleButtonEvent, false);
document.addEventListener("volumedownbutton", handleButtonEvent, false);
//start watching gps
navigator.geolocation.watchPosition((pos) => {position = pos;}, (error) => console.log(error), {timeout: 100, enableHighAccuracy: true });
navigator.geolocation.watchPosition((pos) => {position = pos;}, (error) => handleError(error), {timeout: 100, enableHighAccuracy: true });
//start watching acceleration
navigator.accelerometer.watchAcceleration((acc) => {acceleration = acc;}, (error) => console.log(error), { frequency: 100 });
navigator.accelerometer.watchAcceleration((acc) => {acceleration = acc;}, (error) => handleError(error), { frequency: 100 });
//start watching gyroscope
navigator.gyroscope.watch((gyro) => {gyroscope = gyro;}, (error) => console.log(error), { frequency: 100 });
navigator.gyroscope.watch((gyro) => {gyroscope = gyro;}, (error) => handleError(error), { frequency: 100 });
//start watching magneto
cordova.plugins.magnetometer.watchReadings((magn) => {magnetometer = magn;}, (error) => console.log(error), { frequency: 100 });
// Removing file from last session
setTimeout(clearFile, 100, 'sessionData.csv');
setTimeout(clearFile, 100, 'errors.csv');
// Creating a file to save data
setTimeout(createDataFile, 100);
setTimeout(createErrorsFile, 100);
cordova.plugins.magnetometer.watchReadings((magn) => {magnetometer = magn;}, (error) => handleError(error), { frequency: 100 });
}
function handleButtonEvent() {
//Set position in html
if (position) {
......@@ -107,9 +107,8 @@ function handleButtonEvent() {
}
function handleError(error) {
//TODO: log error to error file / db
console.log(error);
writeFile(error.toString());
var errorMessage = typeof(error) === 'string' ? error : error.message;
writeFile(errorsFile, new Blob([`${new Date()};${errorMessage}\n`]));
}
function startOrStopTimer() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment