BangleApps/apps/android
Gordon Williams 0ba8cef33c Convert Yes/No On/Off in settings to checkboxes, add /*LANG*/ to some more text strings 2023-02-23 11:46:49 +00:00
..
ChangeLog android 0.23: Handle 'act' Gadgetbridge messages for realtime activity monitoring 2023-01-25 09:29:34 +00:00
README.md slight tweaks to https://github.com/espruino/BangleApps/pull/2304/ 2022-11-28 14:22:44 +00:00
app-icon.js ability to depend on a specific app ID 2021-11-04 17:16:02 +00:00
app.js messages 0.07: Added settings menu with option to choose vibrate pattern and frequency (fix #909) 2021-11-25 15:50:07 +00:00
app.png ability to depend on a specific app ID 2021-11-04 17:16:02 +00:00
boot.js android 0.23: Handle 'act' Gadgetbridge messages for realtime activity monitoring 2023-01-25 09:29:34 +00:00
metadata.json android 0.23: Handle 'act' Gadgetbridge messages for realtime activity monitoring 2023-01-25 09:29:34 +00:00
settings.js Convert Yes/No On/Off in settings to checkboxes, add /*LANG*/ to some more text strings 2023-02-23 11:46:49 +00:00
test.js android - Check for internal GPS by using the pin state 2023-01-14 01:11:42 +01:00

README.md

Android Integration

This app allows your Bangle.js to receive notifications from the Gadgetbridge app on Android

See this link for notes on how to install the Android app (and how it works).

It requires the Messages app on Bangle.js (which should be automatically installed) to display any notifications that are received.

Settings

You can access the settings menu either from the Android icon in the launcher, or from App Settings in the Settings menu.

It contains:

  • Connected - shows whether there is an active Bluetooth connection or not
  • Find Phone - opens a submenu where you can activate the Find Phone functionality of Gadgetbridge - making your phone make noise so you can find it.
  • Keep Msgs - default is Off. When Gadgetbridge disconnects, should Bangle.js keep any messages it has received, or should it delete them?
  • Overwrite GPS - when GPS is requested by an app, this doesn't use Bangle.js's GPS but instead asks Gadgetbridge on the phone to use the phone's GPS
  • Messages - launches the messages app, showing a list of messages

How it works

Gadgetbridge on Android connects to Bangle.js, and sends commands over the BLE UART connection. These take the form of GB({ ... JSON ... })\n - so they call a global function called GB which then interprets the JSON.

Responses are sent back to Gadgetbridge simply as one line of JSON.

More info on message formats on http://www.espruino.com/Gadgetbridge

Functions provided

The boot code also provides some useful functions:

  • Bangle.messageResponse = function(msg,response) - send a yes/no response to a message. msg is a message object, and response is a boolean.
  • Bangle.musicControl = function(cmd) - control music, cmd = play/pause/next/previous/volumeup/volumedown
  • Bangle.http = function(url,options) - make an HTTPS request to a URL and return a promise with the data. Requires the internet enabled Bangle.js Gadgetbridge app. options can contain:
    • id - a custom (string) ID
    • timeout - a timeout for the request in milliseconds (default 30000ms)
    • xpath an xPath query to run on the request (but right now the URL requested must be XML - HTML is rarely XML compliant)

eg:

Bangle.http("https://pur3.co.uk/hello.txt").then(data=>{
  console.log("Got ",data);
});

Testing

Bangle.js can only hold one connection open at a time, so it's hard to see if there are any errors when handling Gadgetbridge messages.

However you can:

  • Use the Gadgetbridge Debug app on Bangle.js to display/log the messages received from Gadgetbridge
  • Connect with the Web IDE and manually enter the Gadgetbridge messages on the left-hand side to execute them as if they came from Gadgetbridge, for instance:
GB({"t":"notify","id":1575479849,"src":"Hangouts","title":"A Name","body":"message contents"})