I would like a simple app that periodically checks the bluetooth connection between the phone and my watch (GTR 3 Pro), and buzzes the watch when it gets disconnected from my phone. This will be useful if I accidentally leave my phone somewhere and walk away from it, or my phone gets stolen or something like that.
Some previous amazfit watches had this feature built-in, but it doesn't seem to be available in my GTR 3 Pro right now. Thank you.
You'll need to do a little hack to poll the Bluetooth connection to achieve the desired behavior, but first let's understand why.
Per ZeppOS architectural decision, your app will never run in background on the device. I believe this is for battery efficiency reasons or even available processing power.
With that in mind, We'll use
hmApp.alarmNew
andhmApp.alarmCancel
in order to get it working, as follows:page
that will be responsible for checking the bluetooth connection, something likepage/connectionCheck.js
and declare it in yourapp.json
target (you can also use the defaultindex.js
if you want)onInit()
of the page, register a newhmApp.alarm
and cancel the existing ones if needed to avoid waking up the app unnecessarilybuild()
call, verify if it's connected to the cellphone using thehmBle.connectStatus()
and alert the user.Summarizing, it'll look like this:
(I'm using zeppOS API v1.0 here to make it work on all devices)