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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
26 #include <occoaptoken.h>
28 typedef struct OCPresence {
29 // This is the TTL associated with presence
35 typedef struct OCMulticastNode {
38 struct OCMulticastNode * next;
41 extern OCMulticastNode * mcPresenceNodes;
43 typedef struct ClientCB {
44 // callback method defined in application address space
45 OCClientResponseHandler callBack;
46 // callback context data
48 // callback method to delete context data
49 OCClientContextDeleter deleteCallback;
50 // when a response is recvd with this token, above callback will be invoked
52 // Invocation handle tied to original call to OCDoResource()
54 // This is used to determine if all responses should be consumed or not.
55 // (For now, only pertains to OC_REST_OBSERVE_ALL Vs. OC_REST_OBSERVE functionality)
57 // This is the sequence identifier the server applies to the invocation tied to 'handle'.
58 uint32_t sequenceNumber;
59 // This is the request uri associated with the call back
60 unsigned char * requestUri;
61 // Struct to hold TTL info for presence
63 OCPresence * presence;
64 unsigned char * filterResourceType;
66 // next node in this list
67 struct ClientCB *next;
70 extern struct ClientCB *cbList;
72 //-- AddClientCB -----------------------------------------------------------
75 * This method is used to add a client callback method in cbList.
77 * @param[out] clientCB
78 * The resulting node from making this call. Null if out of memory.
80 * address to client callback function.
82 * identifier for OTA CoAP comms.
84 * Masked in the public API as an 'invocation handle' - Used for callback management.
85 * @param[in] requestUri
86 * the resource uri of the request.
87 * @param[in] resourceType
88 * the resourceType associated with this request.
90 * @brief If the handle you're looking for does not exist, the stack will reply with a RST message.
92 * @retval OC_STACK_OK for Success, otherwise some error value
94 //------------------------------------------------------------------------
95 OCStackResult AddClientCB(ClientCB** clientCB, OCCallbackData* cbData,
96 OCCoAPToken * token, OCDoHandle handle, OCMethod method,
97 unsigned char * requestUri, unsigned char * resourceType);
99 //-- DeleteClientCB -----------------------------------------------------------
102 * This method is used to remove a callback node from cbList.
105 * address to client callback node.
107 //------------------------------------------------------------------------
108 void DeleteClientCB(ClientCB *cbNode);
111 //-- GetClientCB ---------------------------------------------------------
114 * This method is used to search a cb node in cbList.
117 * token to search for.
119 * handle to search for.
120 * @param[in] requestUri
123 * @brief You can search by token OR by handle. Not both.
125 * @retval address of the node if found, otherwise NULL
127 //------------------------------------------------------------------------
128 ClientCB* GetClientCB(OCCoAPToken * token, OCDoHandle handle, unsigned char * requestUri);
130 //-- DeleteClientCBList --------------------------------------------------
133 * This method is used to clear the cbList.
136 //------------------------------------------------------------------------
137 void DeleteClientCBList();
139 //-- FindAndDeleteClientCB -----------------------------------------------
142 * This method is used to verify the presence of a cb node in cbList
143 * and then delete it.
146 * address to client callback node.
148 //------------------------------------------------------------------------
149 void FindAndDeleteClientCB(ClientCB * cbNode);
153 * This method is used to search a multicast presence node from list.
156 * the uri of the request.
158 * @return OCMulticastNode
159 * The resulting node from making this call. Null if doesn't exist.
161 //------------------------------------------------------------------------
162 OCMulticastNode* GetMCPresenceNode(unsigned char * uri);
166 * This method is used to add a multicast presence node to the list.
168 * @param[out] outnode
169 * The resulting node from making this call. Null if out of memory.
171 * the uri of the server.
173 * current nonce for the server
175 * @return OC_STACK_OK for Success, otherwise some error value
177 //------------------------------------------------------------------------
178 OCStackResult AddMCPresenceNode(OCMulticastNode** outnode, unsigned char* uri, uint32_t nonce);
180 #endif //OC_CLIENT_CB