Skip to content

Commit 20b602c

Browse files
authored
Merge pull request #4322 from RKBoss6/Bluewatch-Updates
[BlueWatch] Update for app version 1.4
2 parents c8e9415 + 21ace7b commit 20b602c

5 files changed

Lines changed: 31 additions & 10 deletions

File tree

apps/bluewatch/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
0.01: New App!
22
0.02: Use new device handshake method for more reliable connections (Requires BlueWatch on iOS version 1.1)
33
0.03: Fix data intervals firing randomly, pairing issues, increased time between battery pushing, and queued data sending (Requires BlueWatch on iOS version 1.2)
4+
0.04: Add sending of calories (if installed), fix myLocation not saving if file doesn't exist, and emit BlueWatchMessage event upon message received

apps/bluewatch/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ Bangle.js 1 support coming soon!
1414
- Automatic weather updates without any additional setup
1515
- Find my phone support
1616
- Use of the phone's GPS for Bangle.js GPS.
17+
- Sending and storing of heart rate, steps, battery, and active/resting calories (if installed) to Apple Health/BlueWatch app
18+
19+
Additionally, the iOS app provides shortcuts actions to create your own workflows and automations. By hooking into when BlueWatch receives a message (see developer info), you can send messages through shortcuts that your watch receives and handles. This allows you to create complex workflows such as:
20+
- When you reach home, alert your watch to change the clock to an inexact clock face to relax
21+
- When CarPlay is connected to your car, send a message to your watch to turn on quiet mode for driving
22+
- When you receive a message from a specific person, vibrate continuously so you never miss the message
1723

1824
**Note:** This app still uses the `iOS Integration app` to handle pushing notifications from the phone to the watch.
1925

@@ -36,6 +42,13 @@ To send a string or a JSON, you can use the following:
3642
require("bluewatch").sendData("string or object", true);
3743
```
3844
with an optional second parameter `forceSend`. When true, it sends even if BlueWatch is not connected at the time. By default it doesn't send info unless the device handshake is completed and BlueWatch is connected
45+
46+
In the iOS app version 1.4, you can also use the Shortcuts app to send custom messages to the watch, as well as checking connection, and pushing weather/location via shortcuts. In the Bangle app version v0.04, the watch will emit the `BlueWatchMessage` event when a new message is received, allowing you to create your own workflows and automations using shortcuts and a receiving script:
47+
```
48+
Bangle.on("BlueWatchMessage", (message) => {
49+
// your receiving code here
50+
});
51+
```
3952
## Author and Creator of the iOS App
4053
RKBoss6
4154

apps/bluewatch/boot.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ function setMyLocation(d) {
9999
numFields.forEach((field) => {
100100
if (locationJson[field] != null) locationJson[field] = +locationJson[field];
101101
});
102-
102+
let myLocationSaved = require("Storage").readJSON("mylocation.json", true) || {}
103+
104+
103105
//load mylocation file
104106
let myLocationJson = Object.assign(
105107
{
@@ -110,12 +112,14 @@ function setMyLocation(d) {
110112
require("Storage").readJSON("mylocation.json", true) || {}
111113
);
112114
//remove notification from phone
113-
if (
114-
Math.abs(myLocationJson.lat - locationJson.lat) < 0.0001 &&
115-
Math.abs(myLocationJson.lon - locationJson.lon) < 0.0001
116-
) {
117-
//same location, do not write
118-
return;
115+
if(myLocationSaved.lat){
116+
if (
117+
Math.abs(myLocationJson.lat - locationJson.lat) < 0.0001 &&
118+
Math.abs(myLocationJson.lon - locationJson.lon) < 0.0001
119+
) {
120+
//same location, do not write
121+
return;
122+
}
119123
}
120124

121125
myLocationJson.lon = locationJson.lon;
@@ -131,6 +135,5 @@ function saveData() {
131135
}
132136

133137
E.on("kill", function () {
134-
//save cals counted
135138
saveData();
136139
});

apps/bluewatch/lib.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ function sendRawHealthData(data) {
9393
sendableData.movement = data.movement;
9494
sendableData.state = data.movement <= 150 ? "sedentary" : "moving";
9595
}
96+
if (global.calories) {
97+
sendableData.activeCalories = global.calories.activeCaloriesBurned || 0;
98+
sendableData.bmrCalories = global.calories.bmrCaloriesBurned || 0;
99+
}
96100
if (data.bpmConfidence && data.bpm) {
97101
if (data.bpmConfidence > 75 && data.bpm != 0) sendableData.hr = data.bpm;
98102
sendableData.confidence = data.bpmConfidence;
@@ -118,7 +122,7 @@ function onConnect() {
118122
function processMessage(raw) {
119123
raw = raw.trim();
120124
print("Processing complete message:", raw.length, "chars");
121-
125+
Bangle.emit("BlueWatchMessage", raw);
122126
let obj;
123127
try {
124128
obj = JSON.parse(raw);

apps/bluewatch/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "bluewatch",
33
"name": "BlueWatch iOS Integration",
44
"shortName": "BlueWatch",
5-
"version": "0.03",
5+
"version": "0.04",
66
"description": "Uses the native iOS app 'BlueWatch' to fetch weather, location, use phone GPS, find phone/watch, and more.",
77
"icon": "app.png",
88
"tags": "tool,bluetooth,apple,ios,system",

0 commit comments

Comments
 (0)