Closed sam2b closed 6 years ago
Can you please provide the code to reproduce the issue? Thank you
Sure, see file here: https://github.com/olympum/ant-cycling-power/blob/master/power-meter.js
stick.on('startup', function () {
console.log('startup');
console.log('Max channels:', stick.maxChannels);
var deviceId = 0xBEEF;
stick.write(Ant.Messages.assignChannel(channel, 'transmit'));
stick.write(Ant.Messages.setDevice(channel, deviceId, 11, 1));
stick.write(Ant.Messages.setFrequency(channel, 57));
stick.write(Ant.Messages.setPeriod(channel, 8182));
stick.write(Ant.Messages.openChannel(channel));
console.log('cycling power meter initialized');
});
...
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.
Regardless of the project, is it improper to write Ant.Messages.* to the stick? If not, what & where is your intended use of Ant.Messages, because the missing export was the source of my issues. Please advise.
Ant.Messages is meant to be used only by the library internal functions (and this is the reason it's not exported)
Bug in ant-plus.js that is missing this line in the module.exports = { } block: Messages: Ant.Messages,
After I added that line to the other exports, the error disappeared and the stick initialized fine.