replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / android / EasySetupCore / src / main / java / org / iotivity / service / easysetup / mediator / samsung / SCDeviceProp.java
1 /**
2  * ***************************************************************
3  *
4  * Copyright 2016 Samsung Electronics All Rights Reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * ****************************************************************
19  */
20
21 package org.iotivity.service.easysetup.mediator.samsung;
22
23 import java.util.ArrayList;
24 import java.util.Arrays;
25
26 import android.util.Log;
27
28 import org.iotivity.service.easysetup.mediator.DeviceProp;
29 import org.iotivity.service.easysetup.mediator.ESConstants;
30 import org.iotivity.service.easysetup.mediator.enums.WIFI_AUTHTYPE;
31 import org.iotivity.service.easysetup.mediator.enums.WIFI_ENCTYPE;
32
33 import org.iotivity.base.OcException;
34 import org.iotivity.base.OcRepresentation;
35
36 /**
37  * This class contains device properties to be delivered to Enrollee
38  */
39 public class SCDeviceProp extends DeviceProp {
40     private static final String TAG = SCDeviceProp.class.getName();
41     final int INVALID_DISCOVERY_CHANNEL = -1;
42
43     /**
44      * Set Channel of Enroller for fast discover
45      */
46     public void setDiscoveryChannel(int discoveryChannel)
47     {
48         try
49         {
50             mRep.setValue(ESConstants.OC_RSRVD_ES_VENDOR_DISCOVERYCHANNEL, discoveryChannel);
51         } catch (OcException e) {
52             Log.e(TAG, "setDiscoveryChannel is failed.");
53         }
54     }
55
56     /**
57      * Get Channel of Enroller for fast discover
58      *
59      * @return int Enroller's DiscoveryChannel
60      */
61     public int getDiscoveryChannel()
62     {
63         try {
64             if(mRep.hasAttribute(ESConstants.OC_RSRVD_ES_VENDOR_DISCOVERYCHANNEL))
65                 return mRep.getValue(ESConstants.OC_RSRVD_ES_VENDOR_DISCOVERYCHANNEL);
66         } catch (OcException e) {
67             Log.e(TAG, "getDiscoveryChannel is failed.");
68         }
69         return INVALID_DISCOVERY_CHANNEL;
70     }
71
72      /**
73      * Set samsung-specific location property to be delivered to Enrollee
74      *
75      * @param locations a set of location information
76      */
77     public void setSCLocation(ArrayList<String> locations)
78     {
79         try
80         {
81             mRep.setValue(ESConstants.SC_RSRVD_ES_VENDOR_LOCATION, locations.toArray(new
82             String[locations.size()]));
83         } catch (OcException e) {
84             Log.e(TAG, "setSCLocation is failed.");
85         }
86     }
87 }