1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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 ******************************************************************/
21 * @file ThingsManagerNativeInterface.java
23 * @brief This file provides a class which provides a set of native functions relating to group
24 * management, synchronization of group, configuration of things, and
25 * diagnostics about things.
28 package org.iotivity.service.tm;
31 import java.util.Vector;
33 import org.iotivity.base.OcResource;
34 import org.iotivity.base.OcResourceHandle;
37 * This class provides a set of native functions relating to group
38 * management, synchronization of group, configuration of things, and
39 * diagnostics about things.
42 class ThingsManagerNativeInterface {
44 * Native function for discoverying candidate resources.
46 * @param resourceTypes
47 * - required resource types(called "candidate")
49 * - Delay time in seconds to add before starting to find the
50 * resources in network.
52 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
56 public static native int findCandidateResources(
57 Vector<String> resourceTypes, int waitTime);
60 * Native function for subscribing child's state.
63 * - collection resource for subscribing presence of all child
66 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
70 public static native int subscribeCollectionPresence(OcResource resource);
73 * Native function for register and bind resource to group.
76 * - resource for register and bind to group. It has all data.
77 * @param collectionHandle
78 * - collection resource handle. It will be added child resource.
80 * @return OcResourceHandle - Child resource handle.
83 public static native OcResourceHandle bindResourceToGroup(OcResource resource,
84 OcResourceHandle collectionHandle);
87 * Native function for finding a specific remote group when a resource tries
88 * to join a group. Callback is called when a group is found or not.
90 * @param collectionResourceTypes
91 * - resource types of a group to find and join
93 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
97 public static native int findGroup(Vector<String> collectionResourceTypes);
100 * Native function for creating a new group.
102 * @param collectionResourceType
103 * - resource type of a group to create
105 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
108 public static native int createGroup(String collectionResourceType);
111 * Native function for joining a group. This API is used when a resource
112 * that has a group tries to find a specific remote resource and makes it
115 * @param collectionResourceType
116 * - resource type of a group to join.
117 * @param resourceHandle
118 * - resource handle to join a group.
120 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
124 public static native int joinGroup(String collectionResourceType,
125 OcResourceHandle resourceHandle);
128 * Native function for joining a group. This is used when a resource that
129 * doesn't have a group tries to find and join a specific remote group.
132 * - group resource to join.
133 * @param resourceHandle
134 * - resource handle to join a group.
136 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
140 public static native int joinGroup(OcResource resource,
141 OcResourceHandle resourceHandle);
144 * Native function for leaving a joined group.
146 * @param collectionResourceType
147 * - resource type of a group to leave.
148 * @param resourceHandle
149 * - resource handle to leave a group.
151 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
155 public static native int leaveGroup(String collectionResourceType,
156 OcResourceHandle resourceHandle);
159 * Native function for leaving a joined group.
162 * - resource of a group to leave.
163 * @param collectionResourceType
164 * - resource type of a group to leave.
165 * @param resourceHandle
166 * - resource handle to leave a group.
168 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
172 public static native int leaveGroup(OcResource resource,
173 String collectionResourceType, OcResourceHandle resourceHandle);
176 * Native function for deleting a group.
178 * @param collectionResourceType
179 * - resource type of a group to delete.
183 public static native void deleteGroup(String collectionResourceType);
186 * Native function for getting a list of joined groups.
188 * @return Returns group resource type and group resource handle as a map
192 public static native Map<String, OcResourceHandle> getGroupList();
195 * Native function for updating configuration value of multiple things of a
196 * target group or a single thing.
199 * - resource representing the target group or the single thing.
200 * @param configurations
201 * - ConfigurationUnit: a nickname of attribute of target
202 * resource (e.g., installed location, currency, (IP)address)
203 * Value : a value to be updated
205 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
209 public static native int updateConfigurations(OcResource resource,
210 Map<String, String> configurations);
213 * Native function for getting configuration value of multiple things of a
214 * target group or a single thing.
217 * - resource representing the target group or the single thing.
218 * @param configurations
219 * - ConfigurationUnit: a nickname of attribute of target
222 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
226 public static native int getConfigurations(OcResource resource,
227 Vector<String> configurations);
230 * Native function for showing the list of supported configuration units
231 * (configurable parameters)
233 * @return Returns the configuration list in JSON format.
236 public static native String getListOfSupportedConfigurationUnits();
239 * Native function for bootstrapping system configuration parameters from a
242 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
245 public static native int doBootstrap();
248 * Native function to let thing(device) reboot. The target thing could be a
249 * group of multiple things or a single thing.
252 * - resource pointer representing the target group
254 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
257 public static native int reboot(OcResource resource);
260 * Native function for factory reset on thing(device). The target thing
261 * could be a group of multiple things or a single thing.
264 * - resource pointer representing the target group
266 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
269 public static native int factoryReset(OcResource resource);
272 * Native function for adding an Action Set. Callback is called when the
273 * response of PUT operation arrives.
276 * - resource pointer of the group resource
278 * - pointer of Action Set
280 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
283 public static native int addActionSet(OcResource resource,
284 ActionSet actionSet);
287 * Native function for executing the Action Set. Callback is called when the
288 * response of POST operation arrives.
291 * - resource pointer of the group resource
292 * @param actionsetName
293 * - Action Set name for removing the Action set
295 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
298 public static native int executeActionSet(OcResource resource,
299 String actionsetName);
302 * Native function for executing the Action Set. Callback is called when the
303 * response of POST operation arrives.
306 * - resource pointer of the group resource
307 * @param actionsetName
308 * - Action Set name for removing the Action set
310 * - waiting time for until action set run.
312 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
315 public static native int executeActionSet(OcResource resource,
316 String actionsetName, long delay);
319 * Native function for cancelling the Action Set. Callback is called when
320 * the response of POST operation arrives.
323 * - resource pointer of the group resource
324 * @param actionsetName
325 * - Action Set name for removing the Action set
327 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
330 public static native int cancelActionSet(OcResource resource,
331 String actionsetName);
334 * Native function for reading the Action Set. Callback is called when the
335 * response of GET operation arrives.
338 * - resource pointer of the group resource
339 * @param actionsetName
340 * - Action Set name for removing the Action set
342 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
345 public static native int getActionSet(OcResource resource,
346 String actionsetName);
349 * Native function for removing the action set. Callback is called when the
350 * response of POST operation arrives.
353 * - resource pointer of the group resource
354 * @param actionsetName
355 * - Action Set name for removing the Action set
357 * @return OCStackResult - return value of this API. It returns OC_STACK_OK
360 public static native int deleteActionSet(OcResource resource,
361 String actionsetName);