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

Possibly wrong status returned by SwitchClass #1284

Closed
janakj opened this issue Mar 14, 2022 · 2 comments
Closed

Possibly wrong status returned by SwitchClass #1284

janakj opened this issue Mar 14, 2022 · 2 comments

Comments

@janakj
Copy link
Contributor

janakj commented Mar 14, 2022

The function SwitchClass performs the following side-effect when the caller attempts to switch to class A when the device is in class A already (i.e., no change):

    LoRaMacStatus_t status = LORAMAC_STATUS_PARAMETER_INVALID;

    switch( Nvm.MacGroup2.DeviceClass )
    {
        case CLASS_A:
        {
            if( deviceClass == CLASS_A )
            {
                // Revert back RxC parameters
                Nvm.MacGroup2.MacParams.RxCChannel = Nvm.MacGroup2.MacParams.Rx2Channel;
            }
    [...]

However, in this particular case the status value is not updated and the function returns LORAMAC_STATUS_PARAMETER_INVALID while performing the side-effect.

Shouldn't SwitchClass be updated to return LORAMAC_STATUS_OK if the side-effect (reverting RxC params) is performed?

commit bc9a93e

@MarekNovakACRIOS
Copy link
Contributor

I have noticed that when evaluting class B - if the function has some side-effect, even when no actual change happened, it is error prone to return an error and it can easily mislead the user of the API. I definitely agree with @janakj .

@mluis1 mluis1 added this to the Release Version 4.7.0 milestone Mar 21, 2022
@mluis1
Copy link
Contributor

mluis1 commented Mar 21, 2022

Thanks for reporting this issue.

We will try to fix it for next release.

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

3 participants