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 return OcPlatform.registerResource1(resourceUri,
499 private static native OcResourceHandle registerResource1(
501 String resourceTypeName,
502 String resourceInterface,
503 EntityHandler entityHandler,
504 int resourceProperty) throws OcException;
507 * Register Device Info
509 * @param ocDeviceInfo object containing all the device specific information
510 * @throws OcException
512 public static void registerDeviceInfo(
513 OcDeviceInfo ocDeviceInfo) throws OcException {
514 OcPlatform.initCheck();
515 OcPlatform.registerDeviceInfo0(
516 ocDeviceInfo.getDeviceName()
520 private static native void registerDeviceInfo0(
522 ) throws OcException;
525 * Register Platform Info
527 * @param ocPlatformInfo object containing all the platform specific information
528 * @throws OcException
530 public static void registerPlatformInfo(
531 OcPlatformInfo ocPlatformInfo) throws OcException {
532 OcPlatform.initCheck();
533 OcPlatform.registerPlatformInfo0(
534 ocPlatformInfo.getPlatformId(),
535 ocPlatformInfo.getManufacturerName(),
536 ocPlatformInfo.getManufacturerUrl(),
537 ocPlatformInfo.getModelNumber(),
538 ocPlatformInfo.getDateOfManufacture(),
539 ocPlatformInfo.getPlatformVersion(),
540 ocPlatformInfo.getOperatingSystemVersion(),
541 ocPlatformInfo.getHardwareVersion(),
542 ocPlatformInfo.getFirmwareVersion(),
543 ocPlatformInfo.getSupportUrl(),
544 ocPlatformInfo.getSystemTime()
548 private static native void registerPlatformInfo0(
549 String platformId, String manufacturerName, String manufacturerUrl,
550 String modelNumber, String dateOfManufacture, String platformVersion,
551 String operatingSystemVersion, String hardwareVersion, String firmwareVersion,
552 String supportUrl, String systemTime
553 ) throws OcException;
556 * This API unregisters a resource with the server NOTE: This API applies to server side only.
558 * @param ocResourceHandle This is the resource handle which we which to unregister from the
560 * @throws OcException
562 public static void unregisterResource(
563 OcResourceHandle ocResourceHandle) throws OcException {
564 OcPlatform.initCheck();
565 OcPlatform.unregisterResource0(ocResourceHandle);
568 private static native void unregisterResource0(
569 OcResourceHandle ocResourceHandle) throws OcException;
573 * Add a resource to a collection resource
575 * @param ocResourceCollectionHandle handle to the collection resource
576 * @param ocResourceHandle handle to resource to be added to the collection resource
577 * @throws OcException
579 public static void bindResource(
580 OcResourceHandle ocResourceCollectionHandle,
581 OcResourceHandle ocResourceHandle) throws OcException {
582 OcPlatform.initCheck();
583 OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle);
586 private static native void bindResource0(
587 OcResourceHandle ocResourceCollectionHandle,
588 OcResourceHandle ocResourceHandle) throws OcException;
591 * Add multiple resources to a collection resource.
593 * @param ocResourceCollectionHandle handle to the collection resource
594 * @param ocResourceHandleList reference to list of resource handles to be added to the
595 * collection resource
596 * @throws OcException
598 public static void bindResources(
599 OcResourceHandle ocResourceCollectionHandle,
600 List<OcResourceHandle> ocResourceHandleList) throws OcException {
601 OcPlatform.initCheck();
602 OcPlatform.bindResources0(
603 ocResourceCollectionHandle,
604 ocResourceHandleList.toArray(
605 new OcResourceHandle[ocResourceHandleList.size()])
609 private static native void bindResources0(
610 OcResourceHandle ocResourceCollectionHandle,
611 OcResourceHandle[] ocResourceHandleArray) throws OcException;
614 * Unbind a resource from a collection resource.
616 * @param ocResourceCollectionHandle handle to the collection resource
617 * @param ocResourceHandle resource handle to be unbound from the collection resource
618 * @throws OcException
620 public static void unbindResource(
621 OcResourceHandle ocResourceCollectionHandle,
622 OcResourceHandle ocResourceHandle) throws OcException {
623 OcPlatform.initCheck();
624 OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle);
627 private static native void unbindResource0(
628 OcResourceHandle ocResourceCollectionHandle,
629 OcResourceHandle ocResourceHandle) throws OcException;
632 * Unbind resources from a collection resource.
634 * @param ocResourceCollectionHandle Handle to the collection resource
635 * @param ocResourceHandleList List of resource handles to be unbound from the collection
637 * @throws OcException
639 public static void unbindResources(
640 OcResourceHandle ocResourceCollectionHandle,
641 List<OcResourceHandle> ocResourceHandleList) throws OcException {
642 OcPlatform.initCheck();
643 OcPlatform.unbindResources0(
644 ocResourceCollectionHandle,
645 ocResourceHandleList.toArray(
646 new OcResourceHandle[ocResourceHandleList.size()])
650 private static native void unbindResources0(
651 OcResourceHandle ocResourceCollectionHandle,
652 OcResourceHandle[] ocResourceHandleArray) throws OcException;
655 * Binds a type to a particular resource
657 * @param ocResourceHandle handle to the resource
658 * @param resourceTypeName new typename to bind to the resource
659 * @throws OcException
661 public static void bindTypeToResource(
662 OcResourceHandle ocResourceHandle,
663 String resourceTypeName) throws OcException {
664 OcPlatform.initCheck();
665 OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName);
668 private static native void bindTypeToResource0(
669 OcResourceHandle ocResourceHandle,
670 String resourceTypeName) throws OcException;
673 * Binds an interface to a particular resource
675 * @param ocResourceHandle handle to the resource
676 * @param resourceInterfaceName new interface to bind to the resource
677 * @throws OcException
679 public static void bindInterfaceToResource(
680 OcResourceHandle ocResourceHandle,
681 String resourceInterfaceName) throws OcException {
682 OcPlatform.initCheck();
683 OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName);
686 private static native void bindInterfaceToResource0(
687 OcResourceHandle ocResourceHandle,
688 String resourceInterfaceName) throws OcException;
691 * Start Presence announcements.
693 * @param ttl time to live in seconds
694 * @throws OcException
696 public static void startPresence(int ttl) throws OcException {
697 OcPlatform.initCheck();
698 OcPlatform.startPresence0(ttl);
701 private static native void startPresence0(int ttl) throws OcException;
704 * Stop Presence announcements.
706 * @throws OcException
708 public static void stopPresence() throws OcException {
709 OcPlatform.initCheck();
710 OcPlatform.stopPresence0();
713 private static native void stopPresence0() throws OcException;
716 * Subscribes to a server's presence change events. By making this subscription, every time a
717 * server adds/removes/alters a resource, starts or is intentionally stopped
719 * @param host The IP address/addressable name of the server to subscribe to
720 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
722 * @param onPresenceListener listener that will receive notifications/subscription events
723 * @return a handle object that can be used to identify this subscription request. It can be
724 * used to unsubscribe from these events in the future
725 * @throws OcException
727 public static OcPresenceHandle subscribePresence(
729 EnumSet<OcConnectivityType> connectivityTypeSet,
730 OnPresenceListener onPresenceListener) throws OcException {
731 OcPlatform.initCheck();
734 for (OcConnectivityType connType : OcConnectivityType.values()) {
735 if (connectivityTypeSet.contains(connType))
736 connTypeInt |= connType.getValue();
738 return OcPlatform.subscribePresence0(
745 private static native OcPresenceHandle subscribePresence0(
747 int connectivityType,
748 OnPresenceListener onPresenceListener) throws OcException;
751 * Subscribes to a server's presence change events. By making this subscription, every time a
752 * server adds/removes/alters a resource, starts or is intentionally stopped
754 * @param host The IP address/addressable name of the server to subscribe to
755 * @param resourceType a resource type specified as a filter for subscription events.
756 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
758 * @param onPresenceListener listener that will receive notifications/subscription events
759 * @return a handle object that can be used to identify this subscription request. It can be
760 * used to unsubscribe from these events in the future
761 * @throws OcException
763 public static OcPresenceHandle subscribePresence(
766 EnumSet<OcConnectivityType> connectivityTypeSet,
767 OnPresenceListener onPresenceListener) throws OcException {
768 OcPlatform.initCheck();
771 for (OcConnectivityType connType : OcConnectivityType.values()) {
772 if (connectivityTypeSet.contains(connType))
773 connTypeInt |= connType.getValue();
775 return OcPlatform.subscribePresence1(
782 private static native OcPresenceHandle subscribePresence1(
785 int connectivityType,
786 OnPresenceListener onPresenceListener) throws OcException;
789 * Unsubscribes from a previously subscribed server's presence events. Note that you may for
790 * a short time still receive events from the server since it may take time for the
791 * unsubscribe to take effect.
793 * @param ocPresenceHandle the handle object provided by the subscribePresence call that
794 * identifies this subscription
795 * @throws OcException
797 public static void unsubscribePresence(
798 OcPresenceHandle ocPresenceHandle) throws OcException {
799 OcPlatform.initCheck();
800 OcPlatform.unsubscribePresence0(ocPresenceHandle);
803 private static native void unsubscribePresence0(
804 OcPresenceHandle ocPresenceHandle) throws OcException;
807 * Creates a resource proxy object so that get/put/observe functionality can be used without
808 * discovering the object in advance. Note that the consumer of this method needs to provide
809 * all of the details required to correctly contact and observe the object. If the consumer
810 * lacks any of this information, they should discover the resource object normally.
811 * Additionally, you can only create this object if OcPlatform was initialized to be a Client
814 * @param host a string containing a resolvable host address of the server holding
816 * @param uri the rest of the resource's URI that will permit messages to be
819 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
821 * @param isObservable a boolean containing whether the resource supports observation
822 * @param resourceTypeList a collection of resource types implemented by the resource
823 * @param interfaceList a collection of interfaces that the resource supports/implements
824 * @return new resource object
825 * @throws OcException
827 public static OcResource constructResourceObject(
830 EnumSet<OcConnectivityType> connectivityTypeSet,
831 boolean isObservable,
832 List<String> resourceTypeList,
833 List<String> interfaceList) throws OcException {
834 OcPlatform.initCheck();
837 for (OcConnectivityType connType : OcConnectivityType.values()) {
838 if (connectivityTypeSet.contains(connType))
839 connTypeInt |= connType.getValue();
841 return OcPlatform.constructResourceObject0(
846 resourceTypeList.toArray(new String[resourceTypeList.size()]),
847 interfaceList.toArray(new String[interfaceList.size()])
851 private static native OcResource constructResourceObject0(
854 int connectivityType,
855 boolean isObservable,
856 String[] resourceTypes,
857 String[] interfaces) throws OcException;
860 * Allows application entity handler to send response to an incoming request.
862 * @param ocResourceResponse resource response
863 * @throws OcException
865 public static void sendResponse(OcResourceResponse ocResourceResponse)
867 OcPlatform.initCheck();
868 OcPlatform.sendResponse0(ocResourceResponse);
871 private static native void sendResponse0(OcResourceResponse ocResourceResponse)
875 * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
876 * Event listeners are notified asynchronously
878 public interface OnResourceFoundListener {
879 public void onResourceFound(OcResource resource);
883 * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call.
884 * Event listeners are notified asynchronously
886 public interface OnDeviceFoundListener {
887 public void onDeviceFound(OcRepresentation ocRepresentation);
891 * An OnPlatformFoundListener can be registered via the OcPlatform.getPlatformInfo call.
892 * Event listeners are notified asynchronously
894 public interface OnPlatformFoundListener {
895 public void onPlatformFound(OcRepresentation ocRepresentation);
899 * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call.
900 * Event listeners are notified asynchronously
902 public interface OnPresenceListener {
903 public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress);
907 * An EntityHandler can be registered via the OcPlatform.registerResource call.
908 * Event listeners are notified asynchronously
910 public interface EntityHandler {
911 public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);
914 private static void initCheck() {
915 if (!sIsPlatformInitialized) {
916 throw new IllegalStateException("OcPlatform must be configured by making a call to " +
917 "OcPlatform.Configure before any other API calls are permitted");