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.if.baseline";
\r
52 * Used in discovering (GET) links to other resources of a collection
\r
54 public static final String LINK_INTERFACE = "oic.if.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.if.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
74 private static volatile boolean sIsPlatformInitialized = false;
\r
76 private OcPlatform() {
\r
80 * API for setting the configuration of the OcPlatform.
\r
81 * Note: Any calls made to this AFTER the first call to OcPlatform.Configure will have no affect
\r
83 * @param platformConfig platform configuration
\r
85 public synchronized static void Configure(PlatformConfig platformConfig) {
\r
86 if (!sIsPlatformInitialized) {
\r
87 CaInterface.initialize(platformConfig.getContext());
\r
89 OcPlatform.configure(
\r
90 platformConfig.getServiceType().getValue(),
\r
91 platformConfig.getModeType().getValue(),
\r
92 platformConfig.getIpAddress(),
\r
93 platformConfig.getPort(),
\r
94 platformConfig.getQualityOfService().getValue()
\r
97 sIsPlatformInitialized = true;
\r
101 private static native void configure(int serviceType,
\r
105 int qualityOfService);
\r
108 * API for notifying base that resource's attributes have changed.
\r
110 * @param ocResourceHandle resource handle of the resource
\r
111 * @throws OcException
\r
113 public static void notifyAllObservers(
\r
114 OcResourceHandle ocResourceHandle) throws OcException {
\r
115 OcPlatform.initCheck();
\r
116 OcPlatform.notifyAllObservers0(ocResourceHandle);
\r
119 private static native void notifyAllObservers0(
\r
120 OcResourceHandle ocResourceHandle) throws OcException;
\r
123 * API for notifying base that resource's attributes have changed.
\r
125 * @param ocResourceHandle resource handle of the resource
\r
126 * @param qualityOfService the quality of communication
\r
127 * @throws OcException
\r
129 public static void notifyAllObservers(
\r
130 OcResourceHandle ocResourceHandle,
\r
131 QualityOfService qualityOfService) throws OcException {
\r
132 OcPlatform.initCheck();
\r
133 OcPlatform.notifyAllObservers1(ocResourceHandle, qualityOfService.getValue());
\r
136 private static native void notifyAllObservers1(
\r
137 OcResourceHandle ocResourceHandle,
\r
138 int qualityOfService) throws OcException;
\r
141 * API for notifying only specific clients that resource's attributes have changed.
\r
143 * @param ocResourceHandle resource handle of the resource
\r
144 * @param ocObservationIdList These set of ids are ones which which will be notified upon
\r
146 * @param ocResourceResponse OcResourceResponse object used by app to fill the response for
\r
147 * this resource change
\r
148 * @throws OcException
\r
150 public static void notifyListOfObservers(
\r
151 OcResourceHandle ocResourceHandle,
\r
152 List<Byte> ocObservationIdList,
\r
153 OcResourceResponse ocResourceResponse) throws OcException {
\r
154 OcPlatform.initCheck();
\r
156 byte[] idArr = new byte[ocObservationIdList.size()];
\r
157 Iterator<Byte> it = ocObservationIdList.iterator();
\r
159 while (it.hasNext()) {
\r
160 idArr[i++] = (byte) it.next();
\r
163 OcPlatform.notifyListOfObservers2(
\r
166 ocResourceResponse);
\r
169 private static native void notifyListOfObservers2(
\r
170 OcResourceHandle ocResourceHandle,
\r
171 byte[] ocObservationIdArray,
\r
172 OcResourceResponse ocResourceResponse) throws OcException;
\r
175 * API for notifying only specific clients that resource's attributes have changed.
\r
177 * @param ocResourceHandle resource handle of the resource
\r
178 * @param ocObservationIdList These set of ids are ones which which will be notified upon
\r
180 * @param ocResourceResponse OcResourceResponse object used by app to fill the response for
\r
181 * this resource change
\r
182 * @param qualityOfService the quality of communication
\r
183 * @throws OcException
\r
185 public static void notifyListOfObservers(
\r
186 OcResourceHandle ocResourceHandle,
\r
187 List<Byte> ocObservationIdList,
\r
188 OcResourceResponse ocResourceResponse,
\r
189 QualityOfService qualityOfService) throws OcException {
\r
190 OcPlatform.initCheck();
\r
192 byte[] idArr = new byte[ocObservationIdList.size()];
\r
193 Iterator<Byte> it = ocObservationIdList.iterator();
\r
195 while (it.hasNext()) {
\r
196 idArr[i++] = (byte) it.next();
\r
199 OcPlatform.notifyListOfObservers3(
\r
202 ocResourceResponse,
\r
203 qualityOfService.getValue()
\r
207 private static native void notifyListOfObservers3(
\r
208 OcResourceHandle ocResourceHandle,
\r
209 byte[] ocObservationIdArray,
\r
210 OcResourceResponse ocResourceResponse,
\r
211 int qualityOfService) throws OcException;
\r
214 * API for Service and Resource Discovery. NOTE: This API applies to client side only
\r
216 * @param host Host IP Address of a service to direct resource discovery query.
\r
217 * If empty, performs multicast resource discovery query
\r
218 * @param resourceUri name of the resource. If null or empty, performs search for all
\r
220 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
222 * @param onResourceFoundListener Handles events, success states and failure states.
\r
223 * @throws OcException
\r
225 public static void findResource(
\r
227 String resourceUri,
\r
228 OcConnectivityType connectivityType,
\r
229 OnResourceFoundListener onResourceFoundListener) throws OcException {
\r
230 OcPlatform.initCheck();
\r
231 OcPlatform.findResource0(
\r
234 connectivityType.getValue(),
\r
235 onResourceFoundListener
\r
239 private static native void findResource0(
\r
241 String resourceUri,
\r
242 int connectivityType,
\r
243 OnResourceFoundListener onResourceFoundListener) throws OcException;
\r
246 * API for Service and Resource Discovery. NOTE: This API applies to client side only
\r
248 * @param host Host IP Address of a service to direct resource discovery query.
\r
249 * If empty, performs multicast resource discovery query
\r
250 * @param resourceUri name of the resource. If null or empty, performs search for all
\r
252 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
254 * @param onResourceFoundListener Handles events, success states and failure states.
\r
255 * @param qualityOfService the quality of communication
\r
256 * @throws OcException
\r
258 public static void findResource(
\r
260 String resourceUri,
\r
261 OcConnectivityType connectivityType,
\r
262 OnResourceFoundListener onResourceFoundListener,
\r
263 QualityOfService qualityOfService) throws OcException {
\r
264 OcPlatform.initCheck();
\r
265 OcPlatform.findResource1(host,
\r
267 connectivityType.getValue(),
\r
268 onResourceFoundListener,
\r
269 qualityOfService.getValue()
\r
273 private static native void findResource1(
\r
275 String resourceUri,
\r
276 int connectivityType,
\r
277 OnResourceFoundListener onResourceFoundListener,
\r
278 int qualityOfService) throws OcException;
\r
281 * API for Device Discovery
\r
283 * @param host Host IP Address. If null or empty, Multicast is performed.
\r
284 * @param deviceUri Uri containing address to the virtual device
\r
285 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
287 * @param onDeviceFoundListener Handles events, success states and failure states.
\r
288 * @throws OcException
\r
290 public static void getDeviceInfo(
\r
293 OcConnectivityType connectivityType,
\r
294 OnDeviceFoundListener onDeviceFoundListener) throws OcException {
\r
295 OcPlatform.initCheck();
\r
296 OcPlatform.getDeviceInfo0(
\r
299 connectivityType.getValue(),
\r
300 onDeviceFoundListener
\r
304 private static native void getDeviceInfo0(
\r
307 int connectivityType,
\r
308 OnDeviceFoundListener onDeviceFoundListener) throws OcException;
\r
311 * API for Device Discovery
\r
313 * @param host Host IP Address. If null or empty, Multicast is performed.
\r
314 * @param deviceUri Uri containing address to the virtual device
\r
315 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
317 * @param onDeviceFoundListener Handles events, success states and failure states.
\r
318 * @param qualityOfService the quality of communication
\r
319 * @throws OcException
\r
321 public static void getDeviceInfo(
\r
324 OcConnectivityType connectivityType,
\r
325 OnDeviceFoundListener onDeviceFoundListener,
\r
326 QualityOfService qualityOfService) throws OcException {
\r
327 OcPlatform.initCheck();
\r
328 OcPlatform.getDeviceInfo1(
\r
331 connectivityType.getValue(),
\r
332 onDeviceFoundListener,
\r
333 qualityOfService.getValue()
\r
337 private static native void getDeviceInfo1(
\r
340 int connectivityType,
\r
341 OnDeviceFoundListener onDeviceFoundListener,
\r
342 int qualityOfService) throws OcException;
\r
345 * This API registers a resource with the server NOTE: This API applies to server side only.
\r
347 * @param ocResource The instance of OcResource with all data filled
\r
348 * @return resource handle
\r
349 * @throws OcException
\r
351 public static OcResourceHandle registerResource(
\r
352 OcResource ocResource) throws OcException {
\r
353 OcPlatform.initCheck();
\r
354 return OcPlatform.registerResource0(ocResource);
\r
357 private static native OcResourceHandle registerResource0(
\r
358 OcResource ocResource) throws OcException;
\r
361 * This API registers a resource with the server NOTE: This API applies to server side only.
\r
363 * @param resourceUri The URI of the resource. Example: "a/light"
\r
364 * @param resourceTypeName The resource type. Example: "light"
\r
365 * @param resourceInterface The resource interface (whether it is collection etc).
\r
366 * @param entityHandler entity handler.
\r
367 * @param resourcePropertySet indicates the property of the resource
\r
368 * @return resource handle
\r
369 * @throws OcException
\r
371 public static OcResourceHandle registerResource(
\r
372 String resourceUri,
\r
373 String resourceTypeName,
\r
374 String resourceInterface,
\r
375 EntityHandler entityHandler,
\r
376 EnumSet<ResourceProperty> resourcePropertySet) throws OcException {
\r
377 OcPlatform.initCheck();
\r
379 int resProperty = 0;
\r
381 for (ResourceProperty prop : ResourceProperty.values()) {
\r
382 if (resourcePropertySet.contains(prop))
\r
383 resProperty |= prop.getValue();
\r
386 return OcPlatform.registerResource1(resourceUri,
\r
393 private static native OcResourceHandle registerResource1(
\r
394 String resourceUri,
\r
395 String resourceTypeName,
\r
396 String resourceInterface,
\r
397 EntityHandler entityHandler,
\r
398 int resourceProperty) throws OcException;
\r
401 * Register Device Info
\r
403 * @param ocDeviceInfo object containing all the device specific information
\r
404 * @throws OcException
\r
406 public static void registerDeviceInfo(
\r
407 OcDeviceInfo ocDeviceInfo) throws OcException {
\r
408 OcPlatform.initCheck();
\r
409 OcPlatform.registerDeviceInfo0(
\r
410 ocDeviceInfo.getDeviceName()
\r
414 private static native void registerDeviceInfo0(
\r
416 ) throws OcException;
\r
419 * This API unregisters a resource with the server NOTE: This API applies to server side only.
\r
421 * @param ocResourceHandle This is the resource handle which we which to unregister from the
\r
423 * @throws OcException
\r
425 public static void unregisterResource(
\r
426 OcResourceHandle ocResourceHandle) throws OcException {
\r
427 OcPlatform.initCheck();
\r
428 OcPlatform.unregisterResource0(ocResourceHandle);
\r
431 private static native void unregisterResource0(
\r
432 OcResourceHandle ocResourceHandle) throws OcException;
\r
436 * Add a resource to a collection resource
\r
438 * @param ocResourceCollectionHandle handle to the collection resource
\r
439 * @param ocResourceHandle handle to resource to be added to the collection resource
\r
440 * @throws OcException
\r
442 public static void bindResource(
\r
443 OcResourceHandle ocResourceCollectionHandle,
\r
444 OcResourceHandle ocResourceHandle) throws OcException {
\r
445 OcPlatform.initCheck();
\r
446 OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle);
\r
449 private static native void bindResource0(
\r
450 OcResourceHandle ocResourceCollectionHandle,
\r
451 OcResourceHandle ocResourceHandle) throws OcException;
\r
454 * Add multiple resources to a collection resource.
\r
456 * @param ocResourceCollectionHandle handle to the collection resource
\r
457 * @param ocResourceHandleList reference to list of resource handles to be added to the
\r
458 * collection resource
\r
459 * @throws OcException
\r
461 public static void bindResources(
\r
462 OcResourceHandle ocResourceCollectionHandle,
\r
463 List<OcResourceHandle> ocResourceHandleList) throws OcException {
\r
464 OcPlatform.initCheck();
\r
465 OcPlatform.bindResources0(
\r
466 ocResourceCollectionHandle,
\r
467 ocResourceHandleList.toArray(
\r
468 new OcResourceHandle[ocResourceHandleList.size()])
\r
472 private static native void bindResources0(
\r
473 OcResourceHandle ocResourceCollectionHandle,
\r
474 OcResourceHandle[] ocResourceHandleArray) throws OcException;
\r
477 * Unbind a resource from a collection resource.
\r
479 * @param ocResourceCollectionHandle handle to the collection resource
\r
480 * @param ocResourceHandle resource handle to be unbound from the collection resource
\r
481 * @throws OcException
\r
483 public static void unbindResource(
\r
484 OcResourceHandle ocResourceCollectionHandle,
\r
485 OcResourceHandle ocResourceHandle) throws OcException {
\r
486 OcPlatform.initCheck();
\r
487 OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle);
\r
490 private static native void unbindResource0(
\r
491 OcResourceHandle ocResourceCollectionHandle,
\r
492 OcResourceHandle ocResourceHandle) throws OcException;
\r
495 * Unbind resources from a collection resource.
\r
497 * @param ocResourceCollectionHandle Handle to the collection resource
\r
498 * @param ocResourceHandleList List of resource handles to be unbound from the collection
\r
500 * @throws OcException
\r
502 public static void unbindResources(
\r
503 OcResourceHandle ocResourceCollectionHandle,
\r
504 List<OcResourceHandle> ocResourceHandleList) throws OcException {
\r
505 OcPlatform.initCheck();
\r
506 OcPlatform.unbindResources0(
\r
507 ocResourceCollectionHandle,
\r
508 ocResourceHandleList.toArray(
\r
509 new OcResourceHandle[ocResourceHandleList.size()])
\r
513 private static native void unbindResources0(
\r
514 OcResourceHandle ocResourceCollectionHandle,
\r
515 OcResourceHandle[] ocResourceHandleArray) throws OcException;
\r
518 * Binds a type to a particular resource
\r
520 * @param ocResourceHandle handle to the resource
\r
521 * @param resourceTypeName new typename to bind to the resource
\r
522 * @throws OcException
\r
524 public static void bindTypeToResource(
\r
525 OcResourceHandle ocResourceHandle,
\r
526 String resourceTypeName) throws OcException {
\r
527 OcPlatform.initCheck();
\r
528 OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName);
\r
531 private static native void bindTypeToResource0(
\r
532 OcResourceHandle ocResourceHandle,
\r
533 String resourceTypeName) throws OcException;
\r
536 * Binds an interface to a particular resource
\r
538 * @param ocResourceHandle handle to the resource
\r
539 * @param resourceInterfaceName new interface to bind to the resource
\r
540 * @throws OcException
\r
542 public static void bindInterfaceToResource(
\r
543 OcResourceHandle ocResourceHandle,
\r
544 String resourceInterfaceName) throws OcException {
\r
545 OcPlatform.initCheck();
\r
546 OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName);
\r
549 private static native void bindInterfaceToResource0(
\r
550 OcResourceHandle ocResourceHandle,
\r
551 String resourceInterfaceName) throws OcException;
\r
554 * Start Presence announcements.
\r
556 * @param ttl time to live in seconds
\r
557 * @throws OcException
\r
559 public static void startPresence(int ttl) throws OcException {
\r
560 OcPlatform.initCheck();
\r
561 OcPlatform.startPresence0(ttl);
\r
564 private static native void startPresence0(int ttl) throws OcException;
\r
567 * Stop Presence announcements.
\r
569 * @throws OcException
\r
571 public static void stopPresence() throws OcException {
\r
572 OcPlatform.initCheck();
\r
573 OcPlatform.stopPresence0();
\r
576 private static native void stopPresence0() throws OcException;
\r
579 * Subscribes to a server's presence change events. By making this subscription, every time a
\r
580 * server adds/removes/alters a resource, starts or is intentionally stopped
\r
582 * @param host The IP address/addressable name of the server to subscribe to
\r
583 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
585 * @param onPresenceListener listener that will receive notifications/subscription events
\r
586 * @return a handle object that can be used to identify this subscription request. It can be
\r
587 * used to unsubscribe from these events in the future
\r
588 * @throws OcException
\r
590 public static OcPresenceHandle subscribePresence(
\r
592 OcConnectivityType connectivityType,
\r
593 OnPresenceListener onPresenceListener) throws OcException {
\r
594 OcPlatform.initCheck();
\r
595 return OcPlatform.subscribePresence0(
\r
597 connectivityType.getValue(),
\r
602 private static native OcPresenceHandle subscribePresence0(
\r
604 int connectivityType,
\r
605 OnPresenceListener onPresenceListener) throws OcException;
\r
608 * Subscribes to a server's presence change events. By making this subscription, every time a
\r
609 * server adds/removes/alters a resource, starts or is intentionally stopped
\r
611 * @param host The IP address/addressable name of the server to subscribe to
\r
612 * @param resourceType a resource type specified as a filter for subscription events.
\r
613 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
615 * @param onPresenceListener listener that will receive notifications/subscription events
\r
616 * @return a handle object that can be used to identify this subscription request. It can be
\r
617 * used to unsubscribe from these events in the future
\r
618 * @throws OcException
\r
620 public static OcPresenceHandle subscribePresence(
\r
622 String resourceType,
\r
623 OcConnectivityType connectivityType,
\r
624 OnPresenceListener onPresenceListener) throws OcException {
\r
625 OcPlatform.initCheck();
\r
626 return OcPlatform.subscribePresence1(
\r
629 connectivityType.getValue(),
\r
630 onPresenceListener);
\r
633 private static native OcPresenceHandle subscribePresence1(
\r
635 String resourceType,
\r
636 int connectivityType,
\r
637 OnPresenceListener onPresenceListener) throws OcException;
\r
640 * Unsubscribes from a previously subscribed server's presence events. Note that you may for
\r
641 * a short time still receive events from the server since it may take time for the
\r
642 * unsubscribe to take effect.
\r
644 * @param ocPresenceHandle the handle object provided by the subscribePresence call that
\r
645 * identifies this subscription
\r
646 * @throws OcException
\r
648 public static void unsubscribePresence(
\r
649 OcPresenceHandle ocPresenceHandle) throws OcException {
\r
650 OcPlatform.initCheck();
\r
651 OcPlatform.unsubscribePresence0(ocPresenceHandle);
\r
654 private static native void unsubscribePresence0(
\r
655 OcPresenceHandle ocPresenceHandle) throws OcException;
\r
658 * Creates a resource proxy object so that get/put/observe functionality can be used without
\r
659 * discovering the object in advance. Note that the consumer of this method needs to provide
\r
660 * all of the details required to correctly contact and observe the object. If the consumer
\r
661 * lacks any of this information, they should discover the resource object normally.
\r
662 * Additionally, you can only create this object if OcPlatform was initialized to be a Client
\r
663 * or Client/Server.
\r
665 * @param host a string containing a resolvable host address of the server holding
\r
667 * @param uri the rest of the resource's URI that will permit messages to be
\r
669 * Example: /a/light
\r
670 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
672 * @param isObservable a boolean containing whether the resource supports observation
\r
673 * @param resourceTypeList a collection of resource types implemented by the resource
\r
674 * @param interfaceList a collection of interfaces that the resource supports/implements
\r
675 * @return new resource object
\r
676 * @throws OcException
\r
678 public static OcResource constructResourceObject(
\r
681 OcConnectivityType connectivityType,
\r
682 boolean isObservable,
\r
683 List<String> resourceTypeList,
\r
684 List<String> interfaceList) throws OcException {
\r
685 OcPlatform.initCheck();
\r
686 return OcPlatform.constructResourceObject0(
\r
689 connectivityType.getValue(),
\r
691 resourceTypeList.toArray(new String[resourceTypeList.size()]),
\r
692 interfaceList.toArray(new String[interfaceList.size()])
\r
696 private static native OcResource constructResourceObject0(
\r
699 int connectivityType,
\r
700 boolean isObservable,
\r
701 String[] resourceTypes,
\r
702 String[] interfaces) throws OcException;
\r
705 * Allows application entity handler to send response to an incoming request.
\r
707 * @param ocResourceResponse resource response
\r
708 * @throws OcException
\r
710 public static void sendResponse(OcResourceResponse ocResourceResponse)
\r
711 throws OcException {
\r
712 OcPlatform.initCheck();
\r
713 OcPlatform.sendResponse0(ocResourceResponse);
\r
716 private static native void sendResponse0(OcResourceResponse ocResourceResponse)
\r
717 throws OcException;
\r
720 * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
\r
721 * Event listeners are notified asynchronously
\r
723 public interface OnResourceFoundListener {
\r
724 public void onResourceFound(OcResource resource);
\r
728 * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call.
\r
729 * Event listeners are notified asynchronously
\r
731 public interface OnDeviceFoundListener {
\r
732 public void onDeviceFound(OcRepresentation ocRepresentation);
\r
736 * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call.
\r
737 * Event listeners are notified asynchronously
\r
739 public interface OnPresenceListener {
\r
740 public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress);
\r
744 * An EntityHandler can be registered via the OcPlatform.registerResource call.
\r
745 * Event listeners are notified asynchronously
\r
747 public interface EntityHandler {
\r
748 public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);
\r
751 private static void initCheck() {
\r
752 if (!sIsPlatformInitialized) {
\r
753 throw new IllegalStateException("OcPlatform must be configured by making a call to " +
\r
754 "OcPlatform.Configure before any other API calls are permitted");
\r