1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 /* Sequence number is a 24 bit field */
25 #define MAX_SEQUENCE_NUMBER (0xFFFFFF)
27 #define MAX_OBSERVER_FAILED_COMM (2)
28 #define MAX_OBSERVER_NON_COUNT (3)
30 /* This information is stored for each registerd observer */
31 typedef struct ResourceObserver
33 // Observation Identifier for request
34 OCObservationId observeId;
35 // URI of observed resource
39 //token for the observe request
43 //TODO bundle it in Endpoint structure(address, uri, type, secured)
44 /** Remote Endpoint address **/
45 CAAddress_t addressInfo;
46 /** Connectivity of the endpoint**/
47 CAConnectivityType_t connectivityType;
48 // Quality of service of the request
49 OCQualityOfService qos;
50 // number of times the server failed to reach the observer
51 uint8_t failedCommCount;
52 // number of times the server sent NON notifications
54 // force the qos value to CON
56 // next node in this list
57 struct ResourceObserver *next;
61 OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr, uint32_t maxAge,
62 OCResourceType *resourceType, OCQualityOfService qos);
64 OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr, uint32_t maxAge,
65 OCQualityOfService qos);
67 OCStackResult SendListObserverNotification (OCResource * resource,
68 OCObservationId *obsIdList, uint8_t numberOfIds,
69 const char *notificationJSONPayload, uint32_t maxAge,
70 OCQualityOfService qos);
72 void DeleteObserverList();
74 OCStackResult GenerateObserverId (OCObservationId *observationId);
76 OCStackResult AddObserver (const char *resUri,
78 OCObservationId obsId,
80 OCResource *resHandle,
81 OCQualityOfService qos,
82 const CAAddress_t *addressInfo,
83 CAConnectivityType_t connectivityType);
85 OCStackResult DeleteObserverUsingToken (CAToken_t * token);
87 ResourceObserver* GetObserverUsingToken (const CAToken_t * token);
89 ResourceObserver* GetObserverUsingId (const OCObservationId observeId);
92 CreateObserveHeaderOption (CAHeaderOption_t **caHdrOpt,
93 OCHeaderOption *ocHdrOpt,
97 GetObserveHeaderOption (uint32_t * observationOption,
98 CAHeaderOption_t *options,
99 uint8_t * numOptions);
101 #endif //OC_OBSERVE_H