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

Connecting to a specific device #35

Open
luke-harris opened this issue Mar 27, 2018 · 2 comments
Open

Connecting to a specific device #35

luke-harris opened this issue Mar 27, 2018 · 2 comments

Comments

@luke-harris
Copy link

Hi. I'm trying to make your heart rate example always connect to a specific device. I know that I'm supposed to be able to do this by setting the device number. I've added some code to the hr.py example to get the device number of my device.

Added code:
m = node.request_message(Message.ID.RESPONSE_CHANNEL_ID)
print("channel id:" + repr(m))

Output:
channel id:(0, 81, array('B', [28, 152, 120, 17]))

The ant documentation says that this channel response should return:
[ channel number, device number, device type id, transmission type]

However, when I change channel.set_id(0, 120, 0) to channel.set_id(152, 120, 0), I am unable to connect to my device. What am I missing here?

@clyra
Copy link

clyra commented Jun 1, 2019

Hi,

I Have a similar issue, but I went the other way around :-). I do have my device number (got from my garmin gps sensor page). I was calling set_id the wrong way (0, 120, <device_number>) so I thank you for show me the right way :-). Now, it's my turn... As I understand the device number is a 2 byte number (1-65535). From your array I would guess that your device number is made from the two first bytes of the array (28, 152), which should translate to 7320 or 38940 (ant+ uses little endian so the byte order is reversed).

@2l47
Copy link

2l47 commented Nov 19, 2023

If anyone else runs into this, you can now get the device number via device.device_id once on_found has been called, e.g. define device above and then print it in on_found. It's also just the digits at the end of the string representation of the device, as seen in the heart rate example. openant.devices.heart_rate.HeartRate(device_id=XXX) can then be manually set in the future to only connect to that device, no need to mess with the node/channel stuff. Setting to 0 uses any device.

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

No branches or pull requests

3 participants