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

Use device name as well as location to determine type? #7

Open
sandeen opened this issue Jan 29, 2021 · 2 comments
Open

Use device name as well as location to determine type? #7

sandeen opened this issue Jan 29, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@sandeen
Copy link

sandeen commented Jan 29, 2021

I have Garmin speed & cadence sensors, and they have nothing in their location field AFAICT.
However, they are named, i.e. SPD-BLE0XXXXXX.

If I'm reading it right, the code will only listen to a sensor which has "Wheel" in its location. While I might be able to write that to the device, would it be possible detect which sensor is which based on the device name as well?

@kloppen
Copy link
Owner

kloppen commented Jan 31, 2021

Not all sensors implement all the characteristics defined in BLE spec. the BLE CSCP spec defines the location characteristic as optional. I don't have a Garmin sensor to test this with, but I'd believe you if you said that the Garmin sensors don't implement the "location" characteristic (which seems to be what you are saying).

It's been a while since I've looked at this code. I believe that when the thread corresponding to each sensor is started, it reads the "location" characteristic from the sensor and stores this in a variable. This is done in the line self._location = sensor.get_location() within CSCTrainer.worker(). It shouldn't be too hard to change this behavior.

Implementation would be easier if the user just defined the location of each sensors based on its address (eg. D0:AC:A5:BF:B7:52), rather than reading the name, which I suppose is another characteristic (but I'm not sure about this). This would be only slightly more complex for the user to set up, compared with using the name, since the user has to figure out the address of the sensor anyways, and as long as you're figuring this out one sensor at a time, you'll know which one is in which location of your bike.

I'd be happy to receive a PR to allow the user to either manually set the location of each sensor, or for the user to specify location based on the name of the sensor (eg. SPD-BLE0xxxxx), rather than relying on reading the "location" characteristic from the sensor. I'd just ask that if the user doesn't somehow specify the sensor locations, that program continues to read the location characteristic from the sensor.

@kloppen kloppen added the enhancement New feature or request label Jan 31, 2021
@sandeen
Copy link
Author

sandeen commented Jan 31, 2021

Thanks for the reply - I have the characteristic but it's empty. If I can extend this in a nice way I'll send a PR.

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

No branches or pull requests

2 participants