2b4a582eec6f5fa7f502fc417f0e08c9c66228f3
[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 /**
40  * Discover Local RD across the network.
41  *
42  * @param connectivityType Type of connectivity indicating the interface.
43  * @param cbBiasFactor Asynchronous callback function that is invoked by the stack when
44  *                     response is received. The callback is generated for each response
45  *                     received.
46  * @param qos Quality of service.
47  *
48  * @return ::OC_STACK_OK on success, some other value upon failure.
49  */
50 OCStackResult OCRDDiscover(OCConnectivityType connectivityType, OCCallbackData *cbBiasFactor,
51                            OCQualityOfService qos);
52
53 /**
54  * Publish RD resource to Resource Directory.
55  *
56  * @param host The address of the RD.
57  * @param connectivityType Type of connectivity indicating the interface.
58  * @param resourceHandles This is the resource handle which we need to register to RD.
59  * @param nHandles The counts of resource handle.
60  * @param cbData Asynchronous callback function that is invoked by the stack when
61  *               response is received. The callback is generated for each response
62  *               received.
63  * @param qos Quality of service.
64  *
65  * @return ::OC_STACK_OK on success, some other value upon failure.
66  */
67 OCStackResult OCRDPublish(const char *host, OCConnectivityType connectivityType,
68                           OCResourceHandle *resourceHandles, uint8_t nHandles,
69                           OCCallbackData *cbData, OCQualityOfService qos);
70
71 /**
72  * Publish RD resource to Resource Directory with a specific id.
73  *
74  * @param host The address of the RD.
75  * @param id An unique identifier of publishing device.
76  * @param connectivityType Type of connectivity indicating the interface.
77  * @param resourceHandles This is the resource handle which we need to register to RD.
78  * @param nHandles The counts of resource handle.
79  * @param cbData Asynchronous callback function that is invoked by the stack when
80  *               response is received. The callback is generated for each response
81  *               received.
82  * @param qos Quality of service.
83  *
84  * @return ::OC_STACK_OK on success, some other value upon failure.
85  */
86 OCStackResult OCRDPublishWithDeviceId(const char *host, const unsigned char *id,
87                                       OCConnectivityType connectivityType,
88                                       OCResourceHandle *resourceHandles, uint8_t nHandles,
89                                       OCCallbackData *cbData, OCQualityOfService qos);
90
91 /**
92  * Delete RD resource from Resource Directory.
93  *
94  * @param host The address of the RD.
95  * @param connectivityType Type of connectivity indicating the interface.
96  * @param resourceHandles This is the resource handle which we need to delete to RD.
97  * @param nHandles The counts of resource handle.
98  * @param cbData Asynchronous callback function that is invoked by the stack when
99  *               response is received. The callback is generated for each response
100  *               received.
101  * @param qos Quality of service.
102  *
103  * @return ::OC_STACK_OK on success, some other value upon failure.
104  */
105 OCStackResult OCRDDelete(const char *host, OCConnectivityType connectivityType,
106                          OCResourceHandle *resourceHandles, uint8_t nHandles,
107                          OCCallbackData *cbData, OCQualityOfService qos);
108
109 /**
110  * Delete RD resource from Resource Directory.
111  *
112  * @param host The address of the RD.
113  * @param id An unique identifier of publishing device.
114  * @param connectivityType Type of connectivity indicating the interface.
115  * @param resourceHandles This is the resource handle which we need to delete to RD.
116  * @param nHandles The counts of resource handle.
117  * @param cbData Asynchronous callback function that is invoked by the stack when
118  *               response is received. The callback is generated for each response
119  *               received.
120  * @param qos Quality of service.
121  *
122  * @return ::OC_STACK_OK on success, some other value upon failure.
123  */
124 OCStackResult OCRDDeleteWithDeviceId(const char *host, const unsigned char *id,
125                                      OCConnectivityType connectivityType,
126                                      OCResourceHandle *resourceHandles, uint8_t nHandles,
127                                      OCCallbackData *cbData, OCQualityOfService qos);
128
129 #endif
130
131 #ifdef __cplusplus
132 }
133 #endif // __cplusplus
134
135 #endif //_RESOURCE_DIRECTORY_CLIENT_H_