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

Add Read-Composite operation #958

Merged
merged 14 commits into from
Mar 9, 2021
Merged

Add Read-Composite operation #958

merged 14 commits into from
Mar 9, 2021

Conversation

sbernard31
Copy link
Contributor

@sbernard31 sbernard31 commented Jan 8, 2021

This aims to implement #957.

(This is work in progress, not in reviewable state or testable state)

@sbernard31 sbernard31 marked this pull request as draft January 8, 2021 17:28
@sbernard31
Copy link
Contributor Author

sbernard31 commented Jan 12, 2021

I finished to write a first "working" version. This was mainly to detect all the impact on current code base.
This should be enough to play with it but this is clearly not in a clean state.

Now I need to polish this (implement some missing details, clean the code, add more validation, add javadocs, some renames ...)
ReadComposite using "/" is not implemented now and will be probably not in this PR.

The API looks like this :

// read device model number
ReadCompositeResponse response = server.send(registration,
        new ReadCompositeRequest(ContentFormat.SENML_CBOR, ContentFormat.SENML_CBOR, "/3/0/0", "/1"));

if (response.isSuccess()) {
    List<LwM2mNode> content = response.getContent();
    content.get(0); // response for "/3/0/0"
    content.get(1); // response for "/1"
    ...
}

@sbernard31 sbernard31 marked this pull request as ready for review January 14, 2021 16:32
@sbernard31
Copy link
Contributor Author

@madhushreegc @eliasweingaertner I think this is in in a reviewable and testable state.
(If you want to look at the code I advice to check commit by commit this will be more understandable)

My next step for another PR will be to look at the WriteComposite to check if the ReadComposite design matches correctly with it.

@sbernard31
Copy link
Contributor Author

sbernard31 commented Jan 20, 2021

Unfortunately, I need to update the code by mainly switching all the List<LwM2mPath> + List<LwM2mNode> by Map<LwM2mPath, LwM2mNode>.

This was mainly because to decode nodes from WriteComposite. In this case the list of List<LwM2mPath> is unknown and so the result must return Node+Path, I'm not sure I'm so clear ... (see first commit of #959 for more details)

This impacts the ReadCompositeResponse API and so now it looks like :

// read device model number
ReadCompositeResponse response = server.send(registration,
        new ReadCompositeRequest(ContentFormat.SENML_CBOR, ContentFormat.SENML_CBOR, "/3/0/0", "/1"));

if (response.isSuccess()) {
    LwM2mSingleResource resource = (LwM2mSingleResource) response.getContent("/3/0/0");
    LwM2mObject object = (LwM2mObject) response.getContent("/1");
    ...
}

@sbernard31 sbernard31 merged commit 3a184ab into master Mar 9, 2021
@sbernard31
Copy link
Contributor Author

Still not entirely satisfied by the API an maybe we should go to something like #981.

@sbernard31 sbernard31 deleted the read_composite branch June 3, 2021 07:52
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

Successfully merging this pull request may close these issues.

1 participant