Possibly wrong status returned by SwitchClass
Closed this issue · 2 comments
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
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 .
Thanks for reporting this issue.
We will try to fix it for next release.