언어 설정

Menu
Sites
Language
Heart rate green LED sensor is always on on my Gear S2

Hi,

On a Tizen wearable application developed in JavaScript, for the Gear S2, we are regularly sampling the user's heart rate with the HumanActivityMonitor API (every 15 minutes).

 

tizen.humanactivitymonitor.start("HRM", handleHRM)

For each of those sampling, we have to wait multiple measurements to maximize the chances to have a (positive) HR value. We stop the heart rate monitor (HRM), when we get this value or when exceeding a number of tries (180 tries, about 10 seconds).

Yet, after a certain amount of time, the HRM sampling is not working correctly: HRM is started fine (LED at the watch's back turns on), but the HRM is never stopped (it should stopped after 10 seconds max) the green LED at the watch's back is still on (HRM is still on going). The only way to stop the HRM is to wake up the watch and go back to our application.

We thought our application execution context might have changed so that the HRM stop code is no more run. It acts like if our application was put in sleep mode even if we still are measuring the HR. But according to our logs, the watch has not been switched into ambient mode. Moreover, even when requesting the CPU_AWAKE state during the sampling process, the behavior is the same.

Can you please tell us, according to you, why the green LED is always on?

Thank you for your help.

Responses

5 댓글
AVSukhov

Hello,

Very difficult to advise something without having a sample code or the exact steps to reproduce.

Could you please provide some code examples to understand the overall logic

Are you useng background-support setting?

John Smith

Hi AVSukhov,

Thanks for your reactivity.
Yes, the background-support is enabled in the settings.

Here is the code exemple :

var HRMcounter = 0
var lastDataTimestamp = 0
var MAX_TRIES = 180
var hrmIsStarted = false
var samplingRate = 5*60*1000

try {
    tizen.power.setScreenStateChangeListener(function(prevState, currState) {
                                var currentTimeStamp = Date.now();
				if (!hrmIsStarted) {

					if ( (prevState === "SCREEN_NORMAL") && (currState === "SCREEN_OFF") && ((currentTimeStamp - lastDataTimestamp) > samplingRate) ) {	
							HRMcounter = 0;
							hrmIsStarted = true
							tizen.humanactivitymonitor.start("HRM", handleHRM);
					}

				}

			});
} catch (e) {
	log(e.message);
}
function handleHRM(hrmData) {
	HRMcounter++
	var heartRate = hrmData.heartRate;
	if (heartRate <= 0) {
		if (HRMcounter > MAX_TRIES) {			
			HRMcounter = 0
			tizen.humanactivitymonitor.stop("HRM");
			hrmIsStarted = false
		}
		return
	}

    console.log(heartRate);
    
	HRMcounter = 0;
	tizen.humanactivitymonitor.stop("HRM");
	hrmIsStarted = false
	
	var currentTimeStamp = Date.now();
	lastDataTimestamp = currentTimeStamp
}

Thanks

John Smith

Hi AVSukhov,

Thanks for your reactivity.
Yes, the background-support is enabled in the settings.

Here is the code exemple :

var HRMcounter = 0
var lastDataTimestamp = 0
var MAX_TRIES = 180
var hrmIsStarted = false
var samplingRate = 5*60*1000

try {
    tizen.power.setScreenStateChangeListener(function(prevState, currState) {
                                var currentTimeStamp = Date.now();
				if (!hrmIsStarted) {

					if ( (prevState === "SCREEN_NORMAL") && (currState === "SCREEN_OFF") && ((currentTimeStamp - lastDataTimestamp) > samplingRate) ) {	
							HRMcounter = 0;
							hrmIsStarted = true
							tizen.humanactivitymonitor.start("HRM", handleHRM);
					}

				}

			});
} catch (e) {
	log(e.message);
}
function handleHRM(hrmData) {
	HRMcounter++
	var heartRate = hrmData.heartRate;
	if (heartRate <= 0) {
		if (HRMcounter > MAX_TRIES) {			
			HRMcounter = 0
			tizen.humanactivitymonitor.stop("HRM");
			hrmIsStarted = false
		}
		return
	}

    console.log(heartRate);
    
	HRMcounter = 0;
	tizen.humanactivitymonitor.stop("HRM");
	hrmIsStarted = false
	
	var currentTimeStamp = Date.now();
	lastDataTimestamp = currentTimeStamp
}

Thanks

John Smith

Hi AVSukhov,

Thanks for your reactivity.
Yes, the background-support is enabled in the settings.

Here is the code exemple :

var HRMcounter = 0
var lastDataTimestamp = 0
var MAX_TRIES = 180
var hrmIsStarted = false
var samplingRate = 5*60*1000

try {
	tizen.power.setScreenStateChangeListener(function(prevState, currState) {
                                var currentTimeStamp = Date.now();
				if (!hrmIsStarted) {

					if ( (prevState === "SCREEN_NORMAL") && (currState === "SCREEN_OFF") && ((currentTimeStamp - lastDataTimestamp) > samplingRate) ) {	
							HRMcounter = 0;
							hrmIsStarted = true
							tizen.humanactivitymonitor.start("HRM", handleHRM);
					}

				}

			});
} catch (e) {
	log(e.message);
}
function handleHRM(hrmData) {
	HRMcounter++
	var heartRate = hrmData.heartRate;
	if (heartRate <= 0) {
		if (HRMcounter > MAX_TRIES) {			
			HRMcounter = 0
			tizen.humanactivitymonitor.stop("HRM");
			hrmIsStarted = false
		}
		return
	}

    console.log(heartRate);
    
	HRMcounter = 0;
	tizen.humanactivitymonitor.stop("HRM");
	hrmIsStarted = false
	
	var currentTimeStamp = Date.now();
	lastDataTimestamp = currentTimeStamp
}


Thanks

daniel kim

Hi,

It looks like that HRM is triggered by tizen.power.setScreenStateChangeListener() function. so anytime HRM will be activated whenever a contion is ok in this Listerner.

I think that you need to trigger HRM starting not by this Listener.

Regards