Search in sources :

Example 1 with LwM2mSessionMsgListener

use of org.thingsboard.server.transport.lwm2m.server.LwM2mSessionMsgListener in project thingsboard by thingsboard.

the class LwM2MBootstrapSecurityStore method getParametersBootstrap.

private LwM2MBootstrapConfig getParametersBootstrap(TbLwM2MSecurityInfo store) {
    LwM2MBootstrapConfig lwM2MBootstrapConfig = store.getBootstrapCredentialConfig();
    if (lwM2MBootstrapConfig != null) {
        UUID sessionUUiD = UUID.randomUUID();
        TransportProtos.SessionInfoProto sessionInfo = helper.getValidateSessionInfo(store.getMsg(), sessionUUiD.getMostSignificantBits(), sessionUUiD.getLeastSignificantBits());
        bsSessions.put(store.getEndpoint(), sessionInfo);
        context.getTransportService().registerAsyncSession(sessionInfo, new LwM2mSessionMsgListener(null, null, null, sessionInfo, context.getTransportService()));
        if (this.getValidatedSecurityMode(lwM2MBootstrapConfig)) {
            return lwM2MBootstrapConfig;
        } else {
            log.error(" [{}] Different values SecurityMode between of client and profile.", store.getEndpoint());
            log.error("{} getParametersBootstrap: [{}] Different values SecurityMode between of client and profile.", LOG_LWM2M_ERROR, store.getEndpoint());
            String logMsg = String.format("%s: Different values SecurityMode between of client and profile.", LOG_LWM2M_ERROR);
            helper.sendParametersOnThingsboardTelemetry(helper.getKvStringtoThingsboard(LOG_LWM2M_TELEMETRY, logMsg), sessionInfo);
            return null;
        }
    }
    log.error("Unable to decode Json or Certificate for [{}]", store.getEndpoint());
    return null;
}
Also used : LwM2mSessionMsgListener(org.thingsboard.server.transport.lwm2m.server.LwM2mSessionMsgListener) LwM2MBootstrapConfig(org.thingsboard.server.transport.lwm2m.bootstrap.secure.LwM2MBootstrapConfig) TransportProtos(org.thingsboard.server.gen.transport.TransportProtos) UUID(java.util.UUID)

Example 2 with LwM2mSessionMsgListener

use of org.thingsboard.server.transport.lwm2m.server.LwM2mSessionMsgListener in project thingsboard by thingsboard.

the class DefaultLwM2MSessionManager method register.

@Override
public void register(TransportProtos.SessionInfoProto sessionInfo) {
    transportService.registerAsyncSession(sessionInfo, new LwM2mSessionMsgListener(uplinkHandler, attributesService, rpcHandler, sessionInfo, transportService));
    TransportProtos.TransportToDeviceActorMsg msg = TransportProtos.TransportToDeviceActorMsg.newBuilder().setSessionInfo(sessionInfo).setSessionEvent(SESSION_EVENT_MSG_OPEN).setSubscribeToAttributes(SUBSCRIBE_TO_ATTRIBUTE_UPDATES_ASYNC_MSG).setSubscribeToRPC(SUBSCRIBE_TO_RPC_ASYNC_MSG).build();
    transportService.process(msg, null);
}
Also used : LwM2mSessionMsgListener(org.thingsboard.server.transport.lwm2m.server.LwM2mSessionMsgListener) TransportProtos(org.thingsboard.server.gen.transport.TransportProtos)

Aggregations

TransportProtos (org.thingsboard.server.gen.transport.TransportProtos)2 LwM2mSessionMsgListener (org.thingsboard.server.transport.lwm2m.server.LwM2mSessionMsgListener)2 UUID (java.util.UUID)1 LwM2MBootstrapConfig (org.thingsboard.server.transport.lwm2m.bootstrap.secure.LwM2MBootstrapConfig)1