|
|
|
@ -20,6 +20,8 @@ import com.google.gson.GsonBuilder; |
|
|
|
import com.google.gson.JsonElement; |
|
|
|
import com.google.gson.JsonObject; |
|
|
|
import com.google.gson.reflect.TypeToken; |
|
|
|
import lombok.Getter; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.eclipse.leshan.core.ResponseCode; |
|
|
|
import org.eclipse.leshan.core.model.ObjectModel; |
|
|
|
@ -32,6 +34,7 @@ import org.eclipse.leshan.core.node.LwM2mPath; |
|
|
|
import org.eclipse.leshan.core.node.LwM2mResource; |
|
|
|
import org.eclipse.leshan.core.node.LwM2mResourceInstance; |
|
|
|
import org.eclipse.leshan.core.node.LwM2mSingleResource; |
|
|
|
import org.eclipse.leshan.core.node.codec.LwM2mValueConverter; |
|
|
|
import org.eclipse.leshan.core.observation.Observation; |
|
|
|
import org.eclipse.leshan.core.request.*; |
|
|
|
import org.eclipse.leshan.core.request.WriteRequest.Mode; |
|
|
|
@ -122,69 +125,41 @@ import static org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil.fr |
|
|
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@Service("lwM2mUplinkMsgHandler") |
|
|
|
@TbLwM2mTransportComponent |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class DefaultLwM2mUplinkMsgHandler extends LwM2MExecutorAwareService implements LwM2mUplinkMsgHandler { |
|
|
|
|
|
|
|
public LwM2mValueConverterImpl converter; |
|
|
|
@Getter |
|
|
|
private final LwM2mValueConverter converter = LwM2mValueConverterImpl.getInstance();; |
|
|
|
|
|
|
|
private final TransportService transportService; |
|
|
|
private final LwM2mTransportContext context; |
|
|
|
@Lazy |
|
|
|
private final LwM2MAttributesService attributesService; |
|
|
|
private final LwM2MSessionManager sessionManager; |
|
|
|
@Lazy |
|
|
|
private final LwM2MOtaUpdateService otaService; |
|
|
|
private final LwM2MTransportServerConfig config; |
|
|
|
private final LwM2MTelemetryLogService logService; |
|
|
|
private final LwM2mTransportServerHelper helper; |
|
|
|
private final TbLwM2MDtlsSessionStore sessionStore; |
|
|
|
private final LwM2mClientContext clientContext; |
|
|
|
private final LwM2mDownlinkMsgHandler defaultLwM2MDownlinkMsgHandler; |
|
|
|
private final LwM2mDownlinkMsgHandler defaultLwM2MDownlinkMsgHandler; //Do not use Lazy because we need live executor to handle msgs
|
|
|
|
private final LwM2mVersionedModelProvider modelProvider; |
|
|
|
private final RegistrationStore registrationStore; |
|
|
|
private final TbLwM2mSecurityStore securityStore; |
|
|
|
private final LwM2MModelConfigService modelConfigService; |
|
|
|
|
|
|
|
public DefaultLwM2mUplinkMsgHandler(TransportService transportService, |
|
|
|
LwM2MTransportServerConfig config, |
|
|
|
LwM2mTransportServerHelper helper, |
|
|
|
LwM2mClientContext clientContext, |
|
|
|
LwM2MTelemetryLogService logService, |
|
|
|
LwM2MSessionManager sessionManager, |
|
|
|
@Lazy LwM2MOtaUpdateService otaService, |
|
|
|
@Lazy LwM2MAttributesService attributesService, |
|
|
|
@Lazy LwM2mDownlinkMsgHandler defaultLwM2MDownlinkMsgHandler, |
|
|
|
LwM2mTransportContext context, |
|
|
|
TbLwM2MDtlsSessionStore sessionStore, |
|
|
|
LwM2mVersionedModelProvider modelProvider, |
|
|
|
RegistrationStore registrationStore, |
|
|
|
TbLwM2mSecurityStore securityStore, |
|
|
|
LwM2MModelConfigService modelConfigService) { |
|
|
|
this.transportService = transportService; |
|
|
|
this.sessionManager = sessionManager; |
|
|
|
this.attributesService = attributesService; |
|
|
|
this.otaService = otaService; |
|
|
|
this.config = config; |
|
|
|
this.helper = helper; |
|
|
|
this.clientContext = clientContext; |
|
|
|
this.logService = logService; |
|
|
|
this.defaultLwM2MDownlinkMsgHandler = defaultLwM2MDownlinkMsgHandler; |
|
|
|
this.context = context; |
|
|
|
this.sessionStore = sessionStore; |
|
|
|
this.modelProvider = modelProvider; |
|
|
|
this.registrationStore = registrationStore; |
|
|
|
this.securityStore = securityStore; |
|
|
|
this.modelConfigService = modelConfigService; |
|
|
|
} |
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
public void init() { |
|
|
|
super.init(); |
|
|
|
this.context.getScheduler().scheduleAtFixedRate(this::reportActivity, new Random().nextInt((int) config.getSessionReportTimeout()), config.getSessionReportTimeout(), TimeUnit.MILLISECONDS); |
|
|
|
this.converter = LwM2mValueConverterImpl.getInstance(); |
|
|
|
} |
|
|
|
|
|
|
|
@PreDestroy |
|
|
|
public void destroy() { |
|
|
|
log.trace("Destroying {}", getClass().getSimpleName()); |
|
|
|
super.destroy(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -955,6 +930,7 @@ public class DefaultLwM2mUplinkMsgHandler extends LwM2MExecutorAwareService impl |
|
|
|
* |
|
|
|
* @param lwM2MClient - LwM2M Client |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void initAttributes(LwM2mClient lwM2MClient, boolean logFailedUpdateOfNonChangedValue) { |
|
|
|
Map<String, String> keyNamesMap = this.getNamesFromProfileForSharedAttributes(lwM2MClient); |
|
|
|
if (!keyNamesMap.isEmpty()) { |
|
|
|
|