-
Notifications
You must be signed in to change notification settings - Fork 407
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
read composite on root path #1520
read composite on root path #1520
Conversation
(@mgdlkundera let me know when this is in a reviewable state) |
@sbernard31 It's ready for review |
@@ -74,9 +78,22 @@ public void removeListener(ObjectsListener listener) { | |||
@Override | |||
public ReadCompositeResponse read(LwM2mServer server, ReadCompositeRequest request) { | |||
List<LwM2mPath> paths = request.getPaths(); | |||
// TODO: add checks for failure and log it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I think some check should be done here.
The spec says :
The Read-Composite operation is treated as non-atomic and handled as best effort by the client. That is, if any of the requested resources do not have a valid value to return, they will not be included in the response.
So I think on failure, we should not stop the read-composite operation but just log as error.
(so error will not be seen at server side)
default void visit(LwM2mRoot root) { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we should add a default visit.
Better to add to all visitor the new function and raise exception is not supported.
// TODO: visitors currently don't support a visit from LwM2mRoot | ||
visitor.visit(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to get this TODO ?
public String toPrettyString(LwM2mPath path) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public StringBuilder appendPrettyNode(StringBuilder b, LwM2mPath path) { | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be implemented.
return objects; | ||
} | ||
|
||
// TODO: add compare and other stuff that a LwM2m node should have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep this should probably added.
(See #1504 maybe this could help)
if (!n.isEmpty() && !bn.equals("/")) { | ||
bn += "/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds strange I need to look at this deeper.
// verify result | ||
// assertEquals(CONTENT, response.getCode()); | ||
// assertContentFormat(responseContentFormat, response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be removed ?
Set<Integer> objectIdsFromRootObject = root.getObjects().keySet(); | ||
Set<Integer> objectIdsFromObjectTree = new HashSet<>(Arrays.asList(1, 3, 3442)); | ||
|
||
// assertEquals(objectIdsFromObjectTree, objectIdsFromRootObject); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be removed ?
@@ -53,39 +54,89 @@ public JacksonLwM2mNodeSerializer() { | |||
@Override | |||
public void serialize(LwM2mNode src, JsonGenerator gen, SerializerProvider provider) throws IOException { | |||
Map<String, Object> element = new HashMap<>(); | |||
Map<String, Object> element1 = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all modification in JacksonLwM2mNodeSerializer
are about demo so It should not be part of this PR.
We will see later when/if we add a UI for this.
} | ||
|
||
@TestAllCases | ||
public void can_read_root_single_resource(ContentFormat requestContentFormat, ContentFormat responseContentFormat, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to understand why there is several test where all do a ReadComposite on /
?
Maybe better to have only 1 test OR I missed something ?
A possible way to test it could be to :
- do a
ReadComposite
. - Check that all expected object are here. (maybe using Registration.getSupportedObject() ?)
- (optionally) on instances too (using Registration.getAvailableInstances())
- Then for each LwM2mObject in ReadComposite response, you do a
ReadRequest
on this object and you check that LwM2mObject returned is equals of LwM2mObject from ReadComposite response.
(This will work if no value change between 2 call, if some change let me know)
Not a big deal:slightly_smiling_face: but maybe you could find :
|
test improvement, remove changes from JacksonLwM2mNodeSerializer, add equals and hashcode to LwM2mRoot and visit.
(let me know once, you think the code must be reviewed again, no urgency on my side take, do not hesitate to take time to review your own code like if you review someone else code) |
I will be unavailable next few days. I'll be back on Thursday November 2nd. When I return, I plan to work on this. |
Thank you. I will be out of the office until Monday November 6nd. What do you think about possibility of releasing M14 version containing this issue around November 23? |
We can try, I created a dedicated issue #1531 for that. |
I have one more question, can I add to this pull request observe for root? |
@mgdlkundera I'm working on this PR, I hope I will provide something before the end of the day. So I don't advice to work more on it for now. About observe, I advice to start to work on it in another PR. 🙂 |
I created a PR based on this one : #1534 I added a new Interface @mgdlkundera, @JaroslawLegierski let me know if you plan to review the PR. 🙏 |
8e7cd35
to
2efb924
Compare
@mgdlkundera, @JaroslawLegierski please let me know if you plan to review because if you don't plan to do it better to put this in |
If it is urgent then I suggest integrating it with the master (I can review it on Tuesday next week at the earliest). |
On my side there is no urgency. Looking at : zephyrproject-rtos/zephyr#64013 |
@JaroslawLegierski , @mgdlkundera, As planned, I integrated #1534 in Note that I also added support in leshan-server-demo. Thx both of you for you work/help on this 🙏 ! |
I prepare implementation of observe for root, here is a link: Can I create new pull request from this branch? |
Yep. |
I improved code and add test. Here is pull request: |
Integration tests for root