I have a datafield that uses the Attention module, it plays various tones to alert the user to certain periods of time having elapsed. I use a The code to play the tones is protected by a check and I use a Dictionary to link the tone to play to the type of alert. The code looks like this:
// The tones associated with each alert type
const AlertToneDict as Dictionary<AlertTypeEnum, Attention.Tone> = {
ThirtyMin => Attention.TONE_INTERVAL_ALERT,
FiveMin => Attention.TONE_ALERT_LO,
OneMin => Attention.TONE_ALERT_HI,
TimesUp => Attention.TONE_CANARY,
PointLost => Attention.TONE_LOUD_BEEP,
TimedOut => Attention.TONE_FAILURE
} as Dictionary<AlertTypeEnum, Attention.Tone> ;
// Play the alert for this event
function playMBOAlert(eventType as AlertTypeEnum) as Void {
if (Attention has :playTone) {
var tone = AlertToneDict[eventType] as Attention.Tone;
Attention.playTone(tone) ;
}
}
However I'm getting ERA Crash reports for the VivoActive4 device and when I run the datafield for this device in the simulator I can reproduce the issue:
Error: Symbol Not Found Error Details: Could not find symbol 'TONE_INTERVAL_ALERT' Stack: - <init>() at C:\GarminDevelopment\repos\MBO\MBOCountdown\source\MBOCountdownCommon.mc:23 0x10000837 - Native code0x80000000
So it looks to me as if the Tone constants aren't defined for the VivoActive4.
I'm thinking of replacing the Dictionary with a function that gets called inside the check for tone support (or maybe just dropping VivoActive4 support) but is there a better way to handle this.
It also looks as if jungles might be a way to do this - factor all the tone related code into it's own file and provide a stub that's included for devices that don't support the tones.