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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
27 #include <ocresource.h>
30 typedef struct OCPresence
32 // This is the TTL associated with presence
38 typedef struct OCMulticastNode
42 struct OCMulticastNode * next;
45 typedef struct ClientCB {
46 // callback method defined in application address space
47 OCClientResponseHandler callBack;
48 // callback context data
50 // callback method to delete context data
51 OCClientContextDeleter deleteCallback;
52 // when a response is recvd with this token, above callback will be invoked
54 // a response is recvd with this token length
56 // Invocation handle tied to original call to OCDoResource()
58 // This is used to determine if all responses should be consumed or not.
59 // (For now, only pertains to OC_REST_OBSERVE_ALL Vs. OC_REST_OBSERVE functionality)
61 // This is the sequence identifier the server applies to the invocation tied to 'handle'.
62 uint32_t sequenceNumber;
63 // This is the request uri associated with the call back
65 // Struct to hold TTL info for presence
67 OCPresence * presence;
68 OCResourceType * filterResourceType;
70 // The connectivity type on which the request was sent on.
71 OCConnectivityType conType;
72 // next node in this list
73 struct ClientCB *next;
76 extern struct ClientCB *cbList;
80 * This method is used to add a client callback method in cbList.
82 * @param[out] clientCB
83 * The resulting node from making this call. Null if out of memory.
85 * address to client callback function.
87 * identifier for OTA CoAP comms.
89 * Masked in the public API as an 'invocation handle' - Used for callback management.
91 * OCMethod via which this client callback is expected to operate
92 * @param[in] requestUri
93 * the resource uri of the request.
94 * @param[in] resourceType
95 * the resourceType associated with a presence request.
97 * the connectivity type on which the associated request for this clientCB was sent on.
99 * @brief If the handle you're looking for does not exist, the stack will reply with a RST message.
101 * @return OC_STACK_OK for Success, otherwise some error value
104 AddClientCB (ClientCB** clientCB, OCCallbackData* cbData,
105 CAToken_t token, uint8_t tokenLength,
106 OCDoHandle *handle, OCMethod method,
107 char * requestUri, char * resourceTypeName, OCConnectivityType conType);
111 * This method is used to remove a callback node from cbList.
114 * address to client callback node.
116 void DeleteClientCB(ClientCB *cbNode);
121 * This method is used to search and retrieve a cb node in cbList.
124 * token to search for.
126 * handle to search for.
127 * @param[in] requestUri
130 * @brief You can search by token OR by handle, but not both.
132 * @return address of the node if found, otherwise NULL
134 ClientCB* GetClientCB(const CAToken_t token, uint8_t tokenLength,
135 OCDoHandle handle, const char * requestUri);
138 * Inserts a new resource type filter into this cb node.
141 * the node to add the new resourceType filter to
142 * @param[in] resourceTypeName
143 * the value to create the new resourceType filter from
146 * OC_STACK_OK on success
147 * OC_STACK_ERROR with invalid parameters
148 * OC_STACK_NO_MEMORY when out of memory
151 OCStackResult InsertResourceTypeFilter(ClientCB * cbNode, char * resourceTypeName);
152 #endif // WITH_PRESENCE
156 * This method is used to clear the cbList.
159 void DeleteClientCBList();
163 * This method is used to verify the presence of a cb node in cbList
164 * and then delete it.
167 * address to client callback node.
169 void FindAndDeleteClientCB(ClientCB * cbNode);
173 * This method is used to search a multicast presence node from list.
176 * the uri of the request.
178 * @return OCMulticastNode
179 * The resulting node from making this call. Null if doesn't exist.
181 //------------------------------------------------------------------------
182 OCMulticastNode* GetMCPresenceNode(const char * uri);
186 * This method is used to add a multicast presence node to the list.
188 * @param[out] outnode
189 * The resulting node from making this call. Null if out of memory.
191 * the uri of the server.
193 * current nonce for the server
195 * @return OC_STACK_OK for Success, otherwise some error value
197 //------------------------------------------------------------------------
198 OCStackResult AddMCPresenceNode(OCMulticastNode** outnode, char* uri, uint32_t nonce);
200 #endif //OC_CLIENT_CB