Commit 1f00ae833dcadb668a5b3314e191d8f3023fb848
Committed by
Andrew Shvayka
1 parent
6cace79b
LWM2M: del log warn
Showing
7 changed files
with
92 additions
and
75 deletions
@@ -114,6 +114,7 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.c | @@ -114,6 +114,7 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.c | ||
114 | import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.convertPathFromIdVerToObjectId; | 114 | import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.convertPathFromIdVerToObjectId; |
115 | import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.convertPathFromObjectIdToIdVer; | 115 | import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.convertPathFromObjectIdToIdVer; |
116 | import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.getAckCallback; | 116 | import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.getAckCallback; |
117 | +import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.isFwSwWords; | ||
117 | import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.setValidTypeOper; | 118 | import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.setValidTypeOper; |
118 | import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.validateObjectVerFromKey; | 119 | import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.validateObjectVerFromKey; |
119 | 120 | ||
@@ -356,7 +357,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler | @@ -356,7 +357,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler | ||
356 | String pathName = tsKvProto.getKv().getKey(); | 357 | String pathName = tsKvProto.getKv().getKey(); |
357 | String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, pathName); | 358 | String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, pathName); |
358 | Object valueNew = getValueFromKvProto(tsKvProto.getKv()); | 359 | Object valueNew = getValueFromKvProto(tsKvProto.getKv()); |
359 | - log.warn("12) Shared AttributeUpdate start pathName [{}], pathIdVer [{}], valueNew [{}]", pathName, pathIdVer, valueNew); | ||
360 | if ((FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.VERSION).equals(pathName) | 360 | if ((FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.VERSION).equals(pathName) |
361 | && (!valueNew.equals(lwM2MClient.getFwUpdate().getCurrentVersion()))) | 361 | && (!valueNew.equals(lwM2MClient.getFwUpdate().getCurrentVersion()))) |
362 | || (FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.TITLE).equals(pathName) | 362 | || (FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.TITLE).equals(pathName) |
@@ -379,7 +379,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler | @@ -379,7 +379,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler | ||
379 | LOG_LW2M_ERROR, pathIdVer, valueNew); | 379 | LOG_LW2M_ERROR, pathIdVer, valueNew); |
380 | this.sendLogsToThingsboard(logMsg, lwM2MClient.getRegistration().getId()); | 380 | this.sendLogsToThingsboard(logMsg, lwM2MClient.getRegistration().getId()); |
381 | } | 381 | } |
382 | - } else { | 382 | + } else if (!isFwSwWords(pathName)) { |
383 | log.error("Resource name name - [{}] value - [{}] is not present as attribute/telemetry in profile and cannot be updated", pathName, valueNew); | 383 | log.error("Resource name name - [{}] value - [{}] is not present as attribute/telemetry in profile and cannot be updated", pathName, valueNew); |
384 | String logMsg = String.format("%s: attributeUpdate: attribute name - %s value - %s is not present as attribute in profile and cannot be updated", | 384 | String logMsg = String.format("%s: attributeUpdate: attribute name - %s value - %s is not present as attribute in profile and cannot be updated", |
385 | LOG_LW2M_ERROR, pathName, valueNew); | 385 | LOG_LW2M_ERROR, pathName, valueNew); |
@@ -446,7 +446,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler | @@ -446,7 +446,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler | ||
446 | String bodyParams = StringUtils.trimToNull(toDeviceRpcRequestMsg.getParams()) != null ? toDeviceRpcRequestMsg.getParams() : "null"; | 446 | String bodyParams = StringUtils.trimToNull(toDeviceRpcRequestMsg.getParams()) != null ? toDeviceRpcRequestMsg.getParams() : "null"; |
447 | LwM2mTypeOper lwM2mTypeOper = setValidTypeOper(toDeviceRpcRequestMsg.getMethodName()); | 447 | LwM2mTypeOper lwM2mTypeOper = setValidTypeOper(toDeviceRpcRequestMsg.getMethodName()); |
448 | UUID requestUUID = new UUID(toDeviceRpcRequestMsg.getRequestIdMSB(), toDeviceRpcRequestMsg.getRequestIdLSB()); | 448 | UUID requestUUID = new UUID(toDeviceRpcRequestMsg.getRequestIdMSB(), toDeviceRpcRequestMsg.getRequestIdLSB()); |
449 | - log.warn("4) RPC-OK finish to [{}], keys: [{}]", requestUUID, this.rpcSubscriptions.keySet()); | ||
450 | if (!this.rpcSubscriptions.containsKey(requestUUID)) { | 449 | if (!this.rpcSubscriptions.containsKey(requestUUID)) { |
451 | this.rpcSubscriptions.put(requestUUID, toDeviceRpcRequestMsg.getExpirationTime()); | 450 | this.rpcSubscriptions.put(requestUUID, toDeviceRpcRequestMsg.getExpirationTime()); |
452 | Lwm2mClientRpcRequest lwm2mClientRpcRequest = null; | 451 | Lwm2mClientRpcRequest lwm2mClientRpcRequest = null; |
@@ -647,7 +646,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler | @@ -647,7 +646,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler | ||
647 | * set setClient_fw_info... = value | 646 | * set setClient_fw_info... = value |
648 | **/ | 647 | **/ |
649 | if (lwM2MClient.getFwUpdate().isInfoFwSwUpdate()) { | 648 | if (lwM2MClient.getFwUpdate().isInfoFwSwUpdate()) { |
650 | - lwM2MClient.getFwUpdate().initReadValue(this, this.lwM2mTransportRequest, path); | 649 | + lwM2MClient.getFwUpdate().initReadValue(this, this.lwM2mTransportRequest, path); |
651 | } | 650 | } |
652 | if (lwM2MClient.getSwUpdate().isInfoFwSwUpdate()) { | 651 | if (lwM2MClient.getSwUpdate().isInfoFwSwUpdate()) { |
653 | lwM2MClient.getSwUpdate().initReadValue(this, this.lwM2mTransportRequest, path); | 652 | lwM2MClient.getSwUpdate().initReadValue(this, this.lwM2mTransportRequest, path); |
@@ -1229,7 +1228,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler | @@ -1229,7 +1228,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler | ||
1229 | public void onGetAttributesResponse(TransportProtos.GetAttributeResponseMsg attributesResponse, TransportProtos.SessionInfoProto sessionInfo) { | 1228 | public void onGetAttributesResponse(TransportProtos.GetAttributeResponseMsg attributesResponse, TransportProtos.SessionInfoProto sessionInfo) { |
1230 | try { | 1229 | try { |
1231 | List<TransportProtos.TsKvProto> tsKvProtos = attributesResponse.getSharedAttributeListList(); | 1230 | List<TransportProtos.TsKvProto> tsKvProtos = attributesResponse.getSharedAttributeListList(); |
1232 | - | ||
1233 | this.updateAttributeFromThingsboard(tsKvProtos, sessionInfo); | 1231 | this.updateAttributeFromThingsboard(tsKvProtos, sessionInfo); |
1234 | } catch (Exception e) { | 1232 | } catch (Exception e) { |
1235 | log.error("", e); | 1233 | log.error("", e); |
@@ -1346,7 +1344,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler | @@ -1346,7 +1344,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler | ||
1346 | if (lwM2MClient.getRegistration().getSupportedVersion(FW_ID) != null) { | 1344 | if (lwM2MClient.getRegistration().getSupportedVersion(FW_ID) != null) { |
1347 | SessionInfoProto sessionInfo = this.getSessionInfoOrCloseSession(lwM2MClient); | 1345 | SessionInfoProto sessionInfo = this.getSessionInfoOrCloseSession(lwM2MClient); |
1348 | if (sessionInfo != null) { | 1346 | if (sessionInfo != null) { |
1349 | - DefaultLwM2MTransportMsgHandler serviceImpl = this; | ||
1350 | transportService.process(sessionInfo, createFirmwareRequestMsg(sessionInfo, FirmwareType.FIRMWARE.name()), | 1347 | transportService.process(sessionInfo, createFirmwareRequestMsg(sessionInfo, FirmwareType.FIRMWARE.name()), |
1351 | new TransportServiceCallback<>() { | 1348 | new TransportServiceCallback<>() { |
1352 | @Override | 1349 | @Override |
@@ -23,26 +23,26 @@ public class LwM2mNetworkConfig { | @@ -23,26 +23,26 @@ public class LwM2mNetworkConfig { | ||
23 | NetworkConfig coapConfig = new NetworkConfig(); | 23 | NetworkConfig coapConfig = new NetworkConfig(); |
24 | coapConfig.setInt(NetworkConfig.Keys.COAP_PORT,serverPortNoSec); | 24 | coapConfig.setInt(NetworkConfig.Keys.COAP_PORT,serverPortNoSec); |
25 | coapConfig.setInt(NetworkConfig.Keys.COAP_SECURE_PORT,serverSecurePort); | 25 | 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); | ||
34 | */ | 34 | */ |
35 | 35 | ||
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 | ||
43 | */ | 43 | */ |
44 | coapConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_STRICT_BLOCK2_OPTION, true); | 44 | coapConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_STRICT_BLOCK2_OPTION, true); |
45 | - /* | 45 | + /** |
46 | Property to indicate if the response should always include the Block2 option \ | 46 | Property to indicate if the response should always include the Block2 option \ |
47 | when client request early blockwise negociation but the response can be sent on one packet. | 47 | when client request early blockwise negociation but the response can be sent on one packet. |
48 | - value of false indicate that the server will respond without block2 option if no further blocks are required. | 48 | - 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 { | @@ -51,44 +51,44 @@ public class LwM2mNetworkConfig { | ||
51 | coapConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_ENTITY_TOO_LARGE_AUTO_FAILOVER, true); | 51 | coapConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_ENTITY_TOO_LARGE_AUTO_FAILOVER, true); |
52 | 52 | ||
53 | coapConfig.setInt(NetworkConfig.Keys.BLOCKWISE_STATUS_LIFETIME, 300000); | 53 | 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. | ||
67 | */ | 67 | */ |
68 | coapConfig.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE, 256 * 1024 * 1024); | 68 | 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 | ||
78 | */ | 78 | */ |
79 | coapConfig.setString(NetworkConfig.Keys.RESPONSE_MATCHING, "STRICT"); | 79 | 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 | ||
84 | */ | 84 | */ |
85 | coapConfig.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE, 1024); | 85 | 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 | ||
92 | */ | 92 | */ |
93 | coapConfig.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE, 1024); | 93 | coapConfig.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE, 1024); |
94 | 94 | ||
@@ -96,4 +96,4 @@ public class LwM2mNetworkConfig { | @@ -96,4 +96,4 @@ public class LwM2mNetworkConfig { | ||
96 | 96 | ||
97 | return coapConfig; | 97 | return coapConfig; |
98 | } | 98 | } |
99 | -} | 99 | +} |
@@ -43,7 +43,10 @@ import org.eclipse.leshan.server.registration.Registration; | @@ -43,7 +43,10 @@ import org.eclipse.leshan.server.registration.Registration; | ||
43 | import org.nustaq.serialization.FSTConfiguration; | 43 | import org.nustaq.serialization.FSTConfiguration; |
44 | import org.thingsboard.server.common.data.DeviceProfile; | 44 | import org.thingsboard.server.common.data.DeviceProfile; |
45 | import org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTransportConfiguration; | 45 | 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; | ||
46 | import org.thingsboard.server.common.data.firmware.FirmwareUpdateStatus; | 48 | import org.thingsboard.server.common.data.firmware.FirmwareUpdateStatus; |
49 | +import org.thingsboard.server.common.data.firmware.FirmwareUtil; | ||
47 | import org.thingsboard.server.common.data.id.TenantId; | 50 | import org.thingsboard.server.common.data.id.TenantId; |
48 | import org.thingsboard.server.common.transport.TransportServiceCallback; | 51 | import org.thingsboard.server.common.transport.TransportServiceCallback; |
49 | import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; | 52 | import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; |
@@ -927,4 +930,17 @@ public class LwM2mTransportUtil { | @@ -927,4 +930,17 @@ public class LwM2mTransportUtil { | ||
927 | return null; | 930 | return null; |
928 | } | 931 | } |
929 | } | 932 | } |
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 | + } | ||
930 | } | 946 | } |
@@ -116,7 +116,7 @@ public class LwM2mClientContextImpl implements LwM2mClientContext { | @@ -116,7 +116,7 @@ public class LwM2mClientContextImpl implements LwM2mClientContext { | ||
116 | securityInfo.getDeviceProfile().getUuidId() : null; | 116 | securityInfo.getDeviceProfile().getUuidId() : null; |
117 | // TODO: for tests bug. | 117 | // TODO: for tests bug. |
118 | if (profileUuid== null) { | 118 | 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()); |
120 | } | 120 | } |
121 | LwM2mClient client; | 121 | LwM2mClient client; |
122 | if (securityInfo.getSecurityInfo() != null) { | 122 | if (securityInfo.getSecurityInfo() != null) { |
@@ -188,14 +188,13 @@ public class LwM2mFwSwUpdate { | @@ -188,14 +188,13 @@ public class LwM2mFwSwUpdate { | ||
188 | null, 0, null); | 188 | null, 0, null); |
189 | } | 189 | } |
190 | 190 | ||
191 | - | ||
192 | /** | 191 | /** |
193 | * Firmware start: | 192 | * 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. | ||
199 | */ | 198 | */ |
200 | private boolean conditionalFwUpdateStart() { | 199 | private boolean conditionalFwUpdateStart() { |
201 | Long updateResultFw = (Long) this.lwM2MClient.getResourceValue(null, this.pathResultId); | 200 | Long updateResultFw = (Long) this.lwM2MClient.getResourceValue(null, this.pathResultId); |
@@ -241,12 +240,12 @@ public class LwM2mFwSwUpdate { | @@ -241,12 +240,12 @@ public class LwM2mFwSwUpdate { | ||
241 | 240 | ||
242 | /** | 241 | /** |
243 | * Software start | 242 | * 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. | ||
250 | */ | 249 | */ |
251 | private boolean conditionalSwUpdateStart() { | 250 | private boolean conditionalSwUpdateStart() { |
252 | Long updateResultSw = (Long) this.lwM2MClient.getResourceValue(null, this.pathResultId); | 251 | Long updateResultSw = (Long) this.lwM2MClient.getResourceValue(null, this.pathResultId); |
@@ -214,9 +214,9 @@ public class TbLwM2mRedisRegistrationStore implements CaliforniumRegistrationSto | @@ -214,9 +214,9 @@ public class TbLwM2mRedisRegistrationStore implements CaliforniumRegistrationSto | ||
214 | // Add or update expiration | 214 | // Add or update expiration |
215 | addOrUpdateExpiration(connection, updatedRegistration); | 215 | addOrUpdateExpiration(connection, updatedRegistration); |
216 | 216 | ||
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. */ | ||
220 | byte[] addr_idx = toRegAddrKey(updatedRegistration.getSocketAddress()); | 220 | byte[] addr_idx = toRegAddrKey(updatedRegistration.getSocketAddress()); |
221 | connection.set(addr_idx, updatedRegistration.getEndpoint().getBytes(UTF_8)); | 221 | connection.set(addr_idx, updatedRegistration.getEndpoint().getBytes(UTF_8)); |
222 | if (!r.getSocketAddress().equals(updatedRegistration.getSocketAddress())) { | 222 | if (!r.getSocketAddress().equals(updatedRegistration.getSocketAddress())) { |
@@ -32,6 +32,7 @@ import org.springframework.stereotype.Service; | @@ -32,6 +32,7 @@ import org.springframework.stereotype.Service; | ||
32 | import org.springframework.transaction.annotation.Transactional; | 32 | import org.springframework.transaction.annotation.Transactional; |
33 | import org.springframework.util.CollectionUtils; | 33 | import org.springframework.util.CollectionUtils; |
34 | import org.springframework.util.StringUtils; | 34 | import org.springframework.util.StringUtils; |
35 | +import org.thingsboard.common.util.JacksonUtil; | ||
35 | import org.thingsboard.server.common.data.Customer; | 36 | import org.thingsboard.server.common.data.Customer; |
36 | import org.thingsboard.server.common.data.Device; | 37 | import org.thingsboard.server.common.data.Device; |
37 | import org.thingsboard.server.common.data.DeviceInfo; | 38 | import org.thingsboard.server.common.data.DeviceInfo; |
@@ -80,7 +81,6 @@ import org.thingsboard.server.dao.service.DataValidator; | @@ -80,7 +81,6 @@ import org.thingsboard.server.dao.service.DataValidator; | ||
80 | import org.thingsboard.server.dao.service.PaginatedRemover; | 81 | import org.thingsboard.server.dao.service.PaginatedRemover; |
81 | import org.thingsboard.server.dao.tenant.TbTenantProfileCache; | 82 | import org.thingsboard.server.dao.tenant.TbTenantProfileCache; |
82 | import org.thingsboard.server.dao.tenant.TenantDao; | 83 | import org.thingsboard.server.dao.tenant.TenantDao; |
83 | -import org.thingsboard.common.util.JacksonUtil; | ||
84 | 84 | ||
85 | import javax.annotation.Nullable; | 85 | import javax.annotation.Nullable; |
86 | import java.util.ArrayList; | 86 | import java.util.ArrayList; |
@@ -200,11 +200,16 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe | @@ -200,11 +200,16 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe | ||
200 | Device savedDevice = this.saveDeviceWithoutCredentials(device); | 200 | Device savedDevice = this.saveDeviceWithoutCredentials(device); |
201 | deviceCredentials.setDeviceId(savedDevice.getId()); | 201 | deviceCredentials.setDeviceId(savedDevice.getId()); |
202 | if (device.getId() == null) { | 202 | if (device.getId() == null) { |
203 | - deviceCredentials = deviceCredentialsService.createDeviceCredentials(savedDevice.getTenantId(), deviceCredentials); | 203 | + deviceCredentialsService.createDeviceCredentials(savedDevice.getTenantId(), deviceCredentials); |
204 | } | 204 | } |
205 | else { | 205 | else { |
206 | - deviceCredentials.setId(deviceCredentialsService.findDeviceCredentialsByDeviceId(device.getTenantId(), savedDevice.getId()).getId()); | ||
207 | - deviceCredentials = deviceCredentialsService.updateDeviceCredentials(device.getTenantId(), deviceCredentials); | 206 | + DeviceCredentials foundDeviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(device.getTenantId(), savedDevice.getId()); |
207 | + if (foundDeviceCredentials == null) { | ||
208 | + deviceCredentialsService.createDeviceCredentials(savedDevice.getTenantId(), deviceCredentials); | ||
209 | + } | ||
210 | + else { | ||
211 | + deviceCredentialsService.updateDeviceCredentials(device.getTenantId(), deviceCredentials); | ||
212 | + } | ||
208 | } | 213 | } |
209 | return savedDevice; | 214 | return savedDevice; |
210 | } | 215 | } |