02-13-2018 10:50
02-13-2018 10:50
Is it feasible to have a vibration warning built into a watchface that my phone has disconnected from the watch? One of the last features I'm trying to implement from the watchface I had with the Pebble Time is this warning that I've set down my phone and am wandering away from it.
My latest attempt to implement this comes from guidance offered in this thread:
https://community.fitbit.com/t5/SDK-Development/Phone-Security/td-p/2259443
I've added a check of the status of the messaging peer socket on each clock tick to my watchface and created a companion app that just opens the socket, but I'm running into two issues:
1. The connection does not seem at all reliable and frequently breaks, especially when the watchface goes into low power mode.
2. Any vibration I try won't fire when the watchface is in low power mode.
Is there a way to structure this to give the vibration warning no matter what state the watch is in?
02-13-2018 11:14
02-13-2018 11:14
Not until Fitbit decides to fix bluetooth reliability issues. Until then it's not going to work and welcome to the club.
02-13-2018 11:25
02-13-2018 11:25
Don’t forget the ontick event doesn’t fire when the display is off.
An ontimeout however will. You may even choose to reduce how often you check for companion app acknowledging the conection which should reduce impact on battery life,
As @paperinik says, currently the Bluetooth connectivity is quite flaky and is a known issue “across many layers of the platform”. We are awaiting firmware update.....
02-13-2018 11:26
02-13-2018 11:26
The new firmware update has already begun rolling out, and if you don't yet see the update, it should be available sometime this week.
02-13-2018 11:29
02-13-2018 11:29
@JonFitbit Can’t wait
02-13-2018 11:36
02-13-2018 11:36
"Update available". Looking into it.
02-13-2018 11:41
02-13-2018 11:45
02-13-2018 11:45
In the fitbit app (I have iOS). I don't know if I clicked on the Ionic.
02-13-2018 12:16
02-13-2018 12:16
Back in topic:
I don't know if polling is the right solution. You poll too often and the battery is going to drain quickly. You poll not that often and it's useless.
Pebble had a convenient onBluetoothConnectionChange event. You should ask for something similar being available. That will guarantee that your watchface gets notified in a timely fashion vs. constantly polling.
02-13-2018 12:21
02-13-2018 12:21
Huh, never considered that it might just be the ontick that's killing everything in low power mode. I'll have to try triggering a vibration with an ontimeout when I get a chance.
02-13-2018 12:34
02-13-2018 12:34
wrote:Back in topic:
I don't know if polling is the right solution. You poll too often and the battery is going to drain quickly. You poll not that often and it's useless.Pebble had a convenient onBluetoothConnectionChange event. You should ask for something similar being available. That will guarantee that your watchface gets notified in a timely fashion vs. constantly polling.
And yeah I'd rather not poll. It's been awhile since I've even looked at the source code of my Pebble Time's watchface, but I think I remember using bluetooth events when I built it. Since that's not available for the Ionic yet, I'm hoping to use polling as a stopgap measure. I already charge my watch daily while I'm in the shower, so hopefully the drain won't be faster than that.
02-15-2018 10:48 - edited 02-15-2018 10:49
02-15-2018 10:48 - edited 02-15-2018 10:49
@SunsetRunner
I've created a crude recursive setTimeout function that does the polling once per second and can confirm that the vibrations do work with the screen off as long as it's not tied to the ontick event, so thank you for reminding me about it.
I have noticed overnight that this polling function does indeed drain the battery faster, about 2-3 times faster so far, but I'll have to keep monitoring it through normal use.
02-22-2018 09:58
02-22-2018 09:58
After about a week of having the crude polling function, I actually haven't noticed a lot of battery drain. I agree that it's still not a good idea to do it this way and will change it when better means become available, but so far the only higher battery drain I've been seeing is when I forget to disconnect the Developer Bridge.
Something else might be draining the battery overnight as I woke up this morning with it at 94% after it was fully charged when I went to bed, but I'm not seeing that during the day, so it's probably not the polling.
I'm still trying to figure out how to use the Haptics API correctly to get a vibration pattern instead of a brief jolt, but that's probably a separate discussion.
02-22-2018 11:10
02-22-2018 11:10
Not sure if you are talking a custom pattern, but the standard patterns are defined here: https://dev.fitbit.com/build/reference/device-api/haptics/
02-22-2018 13:53
02-22-2018 13:53
@SunsetRunnerwrote:Not sure if you are talking a custom pattern, but the standard patterns are defined here: https://dev.fitbit.com/build/reference/device-api/haptics/
Yeah I've been trying to use one of the standard patterns. The problem I'm running into is that no matter which one I use, I only get a single split-second jolt for each time "vibration.start([pattern])" is called as though something else is immediately calling "vibration.stop()" or the vibration variable is being destroyed and re-instantiated in a way I don't understand.
02-22-2018 15:41
02-22-2018 15:41
What is the polling frequency you are using?
02-22-2018 16:57
02-22-2018 16:57
@paperinikwrote:What is the polling frequency you are using?
1000ms
02-23-2018 18:46
02-23-2018 18:46
Let me restate. You are pinging the companion every second?? And that's not draining the battery on the watch?
02-23-2018 19:38
02-23-2018 19:38
@paperinikwrote:Let me restate. You are pinging the companion every second?? And that's not draining the battery on the watch?
Not noticeably. In the last day alone, I charged it up to full and put it on before I went to bed last night and woke up with it at 92% 7 hours later. Now 12 hours of checking stats and notifications periodically throughout the day, it's only fallen to 84%.
If the watch is checking the status of the connection that was initiated by the phone, is it actually pinging my phone when it does that?
02-23-2018 22:07
02-23-2018 22:07
No, but I would expect that each time the phone pings the watch some battery gets drained in order for the watch to be woken up. Usually these things are meant to running in a suspended state for as long as possible in order to preserve battery. Bottom line, I would be expecting different draining patterns. Or I don't really know what is going on...