[CONPRO-1251]Updated typo error
[platform/upstream/iotivity.git] / resource / csdk / stack / include / internal / ocobserve.h
index 1a98969..2fa6724 100644 (file)
@@ -29,9 +29,6 @@
 #ifndef OC_OBSERVE_H
 #define OC_OBSERVE_H
 
-/** Sequence number is a 24 bit field, per https://tools.ietf.org/html/draft-ietf-core-observe-16.*/
-#define MAX_SEQUENCE_NUMBER              (0xFFFFFF)
-
 /** Maximum number of observers to reach */
 
 #define MAX_OBSERVER_FAILED_COMM         (2)
 #define MAX_OBSERVER_NON_COUNT           (3)
 
 /**
+ *  MAX_OBSERVER_TTL_SECONDS sets the maximum time to live (TTL) for notification.
+ *  60 sec/min * 60 min/hr * 24 hr/day
+ */
+#define MAX_OBSERVER_TTL_SECONDS     (60 * 60 * 24)
+
+#define MILLISECONDS_PER_SECOND   (1000)
+
+/**
  * Data structure to hold informations for each registered observer.
  */
 typedef struct ResourceObserver
@@ -77,6 +82,12 @@ typedef struct ResourceObserver
     /** force the qos value to CON.*/
     uint8_t forceHighQos;
 
+    /** The TTL for this callback. TTL is set to 24 hours.
+     * A server send a notification in a confirmable message every 24 hours.
+     * This prevents a client that went away or is no logger interested
+     * from remaining in the list of observers indefinitely.*/
+    uint32_t TTL;
+
     /** next node in this list.*/
     struct ResourceObserver *next;
 
@@ -85,6 +96,18 @@ typedef struct ResourceObserver
 
 } ResourceObserver;
 
+/**
+ *  Initialize observer list.
+ *
+ * @return ::OC_STACK_OK on success, some other value upon failure.
+ */
+OCStackResult InitializeObserverList();
+
+/**
+ *  Terminate observer list.
+ */
+void TerminateObserverList();
+
 #ifdef WITH_PRESENCE
 /**
  * Create an observe response and send to all observers in the observe list.
@@ -180,6 +203,16 @@ OCStackResult AddObserver (const char         *resUri,
  */
  OCStackResult DeleteObserverUsingToken (CAToken_t token, uint8_t tokenLength);
 
+ /**
+  * Delete observer with device address from list of observers.
+  * Free memory that was allocated for the observer in the list.
+  *
+  * @param devAddr Device's address.
+  *
+  * @return ::OC_STACK_OK on success, some other value upon failure.
+  */
+OCStackResult DeleteObserverUsingDevAddr(const OCDevAddr *devAddr);
+
 /**
  * Search the list of observers for the specified token.
  *
@@ -187,6 +220,7 @@ OCStackResult AddObserver (const char         *resUri,
  * @param tokenLength      Length of token.
  *
  * @return Pointer to found observer.
+ * This is copy of observer, caller must release its memory using FreeObserver().
  */
 ResourceObserver* GetObserverUsingToken (const CAToken_t token, uint8_t tokenLength);
 
@@ -196,10 +230,20 @@ ResourceObserver* GetObserverUsingToken (const CAToken_t token, uint8_t tokenLen
  * @param observeId        Observer ID to search for.
  *
  * @return Pointer to found observer.
+ * This is copy of observer, caller must release its memory using FreeObserver().
  */
 ResourceObserver* GetObserverUsingId (const OCObservationId observeId);
 
 /**
+ * Search the list of observers for the specified observe ID.
+ *
+ * @param observeId        Observer ID to search for.
+ *
+ * @return true if observer found matched with observer ID, otherwise false.
+ */
+bool IsObserverAvailable (const OCObservationId observeId);
+
+/**
  *  Add observe header option to a request.
  *
  * @param caHdrOpt        Target request CA header option.
@@ -234,5 +278,12 @@ GetObserveHeaderOption (uint32_t * observationOption,
                         CAHeaderOption_t *options,
                         uint8_t * numOptions);
 
+/**
+ *  Free memory associated with observer.
+ *
+ * @param obsNode        Observer to be freed.
+ */
+void FreeObserver (ResourceObserver* obsNode);
+
 #endif //OC_OBSERVE_H