pirowflo icon indicating copy to clipboard operation
pirowflo copied to clipboard

Second BLE Server as Bluetooth Passthrough for SmartRow App

Open inonoob opened this issue 4 years ago • 70 comments

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:

  • 1st Bluetooth dongle ==> connected to SmartRow device
  • Internal Raspberry pi Bluetooth ==> connection to iOS/Android device (Fitness equipment Bluetooth profile)
  • 2nd Bluetooth dongle ==> connected to iOS/Android device (SmartRow Bluetooth profile)

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.

inonoob avatar Feb 22 '21 07:02 inonoob

The Gatt server for the SmartRow passthrough is running but the SmartRow apps doesn't want to connect. The SmartRow app sees the raspberry pi SmartRow. If clicked on connect. The app says establishing connection but doesn't pass it. I can't see that the app tries to send any command and I can't see that the app request notification from the smartrow. So there still must be a handshake beside the heart beat and reset.

inonoob avatar Feb 22 '21 17:02 inonoob

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.

inonoob avatar Mar 02 '21 21:03 inonoob

In order to work in the ble2.py the following must be added to the advertiser:

        self.discoverable = None
        if self.discoverable is not None:
            properties["Discoverable"] = dbus.Boolean(self.discoverable)

And in the smartrowble gatt server config the following must be add to the advertiser part:

self.discoverable = True

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.

inonoob avatar Mar 03 '21 23:03 inonoob

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. I still have no idea how to avoid this error or clean dbus from left behind garbage entries.

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.

Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "waterrowerthreads.py", line 71, in BleService2
    bleService2 = smartrowerble.main(out_q, ble_in_q)
  File "/home/pi/pirowflo/src/smartrowerble.py", line 263, in main
    agent_manager.RegisterAgent(AGENT_PATH, "NoInputNoOutput") # register the bluetooth agent with no input and output which should avoid asking for pairing
  File "/usr/local/lib/python3.7/dist-packages/dbus/proxies.py", line 72, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/local/lib/python3.7/dist-packages/dbus/proxies.py", line 147, in __call__
    **keywords)
  File "/usr/local/lib/python3.7/dist-packages/dbus/connection.py", line 653, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.bluez.Error.AlreadyExists: Already Exists

inonoob avatar Mar 04 '21 17:03 inonoob

Oki I got it this time ! It was because the Raspberry pi Bluetooth was set to Bluetooth Classic and LE_only. If both are activated at the same time then SmartRow App and additionally the WaterRower Connect app won't work under Android !! They must be set to LE_only.

In order to fix that issue the following is possible:

  • either set in the option under /etc/bluetooth/main.conf:
# Restricts all controllers to the specified transport. Default value
# is "dual", i.e. both BR/EDR and LE enabled (when supported by the HW).
# Possible values: "dual", "bredr", "le"
#ControllerMode = le

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.

  • Or to re-compile bluez and change the default value in the main.c of bluez:

static int get_mode(const char *str)
{
	if (strcmp(str, "dual") == 0)
		return BT_MODE_DUAL;
	else if (strcmp(str, "bredr") == 0)
		return BT_MODE_BREDR;
	else if (strcmp(str, "le") == 0)
		return BT_MODE_LE;

	error("Unknown controller mode \"%s\"", str);

	return BT_MODE_DUAL;
}

https://github.com/bluez/bluez/blob/a37d53db9ae7d21a8f812925303d767d3f03e597/src/main.c#L306-L318

~~The issue with compiling bluez is that in newer version they added things like Device Information ==> PnP ID~~

Issue has been fix in bluez. But the latest git master must be fetch and build. Bluez 5.56 still has that issue

inonoob avatar Mar 05 '21 22:03 inonoob

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:

Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "waterrowerthreads.py", line 55, in BleService2
    bleService2 = smartrowerble.main(out_q, ble_in_q_sr)
  File "/home/pi/pirowflo/src/smartrowerble.py", line 268, in main
    agent_manager.RegisterAgent(AGENT_PATH, "NoInputNoOutput") # register the bluetooth agent with no input and output which should avoid asking for pairing
  File "/usr/local/lib/python3.7/dist-packages/dbus/proxies.py", line 72, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/local/lib/python3.7/dist-packages/dbus/proxies.py", line 147, in __call__
    **keywords)
  File "/usr/local/lib/python3.7/dist-packages/dbus/connection.py", line 653, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.bluez.Error.AlreadyExists: Already Exists

