User Tools

Site Tools


resource_observe

This is an old revision of the document!


Observe happens at Resource level and operates in server/client model. Handling of observation registration is application specific. Server application decides whether resource is observable and when to send the observe notification. Client application fetches and registers as an observer for the resource. Notifications from the server to the client may be confirmable or non-confirmable, which can be specified in application via QoS levels.

Additionally, attributes can be declared observable to enable remote devices to subscribe to changes

Flow

Once initialization has been setup server side, server can declare resource property attributes to be observable to enable remote devices to subscribe to changes.

Sample Application :

There are a couple of Samples in resource directory provide examples to use observe APIs.

  • Sample with basic observe feature for server side: resource/examples/simpleserver.cpp
  • Sample with basic observe feature for client side: resource/examples/simpleclient.cpp
  uint8_t resourceFlag = OC_DISCOVERABLE | OC_OBSERVABLE;
  result = OCPlatform::registerResource//
                 ( handle,
                   resourceUri, 
                   resourceType,
                   resourceInterface, //
                   handler, 
                   resourceFlag); //
                   

References :

Previously published documentation which this (living) wiki page is based on : https://www.iotivity.org/documentation/linux/programmers-guide/observing-resource-state-observe

resource_observe.1468506064.txt.gz · Last modified: 2016/07/14 14:21 by Ziran Sun