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 MULTICAST_PREFIX = "224.0.1.187:5683";
68 public static final String MULTICAST_IP = "224.0.1.187";
69 public static final int MULTICAST_PORT = 5683;
70 public static final int DEFAULT_PRESENCE_TTL = 60;
71 public static final String DEVICE_URI = "/oic/d";
72 public static final String PRESENCE_URI = "/oic/ad";
74 private static volatile boolean sIsPlatformInitialized = false;
76 private OcPlatform() {
80 * API for setting the configuration of the OcPlatform.
81 * 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 * @param ocResourceHandle resource handle of the resource
113 * @throws OcException
115 public static void notifyAllObservers(
116 OcResourceHandle ocResourceHandle) throws OcException {
117 OcPlatform.initCheck();
118 OcPlatform.notifyAllObservers0(ocResourceHandle);
121 private static native void notifyAllObservers0(
122 OcResourceHandle ocResourceHandle) throws OcException;
125 * API for notifying base that resource's attributes have changed.
127 * @param ocResourceHandle resource handle of the resource
128 * @param qualityOfService the quality of communication
129 * @throws OcException
131 public static void notifyAllObservers(
132 OcResourceHandle ocResourceHandle,
133 QualityOfService qualityOfService) throws OcException {
134 OcPlatform.initCheck();
135 OcPlatform.notifyAllObservers1(ocResourceHandle, qualityOfService.getValue());
138 private static native void notifyAllObservers1(
139 OcResourceHandle ocResourceHandle,
140 int qualityOfService) throws OcException;
143 * API for notifying only specific clients that resource's attributes have changed.
145 * @param ocResourceHandle resource handle of the resource
146 * @param ocObservationIdList These set of ids are ones which which will be notified upon
148 * @param ocResourceResponse OcResourceResponse object used by app to fill the response for
149 * this resource change
150 * @throws OcException
152 public static void notifyListOfObservers(
153 OcResourceHandle ocResourceHandle,
154 List<Byte> ocObservationIdList,
155 OcResourceResponse ocResourceResponse) throws OcException {
156 OcPlatform.initCheck();
158 byte[] idArr = new byte[ocObservationIdList.size()];
159 Iterator<Byte> it = ocObservationIdList.iterator();
161 while (it.hasNext()) {
162 idArr[i++] = (byte) it.next();
165 OcPlatform.notifyListOfObservers2(
171 private static native void notifyListOfObservers2(
172 OcResourceHandle ocResourceHandle,
173 byte[] ocObservationIdArray,
174 OcResourceResponse ocResourceResponse) throws OcException;
177 * API for notifying only specific clients that resource's attributes have changed.
179 * @param ocResourceHandle resource handle of the resource
180 * @param ocObservationIdList These set of ids are ones which which will be notified upon
182 * @param ocResourceResponse OcResourceResponse object used by app to fill the response for
183 * this resource change
184 * @param qualityOfService the quality of communication
185 * @throws OcException
187 public static void notifyListOfObservers(
188 OcResourceHandle ocResourceHandle,
189 List<Byte> ocObservationIdList,
190 OcResourceResponse ocResourceResponse,
191 QualityOfService qualityOfService) throws OcException {
192 OcPlatform.initCheck();
194 byte[] idArr = new byte[ocObservationIdList.size()];
195 Iterator<Byte> it = ocObservationIdList.iterator();
197 while (it.hasNext()) {
198 idArr[i++] = (byte) it.next();
201 OcPlatform.notifyListOfObservers3(
205 qualityOfService.getValue()
209 private static native void notifyListOfObservers3(
210 OcResourceHandle ocResourceHandle,
211 byte[] ocObservationIdArray,
212 OcResourceResponse ocResourceResponse,
213 int qualityOfService) throws OcException;
216 * API for Service and Resource Discovery. NOTE: This API applies to client side only
218 * @param host Host IP Address of a service to direct resource discovery query.
219 * If empty, performs multicast resource discovery query
220 * @param resourceUri name of the resource. If null or empty, performs search for all
222 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
224 * @param onResourceFoundListener Handles events, success states and failure states.
225 * @throws OcException
227 public static void findResource(
230 EnumSet<OcConnectivityType> connectivityTypeSet,
231 OnResourceFoundListener onResourceFoundListener) throws OcException {
232 OcPlatform.initCheck();
236 for (OcConnectivityType connType : OcConnectivityType.values()) {
237 if (connectivityTypeSet.contains(connType))
238 connTypeInt |= connType.getValue();
241 OcPlatform.findResource0(
245 onResourceFoundListener
249 private static native void findResource0(
252 int connectivityType,
253 OnResourceFoundListener onResourceFoundListener) throws OcException;
256 * API for Service and Resource Discovery. NOTE: This API applies to client side only
258 * @param host Host IP Address of a service to direct resource discovery query.
259 * If empty, performs multicast resource discovery query
260 * @param resourceUri name of the resource. If null or empty, performs search for all
262 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
264 * @param onResourceFoundListener Handles events, success states and failure states.
265 * @param qualityOfService the quality of communication
266 * @throws OcException
268 public static void findResource(
271 EnumSet<OcConnectivityType> connectivityTypeSet,
272 OnResourceFoundListener onResourceFoundListener,
273 QualityOfService qualityOfService) throws OcException {
274 OcPlatform.initCheck();
278 for (OcConnectivityType connType : OcConnectivityType.values()) {
279 if (connectivityTypeSet.contains(connType))
280 connTypeInt |= connType.getValue();
283 OcPlatform.findResource1(host,
286 onResourceFoundListener,
287 qualityOfService.getValue()
291 private static native void findResource1(
294 int connectivityType,
295 OnResourceFoundListener onResourceFoundListener,
296 int qualityOfService) throws OcException;
299 * API for Device Discovery
301 * @param host Host IP Address. If null or empty, Multicast is performed.
302 * @param deviceUri Uri containing address to the virtual device
303 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
305 * @param onDeviceFoundListener Handles events, success states and failure states.
306 * @throws OcException
308 public static void getDeviceInfo(
311 EnumSet<OcConnectivityType> connectivityTypeSet,
312 OnDeviceFoundListener onDeviceFoundListener) throws OcException {
313 OcPlatform.initCheck();
316 for (OcConnectivityType connType : OcConnectivityType.values()) {
317 if (connectivityTypeSet.contains(connType))
318 connTypeInt |= connType.getValue();
320 OcPlatform.getDeviceInfo0(
324 onDeviceFoundListener
328 private static native void getDeviceInfo0(
331 int connectivityType,
332 OnDeviceFoundListener onDeviceFoundListener) throws OcException;
335 * API for Device Discovery
337 * @param host Host IP Address. If null or empty, Multicast is performed.
338 * @param deviceUri Uri containing address to the virtual device
339 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
341 * @param onDeviceFoundListener Handles events, success states and failure states.
342 * @param qualityOfService the quality of communication
343 * @throws OcException
345 public static void getDeviceInfo(
348 EnumSet<OcConnectivityType> connectivityTypeSet,
349 OnDeviceFoundListener onDeviceFoundListener,
350 QualityOfService qualityOfService) throws OcException {
351 OcPlatform.initCheck();
354 for (OcConnectivityType connType : OcConnectivityType.values()) {
355 if (connectivityTypeSet.contains(connType))
356 connTypeInt |= connType.getValue();
358 OcPlatform.getDeviceInfo1(
362 onDeviceFoundListener,
363 qualityOfService.getValue()
367 private static native void getDeviceInfo1(
370 int connectivityType,
371 OnDeviceFoundListener onDeviceFoundListener,
372 int qualityOfService) throws OcException;
375 * API for Platform Discovery
377 * @param host Host IP Address. If null or empty, Multicast is performed.
378 * @param platformUri Uri containing address to the platform
379 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
381 * @param onPlatformFoundListener Handles events, success states and failure states.
382 * @throws OcException
385 public static void getPlatformInfo(
388 EnumSet<OcConnectivityType> connectivityTypeSet,
389 OnPlatformFoundListener onPlatformFoundListener) throws OcException {
390 OcPlatform.initCheck();
393 for (OcConnectivityType connType : OcConnectivityType.values()) {
394 if (connectivityTypeSet.contains(connType))
395 connTypeInt |= connType.getValue();
397 OcPlatform.getPlatformInfo0(
401 onPlatformFoundListener
405 private static native void getPlatformInfo0(
408 int connectivityType,
409 OnPlatformFoundListener onPlatformInfoFoundListener) throws OcException;
412 * API for Platform Discovery
414 * @param host Host IP Address. If null or empty, Multicast is performed.
415 * @param platformUri Uri containing address to the platform
416 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
418 * @param onPlatformFoundListener Handles events, success states and failure states.
419 * @param qualityOfService the quality of communication
420 * @throws OcException
423 public static void getPlatformInfo(
426 EnumSet<OcConnectivityType> connectivityTypeSet,
427 OnPlatformFoundListener onPlatformFoundListener,
428 QualityOfService qualityOfService) throws OcException {
429 OcPlatform.initCheck();
432 for (OcConnectivityType connType : OcConnectivityType.values()) {
433 if (connectivityTypeSet.contains(connType))
434 connTypeInt |= connType.getValue();
436 OcPlatform.getPlatformInfo1(
440 onPlatformFoundListener,
441 qualityOfService.getValue()
445 private static native void getPlatformInfo1(
448 int connectivityType,
449 OnPlatformFoundListener onPlatformFoundListener,
450 int qualityOfService) throws OcException;
453 * This API registers a resource with the server NOTE: This API applies to server side only.
455 * @param ocResource The instance of OcResource with all data filled
456 * @return resource handle
457 * @throws OcException
459 public static OcResourceHandle registerResource(
460 OcResource ocResource) throws OcException {
461 OcPlatform.initCheck();
462 return OcPlatform.registerResource0(ocResource);
465 private static native OcResourceHandle registerResource0(
466 OcResource ocResource) throws OcException;
469 * This API registers a resource with the server NOTE: This API applies to server side only.
471 * @param resourceUri The URI of the resource. Example: "a/light"
472 * @param resourceTypeName The resource type. Example: "light"
473 * @param resourceInterface The resource interface (whether it is collection etc).
474 * @param entityHandler entity handler.
475 * @param resourcePropertySet indicates the property of the resource
476 * @return resource handle
477 * @throws OcException
479 public static OcResourceHandle registerResource(
481 String resourceTypeName,
482 String resourceInterface,
483 EntityHandler entityHandler,
484 EnumSet<ResourceProperty> resourcePropertySet) throws OcException {
485 OcPlatform.initCheck();
489 for (ResourceProperty prop : ResourceProperty.values()) {
490 if (resourcePropertySet.contains(prop))
491 resProperty |= prop.getValue();
494 if(null == entityHandler){
495 entityHandler = new EntityHandler() {
497 public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
498 return EntityHandlerResult.OK;
503 return OcPlatform.registerResource1(resourceUri,
510 private static native OcResourceHandle registerResource1(
512 String resourceTypeName,
513 String resourceInterface,
514 EntityHandler entityHandler,
515 int resourceProperty) throws OcException;
518 * Register Device Info
520 * @param ocDeviceInfo object containing all the device specific information
521 * @throws OcException
523 public static void registerDeviceInfo(
524 OcDeviceInfo ocDeviceInfo) throws OcException {
525 OcPlatform.initCheck();
526 OcPlatform.registerDeviceInfo0(
527 ocDeviceInfo.getDeviceName()
531 private static native void registerDeviceInfo0(
533 ) throws OcException;
536 * Register Platform Info
538 * @param ocPlatformInfo object containing all the platform specific information
539 * @throws OcException
541 public static void registerPlatformInfo(
542 OcPlatformInfo ocPlatformInfo) throws OcException {
543 OcPlatform.initCheck();
544 OcPlatform.registerPlatformInfo0(
545 ocPlatformInfo.getPlatformID(),
546 ocPlatformInfo.getManufacturerName(),
547 ocPlatformInfo.getManufacturerUrl(),
548 ocPlatformInfo.getModelNumber(),
549 ocPlatformInfo.getDateOfManufacture(),
550 ocPlatformInfo.getPlatformVersion(),
551 ocPlatformInfo.getOperatingSystemVersion(),
552 ocPlatformInfo.getHardwareVersion(),
553 ocPlatformInfo.getFirmwareVersion(),
554 ocPlatformInfo.getSupportUrl(),
555 ocPlatformInfo.getSystemTime()
559 private static native void registerPlatformInfo0(
560 String platformId, String manufacturerName, String manufacturerUrl,
561 String modelNumber, String dateOfManufacture, String platformVersion,
562 String operatingSystemVersion, String hardwareVersion, String firmwareVersion,
563 String supportUrl, String systemTime
564 ) throws OcException;
567 * This API unregisters a resource with the server NOTE: This API applies to server side only.
569 * @param ocResourceHandle This is the resource handle which we which to unregister from the
571 * @throws OcException
573 public static void unregisterResource(
574 OcResourceHandle ocResourceHandle) throws OcException {
575 OcPlatform.initCheck();
576 OcPlatform.unregisterResource0(ocResourceHandle);
579 private static native void unregisterResource0(
580 OcResourceHandle ocResourceHandle) throws OcException;
584 * Add a resource to a collection resource
586 * @param ocResourceCollectionHandle handle to the collection resource
587 * @param ocResourceHandle handle to resource to be added to the collection resource
588 * @throws OcException
590 public static void bindResource(
591 OcResourceHandle ocResourceCollectionHandle,
592 OcResourceHandle ocResourceHandle) throws OcException {
593 OcPlatform.initCheck();
594 OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle);
597 private static native void bindResource0(
598 OcResourceHandle ocResourceCollectionHandle,
599 OcResourceHandle ocResourceHandle) throws OcException;
602 * Add multiple resources to a collection resource.
604 * @param ocResourceCollectionHandle handle to the collection resource
605 * @param ocResourceHandleList reference to list of resource handles to be added to the
606 * collection resource
607 * @throws OcException
609 public static void bindResources(
610 OcResourceHandle ocResourceCollectionHandle,
611 List<OcResourceHandle> ocResourceHandleList) throws OcException {
612 OcPlatform.initCheck();
613 OcPlatform.bindResources0(
614 ocResourceCollectionHandle,
615 ocResourceHandleList.toArray(
616 new OcResourceHandle[ocResourceHandleList.size()])
620 private static native void bindResources0(
621 OcResourceHandle ocResourceCollectionHandle,
622 OcResourceHandle[] ocResourceHandleArray) throws OcException;
625 * Unbind a resource from a collection resource.
627 * @param ocResourceCollectionHandle handle to the collection resource
628 * @param ocResourceHandle resource handle to be unbound from the collection resource
629 * @throws OcException
631 public static void unbindResource(
632 OcResourceHandle ocResourceCollectionHandle,
633 OcResourceHandle ocResourceHandle) throws OcException {
634 OcPlatform.initCheck();
635 OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle);
638 private static native void unbindResource0(
639 OcResourceHandle ocResourceCollectionHandle,
640 OcResourceHandle ocResourceHandle) throws OcException;
643 * Unbind resources from a collection resource.
645 * @param ocResourceCollectionHandle Handle to the collection resource
646 * @param ocResourceHandleList List of resource handles to be unbound from the collection
648 * @throws OcException
650 public static void unbindResources(
651 OcResourceHandle ocResourceCollectionHandle,
652 List<OcResourceHandle> ocResourceHandleList) throws OcException {
653 OcPlatform.initCheck();
654 OcPlatform.unbindResources0(
655 ocResourceCollectionHandle,
656 ocResourceHandleList.toArray(
657 new OcResourceHandle[ocResourceHandleList.size()])
661 private static native void unbindResources0(
662 OcResourceHandle ocResourceCollectionHandle,
663 OcResourceHandle[] ocResourceHandleArray) throws OcException;
666 * Binds a type to a particular resource
668 * @param ocResourceHandle handle to the resource
669 * @param resourceTypeName new typename to bind to the resource
670 * @throws OcException
672 public static void bindTypeToResource(
673 OcResourceHandle ocResourceHandle,
674 String resourceTypeName) throws OcException {
675 OcPlatform.initCheck();
676 OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName);
679 private static native void bindTypeToResource0(
680 OcResourceHandle ocResourceHandle,
681 String resourceTypeName) throws OcException;
684 * Binds an interface to a particular resource
686 * @param ocResourceHandle handle to the resource
687 * @param resourceInterfaceName new interface to bind to the resource
688 * @throws OcException
690 public static void bindInterfaceToResource(
691 OcResourceHandle ocResourceHandle,
692 String resourceInterfaceName) throws OcException {
693 OcPlatform.initCheck();
694 OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName);
697 private static native void bindInterfaceToResource0(
698 OcResourceHandle ocResourceHandle,
699 String resourceInterfaceName) throws OcException;
702 * Start Presence announcements.
704 * @param ttl time to live in seconds
705 * @throws OcException
707 public static void startPresence(int ttl) throws OcException {
708 OcPlatform.initCheck();
709 OcPlatform.startPresence0(ttl);
712 private static native void startPresence0(int ttl) throws OcException;
715 * Stop Presence announcements.
717 * @throws OcException
719 public static void stopPresence() throws OcException {
720 OcPlatform.initCheck();
721 OcPlatform.stopPresence0();
724 private static native void stopPresence0() throws OcException;
727 * Subscribes to a server's presence change events. By making this subscription, every time a
728 * server adds/removes/alters a resource, starts or is intentionally stopped
730 * @param host The IP address/addressable name of the server to subscribe to
731 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
733 * @param onPresenceListener listener that will receive notifications/subscription events
734 * @return a handle object that can be used to identify this subscription request. It can be
735 * used to unsubscribe from these events in the future
736 * @throws OcException
738 public static OcPresenceHandle subscribePresence(
740 EnumSet<OcConnectivityType> connectivityTypeSet,
741 OnPresenceListener onPresenceListener) throws OcException {
742 OcPlatform.initCheck();
745 for (OcConnectivityType connType : OcConnectivityType.values()) {
746 if (connectivityTypeSet.contains(connType))
747 connTypeInt |= connType.getValue();
749 return OcPlatform.subscribePresence0(
756 private static native OcPresenceHandle subscribePresence0(
758 int connectivityType,
759 OnPresenceListener onPresenceListener) throws OcException;
762 * Subscribes to a server's presence change events. By making this subscription, every time a
763 * server adds/removes/alters a resource, starts or is intentionally stopped
765 * @param host The IP address/addressable name of the server to subscribe to
766 * @param resourceType a resource type specified as a filter for subscription events.
767 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
769 * @param onPresenceListener listener that will receive notifications/subscription events
770 * @return a handle object that can be used to identify this subscription request. It can be
771 * used to unsubscribe from these events in the future
772 * @throws OcException
774 public static OcPresenceHandle subscribePresence(
777 EnumSet<OcConnectivityType> connectivityTypeSet,
778 OnPresenceListener onPresenceListener) throws OcException {
779 OcPlatform.initCheck();
782 for (OcConnectivityType connType : OcConnectivityType.values()) {
783 if (connectivityTypeSet.contains(connType))
784 connTypeInt |= connType.getValue();
786 return OcPlatform.subscribePresence1(
793 private static native OcPresenceHandle subscribePresence1(
796 int connectivityType,
797 OnPresenceListener onPresenceListener) throws OcException;
800 * Unsubscribes from a previously subscribed server's presence events. Note that you may for
801 * a short time still receive events from the server since it may take time for the
802 * unsubscribe to take effect.
804 * @param ocPresenceHandle the handle object provided by the subscribePresence call that
805 * identifies this subscription
806 * @throws OcException
808 public static void unsubscribePresence(
809 OcPresenceHandle ocPresenceHandle) throws OcException {
810 OcPlatform.initCheck();
811 OcPlatform.unsubscribePresence0(ocPresenceHandle);
814 private static native void unsubscribePresence0(
815 OcPresenceHandle ocPresenceHandle) throws OcException;
818 * Creates a resource proxy object so that get/put/observe functionality can be used without
819 * discovering the object in advance. Note that the consumer of this method needs to provide
820 * all of the details required to correctly contact and observe the object. If the consumer
821 * lacks any of this information, they should discover the resource object normally.
822 * Additionally, you can only create this object if OcPlatform was initialized to be a Client
825 * @param host a string containing a resolvable host address of the server holding
827 * @param uri the rest of the resource's URI that will permit messages to be
830 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
832 * @param isObservable a boolean containing whether the resource supports observation
833 * @param resourceTypeList a collection of resource types implemented by the resource
834 * @param interfaceList a collection of interfaces that the resource supports/implements
835 * @return new resource object
836 * @throws OcException
838 public static OcResource constructResourceObject(
841 EnumSet<OcConnectivityType> connectivityTypeSet,
842 boolean isObservable,
843 List<String> resourceTypeList,
844 List<String> interfaceList) throws OcException {
845 OcPlatform.initCheck();
848 for (OcConnectivityType connType : OcConnectivityType.values()) {
849 if (connectivityTypeSet.contains(connType))
850 connTypeInt |= connType.getValue();
852 return OcPlatform.constructResourceObject0(
857 resourceTypeList.toArray(new String[resourceTypeList.size()]),
858 interfaceList.toArray(new String[interfaceList.size()])
862 private static native OcResource constructResourceObject0(
865 int connectivityType,
866 boolean isObservable,
867 String[] resourceTypes,
868 String[] interfaces) throws OcException;
871 * Allows application entity handler to send response to an incoming request.
873 * @param ocResourceResponse resource response
874 * @throws OcException
876 public static void sendResponse(OcResourceResponse ocResourceResponse)
878 OcPlatform.initCheck();
879 OcPlatform.sendResponse0(ocResourceResponse);
882 private static native void sendResponse0(OcResourceResponse ocResourceResponse)
886 * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
887 * Event listeners are notified asynchronously
889 public interface OnResourceFoundListener {
890 public void onResourceFound(OcResource resource);
894 * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call.
895 * Event listeners are notified asynchronously
897 public interface OnDeviceFoundListener {
898 public void onDeviceFound(OcRepresentation ocRepresentation);
902 * An OnPlatformFoundListener can be registered via the OcPlatform.getPlatformInfo call.
903 * Event listeners are notified asynchronously
905 public interface OnPlatformFoundListener {
906 public void onPlatformFound(OcRepresentation ocRepresentation);
910 * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call.
911 * Event listeners are notified asynchronously
913 public interface OnPresenceListener {
914 public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress);
918 * An EntityHandler can be registered via the OcPlatform.registerResource call.
919 * Event listeners are notified asynchronously
921 public interface EntityHandler {
922 public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);
925 private static void initCheck() {
926 if (!sIsPlatformInitialized) {
927 throw new IllegalStateException("OcPlatform must be configured by making a call to " +
928 "OcPlatform.Configure before any other API calls are permitted");