2 * ***************************************************************
4 * Copyright 2016 Samsung Electronics All Rights Reserved.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 * ****************************************************************
24 package org.iotivity.service.easysetup.mediator;
26 import android.util.Log;
28 import org.iotivity.base.OcRepresentation;
31 * This class represents Remote Enrollee device instance. What operations the class provides:
32 * 1) Ownership transfer for enabling secured communication between Mediator and Enrollee
34 * 2) Provision WiFi AP information used for which Enrollee is going to connect to the AP
35 * 3) Provision Device confiruation setting, i.e. language, country, and etc
36 * 4) Provision Cloud information used for which Enrollee is going to register to the cloud
38 public class RemoteEnrollee{
40 public static final String TAG = RemoteEnrollee.class.getName();
41 private long m_nativeHandle;
43 private native void nativeGetStatus(GetStatusCallback callback);
44 private native void nativeGetConfiguration(GetConfigurationCallback callback);
45 private native void nativeProvisionSecurity(SecurityProvisioningCallback callback);
46 private native void nativeProvisionDeviceProperties(OcRepresentation deviceProp,
47 DevicePropProvisioningCallback callback);
48 private native void nativeProvisionCloudProperties(OcRepresentation cloudProp, String cloudID,
49 int CredID, CloudPropProvisioningCallback callback);
51 /* constructor will be invoked from the native layer */
52 private RemoteEnrollee(long nativeHandle){
53 this.m_nativeHandle = nativeHandle;
57 * Get an Enrollee's status which includes a provisioning status and last error code
59 * @param callback will give the requested status
61 * @throws ESException If some errors happen in this function
63 * @see GetStatusCallback
65 public void getStatus(GetStatusCallback callback) throws ESException
69 nativeGetStatus(callback);
72 Log.d(TAG, "GetStatusCallback is null ");
76 * Get an Enrollee's configuration which includes WiFi supported frequency and device name
78 * @param callback will give the requested configuration
80 * @throws ESException If some errors happen in this function
82 * @see GetConfigurationCallback
84 public void getConfiguration(GetConfigurationCallback callback)
89 nativeGetConfiguration(callback);
92 Log.d(TAG, "GetConfigurationCallback is null ");
96 * Do security provisioning such as ownership tranfer to Enrollee.
98 * @param callback will give the result if the security provisioning succeeds or fails for some reasons
100 * @throws ESException If some errors happen in this function
102 * @see SecurityProvisioningCallback
104 public void provisionSecurity(SecurityProvisioningCallback callback)
109 nativeProvisionSecurity(callback);
112 Log.d(TAG, "SecurityProvisioningCallback is null ");
116 * Provision WiFi AP information and device configuration to Enrollee
117 * 1. WiFi AP information includes a SSID, password, auth type, and encryption type.
118 * 2. Device configuration includes a language (IETF language tags) and country (ISO 3166-1 Alpha-2)
120 * @param deviceProp a data structure storing the above information to be delivered
121 * @param callback will give the result if the provisioning succeeds or fails
123 * @throws ESException If some errors happen in this function
126 * @see DevicePropProvisioningCallback
128 public void provisionDeviceProperties(DeviceProp deviceProp,
129 DevicePropProvisioningCallback callback) throws ESException{
132 nativeProvisionDeviceProperties(deviceProp.toOCRepresentation(),
136 Log.d(TAG, "DevicePropProvisioningCallback is null ");
140 * Provision Cloud information to Enrollee, which includes Auth code, auth provider,
141 * Cloud interface server URL, and etc.
142 * In this function, Discovery for the Enrollee will happen again in a given network.
143 * Because, this function is expected to call *AFTER* the Enrollee disconnects its Soft AP
144 * and successfully connects to the certain WiFi AP. In that case, Mediator should discover
145 * the Enrollee with a certain Device ID in the network.
147 * @param cloudProp a data structure storing the above information to be delivered
148 * @param callback will give the result if the provisioning succeeds or fails
150 * @throws ESException If some errors happen in this function
153 * @see CloudPropProvisioningCallback
155 public void provisionCloudProperties(CloudProp cloudProp,
156 CloudPropProvisioningCallback callback) throws ESException{
159 nativeProvisionCloudProperties(cloudProp.toOCRepresentation(),
160 cloudProp.getCloudID(),
161 cloudProp.getCredID(),
165 Log.d(TAG, "CloudPropProvisioningCallback is null ");