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

Error in function that maps channel to frequency for non-advertising channels #10

Open
andyparkins opened this issue Oct 7, 2021 · 0 comments

Comments

@andyparkins
Copy link

andyparkins commented Oct 7, 2021

uint8_t channel_resolver_get_frequency(uint8_t channel)
{
   // ...
    freq = channel + (channel < 11 ? 2 : 3) * 2; // Spec Vol. 6, Part B, 1.4.1

    return freq;
}

I think this is missing braces. The function returns different results from the referenced table in 6.B.1.4.1.

For example: channel 36 should be 2478MHz. The above equation returns 36 + 3*2 = 42 (which becomes 2042MHz not 2478MHz in the radio peripheral).

I suspect the issue is simply the slight thinko of a missing pair of parenthises:

freq = (channel + (channel < 11 ? 2 : 3)) * 2; // Spec Vol. 6, Part B, 1.4.1

Some test points:

  • channel 0 maps to (0+2)*2 = 4. Correct.
  • channel 10 maps to (10+2)*2 = 24. Correct.
  • channel 11 maps to (11+3)*2 = 28. Correct.
  • channel 36 maps to (36+3)*2 = 78. Correct.
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

1 participant