Skip to content

Commit 1f00ae8

Browse files
nickAS21ashvayka
authored andcommitted
LWM2M: del log warn
1 parent 6cace79 commit 1f00ae8

7 files changed

Lines changed: 92 additions & 75 deletions

File tree

common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/DefaultLwM2MTransportMsgHandler.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.convertPathFromIdVerToObjectId;
115115
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.convertPathFromObjectIdToIdVer;
116116
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.getAckCallback;
117+
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.isFwSwWords;
117118
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.setValidTypeOper;
118119
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.validateObjectVerFromKey;
119120

@@ -356,7 +357,6 @@ public void onAttributeUpdate(AttributeUpdateNotificationMsg msg, TransportProto
356357
String pathName = tsKvProto.getKv().getKey();
357358
String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, pathName);
358359
Object valueNew = getValueFromKvProto(tsKvProto.getKv());
359-
log.warn("12) Shared AttributeUpdate start pathName [{}], pathIdVer [{}], valueNew [{}]", pathName, pathIdVer, valueNew);
360360
if ((FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.VERSION).equals(pathName)
361361
&& (!valueNew.equals(lwM2MClient.getFwUpdate().getCurrentVersion())))
362362
|| (FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.TITLE).equals(pathName)
@@ -379,7 +379,7 @@ public void onAttributeUpdate(AttributeUpdateNotificationMsg msg, TransportProto
379379
LOG_LW2M_ERROR, pathIdVer, valueNew);
380380
this.sendLogsToThingsboard(logMsg, lwM2MClient.getRegistration().getId());
381381
}
382-
} else {
382+
} else if (!isFwSwWords(pathName)) {
383383
log.error("Resource name name - [{}] value - [{}] is not present as attribute/telemetry in profile and cannot be updated", pathName, valueNew);
384384
String logMsg = String.format("%s: attributeUpdate: attribute name - %s value - %s is not present as attribute in profile and cannot be updated",
385385
LOG_LW2M_ERROR, pathName, valueNew);
@@ -446,7 +446,6 @@ public void onToDeviceRpcRequest(TransportProtos.ToDeviceRpcRequestMsg toDeviceR
446446
String bodyParams = StringUtils.trimToNull(toDeviceRpcRequestMsg.getParams()) != null ? toDeviceRpcRequestMsg.getParams() : "null";
447447
LwM2mTypeOper lwM2mTypeOper = setValidTypeOper(toDeviceRpcRequestMsg.getMethodName());
448448
UUID requestUUID = new UUID(toDeviceRpcRequestMsg.getRequestIdMSB(), toDeviceRpcRequestMsg.getRequestIdLSB());
449-
log.warn("4) RPC-OK finish to [{}], keys: [{}]", requestUUID, this.rpcSubscriptions.keySet());
450449
if (!this.rpcSubscriptions.containsKey(requestUUID)) {
451450
this.rpcSubscriptions.put(requestUUID, toDeviceRpcRequestMsg.getExpirationTime());
452451
Lwm2mClientRpcRequest lwm2mClientRpcRequest = null;
@@ -647,7 +646,7 @@ private void updateResourcesValue(Registration registration, LwM2mResource lwM2m
647646
* set setClient_fw_info... = value
648647
**/
649648
if (lwM2MClient.getFwUpdate().isInfoFwSwUpdate()) {
650-
lwM2MClient.getFwUpdate().initReadValue(this, this.lwM2mTransportRequest, path);
649+
lwM2MClient.getFwUpdate().initReadValue(this, this.lwM2mTransportRequest, path);
651650
}
652651
if (lwM2MClient.getSwUpdate().isInfoFwSwUpdate()) {
653652
lwM2MClient.getSwUpdate().initReadValue(this, this.lwM2mTransportRequest, path);
@@ -1229,7 +1228,6 @@ public String getPresentPathIntoProfile(TransportProtos.SessionInfoProto session
12291228
public void onGetAttributesResponse(TransportProtos.GetAttributeResponseMsg attributesResponse, TransportProtos.SessionInfoProto sessionInfo) {
12301229
try {
12311230
List<TransportProtos.TsKvProto> tsKvProtos = attributesResponse.getSharedAttributeListList();
1232-
12331231
this.updateAttributeFromThingsboard(tsKvProtos, sessionInfo);
12341232
} catch (Exception e) {
12351233
log.error("", e);
@@ -1346,7 +1344,6 @@ public void getInfoFirmwareUpdate(LwM2mClient lwM2MClient) {
13461344
if (lwM2MClient.getRegistration().getSupportedVersion(FW_ID) != null) {
13471345
SessionInfoProto sessionInfo = this.getSessionInfoOrCloseSession(lwM2MClient);
13481346
if (sessionInfo != null) {
1349-
DefaultLwM2MTransportMsgHandler serviceImpl = this;
13501347
transportService.process(sessionInfo, createFirmwareRequestMsg(sessionInfo, FirmwareType.FIRMWARE.name()),
13511348
new TransportServiceCallback<>() {
13521349
@Override

common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mNetworkConfig.java

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,26 @@ public static NetworkConfig getCoapConfig(Integer serverPortNoSec, Integer serve
2323
NetworkConfig coapConfig = new NetworkConfig();
2424
coapConfig.setInt(NetworkConfig.Keys.COAP_PORT,serverPortNoSec);
2525
coapConfig.setInt(NetworkConfig.Keys.COAP_SECURE_PORT,serverSecurePort);
26-
/*
27-
Example:Property for large packet:
28-
#NetworkConfig config = new NetworkConfig();
29-
#config.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE,32);
30-
#config.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE,32);
31-
#config.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE,2048);
32-
#config.setInt(NetworkConfig.Keys.MAX_RETRANSMIT,3);
33-
#config.setInt(NetworkConfig.Keys.MAX_TRANSMIT_WAIT,120000);
26+
/**
27+
Example:Property for large packet:
28+
#NetworkConfig config = new NetworkConfig();
29+
#config.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE,32);
30+
#config.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE,32);
31+
#config.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE,2048);
32+
#config.setInt(NetworkConfig.Keys.MAX_RETRANSMIT,3);
33+
#config.setInt(NetworkConfig.Keys.MAX_TRANSMIT_WAIT,120000);
3434
*/
3535

36-
/*
37-
Property to indicate if the response should always include the Block2 option \
38-
when client request early blockwise negociation but the response can be sent on one packet.
39-
- value of false indicate that the server will respond without block2 option if no further blocks are required.
40-
- value of true indicate that the server will response with block2 option event if no further blocks are required.
41-
CoAP client will try to use block mode
42-
or adapt the block size when receiving a 4.13 Entity too large response code
36+
/**
37+
Property to indicate if the response should always include the Block2 option \
38+
when client request early blockwise negociation but the response can be sent on one packet.
39+
- value of false indicate that the server will respond without block2 option if no further blocks are required.
40+
- value of true indicate that the server will response with block2 option event if no further blocks are required.
41+
CoAP client will try to use block mode
42+
or adapt the block size when receiving a 4.13 Entity too large response code
4343
*/
4444
coapConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_STRICT_BLOCK2_OPTION, true);
45-
/*
45+
/**
4646
Property to indicate if the response should always include the Block2 option \
4747
when client request early blockwise negociation but the response can be sent on one packet.
4848
- value of false indicate that the server will respond without block2 option if no further blocks are required.
@@ -51,49 +51,49 @@ public static NetworkConfig getCoapConfig(Integer serverPortNoSec, Integer serve
5151
coapConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_ENTITY_TOO_LARGE_AUTO_FAILOVER, true);
5252

5353
coapConfig.setInt(NetworkConfig.Keys.BLOCKWISE_STATUS_LIFETIME, 300000);
54-
/*
55-
!!! REQUEST_ENTITY_TOO_LARGE CODE=4.13
56-
The maximum size of a resource body (in bytes) that will be accepted
57-
as the payload of a POST/PUT or the response to a GET request in a
58-
transparent> blockwise transfer.
59-
This option serves as a safeguard against excessive memory
60-
consumption when many resources contain large bodies that cannot be
61-
transferred in a single CoAP message. This option has no impact on
62-
*manually* managed blockwise transfers in which the blocks are handled individually.
63-
Note that this option does not prevent local clients or resource
64-
implementations from sending large bodies as part of a request or response to a peer.
65-
The default value of this property is DEFAULT_MAX_RESOURCE_BODY_SIZE = 8192
66-
A value of {@code 0} turns off transparent handling of blockwise transfers altogether.
54+
/**
55+
!!! REQUEST_ENTITY_TOO_LARGE CODE=4.13
56+
The maximum size of a resource body (in bytes) that will be accepted
57+
as the payload of a POST/PUT or the response to a GET request in a
58+
transparent> blockwise transfer.
59+
This option serves as a safeguard against excessive memory
60+
consumption when many resources contain large bodies that cannot be
61+
transferred in a single CoAP message. This option has no impact on
62+
*manually* managed blockwise transfers in which the blocks are handled individually.
63+
Note that this option does not prevent local clients or resource
64+
implementations from sending large bodies as part of a request or response to a peer.
65+
The default value of this property is DEFAULT_MAX_RESOURCE_BODY_SIZE = 8192
66+
A value of {@code 0} turns off transparent handling of blockwise transfers altogether.
6767
*/
6868
coapConfig.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE, 256 * 1024 * 1024);
69-
/*
70-
The default DTLS response matcher.
71-
Supported values are STRICT, RELAXED, or PRINCIPAL.
72-
The default value is STRICT.
73-
Create new instance of udp endpoint context matcher.
74-
Params:
75-
checkAddress
76-
– true with address check, (STRICT, UDP)
77-
- false, without
69+
/**
70+
The default DTLS response matcher.
71+
Supported values are STRICT, RELAXED, or PRINCIPAL.
72+
The default value is STRICT.
73+
Create new instance of udp endpoint context matcher.
74+
Params:
75+
checkAddress
76+
– true with address check, (STRICT, UDP)
77+
- false, without
7878
*/
7979
coapConfig.setString(NetworkConfig.Keys.RESPONSE_MATCHING, "STRICT");
80-
/*
81-
https://tools.ietf.org/html/rfc7959#section-2.9.3
82-
The block size (number of bytes) to use when doing a blockwise transfer. \
83-
This value serves as the upper limit for block size in blockwise transfers
80+
/**
81+
https://tools.ietf.org/html/rfc7959#section-2.9.3
82+
The block size (number of bytes) to use when doing a blockwise transfer. \
83+
This value serves as the upper limit for block size in blockwise transfers
8484
*/
8585
coapConfig.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE, 1024);
86-
/*
87-
The maximum payload size (in bytes) that can be transferred in a
88-
single message, i.e. without requiring a blockwise transfer.
89-
NB: this value MUST be adapted to the maximum message size supported by the transport layer.
90-
In particular, this value cannot exceed the network's MTU if UDP is used as the transport protocol
91-
DEFAULT_VALUE = 1024
86+
/**
87+
The maximum payload size (in bytes) that can be transferred in a
88+
single message, i.e. without requiring a blockwise transfer.
89+
NB: this value MUST be adapted to the maximum message size supported by the transport layer.
90+
In particular, this value cannot exceed the network's MTU if UDP is used as the transport protocol
91+
DEFAULT_VALUE = 1024
9292
*/
9393
coapConfig.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE, 1024);
9494

9595
coapConfig.setInt(NetworkConfig.Keys.MAX_RETRANSMIT, 4);
9696

9797
return coapConfig;
9898
}
99-
}
99+
}

common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportUtil.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@
4343
import org.nustaq.serialization.FSTConfiguration;
4444
import org.thingsboard.server.common.data.DeviceProfile;
4545
import org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTransportConfiguration;
46+
import org.thingsboard.server.common.data.firmware.FirmwareKey;
47+
import org.thingsboard.server.common.data.firmware.FirmwareType;
4648
import org.thingsboard.server.common.data.firmware.FirmwareUpdateStatus;
49+
import org.thingsboard.server.common.data.firmware.FirmwareUtil;
4750
import org.thingsboard.server.common.data.id.TenantId;
4851
import org.thingsboard.server.common.transport.TransportServiceCallback;
4952
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient;
@@ -927,4 +930,17 @@ private static Attribute createAttribute(String key, Object attrValue) {
927930
return null;
928931
}
929932
}
933+
934+
public static boolean isFwSwWords (String pathName) {
935+
return FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.VERSION).equals(pathName)
936+
|| FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.TITLE).equals(pathName)
937+
|| FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.CHECKSUM).equals(pathName)
938+
|| FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.CHECKSUM_ALGORITHM).equals(pathName)
939+
|| FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.SIZE).equals(pathName)
940+
|| FirmwareUtil.getAttributeKey(FirmwareType.SOFTWARE, FirmwareKey.VERSION).equals(pathName)
941+
|| FirmwareUtil.getAttributeKey(FirmwareType.SOFTWARE, FirmwareKey.TITLE).equals(pathName)
942+
|| FirmwareUtil.getAttributeKey(FirmwareType.SOFTWARE, FirmwareKey.CHECKSUM).equals(pathName)
943+
|| FirmwareUtil.getAttributeKey(FirmwareType.SOFTWARE, FirmwareKey.CHECKSUM_ALGORITHM).equals(pathName)
944+
|| FirmwareUtil.getAttributeKey(FirmwareType.SOFTWARE, FirmwareKey.SIZE).equals(pathName);
945+
}
930946
}