I don't know how to fix this issue with the double Gatt server running at the same time !

inonoob avatar Mar 07 '21 20:03 inonoob

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. I got a feedback from the bluez issue forum but I can't implemented, as I don't fully understand what is meant. link

If someone has more skills, please help :)

inonoob avatar Mar 11 '21 19:03 inonoob

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, Florent

FlorentLa avatar Apr 04 '21 13:04 FlorentLa

Hi all,

I have the same use case then FlorentLa

The use case is connecting both a Garmin watch through ant and the smart row app through Bluetooth

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+

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 !

@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.

dbffm avatar May 11 '21 09:05 dbffm

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?

hnfhtw avatar Dec 09 '21 10:12 hnfhtw

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 avatar Jan 07 '22 18:01 inonoob

@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.

dan06 avatar Feb 11 '22 20:02 dan06

@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

dan06 avatar Mar 19 '22 12:03 dan06

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.

image

cc: @hnfhtw, @dbffm, @FlorentLa

dan06 avatar Mar 25 '22 20:03 dan06

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.

  1. Configure the system for input from SmartRow and output to ANT+ (-i sr -a).
  2. DO NOT start the phone app yet.
  3. Pull the handle and make sure the SmartRow is connected (blue lights will go off).
  4. Now start the phone app. If it doesn't connect automatically, then touch the Bluetooth icon and select the SmartRow-44 device.
  5. It should connect.
  6. You should be able to do any workout on the app, and also record on your Garmin / ANT+ device.

Please let me know if you've tried it and if it worked or not. If not, please attach piroflow.log.

dan06 avatar Apr 22 '22 00:04 dan06

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".

dan06 avatar Apr 24 '22 21:04 dan06

@dan06 Hi Dan - Sorry to bother you, but I'm really interested in using this, is there any way I can do this? And do you know, if @inonoob is still developing this project? Been quiet for some time...

Motrail avatar Aug 28 '22 08:08 Motrail

@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.

dan06 avatar Aug 30 '22 14:08 dan06

Hi, @dan06. First of all, than for your works and thanks for sharing it :) I've installed your version of PiRowFLow from your repository on a raspberry Pi 3B+. Then I launch waterrowerthreads.py -i sr -a The BT connection SmartRow -> PiRowFLow works (blue light go off) The BT connection iRowFLow -> Android SmartRow App works too, I see datas into SmartRow app. The next step for me should connecting PiRowFLow ANT+ to my garmin Venu and the native rower gamin's app But I have no idea to peer PiRowFLow and the garmin watch. On the garmin watch I've done a search for new sensor but nothing was found. Could you give me a clue to do it ?

Thanks a lot.

Yann-F avatar Aug 30 '22 22:08 Yann-F

@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.

dan06 avatar Aug 31 '22 13:08 dan06

Ok that why It doesn't work with my watch. Thanks for the info @dan06.

Yann-F avatar Aug 31 '22 21:08 Yann-F

Hi @dan06 first of all thx for your effort. Your version is now running on my raspi. But the SR-App won't connect to PiRowFlo, even it appears sometimes for a second in the available devices "SmartRow-44". I got the following heartbeat "error" in the log: ` INFO - [e8:f6:a2:1e:c4:69] Service [00001801-0000-1000-8000-00805f9b34fb]

2022-09-28 14:01:02,154 - adapters.smartrow.smartrowtobleant - INFO - SmartRow Ready and sending data to BLE and ANT Thread

starting heart beat invalid literal for int() with base 10: '000\rS' a000 SmartRow0'V201+

