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

Question: In the context of file-uploading and file-downloading what is the enum type of HasReturnCode.GroupReturnCode.group and .rc? #201

Open
ksidirop-laerdal opened this issue Oct 25, 2024 · 5 comments
Labels
question Further information is requested

Comments

@ksidirop-laerdal
Copy link
Contributor

ksidirop-laerdal commented Oct 25, 2024

https://github.com/NordicSemiconductor/Android-nRF-Connect-Device-Manager/blob/main/mcumgr-core/src/main/java/io/runtime/mcumgr/response/HasReturnCode.java

In our Laerdal.McuMgr bindings-library we need to perform exception-mapping and error-mapping between the Java world and the C# world whenever an error occurs during file-downloading or file-uploading (for example "file not found", "corrupted", etc).

private final class FileDownloaderCallbackProxy implements DownloadCallback
{
        @Override
        public void onDownloadFailed(@NonNull final McuMgrException exception)
        { ...
        }
}

private final class FileUploaderCallbackProxy implements UploadCallback
{
        @Override
        public void onUploadFailed(@NonNull final McuMgrException error)
        {...
        }
}

Is it correct to say that in the context of file-uploading and file-downloading any McuMgrErrorException adheres to the following statements?

exception.getGroupCode().rc (int field)          ->  always adheres to 'enum McuMgrErrorCode' (?)
exception.getGroupCode().group (int field)   ->  always adheres to 'enum FsManager.ReturnCode' (?)

Likewise in the case of firmware-installation we have the following callbacks-proxy:

private final class FirmwareInstallCallbackProxy implements FirmwareUpgradeCallback<FirmwareUpgradeManager.State>
{
        @Override
        public void onUpgradeFailed(final FirmwareUpgradeManager.State state, final McuMgrException ex)
        {   ...
        }
}

Is it correct to say that in the context of firmware-installation any McuMgrErrorException adheres to the following statements?

exception.getGroupCode().rc (int field)          ->  always adheres to 'enum McuMgrErrorCode' (?)
exception.getGroupCode().group (int field)   ->  always adheres to 'enum ImageManager.ReturnCode' (?)

( I just want to be sure that there isn't some corner case where these integer fields are adhering to some other enums because if this happens our error-mapping and exception-mapping will end up mapping and reporting the wrong kind of error over to the C# world misleading the host-application! )

@philips77
Copy link
Member

The group is the ID of the manager (group), so that's one of these:

// Mcu Manager groups
protected final static int GROUP_DEFAULT = 0;
protected final static int GROUP_IMAGE = 1;
protected final static int GROUP_STATS = 2;
protected final static int GROUP_SETTINGS = 3;
protected final static int GROUP_LOGS = 4;
protected final static int GROUP_CRASH = 5;
protected final static int GROUP_SPLIT = 6;
protected final static int GROUP_RUN = 7;
protected final static int GROUP_FS = 8;
protected final static int GROUP_SHELL = 9;
// https://github.com/nrfconnect/sdk-zephyr/blob/master/include/mgmt/mcumgr/zephyr_groups.h
protected final static int GROUP_BASIC = 63;
protected final static int GROUP_SUIT = 66; // TODO This should be changed to 62 at some point
// User defined groups should start from GROUP_PERUSER.
protected final static int GROUP_PERUSER = 64;

The rc is a the [TheManagerWithGivenGroupId].ReturnCode. So, if exception.getGroupCode().rc == 8 (FSManager), than rc adheres to 'enum FsManager.ReturnCode', etc.

@philips77 philips77 added the question Further information is requested label Oct 27, 2024
@philips77
Copy link
Member

If the device doesn't support SMP v. 2, the exception.getGroupCode() returns null, and you need to use exception.getCode(), which adverse to

@ksidirop-laerdal
Copy link
Contributor Author

Appreciate the prompt response. Now it all makes sense. Just a quick follow up question or two:

  1. I tried to track down the return codes for the following groups but I couldn't spot them anywhere in the code base:
int GROUP_LOGS   = 4
int GROUP_CRASH  = 5
int GROUP_SPLIT  = 6
int GROUP_RUN    = 7
  1. On the flip-side I've found the BasicManager.ReturnCode enum in the java libraries but I can't see which group it belongs to. Does it have a group-id and if so which one?

Appreciate any insights!

@philips77
Copy link
Member

Hi,
Basic Group is called Zephyr Group, as far as I remember. These are Zephyr specific commands, or actually just one, the erase app settings.

The other group you mentioned aren't supported on Zephyr, thus weren't migrated to SMP V2, so they don't support group errors.

@ksidirop-laerdal
Copy link
Contributor Author

ksidirop-laerdal commented Oct 28, 2024

Basic Group is called Zephyr Group, as far as I remember. These are Zephyr specific commands, or actually just one, the erase app settings.

Cool. By the way what is the group-id of the basic-group ("zephyr-group"). Can I find it somewhere?

(pardon me if I'm missing something obvious while reading between the lines)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants