replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / resource-directory / include / rd_client.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef _RESOURCE_DIRECTORY_CLIENT_H_
22 #define _RESOURCE_DIRECTORY_CLIENT_H_
23
24 // Iotivity Base CAPI
25 #include "ocstack.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif // __cplusplus
30
31 #ifdef RD_CLIENT
32
33 #define OIC_RD_PUBLISH_TTL 86400
34
35 #define OIC_RD_DEFAULT_RESOURCE 2
36
37 #define DEFAULT_MESSAGE_TYPE "application/json"
38
39 /** Platform Model Number.*/
40 #define OC_DATA_MODEL_NUMBER            "x.model"
41
42 /**
43  * Discover Local RD across the network.
44  *
45  * @param handle            To refer to the request sent out on behalf of
46  *                          calling this API. This handle can be used to cancel this operation
47  *                          via the OCCancel API.
48  *                          @note: This reference is handled internally, and should not be free'd by
49  *                          the consumer.  A NULL handle is permitted in the event where the caller
50  *                          has no use for the return value.
51  * @param connectivityType  Type of connectivity indicating the interface.
52  * @param cbBiasFactor      Asynchronous callback function that is invoked by the stack when
53  *                          response is received. The callback is generated for each response
54  *                          received.
55  * @param qos               Quality of service.
56  *
57  * @return ::OC_STACK_OK on success, some other value upon failure.
58  */
59 OCStackResult OCRDDiscover(OCDoHandle *handle, OCConnectivityType connectivityType,
60                            OCCallbackData *cbBiasFactor, OCQualityOfService qos);
61
62 /**
63  * Publish RD resource to Resource Directory.
64  *
65  * @param handle            To refer to the request sent out on behalf of
66  *                          calling this API. This handle can be used to cancel this operation
67  *                          via the OCCancel API.
68  *                          @note: This reference is handled internally, and should not be free'd by
69  *                          the consumer.  A NULL handle is permitted in the event where the caller
70  *                          has no use for the return value.
71  * @param host              The address of the RD.
72  * @param connectivityType  Type of connectivity indicating the interface.
73  * @param resourceHandles   This is the resource handle which we need to register to RD.
74  * @param nHandles          The counts of resource handle.
75  * @param cbData            Asynchronous callback function that is invoked by the stack when
76  *                          response is received. The callback is generated for each response
77  *                          received.
78  * @param qos               Quality of service.
79  *
80  * @return ::OC_STACK_OK on success, some other value upon failure.
81  */
82 OCStackResult OCRDPublish(OCDoHandle *handle, const char *host,
83                           OCConnectivityType connectivityType,
84                           OCResourceHandle *resourceHandles, uint8_t nHandles,
85                           OCCallbackData *cbData, OCQualityOfService qos);
86
87 /**
88  * Publish RD resource to Resource Directory with a specific id.
89  *
90  * @param handle            To refer to the request sent out on behalf of
91  *                          calling this API. This handle can be used to cancel this operation
92  *                          via the OCCancel API.
93  *                          @note: This reference is handled internally, and should not be free'd by
94  *                          the consumer.  A NULL handle is permitted in the event where the caller
95  *                          has no use for the return value.
96  * @param host              The address of the RD.
97  * @param id                An unique identifier of publishing device.
98  * @param connectivityType  Type of connectivity indicating the interface.
99  * @param resourceHandles   This is the resource handle which we need to register to RD.
100  * @param nHandles          The counts of resource handle.
101  * @param cbData            Asynchronous callback function that is invoked by the stack when
102  *                          response is received. The callback is generated for each response
103  *                          received.
104  * @param qos               Quality of service.
105  *
106  * @return ::OC_STACK_OK on success, some other value upon failure.
107  */
108 OCStackResult OCRDPublishWithDeviceId(OCDoHandle *handle, const char *host,
109                                       const unsigned char *id,
110                                       OCConnectivityType connectivityType,
111                                       OCResourceHandle *resourceHandles, uint8_t nHandles,
112                                       OCCallbackData *cbData, OCQualityOfService qos);
113
114 /**
115  * Delete RD resource from Resource Directory.
116  *
117  * @param handle            To refer to the request sent out on behalf of
118  *                          calling this API. This handle can be used to cancel this operation
119  *                          via the OCCancel API.
120  *                          @note: This reference is handled internally, and should not be free'd by
121  *                          the consumer.  A NULL handle is permitted in the event where the caller
122  *                          has no use for the return value.
123  * @param host              The address of the RD.
124  * @param connectivityType  Type of connectivity indicating the interface.
125  * @param resourceHandles   This is the resource handle which we need to delete to RD.
126  * @param nHandles          The counts of resource handle.
127  * @param cbData            Asynchronous callback function that is invoked by the stack when
128  *                          response is received. The callback is generated for each response
129  *                          received.
130  * @param qos               Quality of service.
131  *
132  * @return ::OC_STACK_OK on success, some other value upon failure.
133  */
134 OCStackResult OCRDDelete(OCDoHandle *handle, const char *host,
135                          OCConnectivityType connectivityType,
136                          OCResourceHandle *resourceHandles, uint8_t nHandles,
137                          OCCallbackData *cbData, OCQualityOfService qos);
138
139 /**
140  * Delete RD resource from Resource Directory.
141  *
142  * @param handle            To refer to the request sent out on behalf of
143  *                          calling this API. This handle can be used to cancel this operation
144  *                          via the OCCancel API.
145  *                          @note: This reference is handled internally, and should not be free'd by
146  *                          the consumer.  A NULL handle is permitted in the event where the caller
147  *                          has no use for the return value.
148  * @param host              The address of the RD.
149  * @param id                An unique identifier of publishing device.
150  * @param connectivityType  Type of connectivity indicating the interface.
151  * @param resourceHandles   This is the resource handle which we need to delete to RD.
152  * @param nHandles          The counts of resource handle.
153  * @param cbData            Asynchronous callback function that is invoked by the stack when
154  *                          response is received. The callback is generated for each response
155  *                          received.
156  * @param qos               Quality of service.
157  *
158  * @return ::OC_STACK_OK on success, some other value upon failure.
159  */
160 OCStackResult OCRDDeleteWithDeviceId(OCDoHandle *handle, const char *host,
161                                      const unsigned char *id,
162                                      OCConnectivityType connectivityType,
163                                      OCResourceHandle *resourceHandles, uint8_t nHandles,
164                                      OCCallbackData *cbData, OCQualityOfService qos);
165
166 #endif
167
168 #ifdef __cplusplus
169 }
170 #endif // __cplusplus
171
172 #endif //_RESOURCE_DIRECTORY_CLIENT_H_