Jump to content

BLE "translation"?


svenomous

Recommended Posts

As I understand it, the various manufacturers' wheels use a proprietary BLE communication protocol to talk to their respective apps.  This has been reverse-engineered to enable WheelLog and DarknessBot to work.

There are all kinds of smart watches and bike computers and whatnot that are designed to receive data from sensors.  My bike's Garmin computer gets cadence, heart rate, speed, and shifter information (including battery levels).  Often this is done over ANT+, but these devices also advertise the ability to use the newer BLE based sensors that have started replacing ANT+.

Wheels have some useful metrics that they report continuously over BLE connections: speed, distance, battery level, temperature, amps/watts, ..., which leads me to my desire/question/musing: unless wheel manufacturers can be convinced to start outputting standard BLE "sensor protocol" that a variety of devices would be able to receive and display, is it technically feasible for a smartphone to decode the proprietary BLE data stream (as DarknessBot and WheelLog already does) and retransmit certain metrics (speed and battery level at a minimum) via the appropriate sensor protocol, essentially emulating a standard BLE sensor?

I'm a developer, but more of a Windows coder with my last mobile coding experience being in the old Windows Mobile days, so I have no knowledge of current Android/iOS code frameworks and capabilities.  I also know nothing about the BLE "sensor protocol" I speak of, nor whether it's even possible for a phone to emulate this and pretend to be a sensor.  But...maybe someone else in these forums knows enough to help alleviate my ignorance. B)

And btw yes, I'm aware that DarknessBot can talk to an Apple Watch and WheelLog can talk to e.g. a PebbleWatch, but I'm hoping for a solution that opens up wheel metrics to the large field of sport smart watches and bike computers and even smart goggles (HUDs).

Link to comment
Share on other sites

I haven't tinkered with wheels but I'm pretty sure you could monitor whatever is being transmitted with something like wireshark. I bet they are transmitting standard plain text packets.

Edited by wheelr
Link to comment
Share on other sites

12 hours ago, wheelr said:

I haven't tinkered with wheels but I'm pretty sure you could monitor whatever is being transmitted with something like wireshark. I bet they are transmitting standard plain text packets.

Never delved into BLE, I just made a small app for Euc Extreme back in 2015 when Gotways and Kingsongs were still using BT 2.0 (just serial connection with continuously streaming data), but it sure as hell wasn't plain text, and to read out the actual values, I needed to decompile their apps to know how to decipher it (plus ask people to capture the data on their phones and send it to me, since I didn't have either KS or a GW :D). Current wheels use Bluetooth Low Energy (BLE/BT 4.0, don't ask what happened to 3.0, I don't know :P), which has some sort of a publish/subscribe-model instead of continuous data stream to save power (no need to send over data that hasn't changed since the last time), various profiles and whatnot.

The easiest place to start digging into this is probably taking the source code for the open source apps and decompiling the manufacturer (Android) apps. Of course you should also learn the BT 4.0 basics, something I was going to do at one point, but never got around to... :P 

Edited by esaj
Link to comment
Share on other sites

10 minutes ago, wheelr said:

By plain text, I mean unencrypted.

Oh right, yeah, definitely not encrypted, but not human readable either (and why would it be :P)

Quote

More info on the BLE protocol can be found here: https://microchipdeveloper.com/wireless:ble-link-layer-packet-types

Thanks, not sure if one would actually need to go to the link-layer level to read the data with a mobile phone though? Could be wrong, never looked into BLE. I don't really code for fun anymore, or much in the past decade, I get to do that more than enough at my job ;)   Instead, I've focused on hardware (electronics) in my spare time for the last few years.

Edited by esaj
Link to comment
Share on other sites

6 minutes ago, esaj said:

not sure if one would actually need to go to the link-layer level to read the data with a mobile phone though?

Sorry, I meant to link to the document as a whole. But yes, you are right, you don't need to go low level to use BLE, specially on mobile platforms with all their confy abstractions. I'm just a low level programmer and tend to dive as close to the metal as I can  ;)

This may be more inline with what he is looking for: https://developer.apple.com/bluetooth/

  • Upvote 1
Link to comment
Share on other sites

6 minutes ago, wheelr said:

I'm just a low level programmer and tend to dive as close to the metal as I can  ;)

I hear you, I just recently switched from the so-called "systems" (read backend/databases/Linux-servers) -development to embedded (for work, that is), and not some fancy-schmancy Linux "embedded", but bare metal microcontrollers and plain C (and some asm, although I don't know it well enough to do much there). We'll see what happens, I've already ruined "general" programming and game programming as a hobby by turning them into a job earlier, so let's do the same for the lower level stuff... ;) 

  • Like 1
Link to comment
Share on other sites

4 minutes ago, esaj said:

I hear you, I just recently switched from the so-called "systems" (read backend/databases/Linux-servers) -development to embedded (for work, that is), and not some fancy-schmancy Linux "embedded", but bare metal microcontrollers and plain C (and some asm, although I don't know it well enough to do much there). We'll see what happens, I've already ruined "general" programming and game programming as a hobby by turning them into a job earlier, so let's do the same for the lower level stuff... ;) 

Haha embedded is challenging but also very rewarding and it will tie nicely with your passion for hardware. I think you've made a good choice.

  • Upvote 1
Link to comment
Share on other sites

I did some research into iOS's Core Bluetooth framework (iOS because I have an iPhone, so that's my first inclination), and indeed it allows an app to act either/both as a Central (discovering, connecting to, and receiving data from Peripherals), or a Peripheral (advertising services/characteristics, taking connections from Centrals, and feeding data to them).

So yes, I think that what I'm envisioning is possible.  Of course the best/easiest approach would be for the existing apps that know how to talk to the wheels to add this new capability to their arsenal, but if I had the energy and desire I could do a bunch of learning (Objective C) and write a little translator app that steals code from the existing apps and does nothing except translate sensor data to act as a Peripheral that sport watches and similar equipment could receive data from.

I think I'll head over to the DarknessBot thread and see if there's any interest by the author in adding such capabilities at some point.  Doing this from scratch by myself would be daunting and I'm not sure it's quite worth the effort.

  • Like 1
  • Upvote 1
Link to comment
Share on other sites

Something I want to work on for a HUD application is a proximity signal using a radar or sonar peripheral to alert the rider of passing traffic. It would be nice if existing EUC apps had an API whereby we would extend their functionality.

  • Upvote 1
Link to comment
Share on other sites

15 hours ago, svenomous said:

And btw yes, I'm aware that DarknessBot can talk to an Apple Watch and WheelLog can talk to e.g. a PebbleWatch, but I'm hoping for a solution that opens up wheel metrics to the large field of sport smart watches and bike computers and even smart goggles (HUDs).

The problem is that whatever predefined/well-known BLE service you'll use, you will be able to provide very narrow set of wheel data. For example you can transmit speed using services like CSCS or FMS. You can also send battery level using BAS. But what about power? Current? Voltage? These are definitely one of most important wheel parameters. Main limitation is that all of these services are very specialized in their application. This is why it's much better and easier to use smartwatch and create companion app for it. It's already implemented in WheelLog that can be used with Pebble and Gear Sx watches.

  • Upvote 1
Link to comment
Share on other sites

True.  Depends also on the platform.  Some allow creating customized "gauges"/"instruments" and widgets.  A lot of work.  Would be nice to be able to get wheel parameters on a HUD in cycling glasses or ski goggles.  But, may not be worth the effort to do all the end to end work required, including possible expansion of the target platform to support the sensor types.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...