Callback: onResourceObserveRequest

Last modified: Jul 5, 2019 @ 06:41

This callback notifies the gateway implementation that DDM wants to observe changes of a resource value.

The implementation is expected to respond with a ResourceObserveResponse.

The values received are sent as telemetry to DDM by calling gateway.sendResourceObservationValue(senMlObject);

The following is an example implementation of the callback:

@Override
public void onResourceObserveRequest(String correlationId, String endpoint, ResourceLink resourceLink) {
  // Get the device by the endpoint value and do the following
  Path path = new Path(resourceLink.getUrl());
  if(path.isResource()) {
    // Subscribe to the resource of the device
    try {
      gateway.sendResourceObserveResponse(correlationId, endpoint, new ResponseCode(ResponseCode.CHANGED, ""));
    } catch (GatewayException e) {
      logger.log(Level.WARNING, "Failed to send response to DDM", e);
    }
  }
}

The following message sequence chart shows the Resource Observe process.

The following message sequence chart shows the Resource Poll process.