Revert "Change build option - IP only"
[platform/upstream/iotivity.git] / service / easy-setup / sdk / common / escommon.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef ES_COMMON_H_
22 #define ES_COMMON_H_
23
24 #include "ocstack.h"
25 #include "octypes.h"
26
27 // Defines
28 #define OIC_STRING_MAX_VALUE 100
29 #define IPV4_ADDR_SIZE 16
30 #define IP_PORT 55555
31 #define NET_WIFI_SSID_SIZE 16
32 #define NET_WIFI_PWD_SIZE 16
33
34 /**
35  * @brief Mac address length for BT port
36  */
37 #define NET_MACADDR_SIZE 18
38
39 /**
40  * Attributes used to form a proper easysetup conforming JSON message.
41  */
42 #define OC_RSRVD_ES_PS                     "ps"
43 #define OC_RSRVD_ES_TNN                    "tnn"
44 #define OC_RSRVD_ES_CD                     "cd"
45 #define OC_RSRVD_ES_TR                     "tr"
46 #define OC_RSRVD_ES_TNT                    "tnt"
47 #define OC_RSRVD_ES_ANT                    "ant"
48 #define OC_RSRVD_ES_URI_PROV               "/oic/prov"
49 #define OC_RSRVD_ES_URI_NET                "/oic/net"
50
51
52
53 typedef enum
54 {
55
56     ES_ERROR = -1,
57     ES_OK = 0,
58     ES_NETWORKFOUND = 1,
59     ES_NETWORKCONNECTED,
60     ES_NETWORKNOTCONNECTED,
61     ES_RESOURCECREATED = 11,
62     ES_RECVREQOFPROVRES = 21,
63     ES_RECVREQOFNETRES,
64     ES_RECVUPDATEOFPROVRES,
65     ES_RECVTRIGGEROFPROVRES,
66 } ESResult;
67
68 typedef enum
69 {
70     /**
71         * Default state of the device
72         */
73     ES_INIT_STATE,
74
75     /**
76         * Device will move to this state once the on boarding begins
77         */
78     ES_ON_BOARDING_STATE,
79
80     /**
81         * Device will move to this state after successful on-boarding of the device
82         */
83     ES_ON_BOARDED_STATE,
84
85     /**
86         * Device will move to this state once the on boarding is done
87         */
88     ES_PROVISIONING_STATE,
89
90     /**
91         * Easy setup process is successful.
92         */
93     ES_PROVISIONED_STATE,
94
95     /**
96         * This state is arbitrary one, any time device can come into this state
97         * Device will move to this state if the ownership transfer initiated  by the Application
98         */
99     ES_OWNERSHIP_TRANSFERRING_STATE,
100
101     /**
102         * This state is arbitrary one, any time device can come into this state
103         * Device will move to this state if the ownership transfer is completed
104         */
105     ES_OWNERSHIP_TRANSFERRED_STATE,
106
107     /**
108         * This state is arbitrary one, any time device can come into this state
109         * Device will move to this state once the Application factory reset the device
110         */
111     ES_FACTORY_RESET_STATE,
112 }EnrolleeState;
113
114
115
116 /**
117  * Provisioning Device Status
118  */
119 typedef struct {
120     /// Address of remote server
121     OCDevAddr * addr;
122     /// Indicates adaptor type on which the response was received
123     OCConnectivityType connType;
124 } ProvDeviceInfo;
125
126 /**
127  * Provosioning Status
128  */
129 typedef enum {
130     DEVICE_PROVISIONED = 0, DEVICE_NOT_PROVISIONED
131 } ProvStatus;
132
133 /**
134  * Response from queries to remote servers.
135  */
136 typedef struct {
137     // Provisioning Status
138     ProvStatus provStatus;
139     // Provisioning Device Info
140     ProvDeviceInfo provDeviceInfo;
141 } ProvisioningInfo;
142
143 /**
144  * @brief  Network information of the Enroller
145  */
146 typedef union
147 {
148     /**
149      * @brief BT Mac Information
150      */
151     struct
152     {
153         char btMacAddress[NET_MACADDR_SIZE];   /**< BT mac address **/
154     } BT;
155
156     /**
157      * @brief LE MAC Information
158      */
159     struct
160     {
161         char leMacAddress[NET_MACADDR_SIZE];   /**< BLE mac address **/
162     } LE;
163
164     /**
165      * @brief IP Information
166      */
167     struct
168     {
169         char ipAddress[IPV4_ADDR_SIZE]; /**< IP Address of the Enroller**/
170         char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the Enroller**/
171         char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the Enroller**/
172     } WIFI;
173 } EnrolleeInfo_t;
174
175
176 /**
177  * @brief Network Information
178  */
179 typedef struct
180 {
181     EnrolleeInfo_t netAddressInfo;          /**< Enroller Network Info**/
182     OCConnectivityType connType;            /**< Connectivity Type**/
183     bool isSecured;                         /**< Secure connection**/
184 } EnrolleeNWProvInfo_t;
185
186 /**
187  * Client applications implement this callback to consume responses received from Servers.
188  */
189 typedef void (*OCProvisioningStatusCB)(ProvisioningInfo *provInfo);
190
191 #endif