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 ClientCB {
36 // callback method defined in application address space
37 OCClientResponseHandler callBack;
38 // callback context data
40 // callback method to delete context data
41 OCClientContextDeleter deleteCallback;
42 // when a response is recvd with this token, above callback will be invoked
44 // Invocation handle tied to original call to OCDoResource()
46 // This is used to determine if all responses should be consumed or not.
47 // (For now, only pertains to OC_REST_OBSERVE_ALL Vs. OC_REST_OBSERVE functionality)
49 // This is the sequence identifier the server applies to the invocation tied to 'handle'.
50 uint32_t sequenceNumber;
51 // This is the request uri associated with the call back
52 unsigned char * requestUri;
53 // Struct to hold TTL info for presence
55 OCPresence * presence;
57 // next node in this list
58 struct ClientCB *next;
61 extern struct ClientCB *cbList;
63 //-- AddClientCB -----------------------------------------------------------
66 * This method is used to add a client callback method in cbList.
68 * @param[out] clientCB
69 * The resulting node from making this call. Null if out of memory.
71 * address to client callback function.
73 * identifier for OTA CoAP comms.
75 * Masked in the public API as an 'invocation handle' - Used for callback management.
76 * @param[in] requestUri
77 * the resource uri of the request.
79 * @brief If the handle you're looking for does not exist, the stack will reply with a RST message.
81 * @retval OC_STACK_OK for Success, otherwise some error value
83 //------------------------------------------------------------------------
84 OCStackResult AddClientCB(ClientCB** clientCB, OCCallbackData* cbData,
85 OCCoAPToken * token, OCDoHandle handle, OCMethod method,
86 unsigned char * requestUri);
88 //-- DeleteClientCB -----------------------------------------------------------
91 * This method is used to remove a callback node from cbList.
94 * address to client callback node.
96 //------------------------------------------------------------------------
97 void DeleteClientCB(ClientCB *cbNode);
100 //-- GetClientCB ---------------------------------------------------------
103 * This method is used to search a cb node in cbList.
106 * token to search for.
108 * handle to search for.
109 * @param[in] requestUri
112 * @brief You can search by token OR by handle. Not both.
114 * @retval address of the node if found, otherwise NULL
116 //------------------------------------------------------------------------
117 ClientCB* GetClientCB(OCCoAPToken * token, OCDoHandle handle, unsigned char * requestUri);
119 //-- DeleteClientCBList --------------------------------------------------
122 * This method is used to clear the cbList.
125 //------------------------------------------------------------------------
126 void DeleteClientCBList();
128 //-- FindAndDeleteClientCB -----------------------------------------------
131 * This method is used to verify the presence of a cb node in cbList
132 * and then delete it.
135 * address to client callback node.
137 //------------------------------------------------------------------------
138 void FindAndDeleteClientCB(ClientCB * cbNode);
140 #endif //OC_CLIENT_CB