fis_bug: LwM2MClientSerDes test
This commit is contained in:
parent
a6293e8cdb
commit
65fd836d9f
@ -24,7 +24,6 @@ import org.eclipse.leshan.core.LwM2m;
|
|||||||
import org.eclipse.leshan.core.LwM2m.Version;
|
import org.eclipse.leshan.core.LwM2m.Version;
|
||||||
import org.eclipse.leshan.core.link.Link;
|
import org.eclipse.leshan.core.link.Link;
|
||||||
import org.eclipse.leshan.core.link.attributes.Attribute;
|
import org.eclipse.leshan.core.link.attributes.Attribute;
|
||||||
import org.eclipse.leshan.core.link.lwm2m.MixedLwM2mLink;
|
|
||||||
import org.eclipse.leshan.core.model.ObjectModel;
|
import org.eclipse.leshan.core.model.ObjectModel;
|
||||||
import org.eclipse.leshan.core.model.ResourceModel;
|
import org.eclipse.leshan.core.model.ResourceModel;
|
||||||
import org.eclipse.leshan.core.node.LwM2mMultipleResource;
|
import org.eclipse.leshan.core.node.LwM2mMultipleResource;
|
||||||
@ -211,11 +210,14 @@ public class LwM2mClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LwM2m.Version getObjectIDVerFromDeviceProfile(DeviceProfile deviceProfile) {
|
private LwM2m.Version getObjectIDVerFromDeviceProfile(DeviceProfile deviceProfile) {
|
||||||
String defaultObjectIdVer = ((Lwm2mDeviceProfileTransportConfiguration)deviceProfile
|
String defaultObjectIdVer = null;
|
||||||
.getProfileData()
|
if (deviceProfile != null) {
|
||||||
.getTransportConfiguration())
|
defaultObjectIdVer = ((Lwm2mDeviceProfileTransportConfiguration) deviceProfile
|
||||||
.getClientLwM2mSettings()
|
.getProfileData()
|
||||||
.getDefaultObjectIDVer();
|
.getTransportConfiguration())
|
||||||
|
.getClientLwM2mSettings()
|
||||||
|
.getDefaultObjectIDVer();
|
||||||
|
}
|
||||||
return new Version(defaultObjectIdVer == null ? LWM2M_OBJECT_VERSION_DEFAULT : defaultObjectIdVer);
|
return new Version(defaultObjectIdVer == null ? LWM2M_OBJECT_VERSION_DEFAULT : defaultObjectIdVer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,20 +456,17 @@ public class LwM2mClient {
|
|||||||
private void setSupportedClientObjects(){
|
private void setSupportedClientObjects(){
|
||||||
this.supportedClientObjects = new ConcurrentHashMap<>();
|
this.supportedClientObjects = new ConcurrentHashMap<>();
|
||||||
for (Link link: this.registration.getSortedObjectLinks()) {
|
for (Link link: this.registration.getSortedObjectLinks()) {
|
||||||
MixedLwM2mLink mixedLwM2mLink = (MixedLwM2mLink)link;
|
LwM2mPath lwM2mPath = new LwM2mPath(link.getUriReference());
|
||||||
if(!mixedLwM2mLink.getPath().isRoot()){
|
if (lwM2mPath.isObject()) {
|
||||||
LwM2mPath lwM2mPath = mixedLwM2mLink.getPath();
|
LwM2m.Version ver;
|
||||||
if (lwM2mPath.isObject()) {
|
if (link.getAttributes().get("ver")!= null) {
|
||||||
LwM2m.Version ver;
|
ver = (Version) link.getAttributes().get("ver").getValue();
|
||||||
if (mixedLwM2mLink.getAttributes().get("ver")!= null) {
|
} else {
|
||||||
ver = (Version) mixedLwM2mLink.getAttributes().get("ver").getValue();
|
ver = getDefaultObjectIDVer();
|
||||||
} else {
|
|
||||||
ver = getDefaultObjectIDVer();
|
|
||||||
}
|
|
||||||
this.supportedClientObjects.put(lwM2mPath.getObjectId(), ver);
|
|
||||||
} else if (this.supportedClientObjects.get(lwM2mPath.getObjectId()) == null){
|
|
||||||
this.supportedClientObjects.put(lwM2mPath.getObjectId(), getDefaultObjectIDVer());
|
|
||||||
}
|
}
|
||||||
|
this.supportedClientObjects.put(lwM2mPath.getObjectId(), ver);
|
||||||
|
} else if (this.supportedClientObjects.get(lwM2mPath.getObjectId()) == null){
|
||||||
|
this.supportedClientObjects.put(lwM2mPath.getObjectId(), getDefaultObjectIDVer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.protobuf.util.JsonFormat;
|
import com.google.protobuf.util.JsonFormat;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import org.eclipse.leshan.core.LwM2m.Version;
|
||||||
import org.eclipse.leshan.core.model.ResourceModel;
|
import org.eclipse.leshan.core.model.ResourceModel;
|
||||||
import org.eclipse.leshan.core.node.LwM2mMultipleResource;
|
import org.eclipse.leshan.core.node.LwM2mMultipleResource;
|
||||||
import org.eclipse.leshan.core.node.LwM2mNodeException;
|
import org.eclipse.leshan.core.node.LwM2mNodeException;
|
||||||
@ -345,7 +346,7 @@ public class LwM2MClientSerDes {
|
|||||||
if (defaultObjectIDVer != null) {
|
if (defaultObjectIDVer != null) {
|
||||||
Field defaultObjectIDVerField = lwM2mClientClass.getDeclaredField("defaultObjectIDVer");
|
Field defaultObjectIDVerField = lwM2mClientClass.getDeclaredField("defaultObjectIDVer");
|
||||||
defaultObjectIDVerField.setAccessible(true);
|
defaultObjectIDVerField.setAccessible(true);
|
||||||
defaultObjectIDVerField.set(lwM2mClient, defaultObjectIDVer.getAsString());
|
defaultObjectIDVerField.set(lwM2mClient, new Version(defaultObjectIDVer.getAsString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonElement registration = o.get("registration");
|
JsonElement registration = o.get("registration");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user