2022-09-28 14:01:06,214 - adapters.fakesmartrow.fakesmartrowble - INFO - Real SmartRow connected 2022-09-28 14:01:06,409 - adapters.fakesmartrow.fakesmartrowble - INFO - Fake SmartRow using /org/bluez/hci0 2022-09-28 14:01:06,478 - adapters.fakesmartrow.fakesmartrowble - INFO - Registering GATT application... 2022-09-28 14:01:06,532 - adapters.fakesmartrow.ble - INFO - GetManagedObjects 2022-09-28 14:01:06,549 - adapters.fakesmartrow.ble - INFO - GetAll 2022-09-28 14:01:06,565 - adapters.fakesmartrow.ble - INFO - returning props 2022-09-28 14:01:06,586 - adapters.fakesmartrow.fakesmartrowble - INFO - GATT application registered 2022-09-28 14:01:06,602 - adapters.fakesmartrow.fakesmartrowble - INFO - Advertisement registered`

Perhaps you or someone else may help me. Thx in advance.

stampede79 avatar Sep 28 '22 13:09 stampede79

@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?

dan06 avatar Sep 28 '22 18:09 dan06

Hi dan06,

thx for your quick answer. I use an android phone (Samsung) for the SR-Ap. Tried an Fire HD Tablet as well without success. I get the data on my garmin device (Fenix 7) without any problems.

Sometimes the rower appears in the SR App (Smartrow-44). The app says "Establishing connection...) but never returns. The blue light at the rower turns and stays off.

content of /src/piroflow.log: 2022-09-29 11:25:03,336 - __main__ - INFO - S4 not selected 2022-09-29 11:25:03,346 - __main__ - INFO - interface smartrow will be used for data input 2022-09-29 11:25:03,355 - __main__ - INFO - Smartrow Interface started 2022-09-29 11:25:03,356 - __main__ - INFO - SmartRow passthrough is enabled 2022-09-29 11:25:03,382 - __main__ - INFO - Start SmartRow Passthrough BLE Advertise and BLE GATT Server 2022-09-29 11:25:03,389 - __main__ - INFO - Bluetooth service not used 2022-09-29 11:25:03,405 - adapters.fakesmartrow.fakesmartrowble - INFO - Waiting for real SmartRow to connect 2022-09-29 11:25:03,421 - __main__ - INFO - Start Ant and start broadcast data 2022-09-29 11:25:03,520 - adapters.smartrow.smartrowreader - INFO - Preferred SmartRow adapter is hci1 2022-09-29 11:25:03,695 - adapters.smartrow.smartrowreader - INFO - starting discovery 2022-09-29 11:25:09,370 - root - INFO - found SmartRow 2022-09-29 11:25:09,380 - root - INFO - e8:f6:a2:1e:c4:69 2022-09-29 11:25:09,398 - adapters.smartrow.smartrowreader - INFO - found SmartRow macaddress 2022-09-29 11:25:09,489 - adapters.smartrow.smartrowreader - INFO - Preferred SmartRow adapter is hci1 2022-09-29 11:25:15,510 - adapters.smartrow.smartrowreader - INFO - Connected to [e8:f6:a2:1e:c4:69] 2022-09-29 11:25:16,218 - adapters.smartrow.smartrowreader - INFO - Resolved services [e8:f6:a2:1e:c4:69] 2022-09-29 11:25:16,224 - adapters.smartrow.smartrowreader - INFO - [e8:f6:a2:1e:c4:69] Service [00001234-0000-1000-8000-00805f9b34fb] 2022-09-29 11:25:16,230 - adapters.smartrow.smartrowreader - INFO - Characteristic [00001236-0000-1000-8000-00805f9b34fb] 2022-09-29 11:25:16,236 - adapters.smartrow.smartrowreader - INFO - Characteristic [00001235-0000-1000-8000-00805f9b34fb] 2022-09-29 11:25:16,241 - adapters.smartrow.smartrowreader - INFO - [e8:f6:a2:1e:c4:69] Service [00001801-0000-1000-8000-00805f9b34fb] 2022-09-29 11:25:16,301 - adapters.smartrow.smartrowtobleant - INFO - SmartRow Ready and sending data to BLE and ANT Thread 2022-09-29 11:25:20,362 - adapters.fakesmartrow.fakesmartrowble - INFO - Real SmartRow connected 2022-09-29 11:25:20,530 - adapters.fakesmartrow.fakesmartrowble - INFO - Fake SmartRow using /org/bluez/hci0 2022-09-29 11:25:20,651 - adapters.fakesmartrow.fakesmartrowble - INFO - Registering GATT application... 2022-09-29 11:25:20,709 - adapters.fakesmartrow.ble - INFO - GetManagedObjects 2022-09-29 11:25:20,726 - adapters.fakesmartrow.ble - INFO - GetAll 2022-09-29 11:25:20,741 - adapters.fakesmartrow.ble - INFO - returning props 2022-09-29 11:25:20,754 - adapters.fakesmartrow.fakesmartrowble - INFO - GATT application registered 2022-09-29 11:25:20,764 - adapters.fakesmartrow.fakesmartrowble - INFO - Advertisement registered

content of supervisor WebUI log: INFO - [e8:f6:a2:1e:c4:69] Service [00001801-0000-1000-8000-00805f9b34fb] 2022-09-29 11:25:16,301 - adapters.smartrow.smartrowtobleant - INFO - SmartRow Ready and sending data to BLE and ANT Thread starting heart beat invalid literal for int() with base 10: '000@\r' a000@ SmartRow0'V201 2022-09-29 11:25:20,362 - adapters.fakesmartrow.fakesmartrowble - INFO - Real SmartRow connected 2022-09-29 11:25:20,530 - adapters.fakesmartrow.fakesmartrowble - INFO - Fake SmartRow using /org/bluez/hci0 2022-09-29 11:25:20,651 - adapters.fakesmartrow.fakesmartrowble - INFO - Registering GATT application... 2022-09-29 11:25:20,709 - adapters.fakesmartrow.ble - INFO - GetManagedObjects 2022-09-29 11:25:20,726 - adapters.fakesmartrow.ble - INFO - GetAll 2022-09-29 11:25:20,741 - adapters.fakesmartrow.ble - INFO - returning props 2022-09-29 11:25:20,754 - adapters.fakesmartrow.fakesmartrowble - INFO - GATT application registered 2022-09-29 11:25:20,764 - adapters.fakesmartrow.fakesmartrowble - INFO - Advertisement registered

In case you need further information, please contact me. Thx so much in advance!

Regards Jan

stampede79 avatar Sep 29 '22 11:09 stampede79

@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 avatar Sep 29 '22 12:09 dan06

@dan06 here is the log running pirowflo from the terminal until I try to connect with SR-App. No other garmin devices are connected.

2022-09-29 14:16:21,366 - __main__ - INFO - S4 not selected 2022-09-29 14:16:21,377 - __main__ - INFO - interface smartrow will be used for data input 2022-09-29 14:16:21,386 - __main__ - INFO - Smartrow Interface started 2022-09-29 14:16:21,387 - __main__ - INFO - SmartRow passthrough is enabled 2022-09-29 14:16:21,412 - __main__ - INFO - Start SmartRow Passthrough BLE Advertise and BLE GATT Server 2022-09-29 14:16:21,419 - __main__ - INFO - Bluetooth service not used 2022-09-29 14:16:21,433 - adapters.fakesmartrow.fakesmartrowble - INFO - Waiting for real SmartRow to connect 2022-09-29 14:16:21,448 - __main__ - INFO - Start Ant and start broadcast data start search for dongle 2022-09-29 14:16:21,556 - adapters.smartrow.smartrowreader - INFO - Preferred SmartRow adapter is hci1 2022-09-29 14:16:21,761 - adapters.smartrow.smartrowreader - INFO - starting discovery Using Dynastream Innovations dongle calibration set Networkkey:b'\x00\xb9\xa5!\xfb\xbdr\xc3E' create Channel 2022-09-29 14:16:58,786 - root - INFO - found SmartRow 2022-09-29 14:16:58,790 - root - INFO - e8:f6:a2:1e:c4:69 2022-09-29 14:16:58,802 - adapters.smartrow.smartrowreader - INFO - found SmartRow macaddress 2022-09-29 14:16:58,872 - adapters.smartrow.smartrowreader - INFO - Preferred SmartRow adapter is hci1 2022-09-29 14:17:07,024 - adapters.smartrow.smartrowreader - INFO - Connected to [e8:f6:a2:1e:c4:69] 2022-09-29 14:17:07,781 - adapters.smartrow.smartrowreader - INFO - Resolved services [e8:f6:a2:1e:c4:69] 2022-09-29 14:17:07,786 - adapters.smartrow.smartrowreader - INFO - [e8:f6:a2:1e:c4:69] Service [00001234-0000-1000-8000-00805f9b34fb] 2022-09-29 14:17:07,792 - adapters.smartrow.smartrowreader - INFO - Characteristic [00001236-0000-1000-8000-00805f9b34fb] 2022-09-29 14:17:07,797 - adapters.smartrow.smartrowreader - INFO - Characteristic [00001235-0000-1000-8000-00805f9b34fb] 2022-09-29 14:17:07,801 - adapters.smartrow.smartrowreader - INFO - [e8:f6:a2:1e:c4:69] Service [00001801-0000-1000-8000-00805f9b34fb] 2022-09-29 14:17:07,977 - adapters.smartrow.smartrowtobleant - INFO - SmartRow Ready and sending data to BLE and ANT Thread starting heart beat invalid literal for int() with base 10: '00\rSm' SmartRow0'V201+' 2022-09-29 14:17:12,035 - adapters.fakesmartrow.fakesmartrowble - INFO - Real SmartRow connected 2022-09-29 14:17:12,312 - adapters.fakesmartrow.fakesmartrowble - INFO - Fake SmartRow using /org/bluez/hci0 2022-09-29 14:17:12,376 - adapters.fakesmartrow.fakesmartrowble - INFO - Registering GATT application... 2022-09-29 14:17:12,429 - adapters.fakesmartrow.ble - INFO - GetManagedObjects 2022-09-29 14:17:12,445 - adapters.fakesmartrow.ble - INFO - GetAll 2022-09-29 14:17:12,456 - adapters.fakesmartrow.ble - INFO - returning props 2022-09-29 14:17:12,474 - adapters.fakesmartrow.fakesmartrowble - INFO - GATT application registered 2022-09-29 14:17:12,488 - adapters.fakesmartrow.fakesmartrowble - INFO - Advertisement registered

Perhaps its an SmartRow version issue as you mentionned. Noob-question: Is Smartrow updateable ?

stampede79 avatar Sep 29 '22 13:09 stampede79

@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): 2022-08-30 11:59:47,021 - adapters.fakesmartrow.fakesmartrowble - INFO - GATT application registered 2022-08-30 11:59:47,031 - adapters.fakesmartrow.fakesmartrowble - INFO - Advertisement registered 2022-08-30 12:00:02,952 - adapters.fakesmartrow.fakesmartrowble - INFO - Starting notification

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 avatar Sep 29 '22 14:09 dan06

@dan06 I think i finally get it. I did a complete reinstallation of rasberry os and pirowflo. After restarting the service i saw, that the wrong adapters were used for the connections (SR -> Piroflow internal Bluetooth and Pirowflo -> SR-APP dongle). So I changed the def get_sr_preferred_adapter() method in src/adapters/fakesmartrow/ble.py and src/adapters/smartrow/smartrowreader.py (USB -> UART and the other way round). First test seems to run...

stampede79 avatar Sep 30 '22 12:09 stampede79

@stampede79 is it working for you now?

dan06 avatar Oct 05 '22 13:10 dan06

So I have just installed dan06's version. All seems to be good. I don't have a Bluetooth dongle at the moment (the one I thought I has was a WiFi one), but I do have an ANT dongle. So I thought I would start it up with "-i sr -a" just to see if my watch can see it. It doesn't. Do I need the second bluetooth dongle to even use it? it should arrive on Friday

luxmoggy avatar Oct 05 '22 16:10 luxmoggy