Removed Token ASCII-char limit and length limit
[platform/upstream/iotivity.git] / resource / csdk / stack / include / internal / ocobserve.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef OC_OBSERVE_H
22 #define OC_OBSERVE_H
23
24 /* Sequence number is a 24 bit field */
25 #define MAX_SEQUENCE_NUMBER              (0xFFFFFF)
26
27 #define MAX_OBSERVER_FAILED_COMM         (2)
28 #define MAX_OBSERVER_NON_COUNT           (3)
29
30 /* This information is stored for each registerd observer */
31 typedef struct ResourceObserver
32 {
33     // Observation Identifier for request
34     OCObservationId observeId;
35     // URI of observed resource
36     char *resUri;
37     // Query
38     char *query;
39     //token for the observe request
40     CAToken_t token;
41     //token length for the observe request
42     uint8_t tokenLength;
43     // Resource handle
44     OCResource *resource;
45     //TODO bundle it in Endpoint structure(address, uri, type, secured)
46     /** Remote Endpoint address **/
47     CAAddress_t addressInfo;
48     /** Connectivity of the endpoint**/
49     CAConnectivityType_t connectivityType;
50     // Quality of service of the request
51     OCQualityOfService qos;
52     // number of times the server failed to reach the observer
53     uint8_t failedCommCount;
54     // number of times the server sent NON notifications
55     uint8_t lowQosCount;
56     // force the qos value to CON
57     uint8_t forceHighQos;
58     // next node in this list
59     struct ResourceObserver *next;
60 } ResourceObserver;
61
62 #ifdef WITH_PRESENCE
63 OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr, uint32_t maxAge,
64         OCResourceType *resourceType, OCQualityOfService qos);
65 #else
66 OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr, uint32_t maxAge,
67         OCQualityOfService qos);
68 #endif
69 OCStackResult SendListObserverNotification (OCResource * resource,
70         OCObservationId  *obsIdList, uint8_t numberOfIds,
71         const char *notificationJSONPayload, uint32_t maxAge,
72         OCQualityOfService qos);
73
74 void DeleteObserverList();
75
76 OCStackResult GenerateObserverId (OCObservationId *observationId);
77
78 OCStackResult AddObserver (const char         *resUri,
79                            const char         *query,
80                            OCObservationId    obsId,
81                            CAToken_t          *token,
82                            uint8_t            tokenLength,
83                            OCResource         *resHandle,
84                            OCQualityOfService qos,
85                            const CAAddress_t  *addressInfo,
86                            CAConnectivityType_t connectivityType);
87
88 OCStackResult DeleteObserverUsingToken (CAToken_t * token, uint8_t tokenLength);
89
90 ResourceObserver* GetObserverUsingToken (const CAToken_t * token, uint8_t tokenLength);
91
92 ResourceObserver* GetObserverUsingId (const OCObservationId observeId);
93
94 OCStackResult
95 CreateObserveHeaderOption (CAHeaderOption_t **caHdrOpt,
96                            OCHeaderOption *ocHdrOpt,
97                            uint8_t numOptions,
98                            uint8_t observeFlag);
99 OCStackResult
100 GetObserveHeaderOption (uint32_t * observationOption,
101                         CAHeaderOption_t *options,
102                         uint8_t * numOptions);
103
104 #endif //OC_OBSERVE_H
105