-
Notifications
You must be signed in to change notification settings - Fork 408
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 support of write attributes at client side. #534
Comments
+1 |
Hi, any news on this one? I have an urgent need to somehow handle PMAX/PMIN attribute requests in the client. The client now answers with 500 Internal Error, which is not tolerated by our server - we cannot observe anything. I'm happy also with ANY workaround, PMAX/PMIN do not need to actually work in this application, we just need to get the server the expected response (204 I believe) |
Clearly not a priority for us now. Anyway a possible workaround: public class CustomObjectEnabler extends ObjectEnabler {
public CustomObjectEnabler(int id, ObjectModel objectModel, Map<Integer, LwM2mInstanceEnabler> instances,
LwM2mInstanceEnablerFactory instanceFactory, ContentFormat defaultContentFormat) {
super(id, objectModel, instances, instanceFactory, defaultContentFormat);
}
@Override
public synchronized WriteAttributesResponse writeAttributes(ServerIdentity identity,
WriteAttributesRequest request) {
return WriteAttributesResponse.success();
}
} Then if you are using public class CustomObjectsInitializer extends ObjectsInitializer {
@Override
protected ObjectEnabler createNodeEnabler(ObjectModel objectModel) {
Map<Integer, LwM2mInstanceEnabler> instances = new HashMap<>();
LwM2mInstanceEnabler[] newInstances = createInstances(objectModel);
for (LwM2mInstanceEnabler instance : newInstances) {
// set id if not already set
if (instance.getId() == null) {
int id = BaseInstanceEnablerFactory.generateNewInstanceId(instances.keySet());
instance.setId(id);
}
instance.setModel(objectModel);
instances.put(instance.getId(), instance);
}
return new CustomObjectEnabler(objectModel.id, objectModel, instances, getFactoryFor(objectModel),
getContentFormat(objectModel.id));
}
} And this should be OK. |
Hi, Yes I got it working with this, thanks! |
Hi sbernard31, |
I'm sorry but I didn't understand what is your problem. You vaguely try to explain it at : #1330 (comment) You talk about implementing Write Attributes support at client side. I don't get it 🤔 because this is far to implement Write Attribute at client side. Maybe there is way to do that without californium modification but for sure this will not be easy at all.
This looks like : "This ticket was created in 2018, we are in 2022 why this is still not done ? This should be already implemented !" Anyway, the reason is still the same :
Finally, if this sample of code solves your problem perfectly, I guess you don't really need to implement Write Attributes and so maybe just want to write some kind of code to test that a server send the WriteAttributeRequest correctly. If I didn't understand you correctly please clarify your needs. |
I just went through #484 in detail,now I know that it is not easy to implement writeAttributes at the client side。 I am working on a mqtt2lwm2m project, the goal is to connect home-assistant to lwm2m server, so I need to implement a lwm2m client. The biggest hurdle I've run into is not being able to receive the pmax property set on the server side. The setting of the pmax property has now been implemented as per the sample code you mentioned above. But this is still far from the real implementation of writeAttributes, if there is spare time I want to join this job, but before that, I may have to read Thanks. |
Note that currently Leshan v1.x targets LWM2M v1.0.x and Leshan v2.x targets LWM2M v1.1.x. |
Got it, thanks. |
What must be done is explained in this issue description (#534 (comment)) :
(1.) and (3.) the easy part and was partially done in #533 but the critical part is (2.) Currently, I have no clear idea how to handle this with current californium API. You can explore to try to find a solution for (2.) but I feel this could be a not so easy task 😬 Also note that I have some doubts about current observation abstraction at client side. (#1323 (comment)) |
From what I remember I ended with the send function - I didn't implement the observations. |
@sbernard31 Could you explain this?
Do you mean that attributes need to be sent in observations? |
Nope I don't think we need to send attributes in notifications. I meant :
OR in others words : Implementing the behavior of each attributes defined in LWM2M specification. |
So when we send notifications should be influenced by attributes? For example, after exciding pmax? If so, could you point me to where notifications are triggered from after exciding said time? |
Currently, there is no mechanism like this. To better understand the leshan listener/event model, you should probably take a look at :
For now, I don't know exactly how code should looks like. Here some ideas I had very long time ago (#484 (comment)), I don't know if that still makes sense but could help to better understand the feature. |
Response to #1488 (comment)
I looked through it but decided it would be easier to write it myself
Regarding pmin, I created a method (putIntoQueue(LwM2mPath path)) to catch (and delay if needed) rising events but wasn't sure how to implement it (to be precise, I don't know where it would be best to catch raised events).
We need this feature |
I was just talking about reusing the issue for our discussion, not the code.
Sorry, do not be more available, I try to prioritize my effort and put this one pretty low in the list.
That means you are using the leshan-client, could you share for what/ how you use it ? I'm curious 🙂 |
@Warmek, I explore it since few days and I begin to get clearer idea but this will lead to some deep modification at client side. |
Thank you for letting me know. Are those changes regarding my PoC, or are you looking into your own way to implement write attributes? |
For now I didn't reuse your code. As expected this is a very impacting feature because this tweaks behavior which is generally handled by the coap library. |
I looked through the code and other than the multi-threading "issue" described by #1514 (comment), I didn't have any issues. Also, it might be a good idea to be more clear as to how is multi-threading handled in Leshan project as it can have a significant impact on how the code is written. |
I tried to answer to this question with #1514 (comment).
I'm not sure how I can answer to this question. 🤔 If this is not expected answer, please clarify what you have in mind 😬 |
I moved forward on : #1514
Then :
|
Minimal Viable Feature is available at : #1514 If anybody can play with it ? feedback / comments are welcome. |
Co-authored-by: Magdalena Kundera <magdalena.kundera@orange.com>
Minimal Viable Feature is now integrated in |
Missing known feature (Still no support of write attribute for Composite-Observe) |
…erve to client. Co-authored-by: Magdalena Kundera <magdalena.kundera@orange.com>
This means :
There is an ongoing work about this
(#484): #1514The LWM2M v1.1.1 specification about that :
LightweightM2M-1.1-int-710
,LightweightM2M-1.1-int-810
,LightweightM2M-1.1-int-910
)It could be worth to also check LWM2M v1.2.x, just for clarification (not for new feature) :
LightweightM2M-1.1-int-261
,LightweightM2M-1.2-int-264
,LightweightM2M-1.2-int-266
,LightweightM2M-1.1-int-301
,LightweightM2M-1.1-int-308
,LightweightM2M-1.1-int-310
,LightweightM2M-1.2-int-313
,LightweightM2M-1.1-int-760
,LightweightM2M-1.1-int-951
,LightweightM2M-1.1-int-1203
,LightweightM2M-1.1-int-1204
,LightweightM2M-1.1-int-1900
)LWM2M v1.1.x also refer to IETF draft-ietf-core-dynlink-07 as [DynLink], so it could also make to look at it to clarify some ambiguities. Since draft 14, Conditional Attributes section was moved to draft-ietf-core-conditional-attributes. LWM2M v1.2.x refer to this last one draft-ietf-core-conditional-attributes-06 as [Cond_Attr]. So it could also make to look at it to clarify some ambiguities.
There is also some old discussion at OMA Developer repository which could maybe help (when we don't find answer in official specification) :
The text was updated successfully, but these errors were encountered: