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 * Contains the main entrance/functionality of the product. To set a custom configuration, the
33 * implementer must make a call to OcPlatform.Configure before the first usage of a function in this
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.
79 * Note: Any calls made to this AFTER the first call to OcPlatform.Configure will have no affect
81 * @param platformConfig platform configuration
83 public synchronized static void Configure(PlatformConfig platformConfig) {
84 if (!sIsPlatformInitialized) {
85 CaInterface.initialize(platformConfig.getContext());
88 platformConfig.getServiceType().getValue(),
89 platformConfig.getModeType().getValue(),
90 platformConfig.getIpAddress(),
91 platformConfig.getPort(),
92 platformConfig.getQualityOfService().getValue(),
93 platformConfig.getSvrDbPath()
96 sIsPlatformInitialized = true;
100 private static native void configure(int serviceType,
104 int qualityOfService,
108 * API for notifying base that resource's attributes have changed.
110 * @param ocResourceHandle resource handle of the resource
111 * @throws OcException
113 public static void notifyAllObservers(
114 OcResourceHandle ocResourceHandle) throws OcException {
115 OcPlatform.initCheck();
116 OcPlatform.notifyAllObservers0(ocResourceHandle);
119 private static native void notifyAllObservers0(
120 OcResourceHandle ocResourceHandle) throws OcException;
123 * API for notifying base that resource's attributes have changed.
125 * @param ocResourceHandle resource handle of the resource
126 * @param qualityOfService the quality of communication
127 * @throws OcException
129 public static void notifyAllObservers(
130 OcResourceHandle ocResourceHandle,
131 QualityOfService qualityOfService) throws OcException {
132 OcPlatform.initCheck();
133 OcPlatform.notifyAllObservers1(ocResourceHandle, qualityOfService.getValue());
136 private static native void notifyAllObservers1(
137 OcResourceHandle ocResourceHandle,
138 int qualityOfService) throws OcException;
141 * API for notifying only specific clients that resource's attributes have changed.
143 * @param ocResourceHandle resource handle of the resource
144 * @param ocObservationIdList These set of ids are ones which which will be notified upon
146 * @param ocResourceResponse OcResourceResponse object used by app to fill the response for
147 * this resource change
148 * @throws OcException
150 public static void notifyListOfObservers(
151 OcResourceHandle ocResourceHandle,
152 List<Byte> ocObservationIdList,
153 OcResourceResponse ocResourceResponse) throws OcException {
154 OcPlatform.initCheck();
156 byte[] idArr = new byte[ocObservationIdList.size()];
157 Iterator<Byte> it = ocObservationIdList.iterator();
159 while (it.hasNext()) {
160 idArr[i++] = (byte) it.next();
163 OcPlatform.notifyListOfObservers2(
169 private static native void notifyListOfObservers2(
170 OcResourceHandle ocResourceHandle,
171 byte[] ocObservationIdArray,
172 OcResourceResponse ocResourceResponse) throws OcException;
175 * API for notifying only specific clients that resource's attributes have changed.
177 * @param ocResourceHandle resource handle of the resource
178 * @param ocObservationIdList These set of ids are ones which which will be notified upon
180 * @param ocResourceResponse OcResourceResponse object used by app to fill the response for
181 * this resource change
182 * @param qualityOfService the quality of communication
183 * @throws OcException
185 public static void notifyListOfObservers(
186 OcResourceHandle ocResourceHandle,
187 List<Byte> ocObservationIdList,
188 OcResourceResponse ocResourceResponse,
189 QualityOfService qualityOfService) throws OcException {
190 OcPlatform.initCheck();
192 byte[] idArr = new byte[ocObservationIdList.size()];
193 Iterator<Byte> it = ocObservationIdList.iterator();
195 while (it.hasNext()) {
196 idArr[i++] = (byte) it.next();
199 OcPlatform.notifyListOfObservers3(
203 qualityOfService.getValue()
207 private static native void notifyListOfObservers3(
208 OcResourceHandle ocResourceHandle,
209 byte[] ocObservationIdArray,
210 OcResourceResponse ocResourceResponse,
211 int qualityOfService) throws OcException;
214 * API for Service and Resource Discovery. NOTE: This API applies to client side only
216 * @param host Host IP Address of a service to direct resource discovery query.
217 * If empty, performs multicast resource discovery query
218 * @param resourceUri name of the resource. If null or empty, performs search for all
220 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
222 * @param onResourceFoundListener Handles events, success states and failure states.
223 * @throws OcException
225 public static void findResource(
228 EnumSet<OcConnectivityType> connectivityTypeSet,
229 OnResourceFoundListener onResourceFoundListener) throws OcException {
230 OcPlatform.initCheck();
234 for (OcConnectivityType connType : OcConnectivityType.values()) {
235 if (connectivityTypeSet.contains(connType))
236 connTypeInt |= connType.getValue();
239 OcPlatform.findResource0(
243 onResourceFoundListener
247 private static native void findResource0(
250 int connectivityType,
251 OnResourceFoundListener onResourceFoundListener) throws OcException;
254 * API for Service and Resource Discovery. NOTE: This API applies to client side only
256 * @param host Host IP Address of a service to direct resource discovery query.
257 * If empty, performs multicast resource discovery query
258 * @param resourceUri name of the resource. If null or empty, performs search for all
260 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
262 * @param onResourceFoundListener Handles events, success states and failure states.
263 * @param qualityOfService the quality of communication
264 * @throws OcException
266 public static void findResource(
269 EnumSet<OcConnectivityType> connectivityTypeSet,
270 OnResourceFoundListener onResourceFoundListener,
271 QualityOfService qualityOfService) throws OcException {
272 OcPlatform.initCheck();
276 for (OcConnectivityType connType : OcConnectivityType.values()) {
277 if (connectivityTypeSet.contains(connType))
278 connTypeInt |= connType.getValue();
281 OcPlatform.findResource1(host,
284 onResourceFoundListener,
285 qualityOfService.getValue()
289 private static native void findResource1(
292 int connectivityType,
293 OnResourceFoundListener onResourceFoundListener,
294 int qualityOfService) throws OcException;
297 * API for Device Discovery
299 * @param host Host IP Address. If null or empty, Multicast is performed.
300 * @param deviceUri Uri containing address to the virtual device
301 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
303 * @param onDeviceFoundListener Handles events, success states and failure states.
304 * @throws OcException
306 public static void getDeviceInfo(
309 EnumSet<OcConnectivityType> connectivityTypeSet,
310 OnDeviceFoundListener onDeviceFoundListener) throws OcException {
311 OcPlatform.initCheck();
314 for (OcConnectivityType connType : OcConnectivityType.values()) {
315 if (connectivityTypeSet.contains(connType))
316 connTypeInt |= connType.getValue();
318 OcPlatform.getDeviceInfo0(
322 onDeviceFoundListener
326 private static native void getDeviceInfo0(
329 int connectivityType,
330 OnDeviceFoundListener onDeviceFoundListener) throws OcException;
333 * API for Device Discovery
335 * @param host Host IP Address. If null or empty, Multicast is performed.
336 * @param deviceUri Uri containing address to the virtual device
337 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
339 * @param onDeviceFoundListener Handles events, success states and failure states.
340 * @param qualityOfService the quality of communication
341 * @throws OcException
343 public static void getDeviceInfo(
346 EnumSet<OcConnectivityType> connectivityTypeSet,
347 OnDeviceFoundListener onDeviceFoundListener,
348 QualityOfService qualityOfService) throws OcException {
349 OcPlatform.initCheck();
352 for (OcConnectivityType connType : OcConnectivityType.values()) {
353 if (connectivityTypeSet.contains(connType))
354 connTypeInt |= connType.getValue();
356 OcPlatform.getDeviceInfo1(
360 onDeviceFoundListener,
361 qualityOfService.getValue()
365 private static native void getDeviceInfo1(
368 int connectivityType,
369 OnDeviceFoundListener onDeviceFoundListener,
370 int qualityOfService) throws OcException;
373 * API for Platform Discovery
375 * @param host Host IP Address. If null or empty, Multicast is performed.
376 * @param platformUri Uri containing address to the platform
377 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
379 * @param onPlatformFoundListener Handles events, success states and failure states.
380 * @throws OcException
383 public static void getPlatformInfo(
386 EnumSet<OcConnectivityType> connectivityTypeSet,
387 OnPlatformFoundListener onPlatformFoundListener) throws OcException {
388 OcPlatform.initCheck();
391 for (OcConnectivityType connType : OcConnectivityType.values()) {
392 if (connectivityTypeSet.contains(connType))
393 connTypeInt |= connType.getValue();
395 OcPlatform.getPlatformInfo0(
399 onPlatformFoundListener
403 private static native void getPlatformInfo0(
406 int connectivityType,
407 OnPlatformFoundListener onPlatformInfoFoundListener) throws OcException;
410 * API for Platform Discovery
412 * @param host Host IP Address. If null or empty, Multicast is performed.
413 * @param platformUri Uri containing address to the platform
414 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
416 * @param onPlatformFoundListener Handles events, success states and failure states.
417 * @param qualityOfService the quality of communication
418 * @throws OcException
421 public static void getPlatformInfo(
424 EnumSet<OcConnectivityType> connectivityTypeSet,
425 OnPlatformFoundListener onPlatformFoundListener,
426 QualityOfService qualityOfService) throws OcException {
427 OcPlatform.initCheck();
430 for (OcConnectivityType connType : OcConnectivityType.values()) {
431 if (connectivityTypeSet.contains(connType))
432 connTypeInt |= connType.getValue();
434 OcPlatform.getPlatformInfo1(
438 onPlatformFoundListener,
439 qualityOfService.getValue()
443 private static native void getPlatformInfo1(
446 int connectivityType,
447 OnPlatformFoundListener onPlatformFoundListener,
448 int qualityOfService) throws OcException;
451 * This API registers a resource with the server NOTE: This API applies to server side only.
453 * @param ocResource The instance of OcResource with all data filled
454 * @return resource handle
455 * @throws OcException
457 public static OcResourceHandle registerResource(
458 OcResource ocResource) throws OcException {
459 OcPlatform.initCheck();
460 return OcPlatform.registerResource0(ocResource);
463 private static native OcResourceHandle registerResource0(
464 OcResource ocResource) throws OcException;
467 * This API registers a resource with the server NOTE: This API applies to server side only.
469 * @param resourceUri The URI of the resource. Example: "a/light"
470 * @param resourceTypeName The resource type. Example: "light"
471 * @param resourceInterface The resource interface (whether it is collection etc).
472 * @param entityHandler entity handler.
473 * @param resourcePropertySet indicates the property of the resource
474 * @return resource handle
475 * @throws OcException
477 public static OcResourceHandle registerResource(
479 String resourceTypeName,
480 String resourceInterface,
481 EntityHandler entityHandler,
482 EnumSet<ResourceProperty> resourcePropertySet) throws OcException {
483 OcPlatform.initCheck();
487 for (ResourceProperty prop : ResourceProperty.values()) {
488 if (resourcePropertySet.contains(prop))
489 resProperty |= prop.getValue();
492 if (null == entityHandler) {
493 entityHandler = new EntityHandler() {
495 public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
496 return EntityHandlerResult.OK;
501 return OcPlatform.registerResource1(resourceUri,
508 private static native OcResourceHandle registerResource1(
510 String resourceTypeName,
511 String resourceInterface,
512 EntityHandler entityHandler,
513 int resourceProperty) throws OcException;
516 * Register Device Info
518 * @param ocDeviceInfo object containing all the device specific information
519 * @throws OcException
521 public static void registerDeviceInfo(
522 OcDeviceInfo ocDeviceInfo) throws OcException {
523 OcPlatform.initCheck();
524 OcPlatform.registerDeviceInfo0(
525 ocDeviceInfo.getDeviceName()
529 private static native void registerDeviceInfo0(
531 ) throws OcException;
534 * Register Platform Info
536 * @param ocPlatformInfo object containing all the platform specific information
537 * @throws OcException
539 public static void registerPlatformInfo(
540 OcPlatformInfo ocPlatformInfo) throws OcException {
541 OcPlatform.initCheck();
542 OcPlatform.registerPlatformInfo0(
543 ocPlatformInfo.getPlatformId(),
544 ocPlatformInfo.getManufacturerName(),
545 ocPlatformInfo.getManufacturerUrl(),
546 ocPlatformInfo.getModelNumber(),
547 ocPlatformInfo.getDateOfManufacture(),
548 ocPlatformInfo.getPlatformVersion(),
549 ocPlatformInfo.getOperatingSystemVersion(),
550 ocPlatformInfo.getHardwareVersion(),
551 ocPlatformInfo.getFirmwareVersion(),
552 ocPlatformInfo.getSupportUrl(),
553 ocPlatformInfo.getSystemTime()
557 private static native void registerPlatformInfo0(
558 String platformId, String manufacturerName, String manufacturerUrl,
559 String modelNumber, String dateOfManufacture, String platformVersion,
560 String operatingSystemVersion, String hardwareVersion, String firmwareVersion,
561 String supportUrl, String systemTime
562 ) throws OcException;
565 * This API unregisters a resource with the server NOTE: This API applies to server side only.
567 * @param ocResourceHandle This is the resource handle which we which to unregister from the
569 * @throws OcException
571 public static void unregisterResource(
572 OcResourceHandle ocResourceHandle) throws OcException {
573 OcPlatform.initCheck();
574 OcPlatform.unregisterResource0(ocResourceHandle);
577 private static native void unregisterResource0(
578 OcResourceHandle ocResourceHandle) throws OcException;
582 * Add a resource to a collection resource
584 * @param ocResourceCollectionHandle handle to the collection resource
585 * @param ocResourceHandle handle to resource to be added to the collection resource
586 * @throws OcException
588 public static void bindResource(
589 OcResourceHandle ocResourceCollectionHandle,
590 OcResourceHandle ocResourceHandle) throws OcException {
591 OcPlatform.initCheck();
592 OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle);
595 private static native void bindResource0(
596 OcResourceHandle ocResourceCollectionHandle,
597 OcResourceHandle ocResourceHandle) throws OcException;
600 * Add multiple resources to a collection resource.
602 * @param ocResourceCollectionHandle handle to the collection resource
603 * @param ocResourceHandleList reference to list of resource handles to be added to the
604 * collection resource
605 * @throws OcException
607 public static void bindResources(
608 OcResourceHandle ocResourceCollectionHandle,
609 List<OcResourceHandle> ocResourceHandleList) throws OcException {
610 OcPlatform.initCheck();
611 OcPlatform.bindResources0(
612 ocResourceCollectionHandle,
613 ocResourceHandleList.toArray(
614 new OcResourceHandle[ocResourceHandleList.size()])
618 private static native void bindResources0(
619 OcResourceHandle ocResourceCollectionHandle,
620 OcResourceHandle[] ocResourceHandleArray) throws OcException;
623 * Unbind a resource from a collection resource.
625 * @param ocResourceCollectionHandle handle to the collection resource
626 * @param ocResourceHandle resource handle to be unbound from the collection resource
627 * @throws OcException
629 public static void unbindResource(
630 OcResourceHandle ocResourceCollectionHandle,
631 OcResourceHandle ocResourceHandle) throws OcException {
632 OcPlatform.initCheck();
633 OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle);
636 private static native void unbindResource0(
637 OcResourceHandle ocResourceCollectionHandle,
638 OcResourceHandle ocResourceHandle) throws OcException;
641 * Unbind resources from a collection resource.
643 * @param ocResourceCollectionHandle Handle to the collection resource
644 * @param ocResourceHandleList List of resource handles to be unbound from the collection
646 * @throws OcException
648 public static void unbindResources(
649 OcResourceHandle ocResourceCollectionHandle,
650 List<OcResourceHandle> ocResourceHandleList) throws OcException {
651 OcPlatform.initCheck();
652 OcPlatform.unbindResources0(
653 ocResourceCollectionHandle,
654 ocResourceHandleList.toArray(
655 new OcResourceHandle[ocResourceHandleList.size()])
659 private static native void unbindResources0(
660 OcResourceHandle ocResourceCollectionHandle,
661 OcResourceHandle[] ocResourceHandleArray) throws OcException;
664 * Binds a type to a particular resource
666 * @param ocResourceHandle handle to the resource
667 * @param resourceTypeName new typename to bind to the resource
668 * @throws OcException
670 public static void bindTypeToResource(
671 OcResourceHandle ocResourceHandle,
672 String resourceTypeName) throws OcException {
673 OcPlatform.initCheck();
674 OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName);
677 private static native void bindTypeToResource0(
678 OcResourceHandle ocResourceHandle,
679 String resourceTypeName) throws OcException;
682 * Binds an interface to a particular resource
684 * @param ocResourceHandle handle to the resource
685 * @param resourceInterfaceName new interface to bind to the resource
686 * @throws OcException
688 public static void bindInterfaceToResource(
689 OcResourceHandle ocResourceHandle,
690 String resourceInterfaceName) throws OcException {
691 OcPlatform.initCheck();
692 OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName);
695 private static native void bindInterfaceToResource0(
696 OcResourceHandle ocResourceHandle,
697 String resourceInterfaceName) throws OcException;
700 * Start Presence announcements.
702 * @param ttl time to live in seconds
703 * @throws OcException
705 public static void startPresence(int ttl) throws OcException {
706 OcPlatform.initCheck();
707 OcPlatform.startPresence0(ttl);
710 private static native void startPresence0(int ttl) throws OcException;
713 * Stop Presence announcements.
715 * @throws OcException
717 public static void stopPresence() throws OcException {
718 OcPlatform.initCheck();
719 OcPlatform.stopPresence0();
722 private static native void stopPresence0() throws OcException;
725 * Subscribes to a server's presence change events. By making this subscription, every time a
726 * server adds/removes/alters a resource, starts or is intentionally stopped
728 * @param host The IP address/addressable name of the server to subscribe to
729 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
731 * @param onPresenceListener listener that will receive notifications/subscription events
732 * @return a handle object that can be used to identify this subscription request. It can be
733 * used to unsubscribe from these events in the future
734 * @throws OcException
736 public static OcPresenceHandle subscribePresence(
738 EnumSet<OcConnectivityType> connectivityTypeSet,
739 OnPresenceListener onPresenceListener) throws OcException {
740 OcPlatform.initCheck();
743 for (OcConnectivityType connType : OcConnectivityType.values()) {
744 if (connectivityTypeSet.contains(connType))
745 connTypeInt |= connType.getValue();
747 return OcPlatform.subscribePresence0(
754 private static native OcPresenceHandle subscribePresence0(
756 int connectivityType,
757 OnPresenceListener onPresenceListener) throws OcException;
760 * Subscribes to a server's presence change events. By making this subscription, every time a
761 * server adds/removes/alters a resource, starts or is intentionally stopped
763 * @param host The IP address/addressable name of the server to subscribe to
764 * @param resourceType a resource type specified as a filter for subscription events.
765 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
767 * @param onPresenceListener listener that will receive notifications/subscription events
768 * @return a handle object that can be used to identify this subscription request. It can be
769 * used to unsubscribe from these events in the future
770 * @throws OcException
772 public static OcPresenceHandle subscribePresence(
775 EnumSet<OcConnectivityType> connectivityTypeSet,
776 OnPresenceListener onPresenceListener) throws OcException {
777 OcPlatform.initCheck();
780 for (OcConnectivityType connType : OcConnectivityType.values()) {
781 if (connectivityTypeSet.contains(connType))
782 connTypeInt |= connType.getValue();
784 return OcPlatform.subscribePresence1(
791 private static native OcPresenceHandle subscribePresence1(
794 int connectivityType,
795 OnPresenceListener onPresenceListener) throws OcException;
798 * Unsubscribes from a previously subscribed server's presence events. Note that you may for
799 * a short time still receive events from the server since it may take time for the
800 * unsubscribe to take effect.
802 * @param ocPresenceHandle the handle object provided by the subscribePresence call that
803 * identifies this subscription
804 * @throws OcException
806 public static void unsubscribePresence(
807 OcPresenceHandle ocPresenceHandle) throws OcException {
808 OcPlatform.initCheck();
809 OcPlatform.unsubscribePresence0(ocPresenceHandle);
812 private static native void unsubscribePresence0(
813 OcPresenceHandle ocPresenceHandle) throws OcException;
816 * Creates a resource proxy object so that get/put/observe functionality can be used without
817 * discovering the object in advance. Note that the consumer of this method needs to provide
818 * all of the details required to correctly contact and observe the object. If the consumer
819 * lacks any of this information, they should discover the resource object normally.
820 * Additionally, you can only create this object if OcPlatform was initialized to be a Client
823 * @param host a string containing a resolvable host address of the server holding
825 * @param uri the rest of the resource's URI that will permit messages to be
828 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
830 * @param isObservable a boolean containing whether the resource supports observation
831 * @param resourceTypeList a collection of resource types implemented by the resource
832 * @param interfaceList a collection of interfaces that the resource supports/implements
833 * @return new resource object
834 * @throws OcException
836 public static OcResource constructResourceObject(
839 EnumSet<OcConnectivityType> connectivityTypeSet,
840 boolean isObservable,
841 List<String> resourceTypeList,
842 List<String> interfaceList) throws OcException {
843 OcPlatform.initCheck();
846 for (OcConnectivityType connType : OcConnectivityType.values()) {
847 if (connectivityTypeSet.contains(connType))
848 connTypeInt |= connType.getValue();
850 return OcPlatform.constructResourceObject0(
855 resourceTypeList.toArray(new String[resourceTypeList.size()]),
856 interfaceList.toArray(new String[interfaceList.size()])
860 private static native OcResource constructResourceObject0(
863 int connectivityType,
864 boolean isObservable,
865 String[] resourceTypes,
866 String[] interfaces) throws OcException;
869 * Allows application entity handler to send response to an incoming request.
871 * @param ocResourceResponse resource response
872 * @throws OcException
874 public static void sendResponse(OcResourceResponse ocResourceResponse)
876 OcPlatform.initCheck();
877 OcPlatform.sendResponse0(ocResourceResponse);
880 private static native void sendResponse0(OcResourceResponse ocResourceResponse)
884 * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
885 * Event listeners are notified asynchronously
887 public interface OnResourceFoundListener {
888 public void onResourceFound(OcResource resource);
892 * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call.
893 * Event listeners are notified asynchronously
895 public interface OnDeviceFoundListener {
896 public void onDeviceFound(OcRepresentation ocRepresentation);
900 * An OnPlatformFoundListener can be registered via the OcPlatform.getPlatformInfo call.
901 * Event listeners are notified asynchronously
903 public interface OnPlatformFoundListener {
904 public void onPlatformFound(OcRepresentation ocRepresentation);
908 * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call.
909 * Event listeners are notified asynchronously
911 public interface OnPresenceListener {
912 public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress);
916 * An EntityHandler can be registered via the OcPlatform.registerResource call.
917 * Event listeners are notified asynchronously
919 public interface EntityHandler {
920 public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);
923 private static void initCheck() {
924 if (!sIsPlatformInitialized) {
925 throw new IllegalStateException("OcPlatform must be configured by making a call to " +
926 "OcPlatform.Configure before any other API calls are permitted");