2 * //******************************************************************
4 * // Copyright 2015 Intel Corporation.
6 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 * // Licensed under the Apache License, Version 2.0 (the "License");
9 * // you may not use this file except in compliance with the License.
10 * // You may obtain a copy of the License at
12 * // http://www.apache.org/licenses/LICENSE-2.0
14 * // Unless required by applicable law or agreed to in writing, software
15 * // distributed under the License is distributed on an "AS IS" BASIS,
16 * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * // See the License for the specific language governing permissions and
18 * // limitations under the License.
20 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 package org.iotivity.base;
25 import org.iotivity.ca.CaInterface;
27 import java.util.EnumSet;
28 import java.util.Iterator;
29 import java.util.List;
32 * This class contains the main entrance/functionality of the product. To set a custom
33 * configuration, the implementer must make a call to OcPlatform.Configure before the first usage
34 * of a method in this class.
36 public final class OcPlatform {
39 System.loadLibrary("oc_logger");
40 System.loadLibrary("octbstack");
41 System.loadLibrary("connectivity_abstraction");
42 System.loadLibrary("oc");
43 System.loadLibrary("ocstack-jni");
49 public static final String DEFAULT_INTERFACE = "oic.if.baseline";
52 * Used in discovering (GET) links to other resources of a collection
54 public static final String LINK_INTERFACE = "oic.if.ll";
57 * Used in GET, PUT, POST, DELETE methods on links to other resources of a collection
59 public static final String BATCH_INTERFACE = "oic.if.b";
62 * Used in GET, PUT, POST methods on links to other remote resources of a group
64 public static final String GROUP_INTERFACE = "oic.mi.grp";
66 public static final String WELL_KNOWN_QUERY = "/oic/res";
67 public static final String WELL_KNOWN_DEVICE_QUERY = "/oic/d";
68 public static final String WELL_KNOWN_PLATFORM_QUERY = "/oic/p";
69 public static final int DEFAULT_PRESENCE_TTL = 60;
70 public static final String PRESENCE_URI = "/oic/ad";
72 private static volatile boolean sIsPlatformInitialized = false;
74 private OcPlatform() {
78 * API for setting the configuration of the OcPlatform.
80 * Note: Any calls made to this AFTER the first call to OcPlatform.Configure will have no affect
83 * @param platformConfig platform configuration
85 public synchronized static void Configure(PlatformConfig platformConfig) {
86 if (!sIsPlatformInitialized) {
87 CaInterface.initialize(platformConfig.getContext());
90 platformConfig.getServiceType().getValue(),
91 platformConfig.getModeType().getValue(),
92 platformConfig.getIpAddress(),
93 platformConfig.getPort(),
94 platformConfig.getQualityOfService().getValue(),
95 platformConfig.getSvrDbPath()
98 sIsPlatformInitialized = true;
102 private static native void configure(int serviceType,
106 int qualityOfService,
110 * API for notifying base that resource's attributes have changed.
112 * Note: This API is for server side only.
115 * @param ocResourceHandle resource handle of the resource
116 * @throws OcException if failure
118 public static void notifyAllObservers(
119 OcResourceHandle ocResourceHandle) throws OcException {
120 OcPlatform.initCheck();
121 OcPlatform.notifyAllObservers0(ocResourceHandle);
124 private static native void notifyAllObservers0(
125 OcResourceHandle ocResourceHandle) throws OcException;
128 * API for notifying base that resource's attributes have changed.
130 * Note: This API is for server side only.
133 * @param ocResourceHandle resource handle of the resource
134 * @param qualityOfService the quality of communication
135 * @throws OcException if failure
137 public static void notifyAllObservers(
138 OcResourceHandle ocResourceHandle,
139 QualityOfService qualityOfService) throws OcException {
140 OcPlatform.initCheck();
141 OcPlatform.notifyAllObservers1(ocResourceHandle, qualityOfService.getValue());
144 private static native void notifyAllObservers1(
145 OcResourceHandle ocResourceHandle,
146 int qualityOfService) throws OcException;
149 * API for notifying only specific clients that resource's attributes have changed.
151 * Note: This API is for server side only.
154 * @param ocResourceHandle resource handle of the resource
155 * @param ocObservationIdList These set of ids are ones which which will be notified upon
157 * @param ocResourceResponse OcResourceResponse object used by app to fill the response for
158 * this resource change
159 * @throws OcException if failure
161 public static void notifyListOfObservers(
162 OcResourceHandle ocResourceHandle,
163 List<Byte> ocObservationIdList,
164 OcResourceResponse ocResourceResponse) throws OcException {
165 OcPlatform.initCheck();
167 byte[] idArr = new byte[ocObservationIdList.size()];
168 Iterator<Byte> it = ocObservationIdList.iterator();
170 while (it.hasNext()) {
171 idArr[i++] = (byte) it.next();
174 OcPlatform.notifyListOfObservers2(
180 private static native void notifyListOfObservers2(
181 OcResourceHandle ocResourceHandle,
182 byte[] ocObservationIdArray,
183 OcResourceResponse ocResourceResponse) throws OcException;
186 * API for notifying only specific clients that resource's attributes have changed.
188 * Note: This API is for server side only.
191 * @param ocResourceHandle resource handle of the resource
192 * @param ocObservationIdList These set of ids are ones which which will be notified upon
194 * @param ocResourceResponse OcResourceResponse object used by app to fill the response for
195 * this resource change
196 * @param qualityOfService the quality of communication
197 * @throws OcException if failure
199 public static void notifyListOfObservers(
200 OcResourceHandle ocResourceHandle,
201 List<Byte> ocObservationIdList,
202 OcResourceResponse ocResourceResponse,
203 QualityOfService qualityOfService) throws OcException {
204 OcPlatform.initCheck();
206 byte[] idArr = new byte[ocObservationIdList.size()];
207 Iterator<Byte> it = ocObservationIdList.iterator();
209 while (it.hasNext()) {
210 idArr[i++] = (byte) it.next();
213 OcPlatform.notifyListOfObservers3(
217 qualityOfService.getValue()
221 private static native void notifyListOfObservers3(
222 OcResourceHandle ocResourceHandle,
223 byte[] ocObservationIdArray,
224 OcResourceResponse ocResourceResponse,
225 int qualityOfService) throws OcException;
228 * API for Service and Resource Discovery
230 * Note: This API is for client side only.
233 * @param host Host Address of a service to direct resource discovery query.
234 * If empty, performs multicast resource discovery query
235 * @param resourceUri name of the resource. If null or empty, performs search for all
237 * @param connectivityTypeSet Set of types of connectivity. Example: IP
238 * @param onResourceFoundListener Handles events, success states and failure states.
239 * @throws OcException if failure
241 public static void findResource(
244 EnumSet<OcConnectivityType> connectivityTypeSet,
245 OnResourceFoundListener onResourceFoundListener) throws OcException {
246 OcPlatform.initCheck();
250 for (OcConnectivityType connType : OcConnectivityType.values()) {
251 if (connectivityTypeSet.contains(connType))
252 connTypeInt |= connType.getValue();
255 OcPlatform.findResource0(
259 onResourceFoundListener
263 private static native void findResource0(
266 int connectivityType,
267 OnResourceFoundListener onResourceFoundListener) throws OcException;
270 * API for Service and Resource Discovery.
272 * Note: This API is for client side only.
275 * @param host Host IP Address of a service to direct resource discovery query.
276 * If empty, performs multicast resource discovery query
277 * @param resourceUri name of the resource. If null or empty, performs search for all
279 * @param connectivityTypeSet Set of types of connectivity. Example: IP
280 * @param onResourceFoundListener Handles events, success states and failure states.
281 * @param qualityOfService the quality of communication
282 * @throws OcException if failure
284 public static void findResource(
287 EnumSet<OcConnectivityType> connectivityTypeSet,
288 OnResourceFoundListener onResourceFoundListener,
289 QualityOfService qualityOfService) throws OcException {
290 OcPlatform.initCheck();
294 for (OcConnectivityType connType : OcConnectivityType.values()) {
295 if (connectivityTypeSet.contains(connType))
296 connTypeInt |= connType.getValue();
299 OcPlatform.findResource1(host,
302 onResourceFoundListener,
303 qualityOfService.getValue()
307 private static native void findResource1(
310 int connectivityType,
311 OnResourceFoundListener onResourceFoundListener,
312 int qualityOfService) throws OcException;
315 * API for Device Discovery
317 * @param host Host IP Address. If null or empty, Multicast is performed.
318 * @param deviceUri Uri containing address to the virtual device
319 * @param connectivityTypeSet Set of types of connectivity. Example: IP
320 * @param onDeviceFoundListener Handles events, success states and failure states.
321 * @throws OcException if failure
323 public static void getDeviceInfo(
326 EnumSet<OcConnectivityType> connectivityTypeSet,
327 OnDeviceFoundListener onDeviceFoundListener) throws OcException {
328 OcPlatform.initCheck();
331 for (OcConnectivityType connType : OcConnectivityType.values()) {
332 if (connectivityTypeSet.contains(connType))
333 connTypeInt |= connType.getValue();
335 OcPlatform.getDeviceInfo0(
339 onDeviceFoundListener
343 private static native void getDeviceInfo0(
346 int connectivityType,
347 OnDeviceFoundListener onDeviceFoundListener) throws OcException;
350 * API for Device Discovery
352 * @param host Host IP Address. If null or empty, Multicast is performed.
353 * @param deviceUri Uri containing address to the virtual device
354 * @param connectivityTypeSet Set of types of connectivity. Example: IP
355 * @param onDeviceFoundListener Handles events, success states and failure states.
356 * @param qualityOfService the quality of communication
357 * @throws OcException if failure
359 public static void getDeviceInfo(
362 EnumSet<OcConnectivityType> connectivityTypeSet,
363 OnDeviceFoundListener onDeviceFoundListener,
364 QualityOfService qualityOfService) throws OcException {
365 OcPlatform.initCheck();
368 for (OcConnectivityType connType : OcConnectivityType.values()) {
369 if (connectivityTypeSet.contains(connType))
370 connTypeInt |= connType.getValue();
372 OcPlatform.getDeviceInfo1(
376 onDeviceFoundListener,
377 qualityOfService.getValue()
381 private static native void getDeviceInfo1(
384 int connectivityType,
385 OnDeviceFoundListener onDeviceFoundListener,
386 int qualityOfService) throws OcException;
389 * API for Platform Discovery
391 * @param host Host IP Address. If null or empty, Multicast is performed.
392 * @param platformUri Uri containing address to the platform
393 * @param connectivityTypeSet Set of types of connectivity. Example: IP
394 * @param onPlatformFoundListener Handles events, success states and failure states.
395 * @throws OcException if failure
398 public static void getPlatformInfo(
401 EnumSet<OcConnectivityType> connectivityTypeSet,
402 OnPlatformFoundListener onPlatformFoundListener) throws OcException {
403 OcPlatform.initCheck();
406 for (OcConnectivityType connType : OcConnectivityType.values()) {
407 if (connectivityTypeSet.contains(connType))
408 connTypeInt |= connType.getValue();
410 OcPlatform.getPlatformInfo0(
414 onPlatformFoundListener
418 private static native void getPlatformInfo0(
421 int connectivityType,
422 OnPlatformFoundListener onPlatformInfoFoundListener) throws OcException;
425 * API for Platform Discovery
427 * @param host Host IP Address. If null or empty, Multicast is performed.
428 * @param platformUri Uri containing address to the platform
429 * @param connectivityTypeSet Set of types of connectivity. Example: IP
430 * @param onPlatformFoundListener Handles events, success states and failure states.
431 * @param qualityOfService the quality of communication
432 * @throws OcException if failure
435 public static void getPlatformInfo(
438 EnumSet<OcConnectivityType> connectivityTypeSet,
439 OnPlatformFoundListener onPlatformFoundListener,
440 QualityOfService qualityOfService) throws OcException {
441 OcPlatform.initCheck();
444 for (OcConnectivityType connType : OcConnectivityType.values()) {
445 if (connectivityTypeSet.contains(connType))
446 connTypeInt |= connType.getValue();
448 OcPlatform.getPlatformInfo1(
452 onPlatformFoundListener,
453 qualityOfService.getValue()
457 private static native void getPlatformInfo1(
460 int connectivityType,
461 OnPlatformFoundListener onPlatformFoundListener,
462 int qualityOfService) throws OcException;
465 * This API registers a resource with the server
467 * Note: This API applies to server & client side.
470 * @param ocResource The instance of OcResource with all data filled
471 * @return resource handle
472 * @throws OcException if failure
474 public static OcResourceHandle registerResource(
475 OcResource ocResource) throws OcException {
476 OcPlatform.initCheck();
477 return OcPlatform.registerResource0(ocResource);
480 private static native OcResourceHandle registerResource0(
481 OcResource ocResource) throws OcException;
484 * This API registers a resource with the server NOTE: This API applies to server side only.
486 * Note: This API applies to server side only.
488 * @param resourceUri The URI of the resource. Example: "a/light"
489 * @param resourceTypeName The resource type. Example: "light"
490 * @param resourceInterface The resource interface (whether it is collection etc).
491 * @param entityHandler entity handler.
492 * @param resourcePropertySet indicates the property of the resource
493 * @return resource handle
494 * @throws OcException if failure
496 public static OcResourceHandle registerResource(
498 String resourceTypeName,
499 String resourceInterface,
500 EntityHandler entityHandler,
501 EnumSet<ResourceProperty> resourcePropertySet) throws OcException {
502 OcPlatform.initCheck();
506 for (ResourceProperty prop : ResourceProperty.values()) {
507 if (resourcePropertySet.contains(prop))
508 resProperty |= prop.getValue();
511 return OcPlatform.registerResource1(resourceUri,
518 private static native OcResourceHandle registerResource1(
520 String resourceTypeName,
521 String resourceInterface,
522 EntityHandler entityHandler,
523 int resourceProperty) throws OcException;
526 * Register Device Info
528 * @param ocDeviceInfo object containing all the device specific information
529 * @throws OcException if failure
531 public static void registerDeviceInfo(
532 OcDeviceInfo ocDeviceInfo) throws OcException {
533 OcPlatform.initCheck();
534 OcPlatform.registerDeviceInfo0(
535 ocDeviceInfo.getDeviceName()
539 private static native void registerDeviceInfo0(
541 ) throws OcException;
544 * Register Platform Info
546 * @param ocPlatformInfo object containing all the platform specific information
547 * @throws OcException if failure
549 public static void registerPlatformInfo(
550 OcPlatformInfo ocPlatformInfo) throws OcException {
551 OcPlatform.initCheck();
552 OcPlatform.registerPlatformInfo0(
553 ocPlatformInfo.getPlatformId(),
554 ocPlatformInfo.getManufacturerName(),
555 ocPlatformInfo.getManufacturerUrl(),
556 ocPlatformInfo.getModelNumber(),
557 ocPlatformInfo.getDateOfManufacture(),
558 ocPlatformInfo.getPlatformVersion(),
559 ocPlatformInfo.getOperatingSystemVersion(),
560 ocPlatformInfo.getHardwareVersion(),
561 ocPlatformInfo.getFirmwareVersion(),
562 ocPlatformInfo.getSupportUrl(),
563 ocPlatformInfo.getSystemTime()
567 private static native void registerPlatformInfo0(
568 String platformId, String manufacturerName, String manufacturerUrl,
569 String modelNumber, String dateOfManufacture, String platformVersion,
570 String operatingSystemVersion, String hardwareVersion, String firmwareVersion,
571 String supportUrl, String systemTime
572 ) throws OcException;
575 * This API unregisters a resource with the server NOTE: This API applies to server side only.
577 * @param ocResourceHandle This is the resource handle which we which to unregister from the
579 * @throws OcException if failure
581 public static void unregisterResource(
582 OcResourceHandle ocResourceHandle) throws OcException {
583 OcPlatform.initCheck();
584 OcPlatform.unregisterResource0(ocResourceHandle);
587 private static native void unregisterResource0(
588 OcResourceHandle ocResourceHandle) throws OcException;
592 * Add a resource to a collection resource
594 * @param ocResourceCollectionHandle handle to the collection resource
595 * @param ocResourceHandle handle to resource to be added to the collection resource
596 * @throws OcException if failure
598 public static void bindResource(
599 OcResourceHandle ocResourceCollectionHandle,
600 OcResourceHandle ocResourceHandle) throws OcException {
601 OcPlatform.initCheck();
602 OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle);
605 private static native void bindResource0(
606 OcResourceHandle ocResourceCollectionHandle,
607 OcResourceHandle ocResourceHandle) throws OcException;
610 * Add multiple resources to a collection resource.
612 * @param ocResourceCollectionHandle handle to the collection resource
613 * @param ocResourceHandleList reference to list of resource handles to be added to the
614 * collection resource
615 * @throws OcException if failure
617 public static void bindResources(
618 OcResourceHandle ocResourceCollectionHandle,
619 List<OcResourceHandle> ocResourceHandleList) throws OcException {
620 OcPlatform.initCheck();
621 OcPlatform.bindResources0(
622 ocResourceCollectionHandle,
623 ocResourceHandleList.toArray(
624 new OcResourceHandle[ocResourceHandleList.size()])
628 private static native void bindResources0(
629 OcResourceHandle ocResourceCollectionHandle,
630 OcResourceHandle[] ocResourceHandleArray) throws OcException;
633 * Unbind a resource from a collection resource.
635 * @param ocResourceCollectionHandle handle to the collection resource
636 * @param ocResourceHandle resource handle to be unbound from the collection resource
637 * @throws OcException if failure
639 public static void unbindResource(
640 OcResourceHandle ocResourceCollectionHandle,
641 OcResourceHandle ocResourceHandle) throws OcException {
642 OcPlatform.initCheck();
643 OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle);
646 private static native void unbindResource0(
647 OcResourceHandle ocResourceCollectionHandle,
648 OcResourceHandle ocResourceHandle) throws OcException;
651 * Unbind resources from a collection resource.
653 * @param ocResourceCollectionHandle Handle to the collection resource
654 * @param ocResourceHandleList List of resource handles to be unbound from the collection
656 * @throws OcException if failure
658 public static void unbindResources(
659 OcResourceHandle ocResourceCollectionHandle,
660 List<OcResourceHandle> ocResourceHandleList) throws OcException {
661 OcPlatform.initCheck();
662 OcPlatform.unbindResources0(
663 ocResourceCollectionHandle,
664 ocResourceHandleList.toArray(
665 new OcResourceHandle[ocResourceHandleList.size()])
669 private static native void unbindResources0(
670 OcResourceHandle ocResourceCollectionHandle,
671 OcResourceHandle[] ocResourceHandleArray) throws OcException;
674 * Binds a type to a particular resource
676 * @param ocResourceHandle handle to the resource
677 * @param resourceTypeName new typename to bind to the resource
678 * @throws OcException if failure
680 public static void bindTypeToResource(
681 OcResourceHandle ocResourceHandle,
682 String resourceTypeName) throws OcException {
683 OcPlatform.initCheck();
684 OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName);
687 private static native void bindTypeToResource0(
688 OcResourceHandle ocResourceHandle,
689 String resourceTypeName) throws OcException;
692 * Binds an interface to a particular resource
694 * @param ocResourceHandle handle to the resource
695 * @param resourceInterfaceName new interface to bind to the resource
696 * @throws OcException if failure
698 public static void bindInterfaceToResource(
699 OcResourceHandle ocResourceHandle,
700 String resourceInterfaceName) throws OcException {
701 OcPlatform.initCheck();
702 OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName);
705 private static native void bindInterfaceToResource0(
706 OcResourceHandle ocResourceHandle,
707 String resourceInterfaceName) throws OcException;
710 * Start Presence announcements.
712 * @param ttl time to live in seconds
713 * @throws OcException if failure
715 public static void startPresence(int ttl) throws OcException {
716 OcPlatform.initCheck();
717 OcPlatform.startPresence0(ttl);
720 private static native void startPresence0(int ttl) throws OcException;
723 * Stop Presence announcements.
725 * @throws OcException if failure
727 public static void stopPresence() throws OcException {
728 OcPlatform.initCheck();
729 OcPlatform.stopPresence0();
732 private static native void stopPresence0() throws OcException;
735 * Subscribes to a server's presence change events. By making this subscription, every time a
736 * server adds/removes/alters a resource, starts or is intentionally stopped
738 * @param host The IP address/addressable name of the server to subscribe to
739 * @param connectivityTypeSet Set of types of connectivity. Example: IP
740 * @param onPresenceListener listener that will receive notifications/subscription events
741 * @return a handle object that can be used to identify this subscription request. It can be
742 * used to unsubscribe from these events in the future
743 * @throws OcException if failure
745 public static OcPresenceHandle subscribePresence(
747 EnumSet<OcConnectivityType> connectivityTypeSet,
748 OnPresenceListener onPresenceListener) throws OcException {
749 OcPlatform.initCheck();
752 for (OcConnectivityType connType : OcConnectivityType.values()) {
753 if (connectivityTypeSet.contains(connType))
754 connTypeInt |= connType.getValue();
756 return OcPlatform.subscribePresence0(
763 private static native OcPresenceHandle subscribePresence0(
765 int connectivityType,
766 OnPresenceListener onPresenceListener) throws OcException;
769 * Subscribes to a server's presence change events. By making this subscription, every time a
770 * server adds/removes/alters a resource, starts or is intentionally stopped
772 * @param host The IP address/addressable name of the server to subscribe to
773 * @param resourceType a resource type specified as a filter for subscription events.
774 * @param connectivityTypeSet Set of types of connectivity. Example: IP
775 * @param onPresenceListener listener that will receive notifications/subscription events
776 * @return a handle object that can be used to identify this subscription request. It can be
777 * used to unsubscribe from these events in the future
778 * @throws OcException if failure
780 public static OcPresenceHandle subscribePresence(
783 EnumSet<OcConnectivityType> connectivityTypeSet,
784 OnPresenceListener onPresenceListener) throws OcException {
785 OcPlatform.initCheck();
788 for (OcConnectivityType connType : OcConnectivityType.values()) {
789 if (connectivityTypeSet.contains(connType))
790 connTypeInt |= connType.getValue();
792 return OcPlatform.subscribePresence1(
799 private static native OcPresenceHandle subscribePresence1(
802 int connectivityType,
803 OnPresenceListener onPresenceListener) throws OcException;
806 * Unsubscribes from a previously subscribed server's presence events. Note that you may for
807 * a short time still receive events from the server since it may take time for the
808 * unsubscribe to take effect.
810 * @param ocPresenceHandle the handle object provided by the subscribePresence call that
811 * identifies this subscription
812 * @throws OcException if failure
814 public static void unsubscribePresence(
815 OcPresenceHandle ocPresenceHandle) throws OcException {
816 OcPlatform.initCheck();
817 OcPlatform.unsubscribePresence0(ocPresenceHandle);
820 private static native void unsubscribePresence0(
821 OcPresenceHandle ocPresenceHandle) throws OcException;
824 * Creates a resource proxy object so that get/put/observe functionality can be used without
825 * discovering the object in advance. Note that the consumer of this method needs to provide
826 * all of the details required to correctly contact and observe the object. If the consumer
827 * lacks any of this information, they should discover the resource object normally.
828 * Additionally, you can only create this object if OcPlatform was initialized to be a Client
831 * @param host a string containing a resolvable host address of the server holding
833 * @param uri the rest of the resource's URI that will permit messages to be
836 * @param connectivityTypeSet Set of types of connectivity. Example: IP
837 * @param isObservable a boolean containing whether the resource supports observation
838 * @param resourceTypeList a collection of resource types implemented by the resource
839 * @param interfaceList a collection of interfaces that the resource supports/implements
840 * @return new resource object
841 * @throws OcException if failure
843 public static OcResource constructResourceObject(
846 EnumSet<OcConnectivityType> connectivityTypeSet,
847 boolean isObservable,
848 List<String> resourceTypeList,
849 List<String> interfaceList) throws OcException {
850 OcPlatform.initCheck();
853 for (OcConnectivityType connType : OcConnectivityType.values()) {
854 if (connectivityTypeSet.contains(connType))
855 connTypeInt |= connType.getValue();
857 return OcPlatform.constructResourceObject0(
862 resourceTypeList.toArray(new String[resourceTypeList.size()]),
863 interfaceList.toArray(new String[interfaceList.size()])
867 private static native OcResource constructResourceObject0(
870 int connectivityType,
871 boolean isObservable,
872 String[] resourceTypes,
873 String[] interfaces) throws OcException;
876 * Allows application entity handler to send response to an incoming request.
878 * @param ocResourceResponse resource response
879 * @throws OcException if failure
881 public static void sendResponse(OcResourceResponse ocResourceResponse)
883 OcPlatform.initCheck();
884 OcPlatform.sendResponse0(ocResourceResponse);
887 private static native void sendResponse0(OcResourceResponse ocResourceResponse)
891 * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
892 * Event listeners are notified asynchronously
894 public interface OnResourceFoundListener {
895 public void onResourceFound(OcResource resource);
899 * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call.
900 * Event listeners are notified asynchronously
902 public interface OnDeviceFoundListener {
903 public void onDeviceFound(OcRepresentation ocRepresentation);
907 * An OnPlatformFoundListener can be registered via the OcPlatform.getPlatformInfo call.
908 * Event listeners are notified asynchronously
910 public interface OnPlatformFoundListener {
911 public void onPlatformFound(OcRepresentation ocRepresentation);
915 * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call.
916 * Event listeners are notified asynchronously
918 public interface OnPresenceListener {
919 public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress);
923 * An EntityHandler can be registered via the OcPlatform.registerResource call.
924 * Event listeners are notified asynchronously
926 public interface EntityHandler {
927 public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);
930 private static void initCheck() {
931 if (!sIsPlatformInitialized) {
932 throw new IllegalStateException("OcPlatform must be configured by making a call to " +
933 "OcPlatform.Configure before any other API calls are permitted");