LWM2M: del log warn
This commit is contained in:
parent
6cace79b3c
commit
1f00ae833d
@ -114,6 +114,7 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.c
|
||||
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.convertPathFromIdVerToObjectId;
|
||||
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.convertPathFromObjectIdToIdVer;
|
||||
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.getAckCallback;
|
||||
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.isFwSwWords;
|
||||
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.setValidTypeOper;
|
||||
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.validateObjectVerFromKey;
|
||||
|
||||
@ -356,7 +357,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
|
||||
String pathName = tsKvProto.getKv().getKey();
|
||||
String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, pathName);
|
||||
Object valueNew = getValueFromKvProto(tsKvProto.getKv());
|
||||
log.warn("12) Shared AttributeUpdate start pathName [{}], pathIdVer [{}], valueNew [{}]", pathName, pathIdVer, valueNew);
|
||||
if ((FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.VERSION).equals(pathName)
|
||||
&& (!valueNew.equals(lwM2MClient.getFwUpdate().getCurrentVersion())))
|
||||
|| (FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.TITLE).equals(pathName)
|
||||
@ -379,7 +379,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
|
||||
LOG_LW2M_ERROR, pathIdVer, valueNew);
|
||||
this.sendLogsToThingsboard(logMsg, lwM2MClient.getRegistration().getId());
|
||||
}
|
||||
} else {
|
||||
} else if (!isFwSwWords(pathName)) {
|
||||
log.error("Resource name name - [{}] value - [{}] is not present as attribute/telemetry in profile and cannot be updated", pathName, valueNew);
|
||||
String logMsg = String.format("%s: attributeUpdate: attribute name - %s value - %s is not present as attribute in profile and cannot be updated",
|
||||
LOG_LW2M_ERROR, pathName, valueNew);
|
||||
@ -446,7 +446,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
|
||||
String bodyParams = StringUtils.trimToNull(toDeviceRpcRequestMsg.getParams()) != null ? toDeviceRpcRequestMsg.getParams() : "null";
|
||||
LwM2mTypeOper lwM2mTypeOper = setValidTypeOper(toDeviceRpcRequestMsg.getMethodName());
|
||||
UUID requestUUID = new UUID(toDeviceRpcRequestMsg.getRequestIdMSB(), toDeviceRpcRequestMsg.getRequestIdLSB());
|
||||
log.warn("4) RPC-OK finish to [{}], keys: [{}]", requestUUID, this.rpcSubscriptions.keySet());
|
||||
if (!this.rpcSubscriptions.containsKey(requestUUID)) {
|
||||
this.rpcSubscriptions.put(requestUUID, toDeviceRpcRequestMsg.getExpirationTime());
|
||||
Lwm2mClientRpcRequest lwm2mClientRpcRequest = null;
|
||||
@ -647,7 +646,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
|
||||
* set setClient_fw_info... = value
|
||||
**/
|
||||
if (lwM2MClient.getFwUpdate().isInfoFwSwUpdate()) {
|
||||
lwM2MClient.getFwUpdate().initReadValue(this, this.lwM2mTransportRequest, path);
|
||||
lwM2MClient.getFwUpdate().initReadValue(this, this.lwM2mTransportRequest, path);
|
||||
}
|
||||
if (lwM2MClient.getSwUpdate().isInfoFwSwUpdate()) {
|
||||
lwM2MClient.getSwUpdate().initReadValue(this, this.lwM2mTransportRequest, path);
|
||||
@ -1229,7 +1228,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
|
||||
public void onGetAttributesResponse(TransportProtos.GetAttributeResponseMsg attributesResponse, TransportProtos.SessionInfoProto sessionInfo) {
|
||||
try {
|
||||
List<TransportProtos.TsKvProto> tsKvProtos = attributesResponse.getSharedAttributeListList();
|
||||
|
||||
this.updateAttributeFromThingsboard(tsKvProtos, sessionInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
@ -1346,7 +1344,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
|
||||
if (lwM2MClient.getRegistration().getSupportedVersion(FW_ID) != null) {
|
||||
SessionInfoProto sessionInfo = this.getSessionInfoOrCloseSession(lwM2MClient);
|
||||
if (sessionInfo != null) {
|
||||
DefaultLwM2MTransportMsgHandler serviceImpl = this;
|
||||
transportService.process(sessionInfo, createFirmwareRequestMsg(sessionInfo, FirmwareType.FIRMWARE.name()),
|
||||
new TransportServiceCallback<>() {
|
||||
@Override
|
||||
|
||||
@ -23,26 +23,26 @@ public class LwM2mNetworkConfig {
|
||||
NetworkConfig coapConfig = new NetworkConfig();
|
||||
coapConfig.setInt(NetworkConfig.Keys.COAP_PORT,serverPortNoSec);
|
||||
coapConfig.setInt(NetworkConfig.Keys.COAP_SECURE_PORT,serverSecurePort);
|
||||
/*
|
||||
Example:Property for large packet:
|
||||
#NetworkConfig config = new NetworkConfig();
|
||||
#config.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE,32);
|
||||
#config.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE,32);
|
||||
#config.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE,2048);
|
||||
#config.setInt(NetworkConfig.Keys.MAX_RETRANSMIT,3);
|
||||
#config.setInt(NetworkConfig.Keys.MAX_TRANSMIT_WAIT,120000);
|
||||
/**
|
||||
Example:Property for large packet:
|
||||
#NetworkConfig config = new NetworkConfig();
|
||||
#config.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE,32);
|
||||
#config.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE,32);
|
||||
#config.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE,2048);
|
||||
#config.setInt(NetworkConfig.Keys.MAX_RETRANSMIT,3);
|
||||
#config.setInt(NetworkConfig.Keys.MAX_TRANSMIT_WAIT,120000);
|
||||
*/
|
||||
|
||||
/*
|
||||
Property to indicate if the response should always include the Block2 option \
|
||||
when client request early blockwise negociation but the response can be sent on one packet.
|
||||
- value of false indicate that the server will respond without block2 option if no further blocks are required.
|
||||
- value of true indicate that the server will response with block2 option event if no further blocks are required.
|
||||
CoAP client will try to use block mode
|
||||
or adapt the block size when receiving a 4.13 Entity too large response code
|
||||
/**
|
||||
Property to indicate if the response should always include the Block2 option \
|
||||
when client request early blockwise negociation but the response can be sent on one packet.
|
||||
- value of false indicate that the server will respond without block2 option if no further blocks are required.
|
||||
- value of true indicate that the server will response with block2 option event if no further blocks are required.
|
||||
CoAP client will try to use block mode
|
||||
or adapt the block size when receiving a 4.13 Entity too large response code
|
||||
*/
|
||||
coapConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_STRICT_BLOCK2_OPTION, true);
|
||||
/*
|
||||
/**
|
||||
Property to indicate if the response should always include the Block2 option \
|
||||
when client request early blockwise negociation but the response can be sent on one packet.
|
||||
- value of false indicate that the server will respond without block2 option if no further blocks are required.
|
||||
@ -51,44 +51,44 @@ public class LwM2mNetworkConfig {
|
||||
coapConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_ENTITY_TOO_LARGE_AUTO_FAILOVER, true);
|
||||
|
||||
coapConfig.setInt(NetworkConfig.Keys.BLOCKWISE_STATUS_LIFETIME, 300000);
|
||||
/*
|
||||
!!! REQUEST_ENTITY_TOO_LARGE CODE=4.13
|
||||
The maximum size of a resource body (in bytes) that will be accepted
|
||||
as the payload of a POST/PUT or the response to a GET request in a
|
||||
transparent> blockwise transfer.
|
||||
This option serves as a safeguard against excessive memory
|
||||
consumption when many resources contain large bodies that cannot be
|
||||
transferred in a single CoAP message. This option has no impact on
|
||||
*manually* managed blockwise transfers in which the blocks are handled individually.
|
||||
Note that this option does not prevent local clients or resource
|
||||
implementations from sending large bodies as part of a request or response to a peer.
|
||||
The default value of this property is DEFAULT_MAX_RESOURCE_BODY_SIZE = 8192
|
||||
A value of {@code 0} turns off transparent handling of blockwise transfers altogether.
|
||||
/**
|
||||
!!! REQUEST_ENTITY_TOO_LARGE CODE=4.13
|
||||
The maximum size of a resource body (in bytes) that will be accepted
|
||||
as the payload of a POST/PUT or the response to a GET request in a
|
||||
transparent> blockwise transfer.
|
||||
This option serves as a safeguard against excessive memory
|
||||
consumption when many resources contain large bodies that cannot be
|
||||
transferred in a single CoAP message. This option has no impact on
|
||||
*manually* managed blockwise transfers in which the blocks are handled individually.
|
||||
Note that this option does not prevent local clients or resource
|
||||
implementations from sending large bodies as part of a request or response to a peer.
|
||||
The default value of this property is DEFAULT_MAX_RESOURCE_BODY_SIZE = 8192
|
||||
A value of {@code 0} turns off transparent handling of blockwise transfers altogether.
|
||||
*/
|
||||
coapConfig.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE, 256 * 1024 * 1024);
|
||||
/*
|
||||
The default DTLS response matcher.
|
||||
Supported values are STRICT, RELAXED, or PRINCIPAL.
|
||||
The default value is STRICT.
|
||||
Create new instance of udp endpoint context matcher.
|
||||
Params:
|
||||
checkAddress
|
||||
– true with address check, (STRICT, UDP)
|
||||
- false, without
|
||||
/**
|
||||
The default DTLS response matcher.
|
||||
Supported values are STRICT, RELAXED, or PRINCIPAL.
|
||||
The default value is STRICT.
|
||||
Create new instance of udp endpoint context matcher.
|
||||
Params:
|
||||
checkAddress
|
||||
– true with address check, (STRICT, UDP)
|
||||
- false, without
|
||||
*/
|
||||
coapConfig.setString(NetworkConfig.Keys.RESPONSE_MATCHING, "STRICT");
|
||||
/*
|
||||
https://tools.ietf.org/html/rfc7959#section-2.9.3
|
||||
The block size (number of bytes) to use when doing a blockwise transfer. \
|
||||
This value serves as the upper limit for block size in blockwise transfers
|
||||
/**
|
||||
https://tools.ietf.org/html/rfc7959#section-2.9.3
|
||||
The block size (number of bytes) to use when doing a blockwise transfer. \
|
||||
This value serves as the upper limit for block size in blockwise transfers
|
||||
*/
|
||||
coapConfig.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE, 1024);
|
||||
/*
|
||||
The maximum payload size (in bytes) that can be transferred in a
|
||||
single message, i.e. without requiring a blockwise transfer.
|
||||
NB: this value MUST be adapted to the maximum message size supported by the transport layer.
|
||||
In particular, this value cannot exceed the network's MTU if UDP is used as the transport protocol
|
||||
DEFAULT_VALUE = 1024
|
||||
/**
|
||||
The maximum payload size (in bytes) that can be transferred in a
|
||||
single message, i.e. without requiring a blockwise transfer.
|
||||
NB: this value MUST be adapted to the maximum message size supported by the transport layer.
|
||||
In particular, this value cannot exceed the network's MTU if UDP is used as the transport protocol
|
||||
DEFAULT_VALUE = 1024
|
||||
*/
|
||||
coapConfig.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE, 1024);
|
||||
|
||||
|
||||
@ -43,7 +43,10 @@ import org.eclipse.leshan.server.registration.Registration;
|
||||
import org.nustaq.serialization.FSTConfiguration;
|
||||
import org.thingsboard.server.common.data.DeviceProfile;
|
||||
import org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTransportConfiguration;
|
||||
import org.thingsboard.server.common.data.firmware.FirmwareKey;
|
||||
import org.thingsboard.server.common.data.firmware.FirmwareType;
|
||||
import org.thingsboard.server.common.data.firmware.FirmwareUpdateStatus;
|
||||
import org.thingsboard.server.common.data.firmware.FirmwareUtil;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.transport.TransportServiceCallback;
|
||||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient;
|
||||
@ -927,4 +930,17 @@ public class LwM2mTransportUtil {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFwSwWords (String pathName) {
|
||||
return FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.VERSION).equals(pathName)
|
||||
|| FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.TITLE).equals(pathName)
|
||||
|| FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.CHECKSUM).equals(pathName)
|
||||
|| FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.CHECKSUM_ALGORITHM).equals(pathName)
|
||||
|| FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.SIZE).equals(pathName)
|
||||
|| FirmwareUtil.getAttributeKey(FirmwareType.SOFTWARE, FirmwareKey.VERSION).equals(pathName)
|
||||
|| FirmwareUtil.getAttributeKey(FirmwareType.SOFTWARE, FirmwareKey.TITLE).equals(pathName)
|
||||
|| FirmwareUtil.getAttributeKey(FirmwareType.SOFTWARE, FirmwareKey.CHECKSUM).equals(pathName)
|
||||
|| FirmwareUtil.getAttributeKey(FirmwareType.SOFTWARE, FirmwareKey.CHECKSUM_ALGORITHM).equals(pathName)
|
||||
|| FirmwareUtil.getAttributeKey(FirmwareType.SOFTWARE, FirmwareKey.SIZE).equals(pathName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public class LwM2mClientContextImpl implements LwM2mClientContext {
|
||||
securityInfo.getDeviceProfile().getUuidId() : null;
|
||||
// TODO: for tests bug.
|
||||
if (profileUuid== null) {
|
||||
log.warn("input parameters toClientProfile if the result is null: [{}]", securityInfo.getDeviceProfile());
|
||||
log.trace("input parameters toClientProfile if the result is null: [{}]", securityInfo.getDeviceProfile());
|
||||
}
|
||||
LwM2mClient client;
|
||||
if (securityInfo.getSecurityInfo() != null) {
|
||||
|
||||
@ -188,14 +188,13 @@ public class LwM2mFwSwUpdate {
|
||||
null, 0, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Firmware start:
|
||||
* -- Если Update Result -errors (более 1) - Это означает что пред. апдейт не прошел.
|
||||
* - Запускаем апдейт в независимости от состяния прошивки и ее версии.
|
||||
* -- Если Update Result - не errors (менее или равно 1) и ver не пустой - Это означает что пред. апдейт прошел.
|
||||
* -- Если Update Result - не errors и ver пустой - Это означает что апдейта еще не было.
|
||||
* - Проверяем поменялась ли версия и запускаем новый апдейт.
|
||||
* -- If the result of the update - errors (more than 1) - This means that the previous. the update failed.
|
||||
* - We launch the update regardless of the state of the firmware and its version.
|
||||
* -- If the result of the update is not errors (equal to 1 or 0) and ver is not empty - This means that before the update has passed.
|
||||
* -- If the result of the update is not errors and is empty - This means that there has not been an update yet.
|
||||
* - Check if the version has changed and launch a new update.
|
||||
*/
|
||||
private boolean conditionalFwUpdateStart() {
|
||||
Long updateResultFw = (Long) this.lwM2MClient.getResourceValue(null, this.pathResultId);
|
||||
@ -241,12 +240,12 @@ public class LwM2mFwSwUpdate {
|
||||
|
||||
/**
|
||||
* Software start
|
||||
* -- Если Update Result -errors (равно и более 50) - Это означает что пред. апдейт не прошел.
|
||||
* * - Запускаем апдейт в независимости от состяния прошивки и ее версии.
|
||||
* -- Если Update Result - не errors (менее 50) и ver не пустой - Это означает что пред. апдейт прошел.
|
||||
* -- Если Update Result - не errors и ver пустой - Это означает что апдейта еще не было или пред. апдейт UnInstall
|
||||
* -- Если Update Result - не errors и ver не пустой - Это означает что пред. апдейт UnInstall
|
||||
* - Проверяем поменялась ли версия и запускаем новый апдейт.
|
||||
* - If Update Result -errors (equal or more than 50) - This means that the previous. the update failed.
|
||||
* * - We launch the update regardless of the state of the firmware and its version.
|
||||
* - If Update Result is not errors (less than 50) and ver is not empty - This means that before. the update has passed.
|
||||
* - If Update Result is not errors and ver is empty - This means that there was no update yet or before. UnInstall update
|
||||
* - If Update Result is not errors and ver is not empty - This means that before unInstall update
|
||||
* * - Check if the version has changed and launch a new update.
|
||||
*/
|
||||
private boolean conditionalSwUpdateStart() {
|
||||
Long updateResultSw = (Long) this.lwM2MClient.getResourceValue(null, this.pathResultId);
|
||||
|
||||
@ -214,9 +214,9 @@ public class TbLwM2mRedisRegistrationStore implements CaliforniumRegistrationSto
|
||||
// Add or update expiration
|
||||
addOrUpdateExpiration(connection, updatedRegistration);
|
||||
|
||||
// Update secondary index :
|
||||
// If registration is already associated to this address we don't care as we only want to keep the most
|
||||
// recent binding.
|
||||
/** Update secondary index :
|
||||
* If registration is already associated to this address we don't care as we only want to keep the most
|
||||
* recent binding. */
|
||||
byte[] addr_idx = toRegAddrKey(updatedRegistration.getSocketAddress());
|
||||
connection.set(addr_idx, updatedRegistration.getEndpoint().getBytes(UTF_8));
|
||||
if (!r.getSocketAddress().equals(updatedRegistration.getSocketAddress())) {
|
||||
|
||||
@ -32,6 +32,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.server.common.data.Customer;
|
||||
import org.thingsboard.server.common.data.Device;
|
||||
import org.thingsboard.server.common.data.DeviceInfo;
|
||||
@ -80,7 +81,6 @@ import org.thingsboard.server.dao.service.DataValidator;
|
||||
import org.thingsboard.server.dao.service.PaginatedRemover;
|
||||
import org.thingsboard.server.dao.tenant.TbTenantProfileCache;
|
||||
import org.thingsboard.server.dao.tenant.TenantDao;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
@ -200,11 +200,16 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe
|
||||
Device savedDevice = this.saveDeviceWithoutCredentials(device);
|
||||
deviceCredentials.setDeviceId(savedDevice.getId());
|
||||
if (device.getId() == null) {
|
||||
deviceCredentials = deviceCredentialsService.createDeviceCredentials(savedDevice.getTenantId(), deviceCredentials);
|
||||
deviceCredentialsService.createDeviceCredentials(savedDevice.getTenantId(), deviceCredentials);
|
||||
}
|
||||
else {
|
||||
deviceCredentials.setId(deviceCredentialsService.findDeviceCredentialsByDeviceId(device.getTenantId(), savedDevice.getId()).getId());
|
||||
deviceCredentials = deviceCredentialsService.updateDeviceCredentials(device.getTenantId(), deviceCredentials);
|
||||
DeviceCredentials foundDeviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(device.getTenantId(), savedDevice.getId());
|
||||
if (foundDeviceCredentials == null) {
|
||||
deviceCredentialsService.createDeviceCredentials(savedDevice.getTenantId(), deviceCredentials);
|
||||
}
|
||||
else {
|
||||
deviceCredentialsService.updateDeviceCredentials(device.getTenantId(), deviceCredentials);
|
||||
}
|
||||
}
|
||||
return savedDevice;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user