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

CalculatedSpeed not working #4

Closed
YoNo2000 opened this issue Dec 13, 2022 · 9 comments
Closed

CalculatedSpeed not working #4

YoNo2000 opened this issue Dec 13, 2022 · 9 comments

Comments

@YoNo2000
Copy link

Hi,

I am able to get the application running. Cadence and Power are working fine. But the CalculatedSpeed does not display a value for me. I have added my Ant+ IDs which are 6 six digits to the CadenceSensor.ts and SpeedSensor.ts

I also did not enter an Ant+ ID for my power meter, but it is picking up the power and displaying it. Not sure if there's anything conflicting with that.

Thanks

@8beeeaaat
Copy link
Owner

@YoNo2000
Thank you for issue!

Are these two console.logs being output?
https://github.com/8beeeaaat/web-ant-plus/blob/master/example/src/App.tsx#L56-L58
https://github.com/8beeeaaat/web-ant-plus/blob/master/example/src/App.tsx#L97-L101

If the 'speedCadenceSensor attached' log is not output, then the speed sensor you are using may not be SpeedCadenceSensor.
In that case, try using SpeedSensor instead of SpeedCadenceSensor. 👍

https://github.com/8beeeaaat/web-ant-plus/blob/master/src/sensors/SpeedSensor.ts

@8beeeaaat
Copy link
Owner

8beeeaaat commented Dec 13, 2022

Sorry if you are already using SpeedSensor and SpeedCadenceSensor...

I have added my Ant+ IDs which are 6 six digits to the CadenceSensor.ts and SpeedSensor.ts

By the way, just to confirm for your information, I did not envision an implementation where you would use ANT+ IDs.
What ANT+ ID was needed to do what?

@YoNo2000
Copy link
Author

@8beeeaaat Thanks for the reply back. I had placed both the corresponding ANT+ IDs in both CadenceSensor.ts and SpeedSensor.ts

For example:

type: 'receive',
deviceID: 123456,
deviceType: SpeedSensor.deviceType,
transmissionType: 0,
timeout: 255,
period: 8086,

This is what I have done. I didn't know that you didn't need to actually put the Ant+ IDs in.

As for your question, yes the log says they are connected

heartRateSensor attached
speedCadenceSensor attached
bicyclePowerSensor attached

@8beeeaaat
Copy link
Owner

I didn't know that you didn't need to actually put the Ant+ IDs in.

In fact, the original package does not need to use the actual device-specific ID for DeviceID to work. 😄

speedCadenceSensor attached

👍

  • Verification 0: Verify that the original Node.JS version works correctly
    If it does not work correctly in the original, there is a possibility that this package does not work either.
    https://github.com/Loghorn/ant-plus

  • Verification 1: Is the console.log of the onSpeedData event being output?

  • Verification 2: If Verification 1 is being output, check if only SpeedCadenceSensorState.CalculatedSpeed is undefined.
    If not, then check if the updateSpeedCadenceSensorState is working and identify the cause.

export function updateSpeedCadenceSensorState(
sensor: SpeedCadenceSensor | SpeedCadenceScanner,
state: SpeedCadenceSensorState | SpeedCadenceScanState,
data: DataView
) {
const { updatedState, resultType } = state.updateState(
data,
sensor.wheelCircumference
);
switch (resultType) {
case 'both':
sensor.emit('cadenceData', updatedState);
sensor.emit('speedData', updatedState);
break;
case 'cadence':
sensor.emit('cadenceData', updatedState);
break;
case 'speed':
sensor.emit('speedData', updatedState);
break;
default:
break;
}
}

I would appreciate a reply once you have identified the cause.

@YoNo2000
Copy link
Author

@8beeeaaat Thanks for your patience. I have been looking into the problem over the past few days and trying to get familiar with React and Node as I am new. I believe I may know what the problem is:

Anything that uses the Speed & Cadence sensors is using the wrong Channel period. Ant+ state in the document: D00001163_-_ANT+Device_Profile-_Bicycle_Speed_and_Cadence

That the channel period must be 8118. However, in one of the cadence sensor typescript files I opened, it is 8086.

After then searching on the original package from Loghorn, it appears that another user pointed this out a few years ago but this wasn't actually changed: Loghorn#31

I did attempt to change it to 8118, but I couldn't get it working on my end as I'm not sure which files to edit and whether I need to reinstall this package again.

If there's anything I can do, let me know. Thanks.

@8beeeaaat
Copy link
Owner

8beeeaaat commented Dec 20, 2022

@YoNo2000

Thank you for your research!
I did check the ANT+ documentation and it seems that the Channel Period for SpeedSensor (not SpeedCadenceSensor) should be 8118.

Please try changing this 8086 to 8118 and then use SpeedSensor instead of SpeedCadenceSensor in the sample application.

If it works correctly, I'd appreciate it if you could send me a Pull Request!
(If you are not familiar with GitHub / Pull Request handling, I will fix it myself.)

@YoNo2000
Copy link
Author

YoNo2000 commented Dec 23, 2022

@8beeeaaat That works. However, I changed SpeedCadenceSensor period & deviceType (to match SpeedSensor)to make it work as a test as I believe I would stumble across another issue. Yes, the speed was now displaying and working but the cadence wasn't and even if I changed it to SpeedSensor the same would've happened I believe.

The app uses:

BicyclePowerSensor
HeartRateSensor
SpeedCadenceSensor

But it would need to use one more sensor, such as cadence?

I am not too sure about the implementation of this as I believe the formulas are different and the example app would need to be rewritten to allow the additional data field of cadence if I am correct?

Thanks

*Sorry I accidentally closed the issue.

@YoNo2000 YoNo2000 reopened this Dec 23, 2022
@YoNo2000
Copy link
Author

YoNo2000 commented Dec 23, 2022

@8beeeaaat Additional feedback to my comment above:

I believe if I am correct that this package is getting Cadence from the Power Meter. However, if a user does not have a Power Meter then the application would not display all the data fields and a user would need to choose between Cadence or Speed by changing the Channel Period & deviceType (for either speed or cadence to match Ant+ documentation). This is even if you use SpeedSensor instead of SpeedCadenceSensor. I will try and confirm this later today and get back to you.

Thanks

Cadence
{newestPowerState?.Cadence}

Power
{newestPowerState?.Power?.toFixed(1)}

@8beeeaaat
Copy link
Owner

8beeeaaat commented Dec 24, 2022

Thank you for your feedbacks!

The app uses:

BicyclePowerSensor
HeartRateSensor
SpeedCadenceSensor

But it would need to use one more sensor, such as cadence?

I use a Pioneer pedaling monitor device.
http://pioneer-cyclesports.com/us-en/

This device functions as a BicyclePowerSensor and transmits power and cadence via ANT+.
No other devices are used other than this, so the sample is an example using BicyclePowerSensor. (It would be unsound to write a sample with a device that I cannot validate myself.)

This sample is not intended to be used as-is by developers, but is intended to be selected by developers themselves to suit their own development environment.
Therefore, I don't intend to change this sample program at this time.

Tanks!

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

2 participants