Hi, I am attempting to monitor the heart rate on my Garmin and send an alert to a web service if it goes below / above a certain number. Above below number and actual call isn't included yet, as I am currently getting an error that I can't figure out. Can't figure out out for the life of me. Grateful if anyone can help! Thanks in advance
Error: Unexpected Type Error Details: Failed to start CIQ Application Stack
Encountered app crash.
On this line:
import Toybox.Application;
import Toybox.Sensor;
import Toybox.WatchUi;
import Toybox.Lang;
import Toybox.Communications; // Add this import statement
class HeartApp extends Application.AppBase {
function initialize() {
AppBase.initialize();
Sensor.setEnabledSensors([Sensor.SENSOR_HEARTRATE]);
}
function onStart(state) {
System.println("Test");
Sensor.enableSensorEvents(method(:onSensor));
}
function onStop(state) {
// Your onStop code here
}
function onUpdate(dc) {
// Your onUpdate code here
}
function onSensor(info as $.Toybox.Sensor.Info) as Void {
System.println(info);
// var heartRateVar = info.heartRate;
// System.println(heartRateVar);
// makeRequest(heartRateVar);
}
function onReceive(responseCode as Number, data as Dictionary?) as Void {
if (responseCode == 200) {
System.println("Request Successful");
} else {
System.println("Response: " + responseCode);
}
}
function makeRequest(heartRate) {
// Replace "">http://test" with your actual URL in the correct format (e.g., "">http://example.com")
var url = "">http://test";
var params = {
"definedParams" => "123456789abcdefg"
};
var options = {
:method => Communications.HTTP_REQUEST_METHOD_GET,
:headers => {
"Content-Type" => Communications.REQUEST_CONTENT_TYPE_URL_ENCODED
},
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_URL_ENCODED
};
// Make the web request
Communications.makeWebRequest(url, params, options, method(:onReceive));
}
}
function getApp() as HeartApp {
return Application.getApp() as HeartApp;
}