-
• #2
At the moment there really isn't anything existing that can do IP over BLE in the way you want.
However I did come up with something for MQTT which may help? https://github.com/gfwilliams/MQTToBLE
-
• #3
Thanks. I'll look at it.
-
• #4
Wow, cool stuff, have to try it.
-
• #5
I'm working on an mqtt to bluetooth project. At the moment I'm using your espruinohub, Gordon, and nodered but I plan to switch to trying out nodered's contrib BLE module
-
• #6
Suggestions for an MQTT server (AKA broker?)? Ideally, one that is in readable JavaScript?
(Oops -- seems to include a server -- will learn more so ignore this. (How do I delete an entry?)
-
• #7
I tried some of the examples at https://googlechrome.github.io/samples/web-bluetooth/index.html and while I could get some to work it was discouraging since, alas, Bluetooth wants to do me favors and builds in application knowledge. This is why I want more generic connectivity. I will look more into the MQTT approach but I still want to find a simple way to do an app that makes an IP connection, fetches data, and displays it.
-
• #8
MQTT with message retention is a pretty easy way to do this. Messages sent from Espruino’s TinyMQTT module have retention set by default. This is a good choice if you can easily have IP at both ends and you can have a slightly beefier box as a server. A Pi2 is fine.
If you are relatively new to all this NodeRed is a good choice because it has a UI to manage the design of the MQTT flows of data between your sensing devices and display, and add logic plus you can easily debug the MQTT messages flying around. However NodeRed doing any amount of work needs a beefier server, a Pi3 would be recommended. -
• #9
Thanks.
At this point, my main interest is a simple broker/server. I looked and found https://www.npmjs.com/package/aedes and going to see how easy it is. NodeRed seems to be a tool for managing the message flows atop the brokers.
import aedes1 from 'aedes'; const aedes = aedes1(); import net from 'net'; const server = net.createServer(aedes.handle); const port = 1883; server.listen(port, () => console.log(`Server listening on port ${port}`));
-
• #10
What do I need to do to use it with the BangeJS? I have the server setup but get "no compatible device" so I presume there is a simple step beyond pairing with my PC.
-
• #11
By “it “ what do you mean?
There is a tutorial here which I started with. https://www.espruino.com/BLE+Node-RED
Here’s a simple breakdown of the general steps you need, I won’t have time (sorry!) to spell them all out in detail
1) you need an MQTT broker, sounds like you have that in aedes, but people often use Mosquitto
2) you need a BLE to MQTT bridge to get messages from Bluetooth to MQTT, for this you could consider Gordon’s EspruinoHub which also by the way has full instructions starting from scratch for running on a Pi.
3) you need a program running on the Bangle which is advertising data on BLE - I imagine it broadcasts battery by default so you could just start with that
4) you configure NodeRed to subscribe to MQTT messages coming from the Bangle and/or send messages to the Bangle take actions based on them. A good place to start is installing NodeRed’s dashboard UI and use the dashboard for testing.
If you are a decent programmer you can skip NodeRed and build your own program on the server to subscribe to the MQTT messages and respond directly.
It is more complicated to handle sending data to the Bangle, and advertising is by far the simplest mechanism.
-
• #12
I'm making progress.
I took
espruino_node
from https://github.com/gfwilliams/MQTToBLE and added it to the end of my watch code (the date/time sample) and commented out the references to TX and Serial1 and switched it to BTN3.I'm also running the server from https://www.npmjs.com/package/aedes.
I was getting
Can't update BLE services until restart
So I installed EspruinoHub on one of my pi's and it found a lot of Bluetooth devices but I'm still getting the error message.
Is there good reference doc I can use to understand this from scratch since the examples have lots of additional complexity.
-
• #13
"Can't update BLE services until restart" on the Espruino?
All it means is you're connected via Bluetooth, and it can't change the services while you're connected. The second you disconnect it'll realise and will change them :)
-
• #14
I've made progress but not there. I installed to flash and disconnected. I eventually got the Espruin hub running on my pi to see the BangleJS but only if I placed it near the pi. No such problems with my pixl. But I'm not seeing the advertising message (Hello World).
I do urge having a WiFi option in the future. It needn't use much power if it is off much of the time and used to send messages rather than listening all the time. And would have far fewer such issues. The limitations of BLE such as a single connection and the lack of preinstalled support is an issue. This is why I made sure Windows got TCP/IP preinstalled and with DHCP rather than forcing users to do it themselves.
In the interim, it would be great to have a use case of a serial stream to an IP address (via TCP) and/or UDP. If I had that then the rest becomes very easy.
As an FYI, I tried using the IDE on the pi it offered the BangleJS but never finished connecting.
-
• #15
So you're not using MQTToBLE at all, just
NRF.setAdvertising
? Could it be that you have a phone (with Gadgetbridge) or something else that is connecting to the Bangle.js? Bangle.js won't advertise when it's connected to other devices.I tried using the IDE on the pi it offered the BangleJS but never finished connecting.
Thanks. I guess it might be related to https://github.com/espruino/EspruinoHub/issues/41 ?
having a WiFi option
I have the Espruino WiFi boards but the issue with something like Bangle.js is just the chipset used. It's a big undertaking to rewrite the WiFi/Bluetooth stack for a whole new device - and the kind of chipsets available are often capable of running Linux/Android - which is the sensible choice for internet stuff if your device is capable of it.
BLE has always been on the edge of offering IPv6 over BLE and having support built into routers. Several routers ship with it and it would have just been a firmware update to turn it on - unfortunately that doesn't really seem to have happened :(
-
• #16
Yes, trying to use as little mechanism as I can to narrow things down. I did install gadgetbridge but, again, too much static friction so haven't connected to it.
I understand why you chose BLE in this case. Indeed, my goal is for IP (4 or 6 don't matter for this purpose) over BLE. I wanted to get some hands-on experience before taking it up with the Bluetooth SIG. This is a full topic in its own right and I write about such issues in my column.
Is the BLE radio in the Bangle very short range? I'm about 2 meters from the particular pi. Is that too far? To test I just replaced the battery in the puck and it shows up (-80 vs the pixel at -87)
It is paired with my PC but I presume there is a difference between connected/disconnected and if I disconnect from the browser it should become available.
IDE -- I sometimes get a connection hang on the PC too and futz (to use the technical term) till somehow it connects. This latest test I brought the BJS to the pi and it immediately adds itself to the list with the puck and pixel but failed to connect. And then, after a refresh, I get no ports found
Not sure how much time I'll have to experiment with this (though, alas, I find myself trying one more thing). I might reach out to the BLE world for a better understanding.
-
• #17
Is the BLE radio in the Bangle very short range?
It's not amazing I'm afraid - I think the case gets in the way, and the aerial isn't as good as the Puck/Pixl ones.
It is paired with my PC but I presume there is a difference between connected/disconnected and if I disconnect from the browser it should become available.
It depends - it's worth checking in the OS if you had something like HID enabled the OS will tend to keep the connection open. If you did have HID enabled in the Bangle settings that could explain a lot of the instability connecting though...
my goal is for IP (4 or 6 don't matter for this purpose) over BLE
I'd be very interested in this. It actually struck me that you could use a similar method to MQTToBLE to do something like an AT-command interface to a bridge. It's a bit hacky but at least it's all 'off the shelf'.
-
• #18
Where do I find the HID settings for Windows 10?
As to IP/BLE -- I'll continue to explore as a background project.
-
• #19
Where do I find the HID settings for Windows 10?
I meant in the Bangle.js settings on the Bangle itself. The default is off, but if it's turned on windows will stay connected because it thinks it's a keyboard.
But the signal strength of the Bangle isn't great. Bangle->Bangle I'm seeing about 2 meters max :(
-
• #20
I'm going to try to avoid spending too much time on this today but I figured I'd give it a try on my pi4a running 64 bit Ubuntu so I could use Visual Studio but it failed on bleno -- bindRaw "No such device".
I'm also pursuing my BLE (human) connections.
-
• #21
Before I forget, this is a copy of the watch app https://1drv.ms/u/s!AglBpbKyzKIQj-VErqGWfcFj_sjaKA?e=UGAOUY which is just the same date/time app plus the sample BT advertising code and some cleanup to use ES5 constructs. It's possible that the code itself has a problem though I tried to keep the Bluetooth portion intact.
-
• #22
Nice! So that one is for MQTToBLE, rather than EspruinoHub?
EspruinoHub expects normal advertising, so won't be compatible with MQTToBLE (yet)
I see a lot of mechanisms in GadgetBridge and WebBLE.
I'm looking for the simplest way to do IP over the BLE connection that I can install on any platform and connect to when I'm in range. The apps can then view it through the lens of IP (albeit with limits on the amount of traffic).
If it exists (including via GB/WB) what is the simplest path to getting up to speed? If not, I may prototype it with a browser app but it would be limited to https or as a shim via WebSockets.