common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mClientContextImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public LwM2mClient fetchClientByEndpoint(String endpoint) {
116116
securityInfo.getDeviceProfile().getUuidId() : null;
117117
// TODO: for tests bug.
118118
if (profileUuid== null) {
119-
log.warn("input parameters toClientProfile if the result is null: [{}]", securityInfo.getDeviceProfile());
119+
log.trace("input parameters toClientProfile if the result is null: [{}]", securityInfo.getDeviceProfile());
120120
}
121121
LwM2mClient client;
122122
if (securityInfo.getSecurityInfo() != null) {

common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mFwSwUpdate.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,13 @@ public void executeFwSwWare(DefaultLwM2MTransportMsgHandler handler, LwM2mTransp
188188
null, 0, null);
189189
}
190190

191-
192191
/**
193192
* Firmware start:
194-
* -- Если Update Result -errors (более 1) - Это означает что пред. апдейт не прошел.
195-
* - Запускаем апдейт в независимости от состяния прошивки и ее версии.
196-
* -- Если Update Result - не errors (менее или равно 1) и ver не пустой - Это означает что пред. апдейт прошел.
197-
* -- Если Update Result - не errors и ver пустой - Это означает что апдейта еще не было.
198-
* - Проверяем поменялась ли версия и запускаем новый апдейт.
193+
* -- If the result of the update - errors (more than 1) - This means that the previous. the update failed.
194+
* - We launch the update regardless of the state of the firmware and its version.
195+
* -- 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.
196+
* -- If the result of the update is not errors and is empty - This means that there has not been an update yet.
197+
* - Check if the version has changed and launch a new update.
199198
*/
200199
private boolean conditionalFwUpdateStart() {
201200
Long updateResultFw = (Long) this.lwM2MClient.getResourceValue(null, this.pathResultId);
@@ -241,12 +240,12 @@ public boolean conditionalFwExecuteAfterError() {
241240

242241
/**
243242
* Software start
244-
* -- Если Update Result -errors (равно и более 50) - Это означает что пред. апдейт не прошел.
245-
* * - Запускаем апдейт в независимости от состяния прошивки и ее версии.
246-
* -- Если Update Result - не errors (менее 50) и ver не пустой - Это означает что пред. апдейт прошел.
247-
* -- Если Update Result - не errors и ver пустой - Это означает что апдейта еще не было или пред. апдейт UnInstall
248-
* -- Если Update Result - не errors и ver не пустой - Это означает что пред. апдейт UnInstall
249-
* - Проверяем поменялась ли версия и запускаем новый апдейт.
243+
* - If Update Result -errors (equal or more than 50) - This means that the previous. the update failed.
244+
* * - We launch the update regardless of the state of the firmware and its version.
245+
* - If Update Result is not errors (less than 50) and ver is not empty - This means that before. the update has passed.
246+
* - If Update Result is not errors and ver is empty - This means that there was no update yet or before. UnInstall update
247+
* - If Update Result is not errors and ver is not empty - This means that before unInstall update
248+
* * - Check if the version has changed and launch a new update.
250249
*/
251250
private boolean conditionalSwUpdateStart() {
252251
Long updateResultSw = (Long) this.lwM2MClient.getResourceValue(null, this.pathResultId);

common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/store/TbLwM2mRedisRegistrationStore.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ public UpdatedRegistration updateRegistration(RegistrationUpdate update) {
214214
// Add or update expiration
215215
addOrUpdateExpiration(connection, updatedRegistration);
216216

217-
// Update secondary index :
218-
// If registration is already associated to this address we don't care as we only want to keep the most
219-
// recent binding.
217+
/** Update secondary index :
218+
* If registration is already associated to this address we don't care as we only want to keep the most
219+
* recent binding. */
220220
byte[] addr_idx = toRegAddrKey(updatedRegistration.getSocketAddress());
221221
connection.set(addr_idx, updatedRegistration.getEndpoint().getBytes(UTF_8));
222222
if (!r.getSocketAddress().equals(updatedRegistration.getSocketAddress())) {

0 commit comments

Comments
 (0)