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 /* In CoAP 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 {
32 // Observation Identifier for request
33 OCObservationId observeId;
34 // URI of observed resource
35 unsigned char *resUri;
38 // CoAP token for the observe request
42 // IP address & port of client registered for observe
44 // Quality of service of the request
45 OCQualityOfService qos;
46 // number of times the server failed to reach the observer
47 uint8_t failedCommCount;
48 // number of times the server sent NON notifications
50 // force the qos value to CON
52 // next node in this list
53 struct ResourceObserver *next;
57 OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr, uint32_t maxAge,
58 OCResourceType *resourceType, OCQualityOfService qos);
60 OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr, uint32_t maxAge,
61 OCQualityOfService qos);
63 OCStackResult SendListObserverNotification (OCResource * resource,
64 OCObservationId *obsIdList, uint8_t numberOfIds,
65 unsigned char *notificationJSONPayload, uint32_t maxAge,
66 OCQualityOfService qos);
68 void DeleteObserverList();
70 OCStackResult GenerateObserverId (OCObservationId *observationId);
72 OCStackResult AddObserver (const char *resUri,
74 OCObservationId obsId,
77 OCResource *resHandle,
78 OCQualityOfService qos);
80 OCStackResult DeleteObserverUsingToken (OCCoAPToken * token);
82 ResourceObserver* GetObserverUsingToken (const OCCoAPToken * token);
84 ResourceObserver* GetObserverUsingId (const OCObservationId observeId);