Loghorn / ant-plus

A node module for ANT+
MIT License
138 stars 67 forks source link

is_present( ) causes the stick to close #16

Closed sam2b closed 6 years ago

sam2b commented 6 years ago

When I call is_present( ), the stick seems to close... or otherwise put the object in a bad state such that write( ) fails and throws and exception.

if (!this.stick.is_present()) { .. } I've verified open() returns true before calling is_present(), and then after calling is_present() I verified open() returns false.

See ./src/ant.ts file.

Loghorn commented 6 years ago

Can you please provide the code to reproduce the issue? Thank you

sam2b commented 6 years ago

Sure: see file here https://github.com/olympum/ant-cycling-power/blob/master/power-meter.js PowerMeter.prototype.broadcast = function(power, cadence) { if (!this.stick.is_present()) { return; } ... }

Loghorn commented 6 years ago

I'm sorry but this project is a ANT+ client, used for receiving data from ANT+ devices (bikes, HR sensors, etc.), while the project you link is for simulating an ANT+ bike. This projects was never meant to be used like that, so I'm not surprised it doesn't work. I believe that simulating a device could be useful but must be a separate project: feel free to start it and take this project as a base if you find it useful.

sam2b commented 6 years ago

Regardless of the usage, why does the stick object get into an unusable state when I call is_present( ) after stick.open( ) ? That is the issue I am raising, please.

Loghorn commented 6 years ago

is_present does not change the state of the stick. open does, and you must not call it twice (unless you call close between the two calls)