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 = "oic.mi.def";
\r
52 * Used in discovering (GET) links to other resources of a collection
\r
54 public static final String LINK_INTERFACE = "oic.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 = "oic.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 = "oic.mi.grp";
\r
66 public static final String WELL_KNOWN_QUERY = "224.0.1.187:5683/oic/res";
\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 DEVICE_URI = "/oic/d";
\r
72 public static final String PRESENCE_URI = "/oic/ad";
\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
413 private static native void registerDeviceInfo0(
\r
415 ) throws OcException;
\r
418 * This API unregisters a resource with the server NOTE: This API applies to server side only.
\r
420 * @param ocResourceHandle This is the resource handle which we which to unregister from the
\r
422 * @throws OcException
\r
424 public static void unregisterResource(
\r
425 OcResourceHandle ocResourceHandle) throws OcException {
\r
426 OcPlatform.initCheck();
\r
427 OcPlatform.unregisterResource0(ocResourceHandle);
\r
430 private static native void unregisterResource0(
\r
431 OcResourceHandle ocResourceHandle) throws OcException;
\r
435 * Add a resource to a collection resource
\r
437 * @param ocResourceCollectionHandle handle to the collection resource
\r
438 * @param ocResourceHandle handle to resource to be added to the collection resource
\r
439 * @throws OcException
\r
441 public static void bindResource(
\r
442 OcResourceHandle ocResourceCollectionHandle,
\r
443 OcResourceHandle ocResourceHandle) throws OcException {
\r
444 OcPlatform.initCheck();
\r
445 OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle);
\r
448 private static native void bindResource0(
\r
449 OcResourceHandle ocResourceCollectionHandle,
\r
450 OcResourceHandle ocResourceHandle) throws OcException;
\r
453 * Add multiple resources to a collection resource.
\r
455 * @param ocResourceCollectionHandle handle to the collection resource
\r
456 * @param ocResourceHandleList reference to list of resource handles to be added to the
\r
457 * collection resource
\r
458 * @throws OcException
\r
460 public static void bindResources(
\r
461 OcResourceHandle ocResourceCollectionHandle,
\r
462 List<OcResourceHandle> ocResourceHandleList) throws OcException {
\r
463 OcPlatform.initCheck();
\r
464 OcPlatform.bindResources0(
\r
465 ocResourceCollectionHandle,
\r
466 ocResourceHandleList.toArray(
\r
467 new OcResourceHandle[ocResourceHandleList.size()])
\r
471 private static native void bindResources0(
\r
472 OcResourceHandle ocResourceCollectionHandle,
\r
473 OcResourceHandle[] ocResourceHandleArray) throws OcException;
\r
476 * Unbind a resource from a collection resource.
\r
478 * @param ocResourceCollectionHandle handle to the collection resource
\r
479 * @param ocResourceHandle resource handle to be unbound from the collection resource
\r
480 * @throws OcException
\r
482 public static void unbindResource(
\r
483 OcResourceHandle ocResourceCollectionHandle,
\r
484 OcResourceHandle ocResourceHandle) throws OcException {
\r
485 OcPlatform.initCheck();
\r
486 OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle);
\r
489 private static native void unbindResource0(
\r
490 OcResourceHandle ocResourceCollectionHandle,
\r
491 OcResourceHandle ocResourceHandle) throws OcException;
\r
494 * Unbind resources from a collection resource.
\r
496 * @param ocResourceCollectionHandle Handle to the collection resource
\r
497 * @param ocResourceHandleList List of resource handles to be unbound from the collection
\r
499 * @throws OcException
\r
501 public static void unbindResources(
\r
502 OcResourceHandle ocResourceCollectionHandle,
\r
503 List<OcResourceHandle> ocResourceHandleList) throws OcException {
\r
504 OcPlatform.initCheck();
\r
505 OcPlatform.unbindResources0(
\r
506 ocResourceCollectionHandle,
\r
507 ocResourceHandleList.toArray(
\r
508 new OcResourceHandle[ocResourceHandleList.size()])
\r
512 private static native void unbindResources0(
\r
513 OcResourceHandle ocResourceCollectionHandle,
\r
514 OcResourceHandle[] ocResourceHandleArray) throws OcException;
\r
517 * Binds a type to a particular resource
\r
519 * @param ocResourceHandle handle to the resource
\r
520 * @param resourceTypeName new typename to bind to the resource
\r
521 * @throws OcException
\r
523 public static void bindTypeToResource(
\r
524 OcResourceHandle ocResourceHandle,
\r
525 String resourceTypeName) throws OcException {
\r
526 OcPlatform.initCheck();
\r
527 OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName);
\r
530 private static native void bindTypeToResource0(
\r
531 OcResourceHandle ocResourceHandle,
\r
532 String resourceTypeName) throws OcException;
\r
535 * Binds an interface to a particular resource
\r
537 * @param ocResourceHandle handle to the resource
\r
538 * @param resourceInterfaceName new interface to bind to the resource
\r
539 * @throws OcException
\r
541 public static void bindInterfaceToResource(
\r
542 OcResourceHandle ocResourceHandle,
\r
543 String resourceInterfaceName) throws OcException {
\r
544 OcPlatform.initCheck();
\r
545 OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName);
\r
548 private static native void bindInterfaceToResource0(
\r
549 OcResourceHandle ocResourceHandle,
\r
550 String resourceInterfaceName) throws OcException;
\r
553 * Start Presence announcements.
\r
555 * @param ttl time to live in seconds
\r
556 * @throws OcException
\r
558 public static void startPresence(int ttl) throws OcException {
\r
559 OcPlatform.initCheck();
\r
560 OcPlatform.startPresence0(ttl);
\r
563 private static native void startPresence0(int ttl) throws OcException;
\r
566 * Stop Presence announcements.
\r
568 * @throws OcException
\r
570 public static void stopPresence() throws OcException {
\r
571 OcPlatform.initCheck();
\r
572 OcPlatform.stopPresence0();
\r
575 private static native void stopPresence0() throws OcException;
\r
578 * Subscribes to a server's presence change events. By making this subscription, every time a
\r
579 * server adds/removes/alters a resource, starts or is intentionally stopped
\r
581 * @param host The IP address/addressable name of the server to subscribe to
\r
582 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
584 * @param onPresenceListener listener that will receive notifications/subscription events
\r
585 * @return a handle object that can be used to identify this subscription request. It can be
\r
586 * used to unsubscribe from these events in the future
\r
587 * @throws OcException
\r
589 public static OcPresenceHandle subscribePresence(
\r
591 OcConnectivityType connectivityType,
\r
592 OnPresenceListener onPresenceListener) throws OcException {
\r
593 OcPlatform.initCheck();
\r
594 return OcPlatform.subscribePresence0(
\r
596 connectivityType.getValue(),
\r
601 private static native OcPresenceHandle subscribePresence0(
\r
603 int connectivityType,
\r
604 OnPresenceListener onPresenceListener) throws OcException;
\r
607 * Subscribes to a server's presence change events. By making this subscription, every time a
\r
608 * server adds/removes/alters a resource, starts or is intentionally stopped
\r
610 * @param host The IP address/addressable name of the server to subscribe to
\r
611 * @param resourceType a resource type specified as a filter for subscription events.
\r
612 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
614 * @param onPresenceListener listener that will receive notifications/subscription events
\r
615 * @return a handle object that can be used to identify this subscription request. It can be
\r
616 * used to unsubscribe from these events in the future
\r
617 * @throws OcException
\r
619 public static OcPresenceHandle subscribePresence(
\r
621 String resourceType,
\r
622 OcConnectivityType connectivityType,
\r
623 OnPresenceListener onPresenceListener) throws OcException {
\r
624 OcPlatform.initCheck();
\r
625 return OcPlatform.subscribePresence1(
\r
628 connectivityType.getValue(),
\r
629 onPresenceListener);
\r
632 private static native OcPresenceHandle subscribePresence1(
\r
634 String resourceType,
\r
635 int connectivityType,
\r
636 OnPresenceListener onPresenceListener) throws OcException;
\r
639 * Unsubscribes from a previously subscribed server's presence events. Note that you may for
\r
640 * a short time still receive events from the server since it may take time for the
\r
641 * unsubscribe to take effect.
\r
643 * @param ocPresenceHandle the handle object provided by the subscribePresence call that
\r
644 * identifies this subscription
\r
645 * @throws OcException
\r
647 public static void unsubscribePresence(
\r
648 OcPresenceHandle ocPresenceHandle) throws OcException {
\r
649 OcPlatform.initCheck();
\r
650 OcPlatform.unsubscribePresence0(ocPresenceHandle);
\r
653 private static native void unsubscribePresence0(
\r
654 OcPresenceHandle ocPresenceHandle) throws OcException;
\r
657 * Creates a resource proxy object so that get/put/observe functionality can be used without
\r
658 * discovering the object in advance. Note that the consumer of this method needs to provide
\r
659 * all of the details required to correctly contact and observe the object. If the consumer
\r
660 * lacks any of this information, they should discover the resource object normally.
\r
661 * Additionally, you can only create this object if OcPlatform was initialized to be a Client
\r
662 * or Client/Server.
\r
664 * @param host a string containing a resolvable host address of the server holding
\r
666 * @param uri the rest of the resource's URI that will permit messages to be
\r
668 * Example: /a/light
\r
669 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
671 * @param isObservable a boolean containing whether the resource supports observation
\r
672 * @param resourceTypeList a collection of resource types implemented by the resource
\r
673 * @param interfaceList a collection of interfaces that the resource supports/implements
\r
674 * @return new resource object
\r
675 * @throws OcException
\r
677 public static OcResource constructResourceObject(
\r
680 OcConnectivityType connectivityType,
\r
681 boolean isObservable,
\r
682 List<String> resourceTypeList,
\r
683 List<String> interfaceList) throws OcException {
\r
684 OcPlatform.initCheck();
\r
685 return OcPlatform.constructResourceObject0(
\r
688 connectivityType.getValue(),
\r
690 resourceTypeList.toArray(new String[resourceTypeList.size()]),
\r
691 interfaceList.toArray(new String[interfaceList.size()])
\r
695 private static native OcResource constructResourceObject0(
\r
698 int connectivityType,
\r
699 boolean isObservable,
\r
700 String[] resourceTypes,
\r
701 String[] interfaces) throws OcException;
\r
704 * Allows application entity handler to send response to an incoming request.
\r
706 * @param ocResourceResponse resource response
\r
707 * @throws OcException
\r
709 public static void sendResponse(OcResourceResponse ocResourceResponse)
\r
710 throws OcException {
\r
711 OcPlatform.initCheck();
\r
712 OcPlatform.sendResponse0(ocResourceResponse);
\r
715 private static native void sendResponse0(OcResourceResponse ocResourceResponse)
\r
716 throws OcException;
\r
719 * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
\r
720 * Event listeners are notified asynchronously
\r
722 public interface OnResourceFoundListener {
\r
723 public void onResourceFound(OcResource resource);
\r
727 * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call.
\r
728 * Event listeners are notified asynchronously
\r
730 public interface OnDeviceFoundListener {
\r
731 public void onDeviceFound(OcRepresentation ocRepresentation);
\r
735 * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call.
\r
736 * Event listeners are notified asynchronously
\r
738 public interface OnPresenceListener {
\r
739 public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress);
\r
743 * An EntityHandler can be registered via the OcPlatform.registerResource call.
\r
744 * Event listeners are notified asynchronously
\r
746 public interface EntityHandler {
\r
747 public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);
\r
750 private static void initCheck() {
\r
751 if (!sIsPlatformInitialized) {
\r
752 throw new IllegalStateException("OcPlatform must be configured by making a call to " +
\r
753 "OcPlatform.Configure before any other API calls are permitted");
\r