1 //******************************************************************
3 // Copyright 2014 MediaTek All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 package org.iotivity.simpleclient;
23 import android.util.Log;
25 import org.iotivity.base.AbstractFindCallback;
26 import org.iotivity.base.OCResource;
28 public class FoundResource extends AbstractFindCallback {
29 final private static String TAG = "FoundResource";
32 public void Callback(OCResource resource) {
34 if(SimpleClient.curResource != null) {
35 Log.e(TAG, "Found another resource, ignoring");
41 if(resource != null) {
42 Log.i(TAG, "DISCOVERED Resource");
44 resourceURI = resource.uri();
45 Log.i(TAG, "URI of the resource: " + resourceURI);
47 hostAddress = resource.host();
48 Log.i(TAG, "Host address of the resource: " + hostAddress);
50 new SimpleToast().execute("URI of the resource: " + resourceURI + "\nHost address of the resource: " + hostAddress);
52 String[] resourceTypes = resource.getResourceTypes();
53 for(int i=0; i<resourceTypes.length; i++) {
54 Log.i(TAG, "[" + i + "] : " + resourceTypes[i]);
57 String[] resourceInterfaces = resource.getResourceInterfaces();
58 for(int i=0; i<resourceInterfaces.length; i++) {
59 Log.i(TAG, "[" + i + "] : " + resourceInterfaces[i]);
62 if(resourceURI.equals("/a/light")) {
63 SimpleClient.curResource = resource;
64 SimpleClient.getLightRepresentation(resource);
68 Log.e(TAG, "Resource is invalid");