lwm2m/coap: client queue Mode
This commit is contained in:
parent
cb674048e7
commit
9cdcad8775
@ -18,7 +18,6 @@ package org.thingsboard.server.transport.coap.client;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.californium.core.coap.CoAP;
|
import org.eclipse.californium.core.coap.CoAP;
|
||||||
import org.eclipse.californium.core.coap.CoAP.ResponseCode;
|
|
||||||
import org.eclipse.californium.core.coap.Response;
|
import org.eclipse.californium.core.coap.Response;
|
||||||
import org.eclipse.californium.core.observe.ObserveRelation;
|
import org.eclipse.californium.core.observe.ObserveRelation;
|
||||||
import org.eclipse.californium.core.server.resources.CoapExchange;
|
import org.eclipse.californium.core.server.resources.CoapExchange;
|
||||||
@ -222,7 +221,7 @@ public class DefaultCoapClientContext implements CoapClientContext {
|
|||||||
private void onUplink(TbCoapClientState client, boolean notifyOtherServers, long uplinkTs) {
|
private void onUplink(TbCoapClientState client, boolean notifyOtherServers, long uplinkTs) {
|
||||||
PowerMode powerMode = client.getPowerMode();
|
PowerMode powerMode = client.getPowerMode();
|
||||||
PowerSavingConfiguration profileSettings = null;
|
PowerSavingConfiguration profileSettings = null;
|
||||||
if (powerMode == null) {
|
if (powerMode == null && client.getProfileId() != null) {
|
||||||
var clientProfile = getProfile(client.getProfileId());
|
var clientProfile = getProfile(client.getProfileId());
|
||||||
if (clientProfile.isPresent()) {
|
if (clientProfile.isPresent()) {
|
||||||
profileSettings = clientProfile.get().getClientSettings();
|
profileSettings = clientProfile.get().getClientSettings();
|
||||||
@ -736,7 +735,7 @@ public class DefaultCoapClientContext implements CoapClientContext {
|
|||||||
private boolean isDownlinkAllowed(TbCoapClientState client) {
|
private boolean isDownlinkAllowed(TbCoapClientState client) {
|
||||||
PowerMode powerMode = client.getPowerMode();
|
PowerMode powerMode = client.getPowerMode();
|
||||||
PowerSavingConfiguration profileSettings = null;
|
PowerSavingConfiguration profileSettings = null;
|
||||||
if (powerMode == null) {
|
if (powerMode == null && client.getProfileId() != null) {
|
||||||
var clientProfile = getProfile(client.getProfileId());
|
var clientProfile = getProfile(client.getProfileId());
|
||||||
if (clientProfile.isPresent()) {
|
if (clientProfile.isPresent()) {
|
||||||
profileSettings = clientProfile.get().getClientSettings();
|
profileSettings = clientProfile.get().getClientSettings();
|
||||||
@ -785,11 +784,12 @@ public class DefaultCoapClientContext implements CoapClientContext {
|
|||||||
private PowerMode getPowerMode(TbCoapClientState client) {
|
private PowerMode getPowerMode(TbCoapClientState client) {
|
||||||
PowerMode powerMode = client.getPowerMode();
|
PowerMode powerMode = client.getPowerMode();
|
||||||
if (powerMode == null) {
|
if (powerMode == null) {
|
||||||
|
powerMode = PowerMode.PSM;
|
||||||
|
if (client.getProfileId() != null) {
|
||||||
Optional<CoapDeviceProfileTransportConfiguration> deviceProfile = getProfile(client.getProfileId());
|
Optional<CoapDeviceProfileTransportConfiguration> deviceProfile = getProfile(client.getProfileId());
|
||||||
if (deviceProfile.isPresent()) {
|
if (deviceProfile.isPresent()) {
|
||||||
powerMode = deviceProfile.get().getClientSettings().getPowerMode();
|
powerMode = deviceProfile.get().getClientSettings().getPowerMode();
|
||||||
} else {
|
}
|
||||||
powerMode = PowerMode.PSM;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return powerMode;
|
return powerMode;
|
||||||
|
|||||||
@ -411,15 +411,12 @@ public class LwM2mClientContextImpl implements LwM2mClientContext {
|
|||||||
public boolean isDownlinkAllowed(LwM2mClient client) {
|
public boolean isDownlinkAllowed(LwM2mClient client) {
|
||||||
PowerMode powerMode = client.getPowerMode();
|
PowerMode powerMode = client.getPowerMode();
|
||||||
OtherConfiguration profileSettings = null;
|
OtherConfiguration profileSettings = null;
|
||||||
if (powerMode == null) {
|
if (powerMode == null && client.getProfileId() != null) {
|
||||||
var clientProfile = getProfile(client.getProfileId());
|
var clientProfile = getProfile(client.getProfileId());
|
||||||
profileSettings = clientProfile.getClientLwM2mSettings();
|
profileSettings = clientProfile.getClientLwM2mSettings();
|
||||||
powerMode = profileSettings.getPowerMode();
|
powerMode = profileSettings.getPowerMode();
|
||||||
if (powerMode == null) {
|
|
||||||
powerMode = PowerMode.DRX;
|
|
||||||
}
|
}
|
||||||
}
|
if (powerMode == null || PowerMode.DRX.equals(powerMode) || otaUpdateService.isOtaDownloading(client)) {
|
||||||
if (PowerMode.DRX.equals(powerMode) || otaUpdateService.isOtaDownloading(client)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
client.lock();
|
client.lock();
|
||||||
@ -460,19 +457,12 @@ public class LwM2mClientContextImpl implements LwM2mClientContext {
|
|||||||
public void onUplink(LwM2mClient client) {
|
public void onUplink(LwM2mClient client) {
|
||||||
PowerMode powerMode = client.getPowerMode();
|
PowerMode powerMode = client.getPowerMode();
|
||||||
OtherConfiguration profileSettings = null;
|
OtherConfiguration profileSettings = null;
|
||||||
if (powerMode == null) {
|
if (powerMode == null && client.getProfileId() != null) {
|
||||||
if (client.getProfileId() == null) {
|
|
||||||
powerMode = PowerMode.DRX;
|
|
||||||
} else {
|
|
||||||
var clientProfile = getProfile(client.getProfileId());
|
var clientProfile = getProfile(client.getProfileId());
|
||||||
profileSettings = clientProfile.getClientLwM2mSettings();
|
profileSettings = clientProfile.getClientLwM2mSettings();
|
||||||
powerMode = profileSettings.getPowerMode();
|
powerMode = profileSettings.getPowerMode();
|
||||||
if (powerMode == null) {
|
|
||||||
powerMode = PowerMode.DRX;
|
|
||||||
}
|
}
|
||||||
}
|
if (powerMode == null || PowerMode.DRX.equals(powerMode)) {
|
||||||
}
|
|
||||||
if (PowerMode.DRX.equals(powerMode)) {
|
|
||||||
client.updateLastUplinkTime();
|
client.updateLastUplinkTime();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user