2 * //******************************************************************
\r
4 * // Copyright 2015 Intel Corporation.
\r
6 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
8 * // Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * // you may not use this file except in compliance with the License.
\r
10 * // You may obtain a copy of the License at
\r
12 * // http://www.apache.org/licenses/LICENSE-2.0
\r
14 * // Unless required by applicable law or agreed to in writing, software
\r
15 * // distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * // See the License for the specific language governing permissions and
\r
18 * // limitations under the License.
\r
20 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
23 package org.iotivity.base;
\r
25 import org.iotivity.ca.CaInterface;
\r
27 import java.util.EnumSet;
\r
28 import java.util.Iterator;
\r
29 import java.util.List;
\r
32 * Contains the main entrance/functionality of the product. To set a custom configuration, the
\r
33 * implementer must make a call to OcPlatform.Configure before the first usage of a function in this
\r
36 public final class OcPlatform {
\r
39 System.loadLibrary("oc_logger");
\r
40 System.loadLibrary("octbstack");
\r
41 System.loadLibrary("connectivity_abstraction");
\r
42 System.loadLibrary("oc");
\r
43 System.loadLibrary("ocstack-jni");
\r
49 public static final String DEFAULT_INTERFACE = "oc.mi.def";
\r
52 * Used in discovering (GET) links to other resources of a collection
\r
54 public static final String LINK_INTERFACE = "oc.mi.ll";
\r
57 * Used in GET, PUT, POST, DELETE methods on links to other resources of a collection
\r
59 public static final String BATCH_INTERFACE = "oc.mi.b";
\r
62 * Used in GET, PUT, POST methods on links to other remote resources of a group
\r
64 public static final String GROUP_INTERFACE = "oc.mi.grp";
\r
66 public static final String WELL_KNOWN_QUERY = "224.0.1.187:5683/oc/core";
\r
67 public static final String MULTICAST_PREFIX = "224.0.1.187:5683";
\r
68 public static final String MULTICAST_IP = "224.0.1.187";
\r
69 public static final int MULTICAST_PORT = 5683;
\r
70 public static final int DEFAULT_PRESENCE_TTL = 60;
\r
71 public static final String PRESENCE_URI = "/oc/presence";
\r
73 private static volatile boolean sIsPlatformInitialized = false;
\r
75 private OcPlatform() {
\r
79 * API for setting the configuration of the OcPlatform.
\r
80 * Note: Any calls made to this AFTER the first call to OcPlatform.Configure will have no affect
\r
82 * @param platformConfig platform configuration
\r
84 public synchronized static void Configure(PlatformConfig platformConfig) {
\r
85 if (!sIsPlatformInitialized) {
\r
86 CaInterface.initialize(platformConfig.getContext());
\r
88 OcPlatform.configure(
\r
89 platformConfig.getServiceType().getValue(),
\r
90 platformConfig.getModeType().getValue(),
\r
91 platformConfig.getIpAddress(),
\r
92 platformConfig.getPort(),
\r
93 platformConfig.getQualityOfService().getValue()
\r
96 sIsPlatformInitialized = true;
\r
100 private static native void configure(int serviceType,
\r
104 int qualityOfService);
\r
107 * API for notifying base that resource's attributes have changed.
\r
109 * @param ocResourceHandle resource handle of the resource
\r
110 * @throws OcException
\r
112 public static void notifyAllObservers(
\r
113 OcResourceHandle ocResourceHandle) throws OcException {
\r
114 OcPlatform.initCheck();
\r
115 OcPlatform.notifyAllObservers0(ocResourceHandle);
\r
118 private static native void notifyAllObservers0(
\r
119 OcResourceHandle ocResourceHandle) throws OcException;
\r
122 * API for notifying base that resource's attributes have changed.
\r
124 * @param ocResourceHandle resource handle of the resource
\r
125 * @param qualityOfService the quality of communication
\r
126 * @throws OcException
\r
128 public static void notifyAllObservers(
\r
129 OcResourceHandle ocResourceHandle,
\r
130 QualityOfService qualityOfService) throws OcException {
\r
131 OcPlatform.initCheck();
\r
132 OcPlatform.notifyAllObservers1(ocResourceHandle, qualityOfService.getValue());
\r
135 private static native void notifyAllObservers1(
\r
136 OcResourceHandle ocResourceHandle,
\r
137 int qualityOfService) throws OcException;
\r
140 * API for notifying only specific clients that resource's attributes have changed.
\r
142 * @param ocResourceHandle resource handle of the resource
\r
143 * @param ocObservationIdList These set of ids are ones which which will be notified upon
\r
145 * @param ocResourceResponse OcResourceResponse object used by app to fill the response for
\r
146 * this resource change
\r
147 * @throws OcException
\r
149 public static void notifyListOfObservers(
\r
150 OcResourceHandle ocResourceHandle,
\r
151 List<Byte> ocObservationIdList,
\r
152 OcResourceResponse ocResourceResponse) throws OcException {
\r
153 OcPlatform.initCheck();
\r
155 byte[] idArr = new byte[ocObservationIdList.size()];
\r
156 Iterator<Byte> it = ocObservationIdList.iterator();
\r
158 while (it.hasNext()) {
\r
159 idArr[i++] = (byte) it.next();
\r
162 OcPlatform.notifyListOfObservers2(
\r
165 ocResourceResponse);
\r
168 private static native void notifyListOfObservers2(
\r
169 OcResourceHandle ocResourceHandle,
\r
170 byte[] ocObservationIdArray,
\r
171 OcResourceResponse ocResourceResponse) throws OcException;
\r
174 * API for notifying only specific clients that resource's attributes have changed.
\r
176 * @param ocResourceHandle resource handle of the resource
\r
177 * @param ocObservationIdList These set of ids are ones which which will be notified upon
\r
179 * @param ocResourceResponse OcResourceResponse object used by app to fill the response for
\r
180 * this resource change
\r
181 * @param qualityOfService the quality of communication
\r
182 * @throws OcException
\r
184 public static void notifyListOfObservers(
\r
185 OcResourceHandle ocResourceHandle,
\r
186 List<Byte> ocObservationIdList,
\r
187 OcResourceResponse ocResourceResponse,
\r
188 QualityOfService qualityOfService) throws OcException {
\r
189 OcPlatform.initCheck();
\r
191 byte[] idArr = new byte[ocObservationIdList.size()];
\r
192 Iterator<Byte> it = ocObservationIdList.iterator();
\r
194 while (it.hasNext()) {
\r
195 idArr[i++] = (byte) it.next();
\r
198 OcPlatform.notifyListOfObservers3(
\r
201 ocResourceResponse,
\r
202 qualityOfService.getValue()
\r
206 private static native void notifyListOfObservers3(
\r
207 OcResourceHandle ocResourceHandle,
\r
208 byte[] ocObservationIdArray,
\r
209 OcResourceResponse ocResourceResponse,
\r
210 int qualityOfService) throws OcException;
\r
213 * API for Service and Resource Discovery. NOTE: This API applies to client side only
\r
215 * @param host Host IP Address of a service to direct resource discovery query.
\r
216 * If empty, performs multicast resource discovery query
\r
217 * @param resourceUri name of the resource. If null or empty, performs search for all
\r
219 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
221 * @param onResourceFoundListener Handles events, success states and failure states.
\r
222 * @throws OcException
\r
224 public static void findResource(
\r
226 String resourceUri,
\r
227 OcConnectivityType connectivityType,
\r
228 OnResourceFoundListener onResourceFoundListener) throws OcException {
\r
229 OcPlatform.initCheck();
\r
230 OcPlatform.findResource0(
\r
233 connectivityType.getValue(),
\r
234 onResourceFoundListener
\r
238 private static native void findResource0(
\r
240 String resourceUri,
\r
241 int connectivityType,
\r
242 OnResourceFoundListener onResourceFoundListener) throws OcException;
\r
245 * API for Service and Resource Discovery. NOTE: This API applies to client side only
\r
247 * @param host Host IP Address of a service to direct resource discovery query.
\r
248 * If empty, performs multicast resource discovery query
\r
249 * @param resourceUri name of the resource. If null or empty, performs search for all
\r
251 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
253 * @param onResourceFoundListener Handles events, success states and failure states.
\r
254 * @param qualityOfService the quality of communication
\r
255 * @throws OcException
\r
257 public static void findResource(
\r
259 String resourceUri,
\r
260 OcConnectivityType connectivityType,
\r
261 OnResourceFoundListener onResourceFoundListener,
\r
262 QualityOfService qualityOfService) throws OcException {
\r
263 OcPlatform.initCheck();
\r
264 OcPlatform.findResource1(host,
\r
266 connectivityType.getValue(),
\r
267 onResourceFoundListener,
\r
268 qualityOfService.getValue()
\r
272 private static native void findResource1(
\r
274 String resourceUri,
\r
275 int connectivityType,
\r
276 OnResourceFoundListener onResourceFoundListener,
\r
277 int qualityOfService) throws OcException;
\r
280 * API for Device Discovery
\r
282 * @param host Host IP Address. If null or empty, Multicast is performed.
\r
283 * @param deviceUri Uri containing address to the virtual device
\r
284 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
286 * @param onDeviceFoundListener Handles events, success states and failure states.
\r
287 * @throws OcException
\r
289 public static void getDeviceInfo(
\r
292 OcConnectivityType connectivityType,
\r
293 OnDeviceFoundListener onDeviceFoundListener) throws OcException {
\r
294 OcPlatform.initCheck();
\r
295 OcPlatform.getDeviceInfo0(
\r
298 connectivityType.getValue(),
\r
299 onDeviceFoundListener
\r
303 private static native void getDeviceInfo0(
\r
306 int connectivityType,
\r
307 OnDeviceFoundListener onDeviceFoundListener) throws OcException;
\r
310 * API for Device Discovery
\r
312 * @param host Host IP Address. If null or empty, Multicast is performed.
\r
313 * @param deviceUri Uri containing address to the virtual device
\r
314 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
316 * @param onDeviceFoundListener Handles events, success states and failure states.
\r
317 * @param qualityOfService the quality of communication
\r
318 * @throws OcException
\r
320 public static void getDeviceInfo(
\r
323 OcConnectivityType connectivityType,
\r
324 OnDeviceFoundListener onDeviceFoundListener,
\r
325 QualityOfService qualityOfService) throws OcException {
\r
326 OcPlatform.initCheck();
\r
327 OcPlatform.getDeviceInfo1(
\r
330 connectivityType.getValue(),
\r
331 onDeviceFoundListener,
\r
332 qualityOfService.getValue()
\r
336 private static native void getDeviceInfo1(
\r
339 int connectivityType,
\r
340 OnDeviceFoundListener onDeviceFoundListener,
\r
341 int qualityOfService) throws OcException;
\r
344 * This API registers a resource with the server NOTE: This API applies to server side only.
\r
346 * @param ocResource The instance of OcResource with all data filled
\r
347 * @return resource handle
\r
348 * @throws OcException
\r
350 public static OcResourceHandle registerResource(
\r
351 OcResource ocResource) throws OcException {
\r
352 OcPlatform.initCheck();
\r
353 return OcPlatform.registerResource0(ocResource);
\r
356 private static native OcResourceHandle registerResource0(
\r
357 OcResource ocResource) throws OcException;
\r
360 * This API registers a resource with the server NOTE: This API applies to server side only.
\r
362 * @param resourceUri The URI of the resource. Example: "a/light"
\r
363 * @param resourceTypeName The resource type. Example: "light"
\r
364 * @param resourceInterface The resource interface (whether it is collection etc).
\r
365 * @param entityHandler entity handler.
\r
366 * @param resourcePropertySet indicates the property of the resource
\r
367 * @return resource handle
\r
368 * @throws OcException
\r
370 public static OcResourceHandle registerResource(
\r
371 String resourceUri,
\r
372 String resourceTypeName,
\r
373 String resourceInterface,
\r
374 EntityHandler entityHandler,
\r
375 EnumSet<ResourceProperty> resourcePropertySet) throws OcException {
\r
376 OcPlatform.initCheck();
\r
378 int resProperty = 0;
\r
380 for (ResourceProperty prop : ResourceProperty.values()) {
\r
381 if (resourcePropertySet.contains(prop))
\r
382 resProperty |= prop.getValue();
\r
385 return OcPlatform.registerResource1(resourceUri,
\r
392 private static native OcResourceHandle registerResource1(
\r
393 String resourceUri,
\r
394 String resourceTypeName,
\r
395 String resourceInterface,
\r
396 EntityHandler entityHandler,
\r
397 int resourceProperty) throws OcException;
\r
400 * Register Device Info
\r
402 * @param ocDeviceInfo object containing all the device specific information
\r
403 * @throws OcException
\r
405 public static void registerDeviceInfo(
\r
406 OcDeviceInfo ocDeviceInfo) throws OcException {
\r
407 OcPlatform.initCheck();
\r
408 OcPlatform.registerDeviceInfo0(
\r
409 ocDeviceInfo.getDeviceName(),
\r
410 ocDeviceInfo.getHostName(),
\r
411 ocDeviceInfo.getDeviceUuid(),
\r
412 ocDeviceInfo.getContentType(),
\r
413 ocDeviceInfo.getVersion(),
\r
414 ocDeviceInfo.getManufacturerName(),
\r
415 ocDeviceInfo.getManufacturerUrl(),
\r
416 ocDeviceInfo.getModelNumber(),
\r
417 ocDeviceInfo.getDateOfManufacture(),
\r
418 ocDeviceInfo.getPlatformVersion(),
\r
419 ocDeviceInfo.getFirmwareVersion(),
\r
420 ocDeviceInfo.getSupportUrl()
\r
424 private static native void registerDeviceInfo0(
\r
428 String contentType,
\r
430 String manufacturerName,
\r
431 String manufacturerUrl,
\r
432 String modelNumber,
\r
433 String dateOfManufacture,
\r
434 String platformVersion,
\r
435 String firmwareVersion,
\r
436 String supportUrl) throws OcException;
\r
439 * This API unregisters a resource with the server NOTE: This API applies to server side only.
\r
441 * @param ocResourceHandle This is the resource handle which we which to unregister from the
\r
443 * @throws OcException
\r
445 public static void unregisterResource(
\r
446 OcResourceHandle ocResourceHandle) throws OcException {
\r
447 OcPlatform.initCheck();
\r
448 OcPlatform.unregisterResource0(ocResourceHandle);
\r
451 private static native void unregisterResource0(
\r
452 OcResourceHandle ocResourceHandle) throws OcException;
\r
456 * Add a resource to a collection resource
\r
458 * @param ocResourceCollectionHandle handle to the collection resource
\r
459 * @param ocResourceHandle handle to resource to be added to the collection resource
\r
460 * @throws OcException
\r
462 public static void bindResource(
\r
463 OcResourceHandle ocResourceCollectionHandle,
\r
464 OcResourceHandle ocResourceHandle) throws OcException {
\r
465 OcPlatform.initCheck();
\r
466 OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle);
\r
469 private static native void bindResource0(
\r
470 OcResourceHandle ocResourceCollectionHandle,
\r
471 OcResourceHandle ocResourceHandle) throws OcException;
\r
474 * Add multiple resources to a collection resource.
\r
476 * @param ocResourceCollectionHandle handle to the collection resource
\r
477 * @param ocResourceHandleList reference to list of resource handles to be added to the
\r
478 * collection resource
\r
479 * @throws OcException
\r
481 public static void bindResources(
\r
482 OcResourceHandle ocResourceCollectionHandle,
\r
483 List<OcResourceHandle> ocResourceHandleList) throws OcException {
\r
484 OcPlatform.initCheck();
\r
485 OcPlatform.bindResources0(
\r
486 ocResourceCollectionHandle,
\r
487 ocResourceHandleList.toArray(
\r
488 new OcResourceHandle[ocResourceHandleList.size()])
\r
492 private static native void bindResources0(
\r
493 OcResourceHandle ocResourceCollectionHandle,
\r
494 OcResourceHandle[] ocResourceHandleArray) throws OcException;
\r
497 * Unbind a resource from a collection resource.
\r
499 * @param ocResourceCollectionHandle handle to the collection resource
\r
500 * @param ocResourceHandle resource handle to be unbound from the collection resource
\r
501 * @throws OcException
\r
503 public static void unbindResource(
\r
504 OcResourceHandle ocResourceCollectionHandle,
\r
505 OcResourceHandle ocResourceHandle) throws OcException {
\r
506 OcPlatform.initCheck();
\r
507 OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle);
\r
510 private static native void unbindResource0(
\r
511 OcResourceHandle ocResourceCollectionHandle,
\r
512 OcResourceHandle ocResourceHandle) throws OcException;
\r
515 * Unbind resources from a collection resource.
\r
517 * @param ocResourceCollectionHandle Handle to the collection resource
\r
518 * @param ocResourceHandleList List of resource handles to be unbound from the collection
\r
520 * @throws OcException
\r
522 public static void unbindResources(
\r
523 OcResourceHandle ocResourceCollectionHandle,
\r
524 List<OcResourceHandle> ocResourceHandleList) throws OcException {
\r
525 OcPlatform.initCheck();
\r
526 OcPlatform.unbindResources0(
\r
527 ocResourceCollectionHandle,
\r
528 ocResourceHandleList.toArray(
\r
529 new OcResourceHandle[ocResourceHandleList.size()])
\r
533 private static native void unbindResources0(
\r
534 OcResourceHandle ocResourceCollectionHandle,
\r
535 OcResourceHandle[] ocResourceHandleArray) throws OcException;
\r
538 * Binds a type to a particular resource
\r
540 * @param ocResourceHandle handle to the resource
\r
541 * @param resourceTypeName new typename to bind to the resource
\r
542 * @throws OcException
\r
544 public static void bindTypeToResource(
\r
545 OcResourceHandle ocResourceHandle,
\r
546 String resourceTypeName) throws OcException {
\r
547 OcPlatform.initCheck();
\r
548 OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName);
\r
551 private static native void bindTypeToResource0(
\r
552 OcResourceHandle ocResourceHandle,
\r
553 String resourceTypeName) throws OcException;
\r
556 * Binds an interface to a particular resource
\r
558 * @param ocResourceHandle handle to the resource
\r
559 * @param resourceInterfaceName new interface to bind to the resource
\r
560 * @throws OcException
\r
562 public static void bindInterfaceToResource(
\r
563 OcResourceHandle ocResourceHandle,
\r
564 String resourceInterfaceName) throws OcException {
\r
565 OcPlatform.initCheck();
\r
566 OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName);
\r
569 private static native void bindInterfaceToResource0(
\r
570 OcResourceHandle ocResourceHandle,
\r
571 String resourceInterfaceName) throws OcException;
\r
574 * Start Presence announcements.
\r
576 * @param ttl time to live in seconds
\r
577 * @throws OcException
\r
579 public static void startPresence(int ttl) throws OcException {
\r
580 OcPlatform.initCheck();
\r
581 OcPlatform.startPresence0(ttl);
\r
584 private static native void startPresence0(int ttl) throws OcException;
\r
587 * Stop Presence announcements.
\r
589 * @throws OcException
\r
591 public static void stopPresence() throws OcException {
\r
592 OcPlatform.initCheck();
\r
593 OcPlatform.stopPresence0();
\r
596 private static native void stopPresence0() throws OcException;
\r
599 * Subscribes to a server's presence change events. By making this subscription, every time a
\r
600 * server adds/removes/alters a resource, starts or is intentionally stopped
\r
602 * @param host The IP address/addressable name of the server to subscribe to
\r
603 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
605 * @param onPresenceListener listener that will receive notifications/subscription events
\r
606 * @return a handle object that can be used to identify this subscription request. It can be
\r
607 * used to unsubscribe from these events in the future
\r
608 * @throws OcException
\r
610 public static OcPresenceHandle subscribePresence(
\r
612 OcConnectivityType connectivityType,
\r
613 OnPresenceListener onPresenceListener) throws OcException {
\r
614 OcPlatform.initCheck();
\r
615 return OcPlatform.subscribePresence0(
\r
617 connectivityType.getValue(),
\r
622 private static native OcPresenceHandle subscribePresence0(
\r
624 int connectivityType,
\r
625 OnPresenceListener onPresenceListener) throws OcException;
\r
628 * Subscribes to a server's presence change events. By making this subscription, every time a
\r
629 * server adds/removes/alters a resource, starts or is intentionally stopped
\r
631 * @param host The IP address/addressable name of the server to subscribe to
\r
632 * @param resourceType a resource type specified as a filter for subscription events.
\r
633 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
635 * @param onPresenceListener listener that will receive notifications/subscription events
\r
636 * @return a handle object that can be used to identify this subscription request. It can be
\r
637 * used to unsubscribe from these events in the future
\r
638 * @throws OcException
\r
640 public static OcPresenceHandle subscribePresence(
\r
642 String resourceType,
\r
643 OcConnectivityType connectivityType,
\r
644 OnPresenceListener onPresenceListener) throws OcException {
\r
645 OcPlatform.initCheck();
\r
646 return OcPlatform.subscribePresence1(
\r
649 connectivityType.getValue(),
\r
650 onPresenceListener);
\r
653 private static native OcPresenceHandle subscribePresence1(
\r
655 String resourceType,
\r
656 int connectivityType,
\r
657 OnPresenceListener onPresenceListener) throws OcException;
\r
660 * Unsubscribes from a previously subscribed server's presence events. Note that you may for
\r
661 * a short time still receive events from the server since it may take time for the
\r
662 * unsubscribe to take effect.
\r
664 * @param ocPresenceHandle the handle object provided by the subscribePresence call that
\r
665 * identifies this subscription
\r
666 * @throws OcException
\r
668 public static void unsubscribePresence(
\r
669 OcPresenceHandle ocPresenceHandle) throws OcException {
\r
670 OcPlatform.initCheck();
\r
671 OcPlatform.unsubscribePresence0(ocPresenceHandle);
\r
674 private static native void unsubscribePresence0(
\r
675 OcPresenceHandle ocPresenceHandle) throws OcException;
\r
678 * Creates a resource proxy object so that get/put/observe functionality can be used without
\r
679 * discovering the object in advance. Note that the consumer of this method needs to provide
\r
680 * all of the details required to correctly contact and observe the object. If the consumer
\r
681 * lacks any of this information, they should discover the resource object normally.
\r
682 * Additionally, you can only create this object if OcPlatform was initialized to be a Client
\r
683 * or Client/Server.
\r
685 * @param host a string containing a resolvable host address of the server holding
\r
687 * @param uri the rest of the resource's URI that will permit messages to be
\r
689 * Example: /a/light
\r
690 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
692 * @param isObservable a boolean containing whether the resource supports observation
\r
693 * @param resourceTypeList a collection of resource types implemented by the resource
\r
694 * @param interfaceList a collection of interfaces that the resource supports/implements
\r
695 * @return new resource object
\r
696 * @throws OcException
\r
698 public static OcResource constructResourceObject(
\r
701 OcConnectivityType connectivityType,
\r
702 boolean isObservable,
\r
703 List<String> resourceTypeList,
\r
704 List<String> interfaceList) throws OcException {
\r
705 OcPlatform.initCheck();
\r
706 return OcPlatform.constructResourceObject0(
\r
709 connectivityType.getValue(),
\r
711 resourceTypeList.toArray(new String[resourceTypeList.size()]),
\r
712 interfaceList.toArray(new String[interfaceList.size()])
\r
716 private static native OcResource constructResourceObject0(
\r
719 int connectivityType,
\r
720 boolean isObservable,
\r
721 String[] resourceTypes,
\r
722 String[] interfaces) throws OcException;
\r
725 * Allows application entity handler to send response to an incoming request.
\r
727 * @param ocResourceResponse resource response
\r
728 * @throws OcException
\r
730 public static void sendResponse(OcResourceResponse ocResourceResponse)
\r
731 throws OcException {
\r
732 OcPlatform.initCheck();
\r
733 OcPlatform.sendResponse0(ocResourceResponse);
\r
736 private static native void sendResponse0(OcResourceResponse ocResourceResponse)
\r
737 throws OcException;
\r
740 * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
\r
741 * Event listeners are notified asynchronously
\r
743 public interface OnResourceFoundListener {
\r
744 public void onResourceFound(OcResource resource);
\r
748 * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call.
\r
749 * Event listeners are notified asynchronously
\r
751 public interface OnDeviceFoundListener {
\r
752 public void onDeviceFound(OcRepresentation ocRepresentation);
\r
756 * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call.
\r
757 * Event listeners are notified asynchronously
\r
759 public interface OnPresenceListener {
\r
760 public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress);
\r
764 * An EntityHandler can be registered via the OcPlatform.registerResource call.
\r
765 * Event listeners are notified asynchronously
\r
767 public interface EntityHandler {
\r
768 public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);
\r
771 private static void initCheck() {
\r
772 if (!sIsPlatformInitialized) {
\r
773 throw new IllegalStateException("OcPlatform must be configured by making a call to " +
\r
774 "OcPlatform.Configure before any other API calls are permitted");
\r