java.lang.Object
org.openremote.agent.protocol.tradfri.device.Observer
All Implemented Interfaces:
org.eclipse.californium.core.CoapHandler
Direct Known Subclasses:
DeviceObserver, GatewayObserver

public abstract class Observer extends Object implements org.eclipse.californium.core.CoapHandler
The class that observes a device to automagically detect changes
  • Constructor Summary

    Constructors
    Constructor
    Description
    Observer(String endpoint, CoapClient coapClient)
    Construct the Observer class
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Call the appropriate event handlers
    protected boolean
    checkChanges(Object oldValue, Object newValue)
    Check if there is a difference between the old value and the new value
    void
    Handles an error from the CoAP client
    void
    onLoad(org.eclipse.californium.core.CoapResponse coapResponse)
    Handles a new response from the CoAP client
    boolean
    Start observing the endpoint to automagically detect changes
    boolean
    Stop observing the device

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Observer

      public Observer(String endpoint, CoapClient coapClient)
      Construct the Observer class
      Parameters:
      endpoint - The endpoint to observe
      coapClient - A CoAP client that can be used to communicate with the device using the IKEA TRÃ…DFRI gateway
  • Method Details

    • start

      public boolean start()
      Start observing the endpoint to automagically detect changes
      Returns:
      True if successfully started observing, false if not
    • stop

      public boolean stop()
      Stop observing the device
      Returns:
      True if successfully stopped observing, false if not
    • checkChanges

      protected boolean checkChanges(Object oldValue, Object newValue)
      Check if there is a difference between the old value and the new value
      Parameters:
      oldValue - The old value
      newValue - The new value
      Returns:
      True if there is a difference between the old value and the new value, false if they are the same
    • onLoad

      public void onLoad(org.eclipse.californium.core.CoapResponse coapResponse)
      Handles a new response from the CoAP client
      Specified by:
      onLoad in interface org.eclipse.californium.core.CoapHandler
      Parameters:
      coapResponse - The response to the CoAP request
    • onError

      public void onError()
      Handles an error from the CoAP client
      Specified by:
      onError in interface org.eclipse.californium.core.CoapHandler
    • callEventHandlers

      public abstract void callEventHandlers(String payload)
      Call the appropriate event handlers
      Parameters:
      payload - The payload text of the CoAP response