@ -50,6 +50,7 @@ import java.util.stream.Collectors;
import static org.eclipse.leshan.core.model.ResourceModel.Type.OPAQUE ;
import static org.eclipse.leshan.server.bootstrap.BootstrapUtil.toWriteRequest ;
import static org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil.BOOTSTRAP_DEFAULT_SHORT_ID ;
@Slf4j
public class LwM2MBootstrapConfigStoreTaskProvider implements LwM2MBootstrapTaskProvider {
@ -104,7 +105,7 @@ public class LwM2MBootstrapConfigStoreTaskProvider implements LwM2MBootstrapTask
"Bootstrap Discover return error {} : to continue bootstrap session without autoIdForSecurityObject mode. {}" ,
discoverResponse , session ) ;
}
if ( this . lwM2MBootstrapSessionClients . get ( session . getEndpoint ( ) ) . getSecurityInstances ( ) . get ( 0 ) = = null ) {
if ( this . lwM2MBootstrapSessionClients . get ( session . getEndpoint ( ) ) . getSecurityInstances ( ) . get ( BOOTSTRAP_DEFAULT_SHORT_ID ) = = null ) {
log . error (
"Unable to find bootstrap server instance in Security Object (0) in response {}: unable to continue bootstrap session with autoIdForSecurityObject mode. {}" ,
discoverResponse , session ) ;
@ -168,7 +169,7 @@ public class LwM2MBootstrapConfigStoreTaskProvider implements LwM2MBootstrapTask
lwM2MBootstrapSessionClients . get ( endpoint ) . getSecurityInstances ( ) . put ( Integer . valueOf ( link . getLinkParams ( ) . get ( "ssid" ) . getUnquoted ( ) ) , path . getObjectInstanceId ( ) ) ;
} else {
if ( ! this . lwM2MBootstrapSessionClients . get ( endpoint ) . getSecurityInstances ( ) . containsKey ( 0 ) ) {
this . lwM2MBootstrapSessionClients . get ( endpoint ) . getSecurityInstances ( ) . put ( 0 , path . getObjectInstanceId ( ) ) ;
this . lwM2MBootstrapSessionClients . get ( endpoint ) . getSecurityInstances ( ) . put ( BOOTSTRAP_DEFAULT_SHORT_ID , path . getObjectInstanceId ( ) ) ;
} else {
log . error ( "Invalid bootstrapSecurityInstance by [{}]" , path . getObjectInstanceId ( ) ) ;
}
@ -242,7 +243,7 @@ public class LwM2MBootstrapConfigStoreTaskProvider implements LwM2MBootstrapTask
Integer bootstrapServerIdNew = null ;
// handle security
int lwm2mSecurityInstanceId = 0 ;
int bootstrapSecurityInstanceId = this . lwM2MBootstrapSessionClients . get ( endpoint ) . getSecurityInstances ( ) . get ( 0 ) ;
int bootstrapSecurityInstanceId = this . lwM2MBootstrapSessionClients . get ( endpoint ) . getSecurityInstances ( ) . get ( BOOTSTRAP_DEFAULT_SHORT_ID ) ;
for ( BootstrapConfig . ServerSecurity security : new TreeMap < > ( bootstrapConfig . security ) . values ( ) ) {
if ( security . bootstrapServer ) {
requestsWrite . add ( toWriteRequest ( bootstrapSecurityInstanceId , security , contentFormat ) ) ;