Application for saving sensor data not working in background
By Stiegeler
03 Jun 2019 04:20
English
1 Replies
Hi,
for a medical study my goal is to obtain several sensor data (HRM, RR Intervall, Light, Pressure, Movement) and save them with the current time to a .txt file.
So far everything was working till I implemented the part to save the data. I could use the method for one sensor and then the app began to lag, if I try to save more than one sensor value, the app stops working completly. To save, I use the following code:
function getHRM() {
var hrm = 0.0;
var rrintervall;
function onGetSuccessCB(hrmInfo) {
hrm = hrmInfo.heartRate;
console.log(hrm);
document.getElementById('hrm').innerHTML = ('hrm: ' + hrm + "<br />");
rrintervall = hrmInfo.rRInterval;
console.log(rrintervall);
document.getElementById('rr-value').innerHTML = ('rr: ' + rrintervall + "<br />");
tizen.filesystem.resolve("documents", function(dir)
{
file = dir.resolve("hrm.txt");
file.openStream(
"a",
function(fs) {
fs.write(" " + hrm + " "+ tizen.time.getCurrentDateTime().toLocaleString()+";");
fs.close();
}, function(e) {
console.log("Error " + e.message);
}, "UTF-8");
});
}
tizen.humanactivitymonitor.start('HRM', onGetSuccessCB);
}
Also I realized, that the app is not saving any data when the screen is turned off. Before saving the data, it was that, when the screen was turned off and I switched it on again, it felt like, the app was "rushing" through the values from the time when the screen was turned off. After I implemented the saving function I just didn't record any background data.
Any ideas, what causes the problems? I read somewhere that it is not possible to record the data in the background without programming it in C but I could't verify it so far, is that true?
I'm glad for every help, thanks.
You must log in to use this service. Log in now?
The tag you entered already exists.
Do you want to report this post as spam?
The post has been reported as spam.
cannot be empty.
Are you sure you want to cancel and return to the list?
The code has been copied to the clipboard.
Enter a title.