Skip to content

Commit

Permalink
#482 : Server ID resource is optional for bootstrap server.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Apr 5, 2018
1 parent c8e1538 commit cc9740a
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -27,6 +27,7 @@
import org.eclipse.leshan.client.resource.LwM2mObjectEnabler;
import org.eclipse.leshan.core.node.LwM2mObject;
import org.eclipse.leshan.core.node.LwM2mObjectInstance;
import org.eclipse.leshan.core.node.LwM2mResource;
import org.eclipse.leshan.core.request.BindingMode;
import org.eclipse.leshan.core.request.ReadRequest;
import org.slf4j.Logger;
Expand Down Expand Up @@ -57,7 +58,11 @@ public static ServersInfo getInfo(Map<Integer, LwM2mObjectEnabler> objectEnabler
} else {
// create bootstrap info
ServerInfo info = new ServerInfo();
info.serverId = (long) security.getResource(SEC_SERVER_ID).getValue();
LwM2mResource serverIdResource = security.getResource(SEC_SERVER_ID);
if (serverIdResource != null && serverIdResource.getValue() != null)
info.serverId = (long) serverIdResource.getValue();
else
info.serverId = 0;
info.serverUri = new URI((String) security.getResource(SEC_SERVER_URI).getValue());
info.secureMode = SecurityMode
.fromCode((long) security.getResource(SEC_SECURITY_MODE).getValue());
Expand Down

0 comments on commit cc9740a

Please sign in to comment.