@Override public void onResponse(Observation observation, Registration registration, ObserveResponse response) { handleNotification(observation, response.getContent()); }
@Override public void onResponse(Observation observation, Registration registration, ObserveResponse response) { handleNotification(observation, response.getContent()); }
@Override public void onResponse(Observation observation, Registration registration, ObserveResponse response) { if (LOG.isDebugEnabled()) { LOG.debug("Received notification from [{}] containing value [{}]", observation.getPath(), response.getContent().toString()); } if (registration != null) { String data = new StringBuilder("{\"ep\":\"").append(registration.getEndpoint()).append("\",\"res\":\"") .append(observation.getPath().toString()).append("\",\"val\":") .append(gson.toJson(response.getContent())).append("}").toString(); sendEvent(EVENT_NOTIFICATION, data, registration.getEndpoint()); } }
LwM2mObjectInstance getLwM2mObjectInstance(int instanceid, LwM2mInstanceEnabler instance, ServerIdentity identity, boolean observe) { List<LwM2mResource> resources = new ArrayList<>(); for (ResourceModel resourceModel : getObjectModel().resources.values()) { // check, if internal request (SYSTEM) or readable if (identity.isSystem() || resourceModel.operations.isReadable()) { if (observe) { ObserveResponse response = instance.observe(resourceModel.id); if (response.getCode() == ResponseCode.CONTENT && response.getContent() instanceof LwM2mResource) resources.add((LwM2mResource) response.getContent()); } else { ReadResponse response = instance.read(resourceModel.id); if (response.getCode() == ResponseCode.CONTENT && response.getContent() instanceof LwM2mResource) resources.add((LwM2mResource) response.getContent()); } } } return new LwM2mObjectInstance(instanceid, resources); }
if (response.getCode() == org.eclipse.leshan.ResponseCode.CONTENT) { LwM2mPath path = new LwM2mPath(URI); LwM2mNode content = response.getContent(); LwM2mModel model = new LwM2mModel(nodeEnabler.getObjectModel()); ContentFormat format = getContentFormat(observeRequest, requestedContentFormat);