1 //******************************************************************
3 // Copyright 2015 Samsung Electronics 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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 #ifndef EASYSETUP_ENROLLEE_H__
23 #define EASYSETUP_ENROLLEE_H__
26 #include "ESEnrolleeCommon.h"
31 * This file contains Enrollee APIs
39 * A function pointer for registering a user-defined function to set user-specific properties to a
40 * response going back to a client.
41 * @param payload Represents a response. You can set a specific value with specific property key
42 * to the payload. If a client receives the response and know the property key, then it can
44 * @param resourceType Used to distinguish which resource the received property belongs to.
46 typedef void (*ESWriteUserdataCb)(OCRepPayload* payload, char* resourceType);
49 * A function pointer for registering a user-defined function to parse user-specific properties from
50 * received POST request.
51 * @param payload Represents a received POST request. If you know user-specific property key,
52 * then you can extract a corresponding value if it exists.
53 * @param resourceType Used to distinguish which resource the received property belongs to
54 * @param userdata User-specific data you want to deliver to desired users, i.e. application.
55 * The user should know a data structure of passed userdata.
57 typedef void (*ESReadUserdataCb)(OCRepPayload* payload, char* resourceType, void** userdata);
60 * This function Initializes the EasySetup. This API must be called prior to invoking any other API
62 * @param isSecured True if the Enrollee is operating in secured mode.
63 * @param resourceMask Provisining Resource Type which application wants to make.
64 * ES_WIFICONF_RESOURCE = 0x01,
65 * ES_COAPCLOUDCONF_RESOURCE = 0x02,
66 * ES_DEVCONF_RESOURCE = 0x04
67 * @param callbacks ESProvisioningCallbacks for updating Easy setup Resources' data to the application
68 * @return ::ES_OK on success, some other value upon failure.
70 ESResult ESInitEnrollee(bool isSecured, ESResourceMask resourceMask, ESProvisioningCallbacks callbacks);
74 * This function Sets Device Information.
76 * @param deviceProperty Contains device information composed of WiFiConf Structure & DevConf Structure
77 * @return ::ES_OK on success, some other value upon failure.
79 * @see ESDeviceProperty
81 ESResult ESSetDeviceProperty(ESDeviceProperty *deviceProperty);
85 * This function Sets Enrollee's State.
87 * @param esState Contains current enrollee's state.
88 * @return ::ES_OK on success, some other value upon failure.
90 * @see ESEnrolleeState
92 ESResult ESSetState(ESEnrolleeState esState);
96 * This function Sets Enrollee's Error Code.
98 * @param esErrCode Contains enrollee's error code.
99 * @return ::ES_OK on success, some other value upon failure.
103 ESResult ESSetErrorCode(ESErrorCode esErrCode);
106 * This function performs termination of all Easy setup resources.
108 * @return ::ES_OK on success, some other value upon failure.
110 ESResult ESTerminateEnrollee();
113 * This function is to set two function pointer to handle user-specific properties in in-comming
114 * POST request and to out-going response for GET or POST request.
115 * If you register certain functions with this API, you have to handle OCRepPayload structure to
116 * set and get properties you want.
118 * @param readCb a callback for parsing properties from POST request
119 * @param writeCb a callback for putting properties to a response to be sent
121 * @return ::ES_OK on success, some other value upon failure.
123 * @see ESReadUserdataCb
124 * @see ESWriteUserdataCb
126 ESResult ESSetCallbackForUserdata(ESReadUserdataCb readCb, ESWriteUserdataCb writeCb);
130 #endif // __cplusplus
133 #endif /* EASYSETUP_ENROLLEE_H__ */