Tigge / openant

ANT and ANT-FS Python Library
MIT License
174 stars 80 forks source link

Improvement of node interface #49

Closed pirower closed 1 year ago

pirower commented 4 years ago

Hi, please let me know if you want me to incorporate all added features from the child Node_easy directly to Node. As I understood "Node" in the folder "easy" is already a facilitation to use message etc. from the base folder. Nether the less, Node doesn't implement any Ant+ devices (e.g heart rate montior) and so on. I added some features to enable unexperienced users to execute some functions (scan, connect to a heart rate monitor, disconnect, etc...) without much effort. In addition I put node.start into a thread to be able to execute commands (connect, disconnect, scan) while the ant+ dongle is running. If you think it is to confusing and should be added directly into Node, please let me know

In node.py I added the function "get_capabilities" which returns the capabilities of the attached Ant+ dongle. This function is executed during the initialisation of Node. I changed the list of self.channels to a vector of fixed size ( self.channels = [None]*cap["max_channels"] ). Every time a new channel is created, the code looks up if there is still a free channel left. I also added a function to remove a channel (including unassignment and closing of the channel)

coveralls commented 4 years ago

Coverage Status

Coverage decreased (-0.7%) to 56.696% when pulling 62652502062694c4928e2089fc5ce71367223e28 on pirower:test into ae9e7366fb78b2c39467e1a028b34cfb0c64ffd7 on Tigge:master.

pirower commented 4 years ago

Hi Tigge, could you please provide me with some feedback. Thx

pirower commented 4 years ago

Hi, so you would see "plus" as another folder under ant/ (next to easy, base, fs and test)? Ant provides a document (device profile) for the different devices running under Ant+ to guarantee a standard message protocol (e.g. heart rate monitor, frequency sensor for a bike, watt sensor, etc etc..). All these devices have different data pages. Therefor you would need to set the device type (e.g. 120 for heart rate montior) in the channel and decode the data pages according to the device type. I could start with heart rate montior to set a base and keep it open to be completed by other device profiles.

pirower commented 4 years ago

Please take a look also in the commit for node_easy and tell me if you want the following functions/fucntionalities included in node:

def remove_deviceNum(self, deviceNum) #only makes sense if a deviceNum has been set in channel def start(self) (as a thread) def stop(self): (stop of the thread) def scan(self, deviceType, timeout = 5, callback=None)

Tigge commented 3 years ago

so you would see "plus" as another folder under ant/ (next to easy, base, fs and test)?

Yes

Ant provides a document (device profile) for the different devices running under Ant+ to guarantee a standard message protocol (e.g. heart rate monitor, frequency sensor for a bike, watt sensor, etc etc..). All these devices have different data pages. Therefor you would need to set the device type (e.g. 120 for heart rate montior) in the channel and decode the data pages according to the device type. I could start with heart rate montior to set a base and keep it open to be completed by other device profiles.

Yes, that is how it would be done. Sounds like a plan!

Tigge commented 3 years ago

Please take a look also in the commit for node_easy and tell me if you want the following functions/fucntionalities included in node:

def remove_deviceNum(self, deviceNum) #only makes sense if a deviceNum has been set in channel def start(self) (as a thread) def stop(self): (stop of the thread) def scan(self, deviceType, timeout = 5, callback=None)

These might be better kept as an example (as it is in this PR now) on how to implement something like that then adding that functionality in node.

Tigge commented 3 years ago

The "Add capabilities to ant and make channels an array instead of a list", "Add new features in channel" and "Add features to node" are ready to commit I think (except the changes requested here). If you want to split this PR those could be merged quickly, but feel free to continue here If you like for the other stuff as well.

tuna-f1sh commented 1 year ago

Closing/unassigned channels and ANT+ device added with #76