-
Notifications
You must be signed in to change notification settings - Fork 33
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
Second BLE Server as Bluetooth Passthrough for SmartRow App #26
Comments
The Gatt server for the SmartRow passthrough is running but the SmartRow apps doesn't want to connect. |
I tried to continue with this implementation. I still hit a wall. I did find out that if I clone the PiRowFlo advertiser in the nRF app and let the SmartRow app try to connect to it, it works. The SmartRow acknowledge that the connection is working. If I try the same with only the Pi then I can't get pass the "establishing connection". Something is the app nRF doing when faking the SmartRow that the GATT bluez implementation doesn't. I tried some of those link but I can't get it connect. But the thing is if I use the nRF app, I can connect to the PI and get the fake data from the Pi. So the App SmarRow expects something to pass the "establishing connection". I already set the recommended min max connection intervals according to the SmartRow itself. It might be necessary to further investigate the connection between the App and the fake SmartRow with the nRF app. And check why it is so different from the PI connection. |
In order to work in the ble2.py the following must be added to the advertiser:
And in the smartrowble gatt server config the following must be add to the advertiser part:
check the api doc link I needed to add it to the gatt example as it was missing and not implemented. with the option the advertiser will set the flag to be discoverable which SmartRow App needs in order to connect to PiRowFlo SmartRow passthrough. Now it's just a question of adapting the code in order to passthrough the SmartRow data and get them to the SmartRow app. |
New feedback even if now smartrow app talk to PiRowFlo, I still have the issue that once the dual Gatt server has been started and then stopped and the dual Gatt server is started again dbus will complain that there is already a Gatt server running. Even restarting bluetooth.service doesn't help. The only solution I found either restart the pi or sometime if I wait long enough then it seems to work again without reboot.
|
Oki I got it this time ! In order to fix that issue the following is possible:
But I found out that the config thing only applied to the last hci. So if you have more than one which is the case for PiRowFlo then only one dongle is set to LE_only the others stays to have Bluetooth Classic and LE_only.
https://github.com/bluez/bluez/blob/a37d53db9ae7d21a8f812925303d767d3f03e597/src/main.c#L306-L318
Issue has been fix in bluez. But the latest git master must be fetch and build. Bluez 5.56 still has that issue |
Oki, SmartRow now can talk to PiRowFlo and the data are also send to the App it is working but. I only can have either smartrow or normal bluetooth le with the Fitness Equipement profile ! When I try to start the second Bluetooth Gatt server in this case the SmartRow LE signal then D-Bus always quit the thread with the following error message:
I don't know how to fix this issue with the double Gatt server running at the same time ! |
Oki, I can't find a solution for that. The only idea would be to shift the second GATT server in a complete new process ! I reached my knowledge point with D-BUS where I can't get any further and debug why I can't have both GATT servers at the same time in different threads. If someone has more skills, please help :) |
Hi, Is it possible to have an option to either launch the SmartRow Bluetooth profile or Fitness equipment Bluetooth profile ? The use case is connecting both a Garmin watch through ant and the smart row app through Bluetooth? Regards, |
Hi all, I have the same use case then FlorentLa
So for me there is no need to connect to coxswain or another app. I would like to go with SmartRow and take the advantage of receiving all the data to my garmin FR 745 via Ant+
@inonoob Can you tell me in which script this has been implemented? I found fakesmartrowthreads.py in folder /src/testing but I assume that this is not the one I am searching for. |
Hi all, any news on that topic? I have the same problem: I want to use the original SmartRow app on my Android phone and at the same time I want to see the SmartRow data in Garmin Connect (I use a Fenix 6x Pro watch). As far as I have tried it, the SmartRow can only connect either to the phone (SmartRow app) or to the Raspberry PI (pirowflo project) but not to both. So when it it possible that the Raspberry PI forwards the SmartRow data 1:1 to the Android phone (SmartRow app) it would be great. @inonoob First of all thank you for that great project! Could you please give as some thoughts where and what needs to be implemented to enable that SmartRow data forwarding? Do you think it is even possible? I am not into BLE a lot but I could imagine that the SmartRow app can detect if the data was sent from the SmartRow or from another device such as the Raspberry? |
Hey, So the thing is in order to it. It would require to copy the smartrow Bluetooth protocol as they have defined their own profile. In addition the Ant+ protocol must work with the data. I haven't implemented. I wanted to start but I had issues with Bluetooth. I wanted to have 1 Bluetooth input smarter then as output 2 Bluetooth. The first would be the Bluetooth with fitness rowing profile and the second would be the relay for smartrow app. But as I mentioned, I did hit a wall with the two gatt server running on the same Device. As I don't have a Fenix 6 I couldn't test the native rowing app. |
@inonoob, have you written any code for the SmartRow pass-through? Or do you have documentation on their interface? If the issue is simply running the two BLE servers in separate processes, that should be easy to sort out with shared memory or pipes or some such inter process communication. I have built up a little system with the display, Pi Zero W, USB / ETH hat and extra BT dongle. I got sample (fake) data to my Garmin FR945 using your code as a base. I am waiting for my SmartRow to be shipped (they are taking forever). As soon as I get it, I will start playing with the code. If you have already written some code for the pass-through, I am willing to give it a shot. At first I won't need two BLE servers, since I don't care about BLE-FE. I'll stick to ANT-FE to the Garmin. |
@inonoob can you share the code where you have the raspberry pi sending data to the smart row app? I've been working on this using the test code in the repository but I can't get data to flow. I can get a connection but when I click start on the app, it never starts to show data. I just get a spinner. I think there is a good number of people that will be happy with a solution where we use ant and ble passthrough only, which does not require 2 gatt servers |
I have the basics going to pass SmartRow data to the SmartRow app. This does not support the BLE fitness profile at the same time. It requires two BlueTooth devices. I use a Raspberry Pi Zero W and one external dongle. It will read data from the SmartRow power meter and transmit via ANT+ and the "fake" SmartRow that the app can connect to. I have a SmartRow V3 and you will probably need the latest version of the app. I still need to do a lot of testing to see how robust it is. At the moment, you need to start the program via a console command line. I have only been testing on Android. If you are interested in helping to test this, please let me know. I may be ready to check something into my fork over the weekend. I will see how easy it is to integrate this with the SuperVisor console. Or maybe editing a config file once. Also, if you want to test, make a backup of your original piroflow directory. Below is a short workout that I recorded on both my Garmin 945 and the SmartRow app. SR App is left, GC is right. Distance and stroke counts are identical. Average power is about 10W lower on the Garmin (87W vs 98W), but that may not mean anything (counting zeros, etc). The Garmin Normalized Power (97W) is pretty close to the SmartRow app. I don't have a SR account, so not sure if it provides more data for comparison. cc: @hnfhtw, @dbffm, @FlorentLa |
I've checked in a release candidate to my fork if anyone wants to test this. No extra configuration is necessary. I tested on a Pi Zero W with an external Bluetooth dongle with the app running on Android. The system must be configured for input from SmartRow and output to ANT+. It will detect this and then automatically enable SmartRow passthrough.
Please let me know if you've tried it and if it worked or not. If not, please attach piroflow.log. |
I committed two changes after doing a rowing workout today. The first was to include the stroke count in the fields that are reset whenever the app requests a reset (the other two are time and distance). I recorded an hour session on my Garmin. During this time, I did two 30 minute workouts from the SmartRow app. I noticed the stroke count discrepancy when I compared the workouts. Other than that, it was pretty cool, and exactly what I wanted. The second fix was to be more deterministic when choosing Bluetooth adapters. I coded the system for the real SmartRow to connect to the on-board Bluetooth dongle. The fake SmartRow advertises on the external dongle. If the external USB dongle is plugged in when the Pi boots, then it gets hci0 and the internal dongle gets hci1. When that happens, the real SmartRow won't connect to PiRowFlow. Not sure why - I don't think I changed any of that code. I have now changed the code that, only if passthrough is enabled, the preferred Bluetooth adapters will be selected. This seems to yield a much more predictable system. @inonoob let me know if you're interested in me making a pull request for this. I am somewhat wary of breaking existing code. I tried hard to write the code such that it only impacts the pass-through functionality. There may be an issue with the new adapter selecting code if there are no on-board Bluetooth adapters - not sure if that is still a "thing". |
@Motrail do you already have PiRoFlow working from @inonoob's branch? If so, you should be able to install from my fork and get the pass through software. There is no additional configuration needed, other than you need two Bluetooth devices. I use a Pi ZeroW, with one external Bluetooth dongle. Just to be clear, my code has only been tested for SmartRow -> PiRowFLow -> Android SmartRow App and simultaneously to a Garmin FR945. FYI SmartRow has just updated their app to do passthrough from their app to a few other apps. So this would not require any other hardware if you want to use the SmartRow with the few other apps they support (Kinomap and Zwift and some other app). They are re-broadcasting the SmartRow data as Bluetooth FTMS. This is absolutely a step in the right direction and has the potential to make this project obsolete, at least if you have a SmartRow. However, I have not been able to get the new SmartRow app to work with my Garmin watch and a 3rd party ConnectIQ app that supports FTMS. I have also not tested the new app with my PiRoFlow setup. Hopefully they didn't make changes that breaks that part. If you try this, please let me know how it goes. I'd be happy to try and help. |
Hi, Thanks a lot. |
@Yann-F I'm afraid I don't think the Venu supports the ANT+ profile for this feature. This also does not work on my wife's Vivoactive. You'll need a watch that supports the FE-C (Fitness Equipment) profile. This is only available on Garmin's higher end watches. You can check https://www.thisisant.com/directory/ and search for your device. |
Ok that why It doesn't work with my watch. |
Hi @dan06 2022-09-28 14:01:02,154 - adapters.smartrow.smartrowtobleant - INFO - SmartRow Ready and sending data to BLE and ANT Thread starting heart beat 2022-09-28 14:01:06,214 - adapters.fakesmartrow.fakesmartrowble - INFO - Real SmartRow connected Perhaps you or someone else may help me. |
@stampede79 can you attach the full log? Does the SmartRow power meter stay connected to the Pi? I.e. blue lights go off and stay off? What device do you use to run the SmartRow app? I have only tested on Android. Are you getting the info via ANT+ to a Garmin or such? |
Hi dan06, thx for your quick answer. Sometimes the rower appears in the SR App (Smartrow-44). The app says "Establishing connection...) but never returns. content of /src/piroflow.log: content of supervisor WebUI log: In case you need further information, please contact me. Thx so much in advance! Regards Jan |
@stampede79 I use a Samsung S8+ with the latest version of the SR app that works for me. I have a V3 SmartRow, whereas you seem to have a V2. I'll take a look at the code and see if something jumps out. Are you familiar enough with the system to run piroflow from the command line in a terminal emulator like Putty? The program prints out quite a bit more info on the command line. I suspect the issue is that the code does not properly emulate a V3 device when a V2 device is connected to it. If you see the SmartRow-44 device at least that means the BT advertising is working. What you are describing is what I experienced when I developed the code. I would see the device but it would never finish connecting. The SR app is quite picky and doesn't connect if the data isn't correct. |
@dan06
Perhaps its an SmartRow version issue as you mentionned. Noob-question: Is Smartrow updateable ? |
@stampede79 I don't think the SR App is completing the connection to the Pi. I had some issues on my system. Check the StartNotify() function in fakesmartrowble.py. It contains a couple of debug print statements in all caps about starting to notify. If you don't see those, then something is not right. You can add a print statement just before "GLib.timeout_add(50, self.Waterrower_cb)" call in StartNotify() and see if you get that printed. I had a suspicion that that function didn't return. But it's been a while. It may also be possible that I have updated my Pi's software. I know I spent a bit of time working through the Bluetooth connection issues. You should get the following line in the log (bold one is missing in your case): Everything else seems fine in the log, at least compared to mine. It finds the expected BT devices. FYI, the basic premise is that the code advertises the BLE service, which is what makes the app see the device. It then connects, which should cause the callback to start the notify task. That is where the data starts to stream to the app. So in you case it looks like the notification thread is not starting. I am not aware if the SR device can be updated - if it could I would imagine the SR App would to it. But I don't think this is the issue you're having. |
@dan06 |
@dan06 I added extra logging comments. After this “main - ERROR - SmartRow passthrough exited!” it doesn’t run another line of code in that script. It is in the next few lines of code to n that script which starts the ANT+. I can see in the install it finds the dongle. Before inserting the BT dongle I will try with innonoob’s code. To check the ant+ dongle. |
So i tried inonoob's code. the code run and picks up the smart rower. but still can't find it on my watch. check for Ant+ dongle in order to set udev rules
|
I have ordered another ANT+ dongle. |
So with new Ant dongle. I get information to my watch. But it doesn't find the BT for the passthrough. Is says it is disabled. I will reinstall the pi. Keep the user as pi. As I need to change the install script due to using a different user. How can I tell that the pi is connected to smartrow? on my iPhone I keep getting BT pair request for "PiRolFlow #1" should I accept? I know apple changed something in their BT stack in iOS16. maybe i is that |
Now that isn't working. What OS should I install? I want to do a clean install and wonder if "Debian Bulleye with the Raspberry PI desktop" is the right starting point. Also before I do the installation is there a way to check if the dongles are there? |
@luxmoggy sorry, I was out of town this weekend. I have not tested this with IOS. The install.sh script has a section about updating Bluetooth settings for Apple. You can take a look there and see if that needs to be modified to change settings for the correct dongle. I.e. the dongle that is used for passthrough. Since I don't have any IOS devices I can't test that part. Do you have access to an Android device that you can verify with? FYI I don't get any pairing requests on Android. |
I posted a fix to the SmartRow passthrough code. Doing interval workouts on the SR app didn't proceed properly from one step to the next. I believe this has been fixed now. |
Where can I found your fix about the SmartRow passthrough code ? |
@Yann-F, the fix should be available on my fork (dan06). Please get it again from GitHub. I think you need to run install.sh again after getting the code. Please check the update instructions. I may have forgotten to push the fix to GitHub. I pushed this morning to make sure it is on GitHub. My last commit should fix both issues you mention. If you start a second workout in the SmartRow app, it will again wait until you start rowing again. Please let me know if there are still issues. |
@dan06 Thanks a lot for this two fixes 👍 |
Hi @dan06 , thanks for your fork as it's cool to keep using SR app with garmin watch sync!
I then tried to force it as connected changing in adapters/fakesmartrow/fakesmartrowble.py row 160: and now the connections is up and stable, I get data on both garmin and SR app.
|
@gabrykkk is your phone Android or IOS? Below is what I get in the piroflow log when everything works. Can you post a similar complete log from startup? 2023-02-02 15:26:20,799 - main - INFO - S4 not selected |
@dan06 sure: Here is the log after completely clean installation, attached with "debug" also here:
|
@gabrykkk do you have an Android device to test with? The log you provided looks ok. I don't have any IOS devices. FYI, the invalid literal is not an issue. It happens during startup when the code gets partial data from the SmartRow. |
@dan06 thanks for your work on this! I'm using your fork. Everything works, but I'm curious if you figured a way to run this with the Bluetooth dongle plugged in at boot. It's the only issue I have. It's minor, but I'd like to get this fixed. Thanks! |
@joedinkle my system works fine with the current code (of course :) ). I have a Pi Zero W2 with a Bluetooth dongle plugged in all the time. I normally power up my system before use, then start the PiRowFlow program using the OLED screen. I then shut down the Pi when I'm done. This works 99% of the time. Very occasionally, the screen won't start and I have to repower the Pi. Can you post the log for when it works and when it doesn't work? I may be able to suggest how you can fix it for your system. What hardware do you use? Does the OS see the BT dongle if you plug it in before boot? |
Hi dan06 again :-) unfortunately I ran into the same issue after reinstalling Pirowflo. As you said I added a println for debugging the code and it seems that the StartNotify() Function is never properly started. Can you still remember how to fix this ? Thx in advance |
@stampede79 , This is what you posted above as having fixed the issue: Have you tried that again? |
Hi dan06, |
@stampede79 that function is a callback from the Bluetooth stack. If you post the log, I'll take a look if anything jumps out. Did you install the same OS version as before? Were there any errors or warnings during piroflow installation? |
Hi dan06. I have now reinstalled it on raspbian os (buster) to figure out what may be the issue: Now i get the following installation error: which os version of raspbian is recommended ? Thx in advance. |
@stampede79 this is the content of /etc/os-release on my Zero W 2: PRETTY_NAME="Raspbian GNU/Linux 10 (buster)" The logs above doesn't really look errors, though. Did pirowflow not run afterwards? And you're sure you don't have BLE enabled as an output? You have to run piroflow with only ANT+ as an output to enable the passthrough code.
Without a log from piroflow I can't really say much else. |
@dan06 can you tell me which version of python module pyftdi / pyusb you have installed ? |
|
@dan06 pip freeze does not give me any installed pyftdi/pyusb versions back. only pip3 shows up the modules. can that be my problem ? |
I was going to try this again. As I have a new phone. So starting from scratch. Bookworm 64/32 or Bullseye to be installed on the Pi? |
@dan06 awesome work! My setup so far: |
@JensWick |
Problem description:
Use the SmartRow app at the same time as an third party app.
Possible solution:
In order to still use the SmartRow app at the same time as a third party app, a second GATT server should be started with the third available Bluetooth module. The setup should look like the following:
the second Bluetooth GATT server would have the same Service and characteristics as the SmartRow device. The SmartRow app would send the heart beat and also reset commands to the GATT Bluetooth server which would forward those signal to the real SmartRow. At the same time the GATT Bluetooth server would send the SmartRow data to the SmartRow app.
Possible alternatives solution:
Have two PI Zero send the data from one pi to the other and vis vera via netcat, if two GATT server at the same time is not possible.
The text was updated successfully, but these errors were encountered: