Commit ff334b54389f9a4ceda9ea6e7fa3cb4415b16128
1 parent
5ca0e05a
Improvements to support large files for firmware updates
Showing
3 changed files
with
10 additions
and
5 deletions
@@ -66,7 +66,7 @@ public class LwM2mNetworkConfig { | @@ -66,7 +66,7 @@ public class LwM2mNetworkConfig { | ||
66 | * A value of {@code 0} turns off transparent handling of blockwise transfers altogether. | 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, 8192); | 68 | // coapConfig.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE, 8192); |
69 | - coapConfig.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE, 16384); | 69 | + coapConfig.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE, 256 * 1024 * 1024); |
70 | /** | 70 | /** |
71 | * The default DTLS response matcher. | 71 | * The default DTLS response matcher. |
72 | * Supported values are STRICT, RELAXED, or PRINCIPAL. | 72 | * Supported values are STRICT, RELAXED, or PRINCIPAL. |
@@ -83,7 +83,7 @@ public class LwM2mNetworkConfig { | @@ -83,7 +83,7 @@ public class LwM2mNetworkConfig { | ||
83 | * The block size (number of bytes) to use when doing a blockwise transfer. \ | 83 | * The block size (number of bytes) to use when doing a blockwise transfer. \ |
84 | * This value serves as the upper limit for block size in blockwise transfers | 84 | * This value serves as the upper limit for block size in blockwise transfers |
85 | */ | 85 | */ |
86 | - coapConfig.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE, 512); | 86 | + coapConfig.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE, 1024); |
87 | /** | 87 | /** |
88 | * The maximum payload size (in bytes) that can be transferred in a | 88 | * The maximum payload size (in bytes) that can be transferred in a |
89 | * single message, i.e. without requiring a blockwise transfer. | 89 | * single message, i.e. without requiring a blockwise transfer. |
@@ -91,7 +91,7 @@ public class LwM2mNetworkConfig { | @@ -91,7 +91,7 @@ public class LwM2mNetworkConfig { | ||
91 | * In particular, this value cannot exceed the network's MTU if UDP is used as the transport protocol | 91 | * In particular, this value cannot exceed the network's MTU if UDP is used as the transport protocol |
92 | * DEFAULT_VALUE = 1024 | 92 | * DEFAULT_VALUE = 1024 |
93 | */ | 93 | */ |
94 | - coapConfig.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE, 512); | 94 | + coapConfig.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE, 1024); |
95 | 95 | ||
96 | coapConfig.setInt(NetworkConfig.Keys.MAX_RETRANSMIT, 4); | 96 | coapConfig.setInt(NetworkConfig.Keys.MAX_RETRANSMIT, 4); |
97 | 97 |
@@ -424,7 +424,7 @@ public class LwM2mTransportRequest { | @@ -424,7 +424,7 @@ public class LwM2mTransportRequest { | ||
424 | LOG_LW2M_INFO, ((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), | 424 | LOG_LW2M_INFO, ((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), |
425 | response.getCode().getName(), request.getPath().toString(), value); | 425 | response.getCode().getName(), request.getPath().toString(), value); |
426 | serviceImpl.sendLogsToThingsboard(msg, registration.getId()); | 426 | serviceImpl.sendLogsToThingsboard(msg, registration.getId()); |
427 | - log.warn("[{}] [{}] [{}] - [{}] [{}] Update finished successfully: [{}]", request.getClass().getName().toString(), registration.getEndpoint(), | 427 | + log.trace("[{}] [{}] [{}] - [{}] [{}] Update finished successfully: [{}]", request.getClass().getName().toString(), registration.getEndpoint(), |
428 | ((Response) response.getCoapResponse()).getCode(), response.getCode(), | 428 | ((Response) response.getCoapResponse()).getCode(), response.getCode(), |
429 | request.getPath().toString(), value); | 429 | request.getPath().toString(), value); |
430 | } | 430 | } |
@@ -334,6 +334,7 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService { | @@ -334,6 +334,7 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService { | ||
334 | String pathName = tsKvProto.getKv().getKey(); | 334 | String pathName = tsKvProto.getKv().getKey(); |
335 | String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, pathName); | 335 | String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, pathName); |
336 | Object valueNew = this.lwM2mTransportContextServer.getValueFromKvProto(tsKvProto.getKv()); | 336 | Object valueNew = this.lwM2mTransportContextServer.getValueFromKvProto(tsKvProto.getKv()); |
337 | + //TODO: react on change of the firmware name. | ||
337 | if (FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.VERSION).equals(pathName) && !valueNew.equals(lwM2MClient.getFrUpdate().getCurrentFwVersion())) { | 338 | if (FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.VERSION).equals(pathName) && !valueNew.equals(lwM2MClient.getFrUpdate().getCurrentFwVersion())) { |
338 | this.getInfoFirmwareUpdate(lwM2MClient); | 339 | this.getInfoFirmwareUpdate(lwM2MClient); |
339 | } | 340 | } |
@@ -612,6 +613,9 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService { | @@ -612,6 +613,9 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService { | ||
612 | public void sendLogsToThingsboard(String logMsg, String registrationId) { | 613 | public void sendLogsToThingsboard(String logMsg, String registrationId) { |
613 | SessionInfoProto sessionInfo = this.getValidateSessionInfo(registrationId); | 614 | SessionInfoProto sessionInfo = this.getValidateSessionInfo(registrationId); |
614 | if (logMsg != null && sessionInfo != null) { | 615 | if (logMsg != null && sessionInfo != null) { |
616 | + if(logMsg.length() > 1024){ | ||
617 | + logMsg = logMsg.substring(0, 1024); | ||
618 | + } | ||
615 | this.lwM2mTransportContextServer.sendParametersOnThingsboardTelemetry(this.lwM2mTransportContextServer.getKvLogyToThingsboard(logMsg), sessionInfo); | 619 | this.lwM2mTransportContextServer.sendParametersOnThingsboardTelemetry(this.lwM2mTransportContextServer.getKvLogyToThingsboard(logMsg), sessionInfo); |
616 | } | 620 | } |
617 | } | 621 | } |
@@ -1372,6 +1376,7 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService { | @@ -1372,6 +1376,7 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService { | ||
1372 | .setDeviceIdLSB(sessionInfo.getDeviceIdLSB()) | 1376 | .setDeviceIdLSB(sessionInfo.getDeviceIdLSB()) |
1373 | .setTenantIdMSB(sessionInfo.getTenantIdMSB()) | 1377 | .setTenantIdMSB(sessionInfo.getTenantIdMSB()) |
1374 | .setTenantIdLSB(sessionInfo.getTenantIdLSB()) | 1378 | .setTenantIdLSB(sessionInfo.getTenantIdLSB()) |
1379 | + .setType(FirmwareType.FIRMWARE.name()) | ||
1375 | .build(); | 1380 | .build(); |
1376 | transportService.process(sessionInfo, getFirmwareRequestMsg, | 1381 | transportService.process(sessionInfo, getFirmwareRequestMsg, |
1377 | new TransportServiceCallback<>() { | 1382 | new TransportServiceCallback<>() { |
@@ -1416,7 +1421,7 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService { | @@ -1416,7 +1421,7 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService { | ||
1416 | Integer objectId = 5; | 1421 | Integer objectId = 5; |
1417 | String verSupportedObject = lwM2MClient.getRegistration().getSupportedObject().get(objectId); | 1422 | String verSupportedObject = lwM2MClient.getRegistration().getSupportedObject().get(objectId); |
1418 | String targetIdVer = LWM2M_SEPARATOR_PATH + objectId + LWM2M_SEPARATOR_KEY + verSupportedObject + LWM2M_SEPARATOR_PATH + 0 + LWM2M_SEPARATOR_PATH + 0; | 1423 | String targetIdVer = LWM2M_SEPARATOR_PATH + objectId + LWM2M_SEPARATOR_KEY + verSupportedObject + LWM2M_SEPARATOR_PATH + 0 + LWM2M_SEPARATOR_PATH + 0; |
1419 | - lwM2mTransportRequest.sendAllRequest(lwM2MClient.getRegistration(), targetIdVer, WRITE_REPLACE, ContentFormat.TLV.getName(), | 1424 | + lwM2mTransportRequest.sendAllRequest(lwM2MClient.getRegistration(), targetIdVer, WRITE_REPLACE, ContentFormat.OPAQUE.getName(), |
1420 | firmwareChunk, lwM2mTransportContextServer.getLwM2MTransportConfigServer().getTimeout(), null); | 1425 | firmwareChunk, lwM2mTransportContextServer.getLwM2MTransportConfigServer().getTimeout(), null); |
1421 | log.warn("updateFirmwareClient [{}] [{}]", lwM2MClient.getFrUpdate().getCurrentFwVersion(), lwM2MClient.getFrUpdate().getClientFwVersion()); | 1426 | log.warn("updateFirmwareClient [{}] [{}]", lwM2MClient.getFrUpdate().getCurrentFwVersion(), lwM2MClient.getFrUpdate().getClientFwVersion()); |
1422 | } | 1427 | } |