Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please implement Bluetooth support #103

Closed
WouterJD opened this issue Sep 7, 2020 · 56 comments · Fixed by #130
Closed

Please implement Bluetooth support #103

WouterJD opened this issue Sep 7, 2020 · 56 comments · Fixed by #130
Assignees
Labels

Comments

@WouterJD
Copy link
Owner

WouterJD commented Sep 7, 2020

Would it be possible to broadcast the data using bluetooth instead of ANT+, no dongle needed in this case.

Thanks a lot for this!

Originally posted by @mruzzon in #61 (comment)

@WouterJD
Copy link
Owner Author

WouterJD commented Sep 7, 2020

There are multiple sides to this

  • implementing a new interface is a challenge
  • but considerably more costly (in hours and effort) than bying some ANT-dongles
  • users will use a PC instead of smartphone anyway (to zwift, or other VR)

But it's noted as a feature request and if anyone likes to do a code-suggestion; I will gladly integrate into the code.

@aegisdesign
Copy link

I'll +1 this. Adding Bluetooth support opens up the possibility of using more hardware such as phones, tablets/iPads and things like AppleTV that don't support ANT+ but run Zwift and other apps well.

Lots of work though.

@roggenbrot
Copy link

roggenbrot commented Sep 27, 2020

https://github.com/jedla22/BleTrainerControl/blob/master/How-to%20FE-C%20over%20BLE%20v1_0_0.pdf

On Linux it should be no problem to create a BLE GATT server via bluez, on windows/mac no idea.

Protocol seems to be the same as used for ANT+

@aegisdesign
Copy link

aegisdesign commented Sep 27, 2020 via email

@roggenbrot
Copy link

BLE part which is required to implement GATT is linux only and experimental.

Microsoft has a documentation how to implement a GATT server with c#. But this would require a python wrapper which would cause additional effort.

@WouterJD WouterJD mentioned this issue Oct 18, 2020
@WouterJD WouterJD added enhancement New feature or request future development This is not on the backlog for the coming releases labels Oct 26, 2020
@marcoveeneman
Copy link
Contributor

I'm interested in this feature since i have a tacx fortius (T1932) trainer laying around but no ant+ dongles (and my macbook only has only 2 usb ports.. 🙄)

Let me see if i can put something together.

@WouterJD
Copy link
Owner Author

Well; two USB-ports would do.

And if not, a USB-hub is a quick fix; avoiding the whole software development traject.
Two USB-dongles (#61) and a USB-hub costs € 75,= and you are good to go this weekend :-)

image

@marcoveeneman
Copy link
Contributor

Hi Wouter, I took the challenge and tried to get Bluetooth (BLE) working this weekend. I just rode my first couple of meters in Zwift on my Apple TV by running FortiusANT with BLE support on my MacBook. I'm Zwifting from Nijmegen btw.

Ok, so instead of implementing Bluetooth (BLE) support directly in FortiusANT i chose to handle the BLE functionality as a separate process in NodeJS. At startup, FortiusANT should start the NodeJS server so it can then communicate with it. Instead of writing data to an ANT+ dongle it can now send a message to the NodeJS server which will then handle the BLE stuff.

Would you be interested to include the changes in FortiusANT? If so, i would first propose some serious code refactoring tbh. It was quite hard to wrap my head around the code in the current state and fit the BLE part in.

Just let me know, i'd be happy to help :)

@WouterJD
Copy link
Owner Author

WouterJD commented Nov 1, 2020

Marco; great work, compliments!👍
And yes i would integrate.

Als je wilt kunnen we wel een conference call organiseren om door te spreken op welke wijze te integreren

@WouterJD
Copy link
Owner Author

WouterJD commented Nov 1, 2020

PS. Welke Tacx heb jij?

@orrmany
Copy link

orrmany commented Nov 2, 2020

Hi @WouterJD congrats for your work. I came over here due to your comment https://www.strava.com/activities/4273307198. :)
Learning Python is on my bucket list, maybe understanding your source code can be a good quest to start with :)

@WouterJD
Copy link
Owner Author

WouterJD commented Nov 2, 2020

@marcoveeneman has done investigations; next steps are to engineer and integrate

@marcoveeneman
Copy link
Contributor

