-
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 supportbleak
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.// Something like this when you want to connect // the interval is stopped once python connects NRF.disconnect(); var dc_interval = setInterval(() => { NRF.disconnect(); }, 10000);
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 accordinglyE.on("notify", function(event){ if (event.preExisting) return if (event.appId !== 'com.omz-software.Pythonista3') return if (event.message === 'connect') // here the code for the connection to python });
Any 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 theBangle.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 -
Yeah I guess that if you update once per hour it does not make much sense to work on this.
Hot starting the gps with agps data is actually very fast, I thought it updated just once per day and didn't try uploading it just before running the gps.
The api I was trying to use is the one from ublox https://developer.thingstream.io/guides/location-services/assistnow-getting-started-guide
I guess, from other posts in the forum, that you were using something like this for Banglejs1? They provide 100k free reqs. per month but I'm not sure how to stream the binary file into the gps chip once I get it.
Anyway it does not seem something worth working on right now, thank you for the details -
Hi Gordon, is it possible for a user to get an api key and download this data manually? I imagine that it refresh more often than what you provide using the AGPS app (you said it updates once per day) and I would like to provide a faster fix to my bangle if I need it.
I am having difficulties finding the ublox developer registration procedure though. Could you provide some links?Edit:
If the service is AssistNow Online I could actually find the documentation, I'm left with a binary file, I guess you encoded it as base64, could you by any chance provide the settings of the get request you use and how you process the file to arrive at what is displayed on https://www.espruino.com/agps/casic.base64Thank you for your time
-
Thank you @fanoush for the links, I won’t bother too much changing it then
-
Hello! This is my first time writing on the forum.
I got my Banglejs2 last week and having plenty of fun with it.I have modified a clockface and was wondering if the way I load images is correct, the original code uses this
function getImage() { return require("heatshrink").decompress(atob("...")); } function draw() { g.drawImage(getImage()); }
While it works flawlessly, I was wondering if this is the correct way, I guess that if the draw is called once per minute it loads the image again every time, would this impact battery life?
I guess, on the bright side that it does not keep the loaded image into RAM after drawing it on the screen which may be good for a limited memory device.Should I make the code keep the image in memory and load it once at the start?
Would having to draw the image multiple times in different parts of the screen change anything?Thank you very much for your help :)
If you have a reference for that I would like to try, anyway with 1h AGPS data I have to admit that it is pretty fast already.
Edit: yes bangle 2