Improvements to support large files for firmware updates
This commit is contained in:
parent
5ca0e05ab5
commit
ff334b5438
@ -66,7 +66,7 @@ public class LwM2mNetworkConfig {
|
||||
* A value of {@code 0} turns off transparent handling of blockwise transfers altogether.
|
||||
*/
|
||||
// coapConfig.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE, 8192);
|
||||
coapConfig.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE, 16384);
|
||||
coapConfig.setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE, 256 * 1024 * 1024);
|
||||
/**
|
||||
* The default DTLS response matcher.
|
||||
* Supported values are STRICT, RELAXED, or PRINCIPAL.
|
||||
@ -83,7 +83,7 @@ public class LwM2mNetworkConfig {
|
||||
* 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, 512);
|
||||
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.
|
||||
@ -91,7 +91,7 @@ public class LwM2mNetworkConfig {
|
||||
* 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, 512);
|
||||
coapConfig.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE, 1024);
|
||||
|
||||
coapConfig.setInt(NetworkConfig.Keys.MAX_RETRANSMIT, 4);
|
||||
|
||||
|
||||
@ -424,7 +424,7 @@ public class LwM2mTransportRequest {
|
||||
LOG_LW2M_INFO, ((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(),
|
||||
response.getCode().getName(), request.getPath().toString(), value);
|
||||
serviceImpl.sendLogsToThingsboard(msg, registration.getId());
|
||||
log.warn("[{}] [{}] [{}] - [{}] [{}] Update finished successfully: [{}]", request.getClass().getName().toString(), registration.getEndpoint(),
|
||||
log.trace("[{}] [{}] [{}] - [{}] [{}] Update finished successfully: [{}]", request.getClass().getName().toString(), registration.getEndpoint(),
|
||||
((Response) response.getCoapResponse()).getCode(), response.getCode(),
|
||||
request.getPath().toString(), value);
|
||||
}
|
||||
|
||||
@ -334,6 +334,7 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService {
|
||||
String pathName = tsKvProto.getKv().getKey();
|
||||
String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, pathName);
|
||||
Object valueNew = this.lwM2mTransportContextServer.getValueFromKvProto(tsKvProto.getKv());
|
||||
//TODO: react on change of the firmware name.
|
||||
if (FirmwareUtil.getAttributeKey(FirmwareType.FIRMWARE, FirmwareKey.VERSION).equals(pathName) && !valueNew.equals(lwM2MClient.getFrUpdate().getCurrentFwVersion())) {
|
||||
this.getInfoFirmwareUpdate(lwM2MClient);
|
||||
}
|
||||
@ -612,6 +613,9 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService {
|
||||
public void sendLogsToThingsboard(String logMsg, String registrationId) {
|
||||
SessionInfoProto sessionInfo = this.getValidateSessionInfo(registrationId);
|
||||
if (logMsg != null && sessionInfo != null) {
|
||||
if(logMsg.length() > 1024){
|
||||
logMsg = logMsg.substring(0, 1024);
|
||||
}
|
||||
this.lwM2mTransportContextServer.sendParametersOnThingsboardTelemetry(this.lwM2mTransportContextServer.getKvLogyToThingsboard(logMsg), sessionInfo);
|
||||
}
|
||||
}
|
||||
@ -1372,6 +1376,7 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService {
|
||||
.setDeviceIdLSB(sessionInfo.getDeviceIdLSB())
|
||||
.setTenantIdMSB(sessionInfo.getTenantIdMSB())
|
||||
.setTenantIdLSB(sessionInfo.getTenantIdLSB())
|
||||
.setType(FirmwareType.FIRMWARE.name())
|
||||
.build();
|
||||
transportService.process(sessionInfo, getFirmwareRequestMsg,
|
||||
new TransportServiceCallback<>() {
|
||||
@ -1416,7 +1421,7 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService {
|
||||
Integer objectId = 5;
|
||||
String verSupportedObject = lwM2MClient.getRegistration().getSupportedObject().get(objectId);
|
||||
String targetIdVer = LWM2M_SEPARATOR_PATH + objectId + LWM2M_SEPARATOR_KEY + verSupportedObject + LWM2M_SEPARATOR_PATH + 0 + LWM2M_SEPARATOR_PATH + 0;
|
||||
lwM2mTransportRequest.sendAllRequest(lwM2MClient.getRegistration(), targetIdVer, WRITE_REPLACE, ContentFormat.TLV.getName(),
|
||||
lwM2mTransportRequest.sendAllRequest(lwM2MClient.getRegistration(), targetIdVer, WRITE_REPLACE, ContentFormat.OPAQUE.getName(),
|
||||
firmwareChunk, lwM2mTransportContextServer.getLwM2MTransportConfigServer().getTimeout(), null);
|
||||
log.warn("updateFirmwareClient [{}] [{}]", lwM2MClient.getFrUpdate().getCurrentFwVersion(), lwM2MClient.getFrUpdate().getClientFwVersion());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user