Marco; great work, compliments!👍
And yes i would integrate.

Als je wilt kunnen we wel een conference call organiseren om door te spreken op welke wijze te integreren

@WouterJD Great, then i'll proceed with it. I'm using a Tacx Fortius Multiplayer T1932. I've sent you a message to setup the conference call.

@orrmany
Copy link

orrmany commented Nov 2, 2020

guys, consider to implement the FE-C profile, too, with BLE, see issue #122 for rationale

@WouterJD
Copy link
Owner Author

WouterJD commented Nov 2, 2020

We're working on it and implement stepwise with purpose a full implementation. I'd be curious to know why zwift does not support ANT/FE-C and Rouvy's ANT runs behind on Bluetooth...

@orrmany
Copy link

orrmany commented Nov 3, 2020

Proposal is to transmit simultaneously on BLE and ANT+. I have to note that not all computers have BLE built in, not even laptops.

@msjnaessens
Copy link

msjnaessens commented Nov 3, 2020

Best would be for Zwift to just support ANT+ FE-C on android tho...
https://forums.zwift.com/t/ant-update/195323
https://forums.zwift.com/t/zwiftgame-android-faq-v-1-0-50775/465924
If there were enough requests for the feature, they would consider implementing it. Maybe the feature will be available soon and it would be a waste of effort implementing the conversion in FortiusANT.

