|
|
|
@ -22,6 +22,8 @@ import org.eclipse.californium.core.coap.Response; |
|
|
|
import org.eclipse.leshan.core.Link; |
|
|
|
import org.eclipse.leshan.core.model.ResourceModel; |
|
|
|
import org.eclipse.leshan.core.node.LwM2mNode; |
|
|
|
import org.eclipse.leshan.core.node.LwM2mObject; |
|
|
|
import org.eclipse.leshan.core.node.LwM2mObjectInstance; |
|
|
|
import org.eclipse.leshan.core.node.LwM2mPath; |
|
|
|
import org.eclipse.leshan.core.node.LwM2mResource; |
|
|
|
import org.eclipse.leshan.core.node.LwM2mSingleResource; |
|
|
|
@ -34,6 +36,7 @@ import org.eclipse.leshan.core.request.DownlinkRequest; |
|
|
|
import org.eclipse.leshan.core.request.ExecuteRequest; |
|
|
|
import org.eclipse.leshan.core.request.ObserveRequest; |
|
|
|
import org.eclipse.leshan.core.request.ReadRequest; |
|
|
|
import org.eclipse.leshan.core.request.WriteAttributesRequest; |
|
|
|
import org.eclipse.leshan.core.request.WriteRequest; |
|
|
|
import org.eclipse.leshan.core.request.exception.ClientSleepingException; |
|
|
|
import org.eclipse.leshan.core.response.DeleteResponse; |
|
|
|
@ -79,10 +82,12 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.L |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LOG_LW2M_VALUE; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.DISCOVER; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.DISCOVER_All; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.DISCOVER_ALL; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.EXECUTE; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_CANCEL; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_CANCEL_ALL; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_READ_ALL; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.WRITE_ATTRIBUTES; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.WRITE_REPLACE; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.WRITE_UPDATE; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.RESPONSE_REQUEST_CHANNEL; |
|
|
|
@ -123,7 +128,7 @@ public class LwM2mTransportRequest { |
|
|
|
*/ |
|
|
|
|
|
|
|
public void sendAllRequest(Registration registration, String targetIdVer, LwM2mTypeOper typeOper, |
|
|
|
String contentFormatName, Object params, long timeoutInMs, Lwm2mClientRpcRequest rpcRequest) { |
|
|
|
String contentFormatName, Object params, long timeoutInMs, Lwm2mClientRpcRequest lwm2mClientRpcRequest) { |
|
|
|
try { |
|
|
|
String target = convertPathFromIdVerToObjectId(targetIdVer); |
|
|
|
ContentFormat contentFormat = contentFormatName != null ? ContentFormat.fromName(contentFormatName.toUpperCase()) : ContentFormat.DEFAULT; |
|
|
|
@ -132,45 +137,42 @@ public class LwM2mTransportRequest { |
|
|
|
if (!OBSERVE_READ_ALL.name().equals(typeOper.name()) && resultIds != null && registration != null && resultIds.getObjectId() >= 0 && lwM2MClient != null) { |
|
|
|
if (lwM2MClient.isValidObjectVersion(targetIdVer)) { |
|
|
|
timeoutInMs = timeoutInMs > 0 ? timeoutInMs : DEFAULT_TIMEOUT; |
|
|
|
DownlinkRequest request = createRequest (registration, lwM2MClient, typeOper, contentFormat, target, |
|
|
|
targetIdVer, resultIds, params, rpcRequest); |
|
|
|
DownlinkRequest request = createRequest(registration, lwM2MClient, typeOper, contentFormat, target, |
|
|
|
targetIdVer, resultIds, params, lwm2mClientRpcRequest); |
|
|
|
if (request != null) { |
|
|
|
try { |
|
|
|
this.sendRequest(registration, lwM2MClient, request, timeoutInMs, rpcRequest); |
|
|
|
this.sendRequest(registration, lwM2MClient, request, timeoutInMs, lwm2mClientRpcRequest); |
|
|
|
} catch (ClientSleepingException e) { |
|
|
|
DownlinkRequest finalRequest = request; |
|
|
|
long finalTimeoutInMs = timeoutInMs; |
|
|
|
Lwm2mClientRpcRequest finalRpcRequest = rpcRequest; |
|
|
|
Lwm2mClientRpcRequest finalRpcRequest = lwm2mClientRpcRequest; |
|
|
|
lwM2MClient.getQueuedRequests().add(() -> sendRequest(registration, lwM2MClient, finalRequest, finalTimeoutInMs, finalRpcRequest)); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("[{}] [{}] [{}] Failed to send downlink.", registration.getEndpoint(), targetIdVer, typeOper.name(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (WRITE_UPDATE.name().equals(typeOper.name())) { |
|
|
|
if (rpcRequest != null) { |
|
|
|
} else if (WRITE_UPDATE.name().equals(typeOper.name())) { |
|
|
|
if (lwm2mClientRpcRequest != null) { |
|
|
|
String errorMsg = String.format("Path %s params is not valid", targetIdVer); |
|
|
|
handler.sentRpcRequest(rpcRequest, BAD_REQUEST.getName(), errorMsg, LOG_LW2M_ERROR); |
|
|
|
handler.sentRpcRequest(lwm2mClientRpcRequest, BAD_REQUEST.getName(), errorMsg, LOG_LW2M_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (WRITE_REPLACE.name().equals(typeOper.name()) || EXECUTE.name().equals(typeOper.name()) ) { |
|
|
|
if (rpcRequest != null) { |
|
|
|
} else if (WRITE_REPLACE.name().equals(typeOper.name()) || EXECUTE.name().equals(typeOper.name())) { |
|
|
|
if (lwm2mClientRpcRequest != null) { |
|
|
|
String errorMsg = String.format("Path %s object model is absent", targetIdVer); |
|
|
|
handler.sentRpcRequest(rpcRequest, BAD_REQUEST.getName(), errorMsg, LOG_LW2M_ERROR); |
|
|
|
handler.sentRpcRequest(lwm2mClientRpcRequest, BAD_REQUEST.getName(), errorMsg, LOG_LW2M_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!OBSERVE_CANCEL.name().equals(typeOper.name())) { |
|
|
|
} else if (!OBSERVE_CANCEL.name().equals(typeOper.name())) { |
|
|
|
log.error("[{}], [{}] - [{}] error SendRequest", registration.getEndpoint(), typeOper.name(), targetIdVer); |
|
|
|
if (rpcRequest != null) { |
|
|
|
if (lwm2mClientRpcRequest != null) { |
|
|
|
ResourceModel resourceModel = lwM2MClient.getResourceModel(targetIdVer, this.config.getModelProvider()); |
|
|
|
String errorMsg = resourceModel == null ? String.format("Path %s not found in object version", targetIdVer) : "SendRequest - null"; |
|
|
|
handler.sentRpcRequest(rpcRequest, NOT_FOUND.getName(), errorMsg, LOG_LW2M_ERROR); |
|
|
|
this.handler.sentRpcRequest(lwm2mClientRpcRequest, NOT_FOUND.getName(), errorMsg, LOG_LW2M_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (rpcRequest != null) { |
|
|
|
} else if (lwm2mClientRpcRequest != null) { |
|
|
|
String errorMsg = String.format("Path %s not found in object version", targetIdVer); |
|
|
|
handler.sentRpcRequest(rpcRequest, NOT_FOUND.getName(), errorMsg, LOG_LW2M_ERROR); |
|
|
|
this.handler.sentRpcRequest(lwm2mClientRpcRequest, NOT_FOUND.getName(), errorMsg, LOG_LW2M_ERROR); |
|
|
|
} |
|
|
|
} else if (OBSERVE_READ_ALL.name().equals(typeOper.name()) || DISCOVER_All.name().equals(typeOper.name())) { |
|
|
|
} else if (OBSERVE_READ_ALL.name().equals(typeOper.name()) || DISCOVER_ALL.name().equals(typeOper.name())) { |
|
|
|
Set<String> paths; |
|
|
|
if (OBSERVE_READ_ALL.name().equals(typeOper.name())) { |
|
|
|
Set<Observation> observations = context.getServer().getObservationService().getObservations(registration); |
|
|
|
@ -179,34 +181,34 @@ public class LwM2mTransportRequest { |
|
|
|
assert registration != null; |
|
|
|
Link[] objectLinks = registration.getSortedObjectLinks(); |
|
|
|
paths = Arrays.stream(objectLinks).map(Link::toString).collect(Collectors.toUnmodifiableSet()); |
|
|
|
String msg = String.format("%s: type operation %s paths - %s", LOG_LW2M_INFO, |
|
|
|
typeOper.name(), paths); |
|
|
|
handler.sendLogsToThingsboard(msg, registration.getId()); |
|
|
|
} |
|
|
|
if (rpcRequest != null) { |
|
|
|
String msg = String.format("%s: type operation %s paths - %s", LOG_LW2M_INFO, |
|
|
|
typeOper.name(), paths); |
|
|
|
this.handler.sendLogsToThingsboard(msg, registration.getId()); |
|
|
|
if (lwm2mClientRpcRequest != null) { |
|
|
|
String valueMsg = String.format("Paths - %s", paths); |
|
|
|
handler.sentRpcRequest(rpcRequest, CONTENT.name(), valueMsg, LOG_LW2M_VALUE); |
|
|
|
this.handler.sentRpcRequest(lwm2mClientRpcRequest, CONTENT.name(), valueMsg, LOG_LW2M_VALUE); |
|
|
|
} |
|
|
|
} else if (OBSERVE_CANCEL.name().equals(typeOper.name())) { |
|
|
|
} else if (OBSERVE_CANCEL_ALL.name().equals(typeOper.name())) { |
|
|
|
int observeCancelCnt = context.getServer().getObservationService().cancelObservations(registration); |
|
|
|
String observeCancelMsgAll = String.format("%s: type operation %s paths: All count: %d", LOG_LW2M_INFO, |
|
|
|
OBSERVE_CANCEL.name(), observeCancelCnt); |
|
|
|
this.afterObserveCancel(registration, observeCancelCnt, observeCancelMsgAll, rpcRequest); |
|
|
|
this.afterObserveCancel(registration, observeCancelCnt, observeCancelMsgAll, lwm2mClientRpcRequest); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
String msg = String.format("%s: type operation %s %s", LOG_LW2M_ERROR, |
|
|
|
typeOper.name(), e.getMessage()); |
|
|
|
handler.sendLogsToThingsboard(msg, registration.getId()); |
|
|
|
if (rpcRequest != null) { |
|
|
|
if (lwm2mClientRpcRequest != null) { |
|
|
|
String errorMsg = String.format("Path %s type operation %s %s", targetIdVer, typeOper.name(), e.getMessage()); |
|
|
|
handler.sentRpcRequest(rpcRequest, NOT_FOUND.getName(), errorMsg, LOG_LW2M_ERROR); |
|
|
|
handler.sentRpcRequest(lwm2mClientRpcRequest, NOT_FOUND.getName(), errorMsg, LOG_LW2M_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private DownlinkRequest createRequest (Registration registration, LwM2mClient lwM2MClient, LwM2mTypeOper typeOper, |
|
|
|
ContentFormat contentFormat, String target, String targetIdVer, |
|
|
|
LwM2mPath resultIds, Object params, Lwm2mClientRpcRequest rpcRequest) { |
|
|
|
private DownlinkRequest createRequest(Registration registration, LwM2mClient lwM2MClient, LwM2mTypeOper typeOper, |
|
|
|
ContentFormat contentFormat, String target, String targetIdVer, |
|
|
|
LwM2mPath resultIds, Object params, Lwm2mClientRpcRequest rpcRequest) { |
|
|
|
DownlinkRequest request = null; |
|
|
|
switch (typeOper) { |
|
|
|
case READ: |
|
|
|
@ -216,7 +218,7 @@ public class LwM2mTransportRequest { |
|
|
|
request = new DiscoverRequest(target); |
|
|
|
break; |
|
|
|
case OBSERVE: |
|
|
|
String msg = String.format("%s: Send Observation %s.", LOG_LW2M_INFO, targetIdVer); |
|
|
|
String msg = String.format("%s: Send Observation %s.", LOG_LW2M_INFO, targetIdVer); |
|
|
|
log.warn(msg); |
|
|
|
if (resultIds.isResource()) { |
|
|
|
Set<Observation> observations = context.getServer().getObservationService().getObservations(registration); |
|
|
|
@ -305,7 +307,7 @@ public class LwM2mTransportRequest { |
|
|
|
} |
|
|
|
break; |
|
|
|
case WRITE_ATTRIBUTES: |
|
|
|
request = createWriteAttributeRequest(target, params); |
|
|
|
request = createWriteAttributeRequest(target, params, this.handler); |
|
|
|
break; |
|
|
|
case DELETE: |
|
|
|
request = new DeleteRequest(target); |
|
|
|
@ -347,10 +349,10 @@ public class LwM2mTransportRequest { |
|
|
|
set setClient_fw_info... = empty |
|
|
|
**/ |
|
|
|
if (lwM2MClient.getFwUpdate().isInfoFwSwUpdate()) { |
|
|
|
lwM2MClient.getFwUpdate().initReadValue(handler, request.getPath().toString()); |
|
|
|
lwM2MClient.getFwUpdate().initReadValue(handler, this, request.getPath().toString()); |
|
|
|
} |
|
|
|
if (lwM2MClient.getSwUpdate().isInfoFwSwUpdate()) { |
|
|
|
lwM2MClient.getSwUpdate().initReadValue(handler, request.getPath().toString()); |
|
|
|
lwM2MClient.getSwUpdate().initReadValue(handler, this, request.getPath().toString()); |
|
|
|
} |
|
|
|
if (request.getPath().toString().equals(FW_PACKAGE_ID) || request.getPath().toString().equals(SW_PACKAGE_ID)) { |
|
|
|
this.afterWriteFwSWUpdateError(registration, request, response.getErrorMessage()); |
|
|
|
@ -364,10 +366,10 @@ public class LwM2mTransportRequest { |
|
|
|
set setClient_fw_info... = empty |
|
|
|
**/ |
|
|
|
if (lwM2MClient.getFwUpdate().isInfoFwSwUpdate()) { |
|
|
|
lwM2MClient.getFwUpdate().initReadValue(handler, request.getPath().toString()); |
|
|
|
lwM2MClient.getFwUpdate().initReadValue(handler, this, request.getPath().toString()); |
|
|
|
} |
|
|
|
if (lwM2MClient.getSwUpdate().isInfoFwSwUpdate()) { |
|
|
|
lwM2MClient.getSwUpdate().initReadValue(handler, request.getPath().toString()); |
|
|
|
lwM2MClient.getSwUpdate().initReadValue(handler, this, request.getPath().toString()); |
|
|
|
} |
|
|
|
if (request.getPath().toString().equals(FW_PACKAGE_ID) || request.getPath().toString().equals(SW_PACKAGE_ID)) { |
|
|
|
this.afterWriteFwSWUpdateError(registration, request, e.getMessage()); |
|
|
|
@ -473,7 +475,13 @@ public class LwM2mTransportRequest { |
|
|
|
} else if (response instanceof ExecuteResponse) { |
|
|
|
log.warn("[{}] Path [{}] ExecuteResponse 7_Send", pathIdVer, response); |
|
|
|
} else if (response instanceof WriteAttributesResponse) { |
|
|
|
msgLog = String.format("%s: type operation: %s path: %s value: %s", |
|
|
|
LOG_LW2M_INFO, WRITE_ATTRIBUTES.name(), request.getPath().toString(), ((WriteAttributesRequest) request).getAttributes().toString()); |
|
|
|
handler.sendLogsToThingsboard(msgLog, registration.getId()); |
|
|
|
log.warn("[{}] Path [{}] WriteAttributesResponse 8_Send", pathIdVer, response); |
|
|
|
if (rpcRequest != null) { |
|
|
|
handler.sentRpcRequest(rpcRequest, response.getCode().getName(), response.toString(), LOG_LW2M_VALUE); |
|
|
|
} |
|
|
|
} else if (response instanceof WriteResponse) { |
|
|
|
log.warn("[{}] Path [{}] WriteResponse 9_Send", pathIdVer, response); |
|
|
|
this.infoWriteResponse(registration, response, request); |
|
|
|
@ -494,29 +502,37 @@ public class LwM2mTransportRequest { |
|
|
|
private void infoWriteResponse(Registration registration, LwM2mResponse response, DownlinkRequest request) { |
|
|
|
try { |
|
|
|
LwM2mNode node = ((WriteRequest) request).getNode(); |
|
|
|
String msg; |
|
|
|
String msg = null; |
|
|
|
Object value; |
|
|
|
LwM2mSingleResource singleResource = (LwM2mSingleResource) node; |
|
|
|
if (singleResource.getType() == ResourceModel.Type.STRING || singleResource.getType() == ResourceModel.Type.OPAQUE) { |
|
|
|
int valueLength; |
|
|
|
if (singleResource.getType() == ResourceModel.Type.STRING) { |
|
|
|
valueLength = ((String) singleResource.getValue()).length(); |
|
|
|
value = ((String) singleResource.getValue()) |
|
|
|
.substring(Math.min(valueLength, config.getLogMaxLength())); |
|
|
|
if (node instanceof LwM2mObject) { |
|
|
|
msg = String.format("%s: Update finished successfully: Lwm2m code - %d Source path: %s value: %s", |
|
|
|
LOG_LW2M_INFO, response.getCode().getCode(), request.getPath().toString(), ((LwM2mObject) node).toString()); |
|
|
|
} else if (node instanceof LwM2mObjectInstance) { |
|
|
|
msg = String.format("%s: Update finished successfully: Lwm2m code - %d Source path: %s value: %s", |
|
|
|
LOG_LW2M_INFO, response.getCode().getCode(), request.getPath().toString(), ((LwM2mObjectInstance) node).prettyPrint()); |
|
|
|
} else if (node instanceof LwM2mSingleResource) { |
|
|
|
LwM2mSingleResource singleResource = (LwM2mSingleResource) node; |
|
|
|
if (singleResource.getType() == ResourceModel.Type.STRING || singleResource.getType() == ResourceModel.Type.OPAQUE) { |
|
|
|
int valueLength; |
|
|
|
if (singleResource.getType() == ResourceModel.Type.STRING) { |
|
|
|
valueLength = ((String) singleResource.getValue()).length(); |
|
|
|
value = ((String) singleResource.getValue()) |
|
|
|
.substring(Math.min(valueLength, config.getLogMaxLength())); |
|
|
|
|
|
|
|
} else { |
|
|
|
valueLength = ((byte[]) singleResource.getValue()).length; |
|
|
|
value = new String(Arrays.copyOf(((byte[]) singleResource.getValue()), |
|
|
|
Math.min(valueLength, config.getLogMaxLength()))); |
|
|
|
} |
|
|
|
value = valueLength > config.getLogMaxLength() ? value + "..." : value; |
|
|
|
msg = String.format("%s: Update finished successfully: Lwm2m code - %d Resource path: %s length: %s value: %s", |
|
|
|
LOG_LW2M_INFO, response.getCode().getCode(), request.getPath().toString(), valueLength, value); |
|
|
|
} else { |
|
|
|
valueLength = ((byte[]) singleResource.getValue()).length; |
|
|
|
value = new String(Arrays.copyOf(((byte[]) singleResource.getValue()), |
|
|
|
Math.min(valueLength, config.getLogMaxLength()))); |
|
|
|
value = this.converter.convertValue(singleResource.getValue(), |
|
|
|
singleResource.getType(), ResourceModel.Type.STRING, request.getPath()); |
|
|
|
msg = String.format("%s: Update finished successfully. Lwm2m code: %d Resource path: %s value: %s", |
|
|
|
LOG_LW2M_INFO, response.getCode().getCode(), request.getPath().toString(), value); |
|
|
|
} |
|
|
|
value = valueLength > config.getLogMaxLength() ? value + "..." : value; |
|
|
|
msg = String.format("%s: Update finished successfully: Lwm2m code - %d Resource path: %s length: %s value: %s", |
|
|
|
LOG_LW2M_INFO, response.getCode().getCode(), request.getPath().toString(), valueLength, value); |
|
|
|
} else { |
|
|
|
value = this.converter.convertValue(singleResource.getValue(), |
|
|
|
singleResource.getType(), ResourceModel.Type.STRING, request.getPath()); |
|
|
|
msg = String.format("%s: Update finished successfully. Lwm2m code: %d Resource path: %s value: %s", |
|
|
|
LOG_LW2M_INFO, response.getCode().getCode(), request.getPath().toString(), value); |
|
|
|
} |
|
|
|
if (msg != null) { |
|
|
|
handler.sendLogsToThingsboard(msg, registration.getId()); |
|
|
|
@ -538,11 +554,11 @@ public class LwM2mTransportRequest { |
|
|
|
LwM2mClient lwM2MClient = this.lwM2mClientContext.getClientByRegistrationId(registration.getId()); |
|
|
|
if (request.getPath().toString().equals(FW_PACKAGE_ID) && lwM2MClient.getFwUpdate() != null) { |
|
|
|
lwM2MClient.getFwUpdate().setStateUpdate(DOWNLOADED.name()); |
|
|
|
lwM2MClient.getFwUpdate().sendLogs(WRITE_REPLACE.name(), LOG_LW2M_INFO, null); |
|
|
|
lwM2MClient.getFwUpdate().sendLogs(this.handler, WRITE_REPLACE.name(), LOG_LW2M_INFO, null); |
|
|
|
} |
|
|
|
if (request.getPath().toString().equals(SW_PACKAGE_ID) && lwM2MClient.getSwUpdate() != null) { |
|
|
|
lwM2MClient.getSwUpdate().setStateUpdate(DOWNLOADED.name()); |
|
|
|
lwM2MClient.getSwUpdate().sendLogs(WRITE_REPLACE.name(), LOG_LW2M_INFO, null); |
|
|
|
lwM2MClient.getSwUpdate().sendLogs(this.handler,WRITE_REPLACE.name(), LOG_LW2M_INFO, null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -553,21 +569,21 @@ public class LwM2mTransportRequest { |
|
|
|
LwM2mClient lwM2MClient = this.lwM2mClientContext.getClientByRegistrationId(registration.getId()); |
|
|
|
if (request.getPath().toString().equals(FW_PACKAGE_ID) && lwM2MClient.getFwUpdate() != null) { |
|
|
|
lwM2MClient.getFwUpdate().setStateUpdate(FAILED.name()); |
|
|
|
lwM2MClient.getFwUpdate().sendLogs(WRITE_REPLACE.name(), LOG_LW2M_ERROR, msgError); |
|
|
|
lwM2MClient.getFwUpdate().sendLogs(this.handler, WRITE_REPLACE.name(), LOG_LW2M_ERROR, msgError); |
|
|
|
} |
|
|
|
if (request.getPath().toString().equals(SW_PACKAGE_ID) && lwM2MClient.getSwUpdate() != null) { |
|
|
|
lwM2MClient.getSwUpdate().setStateUpdate(FAILED.name()); |
|
|
|
lwM2MClient.getSwUpdate().sendLogs(WRITE_REPLACE.name(), LOG_LW2M_ERROR, msgError); |
|
|
|
lwM2MClient.getSwUpdate().sendLogs(this.handler, WRITE_REPLACE.name(), LOG_LW2M_ERROR, msgError); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void afterExecuteFwSwUpdateError(Registration registration, DownlinkRequest request, String msgError) { |
|
|
|
LwM2mClient lwM2MClient = this.lwM2mClientContext.getClientByRegistrationId(registration.getId()); |
|
|
|
if (request.getPath().toString().equals(FW_UPDATE_ID) && lwM2MClient.getFwUpdate() != null) { |
|
|
|
lwM2MClient.getFwUpdate().sendLogs(EXECUTE.name(), LOG_LW2M_ERROR, msgError); |
|
|
|
lwM2MClient.getFwUpdate().sendLogs(this.handler, EXECUTE.name(), LOG_LW2M_ERROR, msgError); |
|
|
|
} |
|
|
|
if (request.getPath().toString().equals(SW_INSTALL_ID) && lwM2MClient.getSwUpdate() != null) { |
|
|
|
lwM2MClient.getSwUpdate().sendLogs(EXECUTE.name(), LOG_LW2M_ERROR, msgError); |
|
|
|
lwM2MClient.getSwUpdate().sendLogs(this.handler, EXECUTE.name(), LOG_LW2M_ERROR, msgError); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|