eclipse-leshan / leshan

Java Library for LWM2M
https://www.eclipse.org/leshan/
BSD 3-Clause "New" or "Revised" License
653 stars 408 forks source link

The addition of a resource instance is not detected by LwM2mTestObject (3442) #1618

Closed slaft closed 5 months ago

slaft commented 5 months ago

Hi, I'm testing the future 2.0.0-M15 (from the nightly build).

I use the Leshan client to test the server part (based on Leshan). The Leshan client is configured with an instance of LwM2mTestObject and a ResourceListener. I send a WriteRequest from the server:

The LwM2mTestObject initially has 1 instance of the resource 1120 (id: 0, value: 1024), so I expect to be notified for change (in the ResourceListener) for: /3442/0/1120/0, /3442/0/1120/1 (and /3442/0/1120 which is something new compared to 2.0.0-M14). But /3442/0/1120/1 is missing from the notification (the instance is nevertheless created).

https://github.com/eclipse-leshan/leshan/blob/dceda02a1fd6f99c93b6742c49fc98e5cdb89ddc/leshan-client-core/src/main/java/org/eclipse/leshan/client/resource/SimpleInstanceEnabler.java#L127-L133 I guess that the issue is just that it should be previousValue instead newValue on L128.

sbernard31 commented 5 months ago

Hi @slaft, Good Catch ! and Thx a lot for taking time to report that :pray:

Following your explanation and reading the code I pretty sure you're right.

I'm gonna fix that.

Do you try your fix and does it solves your issue ?

slaft commented 5 months ago

Thanks. I've just tested it, yes it does solve the issue.

sbernard31 commented 5 months ago

It is fixed in master and will be available in 2.0.0-M15.