Another option would be the NPE Cable ANT+ to BLE converter (https://youtu.be/HvrYcOyd7wA) which does support FE-C control. (Often mentioned in zwift forums).

@WouterJD WouterJD added under investigation Being studied for implementation in next version and removed future development This is not on the backlog for the coming releases labels Nov 3, 2020
@marcoveeneman
Copy link
Contributor

As you can see i just opened a pull request where initial support for Bluetooth is added. It is working fine for me, but i would be very interested in results of other users. Please let me know if it works ok for you too or if you encounter any issues. Thanks!

@brauereik
Copy link

Great work so far Marco. I've just cloned your PR and had issues to connect to 'Virtual Trainer' either through Tacx Training App or RGT Cycling on Android11 - Pixel3a. Pairing the mobile with the trainer directly asked for the pin connects and disconnects right away. FortiusAnt was started on OSX 10.14.6 > python3 FortiusAnt.py -b -t i-Vortex -g -a

Any logs you like to see? BTW, I'm from Germany

@WouterJD
Copy link
Owner Author

Hi @brauereik welcome in the FortiusANT community!

@marcoveeneman
Copy link
Contributor

Great work so far Marco. I've just cloned your PR and had issues to connect to 'Virtual Trainer' either through Tacx Training App or RGT Cycling on Android11 - Pixel3a. Pairing the mobile with the trainer directly asked for the pin connects and disconnects right away. FortiusAnt was started on OSX 10.14.6 > python3 FortiusAnt.py -b -t i-Vortex -g -a

Any logs you like to see? BTW, I'm from Germany

Hi @brauereik, thanks for taking the effort in testing my PR! So if i understand correctly FortiusANT did actually start the BLE server and started advertising, nice, good to know that works for someone else as well.

To better understand why the connection was dropped there might be some information in a file called ble.log, which should be located in the pythoncode folder. Note that this file is currently overwritten each time you start FortiusANT. Can you provide the log file so i can have a look at it?

@marcoveeneman
Copy link
Contributor

I installed both Tacx Training and RGT on my iPhone and both are connecting with the Virtual Trainer (I am thinking to rename this to FortiusANT for clarity). I guess this is an Android vs iOS issue. I'll have a look if there are some special requirements for Android to connect.

@marcoveeneman
Copy link
Contributor

marcoveeneman commented Nov 11, 2020

@brauereik I forgot to ask, what do you mean exactly by pin connects?

@TacxBiker
Copy link

TacxBiker commented Dec 23, 2020

Hi Wouter,
I'm new to this all, so first of all thanks for your work and effort.
I can start the bluetooth version without any error. I try to start in sim mode ( -a -n -s -b -d127 -g)
The gui tells there a Bluetooth interface available, so next step should be pair a tablet / bike computer / smartphone
when trying to do so, none of these devices find a FortiusANT Trainer
I probably miss a step.
FortiusANT.2020-12-23 12-00-09.log
FortiusAntGUI.2020-12-23 12-00-10.log

@marcoveeneman
Copy link
Contributor

Hi Wouter,
I'm new to this all, so first of all thanks for your work and effort.
I can start the bluetooth version without any error. I try to start in sim mode ( -a -n -s -b -d127 -g)
The gui tells there a Bluetooth interface available, so next step should be pair a tablet / bike computer / smartphone
when trying to do so, none of these devices find a FortiusANT Trainer
I probably miss a step.
FortiusANT.2020-12-23 12-00-09.log
FortiusAntGUI.2020-12-23 12-00-10.log

Hi TacxBiker, I guess you started the version from #179 right? Currently Wouter and i are very close to finish integrating bluetooth. However this is done in two separate PRs. #179 implements the necessary logic inside FortiusANT python code, while #130 implements the specific bluetooth logic separately, you need both to get it working. When the two versions are merged, bluetooth support should work (note the setup required for starting Bluetooth in the doc folder of #130, we currently consider bluetooth an advanced feature since it requires extra setup for the user at the moment.)

@WouterJD
Copy link
Owner Author

Ho @TacxBiker
Welcome to the FortiusANT community


I'm always curious to know who I communicate with, where FortiusANT is used and what configuration is used.
Please tell me what bundle did you buy, and what brake and what head unit do you use?
I would therefore appreciate that you introduce yourself; perhaps leave a comment under issue #14.


@TacxBiker
Copy link

Hi,

when starting FortiusANT with bluetooth support I get the following error:

13:42:30,448: ... requests.post() error HTTPConnectionPool(host='localhost', port=9999): Max retries exceeded with url: /ant (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0828A4C0>: Failed to establish a new connection: [WinError 10061] Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd'))

It seems the HTTP server for receiving the data from Fortius ANT isn't online

Is there a way to check that?

@TacxBiker
Copy link

TacxBiker commented Dec 24, 2020

One step further. To start de server I simply can use this command in de \node folder

Node server.js

But then unfortunately the next error:

C:\Github\FortiusAnt\FortiusANTBLE\FortiusANT-master\node\node_modules@abandonware\bluetooth-hci-socket\lib\usb.js:90
throw new Error('No compatible USB Bluetooth 4.0 device found!');

But there should be a right bluetooth device.
I changed the driver with the zadig tool.

The bluetooth device I use has the following ID: USB\VID_0A5C&PID_21F1
so that should not be the problem.

@TacxBiker
Copy link

And there we go:
FortiusANT

@TacxBiker
Copy link

I added a new device in the \bluetooth-hci-socket\lib\usb.js file
var VENDOR_DEVICE_LIST = [
{vid: 0x0CF3, pid: 0xE300 }, // Qualcomm Atheros QCA61x4
{vid: 0x0a5c, pid: 0x21e8 }, // Broadcom BCM20702A0
{vid: 0x0a5c, pid: 0x21f1 }, // Broadcom BCM20702A0
{vid: 0x19ff, pid: 0x0239 }, // Broadcom BCM20702A0
{vid: 0x413c, pid: 0x8143 }, // Broadcom BCM20702A0
{vid: 0x0a12, pid: 0x0001 }, // CSR
{vid: 0x0b05, pid: 0x17cb }, // ASUS BT400
{vid: 0x8087, pid: 0x07da }, // Intel 6235
{vid: 0x8087, pid: 0x07dc }, // Intel 7260
{vid: 0x8087, pid: 0x0a2a }, // Intel 7265
{vid: 0x8087, pid: 0x0a2b }, // Intel 8265
{vid: 0x0489, pid: 0xe07a }, // Broadcom BCM20702A1
{vid: 0x0a5c, pid: 0x6412 }, // Broadcom BCM2045A0
{vid: 0x050D, pid: 0x065A }, // Belkin BCM20702A0
{vid: 0x1286, pid: 0x204C }, // Marvell AVASTAR
{vid: 0x8087, pid: 0x0025 }, // Dell Precision 5530
];

@TacxBiker
Copy link

TacxBiker commented Dec 24, 2020

Connection to an iPad in the Sufferfest app:

FortiusANT1

and with all the data:

FortiusANT2

@WouterJD
Copy link
Owner Author

WouterJD commented Dec 24, 2020

@marcoveeneman you evaluate this?

@TacxBiker
Copy link

FortiusANT receives just like it should the power from the CPT.
But when the power goes up by 50W it doesn't feel like so.
Maybe this has something to do with #173

@WouterJD WouterJD reopened this Dec 24, 2020
@marcoveeneman
Copy link
Contributor

Hi @TacxBiker, I see you got the BLE interface up and running eventually, great!
The change you applied is something that would ideally be integrated in https://github.com/abandonware/node-bluetooth-hci-socket/blob/master/lib/usb.js, since this is part of the library we use. Can you open an issue + PR in that repository?

@WouterJD
Copy link
Owner Author

@marcoveeneman perhaps add a note in the documentation as long as not implemented. Merry Christmas🚴‍♀️🚴‍♀️

@mtbiker22
Copy link

Hi, trying to get FortiusANT up and running on a raspberry pi 3..... So far FortiusANT starts, callibration works, but bluetooth is not working.

Can anybody point me out how to setup and use node.js of the BTLE support?

@TacxBiker
Copy link

@marcoveeneman
Done, see what happens. Thanks

@hleidecker
Copy link

hleidecker commented Jan 1, 2021

@WouterJD and other contributors, I really appreciate all your work on FortiusAnt. It worked 'out of the box' on Windows with two Ant+ dongles.

I can confirm that Bluetooth is working with Linux - tested today with a T1932, Raspberry Pi 3B, Raspbian and Zwift.

@marcoveeneman one observation - the python script must be executed from the 'pythoncode' directory i.e. 'sudo python3 ./FortiusAnt.py' not 'sudo python3 ./FortiusAnt/pythoncode/FortiusAnt.py' as stated in the user manual.

The python script/application tries to execute the node.js script/application from '../node/' relative to where the python script/application is executed from.

In my case it ended up looking for the node.js script/application in '/home/pi/node/' when using 'sudo python3 ./FortiusAnt/pythoncode/FortiusAnt.py'. I have the FortiusAnt python script in '/home/pi/git/FortiusAnt/pythoncode/'

@TacxBiker
Copy link

TacxBiker commented Jan 3, 2021

@hleidecker Is it possible to post a small guide for bluetooth on linux / Paspberry Pi? Or the steps you have done to get it working
I'm stuggling with this

@hleidecker
Copy link

hleidecker commented Jan 3, 2021

@hleidecker Is it possible to post a small guide for bluetooth on linux / Paspberry Pi? Or the steps you have done to get it working
I'm stuggling with this

@TacxBiker, with the basic FortiusAnt functionality up and running I did the following to get it working with the Raspberry Pi 3B:

  1. Install NodeJS
    sudo apt-get install nodejs

  2. Install dependencies:
    sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
    cd node && npm install

  3. Run FortiusAnt with automatic start, BLE support, simulated trainer and any heart rate monitor
    cd FortiusAnt/pytoncode (must be run from this directory)
    sudo python3 ./FortiusAnt.py -a -b -s -H0

Please note that the system had a lot of stuff already installed ... in my pursuit of upgrading to the latest version of wxPython - I eventually gave up as I never succeeded in building it.

Let me know if this works for you.

@WouterJD
Copy link
Owner Author

WouterJD commented Jan 4, 2021

@hleidecker
Welcome to the FortiusANT community


I'm always curious to know who I communicate with, where FortiusANT is used and what configuration is used.
Please tell me what bundle did you buy, and what brake and what head unit do you use?
I would therefore appreciate that you introduce yourself; perhaps leave a comment under issue #14.


@WouterJD WouterJD closed this as completed Jan 9, 2021
@StFalagar
Copy link

Hi @WouterJD

Thanks... I got this working... Connected to Zwift and RGT so far. Also using Golden Cheetah with a usb connection. Just as a side note (not sure if covered before) I am using a Microsoft Surface Pro 4 and only need one BLE dongle for Fortius Ant. The Surface's built in Blue Tooth handles the Zwift Connection. I am also able to connect to it using the companion app... thanks again for this awesome initiative :)

@WouterJD
Copy link
Owner Author

WouterJD commented Mar 5, 2021

@StFalagar thanks for your nice words and the update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.