|
|
|
@ -18,14 +18,13 @@ package org.thingsboard.server.transport.coap.client; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.eclipse.californium.core.coap.CoAP; |
|
|
|
import org.eclipse.californium.core.coap.MediaTypeRegistry; |
|
|
|
import org.eclipse.californium.core.coap.Response; |
|
|
|
import org.eclipse.californium.core.observe.ObserveRelation; |
|
|
|
import org.eclipse.californium.core.server.resources.CoapExchange; |
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.thingsboard.server.coapserver.CoapServerContext; |
|
|
|
import org.thingsboard.server.coapserver.TbCoapServerComponent; |
|
|
|
import org.thingsboard.server.common.data.DataConstants; |
|
|
|
import org.thingsboard.server.common.data.Device; |
|
|
|
import org.thingsboard.server.common.data.DeviceProfile; |
|
|
|
import org.thingsboard.server.common.data.DeviceTransportType; |
|
|
|
@ -51,6 +50,7 @@ import org.thingsboard.server.common.transport.adaptor.AdaptorException; |
|
|
|
import org.thingsboard.server.common.transport.auth.SessionInfoCreator; |
|
|
|
import org.thingsboard.server.common.transport.auth.ValidateDeviceCredentialsResponse; |
|
|
|
import org.thingsboard.server.gen.transport.TransportProtos; |
|
|
|
import org.thingsboard.server.queue.discovery.PartitionService; |
|
|
|
import org.thingsboard.server.transport.coap.CoapTransportContext; |
|
|
|
import org.thingsboard.server.transport.coap.TbCoapMessageObserver; |
|
|
|
import org.thingsboard.server.transport.coap.TransportConfigurationContainer; |
|
|
|
@ -81,6 +81,7 @@ public class DefaultCoapClientContext implements CoapClientContext { |
|
|
|
private final CoapTransportContext transportContext; |
|
|
|
private final TransportService transportService; |
|
|
|
private final TransportDeviceProfileCache profileCache; |
|
|
|
private final PartitionService partitionService; |
|
|
|
private final ConcurrentMap<DeviceId, TbCoapClientState> clients = new ConcurrentHashMap<>(); |
|
|
|
private final ConcurrentMap<String, TbCoapClientState> clientsByToken = new ConcurrentHashMap<>(); |
|
|
|
|
|
|
|
@ -214,7 +215,7 @@ public class DefaultCoapClientContext implements CoapClientContext { |
|
|
|
return null; |
|
|
|
}, timeout, TimeUnit.MILLISECONDS); |
|
|
|
client.setSleepTask(task); |
|
|
|
if (notifyOtherServers) { |
|
|
|
if (notifyOtherServers && partitionService.countTransportsByType(DataConstants.COAP_TRANSPORT_NAME) > 1) { |
|
|
|
transportService.notifyAboutUplink(getNewSyncSession(client), TransportProtos.UplinkNotificationMsg.newBuilder().setUplinkTs(uplinkTime).build(), TransportServiceCallback.EMPTY); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
|