Please note that just like this works:
HRSample.when.value();
HRSample.data);
function sendHR() {
Comm.setMailboxListener(mailMethod);
var listener = new CommListener();
var HRSensorHistoryIterator = SensorHistory.getHeartRateHistory(
{
:period => 10,
:order => SensorHistory.ORDER_NEWEST_FIRST
});
var HRSample = HRSensorHistoryIterator.next();
var dataArray = []; // array size will be increased as needed using .add()
// Starting building the command response
dataArray.add(HISTORIC_HR_COMMAND);
dataArray.add(HISTORIC_HR_COMMAND);
while (HRSample != null) {
dataArray.add(HRSample.when.value());
dataArray.add(HRSample.data);
HRSample = HRSensorHistoryIterator.next();
}
System.println("timeNow " + Time.now().value());
System.println("dataArray " + dataArray);
// Transmit command response
Comm.transmit(dataArray, null, listener);
}
The code running on emulator, all seems ok:
Copying file.... 94% complete
Copying file.... 97% complete
Copying file.... 99% complete
Copying file.... 100% complete
File pushed successfully
Connection Finished
Closing shell and port
Found Transport: tcp
Connecting...
Connecting to device...
Device Version 0.1.0
Device id 1 name "A garmin device"
Shell Version 0.1.0
timeNow 1482242743
dataArray [-24576, -24576, 1482242743, 80, 1482242676, null, 1482242609, 84, 1482242542, 81, 1482242475, 76, 1482242408, 75, 1482242341, 79, 1482242274, 83, 1482242207, 85, 1482242140, 82]
send er 1482242747
timeNow 1482242748
dataArray [-24576, -24576, 1482242743, 80, 1482242676, null, 1482242609, 84, 1482242542, 81, 1482242475, 76, 1482242408, 75, 1482242341, 79, 1482242274, 83, 1482242207, 85, 1482242140, 82]
send er 1482242749
timeNow 1482242753
dataArray [-24576, -24576, 1482242743, 80, 1482242676, null, 1482242609, 84, 1482242542, 81, 1482242475, 76, 1482242408, 75, 1482242341, 79, 1482242274, 83, 1482242207, 85, 1482242140, 82]
send er 1482242755
Complete
Connection Finished
Closing shell and port
But when running on Vivoactive HR 2:
