Android OnBoarding code modifications to handle multiple transports
[platform/upstream/iotivity.git] / service / easy-setup / sdk / common / common.h
1 //******************************************************************
2 //
3 // Copyright 2014 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 6298
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 //The following variable determines the interface (wifi, ethernet etc.)
40 //to be used for sending unicast messages. Default set to Ethernet.
41 static OCConnectivityType OC_CONNTYPE = CT_ADAPTER_IP;
42
43 static const char * UNICAST_PROVISIONING_QUERY = "coap://%s:%d/oic/res?rt=oic.prov";
44 static const char * UNICAST_PROV_STATUS_QUERY = "coap://%s:%d%s";
45
46
47 /**
48  * Attributes used to form a proper easysetup conforming JSON message.
49  */
50 #define OC_RSRVD_ES_PS                     "ps"
51 #define OC_RSRVD_ES_TNN                    "tnn"
52 #define OC_RSRVD_ES_CD                     "cd"
53
54
55
56
57 typedef enum
58 {
59     ES_ERROR = -1,
60     ES_OK = 0,
61     ES_NETWORKFOUND = 1,
62     ES_NETWORKCONNECTED,
63     ES_NETWORKNOTCONNECTED,
64     ES_RESOURCECREATED = 11,
65     ES_RECVREQOFPROVRES = 21,
66     ES_RECVREQOFNETRES,
67     ES_RECVUPDATEOFPROVRES,
68     ES_RECVTRIGGEROFPROVRES,
69 } ES_RESULT;
70
71
72 /**
73  * Provisioning Device Status
74  */
75 typedef struct {
76     /// Address of remote server
77     OCDevAddr * addr;
78     /// Indicates adaptor type on which the response was received
79     OCConnectivityType connType;
80 } ProvDeviceInfo;
81
82 /**
83  * Provosioning Status
84  */
85 typedef enum {
86     DEVICE_PROVISIONED = 0, DEVICE_NOT_PROVISIONED
87 } ProvStatus;
88
89 /**
90  * Response from queries to remote servers. Queries are made by calling the @ref OCDoResource API.
91  */
92 typedef struct {
93     // Provisioning Status
94     ProvStatus provStatus;
95     // Provisioning Device Info
96     ProvDeviceInfo provDeviceInfo;
97 } ProvisioningInfo;
98
99 /**
100  * @brief  Network information of the Enroller
101  */
102 typedef union
103 {
104     /**
105      * @brief BT Mac Information
106      */
107     struct
108     {
109         char btMacAddress[NET_MACADDR_SIZE];   /**< BT mac address **/
110     } BT;
111
112     /**
113      * @brief LE MAC Information
114      */
115     struct
116     {
117         char leMacAddress[NET_MACADDR_SIZE];   /**< BLE mac address **/
118     } LE;
119
120     /**
121      * @brief IP Information
122      */
123     struct
124     {
125         char ipAddress[IPV4_ADDR_SIZE]; /**< IP Address of the Enroller**/
126         char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the Enroller**/
127         char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the Enroller**/
128     } WIFI;
129 } EnrolleeInfo_t;
130
131
132 /**
133  * @brief Network Information
134  */
135 typedef struct
136 {
137     EnrolleeInfo_t netAddressInfo;          /**< Enroller Network Info**/
138     OCConnectivityType connType;            /**< Connectivity Type**/
139     bool isSecured;                         /**< Secure connection**/
140 } EnrolleeNWProvInfo_t;
141
142 /**
143  * Client applications implement this callback to consume responses received from Servers.
144  */
145 typedef void (*OCProvisioningStatusCB)(ProvisioningInfo *provInfo);
146
147 #endif