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;
65 // next node in this list
66 struct ClientCB *next;
69 extern struct ClientCB *cbList;
71 //-- AddClientCB -----------------------------------------------------------
74 * This method is used to add a client callback method in cbList.
76 * @param[out] clientCB
77 * The resulting node from making this call. Null if out of memory.
79 * address to client callback function.
81 * identifier for OTA CoAP comms.
83 * Masked in the public API as an 'invocation handle' - Used for callback management.
84 * @param[in] requestUri
85 * the resource uri of the request.
87 * @brief If the handle you're looking for does not exist, the stack will reply with a RST message.
89 * @retval OC_STACK_OK for Success, otherwise some error value
91 //------------------------------------------------------------------------
92 OCStackResult AddClientCB(ClientCB** clientCB, OCCallbackData* cbData,
93 OCCoAPToken * token, OCDoHandle handle, OCMethod method,
94 unsigned char * requestUri);
96 //-- DeleteClientCB -----------------------------------------------------------
99 * This method is used to remove a callback node from cbList.
102 * address to client callback node.
104 //------------------------------------------------------------------------
105 void DeleteClientCB(ClientCB *cbNode);
108 //-- GetClientCB ---------------------------------------------------------
111 * This method is used to search a cb node in cbList.
114 * token to search for.
116 * handle to search for.
117 * @param[in] requestUri
120 * @brief You can search by token OR by handle. Not both.
122 * @retval address of the node if found, otherwise NULL
124 //------------------------------------------------------------------------
125 ClientCB* GetClientCB(OCCoAPToken * token, OCDoHandle handle, unsigned char * requestUri);
127 //-- DeleteClientCBList --------------------------------------------------
130 * This method is used to clear the cbList.
133 //------------------------------------------------------------------------
134 void DeleteClientCBList();
136 //-- FindAndDeleteClientCB -----------------------------------------------
139 * This method is used to verify the presence of a cb node in cbList
140 * and then delete it.
143 * address to client callback node.
145 //------------------------------------------------------------------------
146 void FindAndDeleteClientCB(ClientCB * cbNode);
150 * This method is used to search a multicast presence node from list.
153 * the uri of the request.
155 * @return OCMulticastNode
156 * The resulting node from making this call. Null if doesn't exist.
158 //------------------------------------------------------------------------
159 OCMulticastNode* GetMCPresenceNode(unsigned char * uri);
163 * This method is used to add a multicast presence node to the list.
165 * @param[out] outnode
166 * The resulting node from making this call. Null if out of memory.
168 * the uri of the server.
170 * current nonce for the server
172 * @return OC_STACK_OK for Success, otherwise some error value
174 //------------------------------------------------------------------------
175 OCStackResult AddMCPresenceNode(OCMulticastNode** outnode, unsigned char* uri, uint32_t nonce);
177 #endif //OC_CLIENT_CB