-
• #2
Hi! That's an interesting thought... Subscribing to
E.notify
sounds like a great solution.Bangle.js can't accept more than one incoming connection unfortunately... You'd hope that Python might somehow be able to find the already-connected device, but if not:
I'm not 100% sure if this'll work with iOS, but what about changing the Bangle's MAC address, so the phone thinks it has gone out of range:
// ... to disconnect and allow a connection from your app NRF.setAddress(NRF.getAddress().slice(0,-1)+"0 random"); NRF.disconnect(); // force a disconnect - Bangle.js should now be at a different address // ... to disconnect and hopefully have iOS reconnect NRF.setAddress(NRF.getAddress()+" random"); NRF.disconnect(); // force a disconnect - Bangle.js should now be at a different address
In the example above I'm assuming your Bangle's address didn't already end in
0
- but hopefully you get the idea :)
Hello, I wanted to ask a few questions for a project I'm working on for my bangle2.
I own an iPhone so GB was not an option for me, I figured out that communicating using BLE between my phone and Bangle was my best option to replace some of the features GB would provide me if I were using android.
I started from the tutorial about BLE communication and managed to connect using the
bleak
library for python.On iOS there's pythonista which allows to install packages and run python with some access to iOS native features, it did not support
bleak
but provided a BLE module called cb.I managed to setup a connection but had to do a few tricks and I would like to ask if there's a workaround to simplify my life.
The problem is the following:
Usually my bangle is connected with my iPhone for notifications, if the bangle is connected to any device I can't manage to connect to it using python unless I first disconnect from such device.
To workaround this without having to 'forget' the device on iOS every time I want to connect (otherwise the phone immediately connects to the watch) the first solution I found was to open an app on the bangle which disconnects from the current device on an interval and during this time window connect using python.
This is not a very nice solution, what I would like is to be able to connect to the watch even when it has another connection open (if only one connection is allowed I would like the watch to drop the other) simply by launching my python script from my iOS device.
The solution I currently use is a bit better, if the phone is connected to the watch and I run my python script it starts by issuing a notification using pythonista which the iOS integration receives.I subscribe to the
notify
event and start the connection procedure accordinglyAny thoughts on this? Is it possible to make the bangle accept a new connection from python even if it is already connected to my phone or computer?
I literally started messing with my bangle one week ago and had no prior experience with espruino firmware so I might be messing obvious solutions.
What I'm able to do once I setup the connection is the following:
1) Run arbitrary code on my bangle which allows me, for example, to send or download data from it
2) I rewrote the
Bangle.http
and I am able to bounce http requests made from bangle apps to my phone as GB would do. This allows me to successfully run the AGPS app which would require android to update my gps fix or download the weather using the GB weather app