Merge branch 'master' into easysetup & CBOR changes
[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 #define OC_RSRVD_ES_TR                     "tr"
54 #define OC_RSRVD_ES_TNT                    "tnt"
55 #define OC_RSRVD_ES_ANT                    "ant"
56 #define OC_RSRVD_ES_URI_PROV               "/oic/prov"
57 #define OC_RSRVD_ES_URI_NET                "/oic/net"
58
59
60
61 typedef enum
62 {
63     ES_ERROR = -1,
64     ES_OK = 0,
65     ES_NETWORKFOUND = 1,
66     ES_NETWORKCONNECTED,
67     ES_NETWORKNOTCONNECTED,
68     ES_RESOURCECREATED = 11,
69     ES_RECVREQOFPROVRES = 21,
70     ES_RECVREQOFNETRES,
71     ES_RECVUPDATEOFPROVRES,
72     ES_RECVTRIGGEROFPROVRES,
73 } ES_RESULT;
74
75
76 /**
77  * Provisioning Device Status
78  */
79 typedef struct {
80     /// Address of remote server
81     OCDevAddr * addr;
82     /// Indicates adaptor type on which the response was received
83     OCConnectivityType connType;
84 } ProvDeviceInfo;
85
86 /**
87  * Provosioning Status
88  */
89 typedef enum {
90     DEVICE_PROVISIONED = 0, DEVICE_NOT_PROVISIONED
91 } ProvStatus;
92
93 /**
94  * Response from queries to remote servers. Queries are made by calling the @ref OCDoResource API.
95  */
96 typedef struct {
97     // Provisioning Status
98     ProvStatus provStatus;
99     // Provisioning Device Info
100     ProvDeviceInfo provDeviceInfo;
101 } ProvisioningInfo;
102
103 /**
104  * @brief  Network information of the Enroller
105  */
106 typedef union
107 {
108     /**
109      * @brief BT Mac Information
110      */
111     struct
112     {
113         char btMacAddress[NET_MACADDR_SIZE];   /**< BT mac address **/
114     } BT;
115
116     /**
117      * @brief LE MAC Information
118      */
119     struct
120     {
121         char leMacAddress[NET_MACADDR_SIZE];   /**< BLE mac address **/
122     } LE;
123
124     /**
125      * @brief IP Information
126      */
127     struct
128     {
129         char ipAddress[IPV4_ADDR_SIZE]; /**< IP Address of the Enroller**/
130         char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the Enroller**/
131         char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the Enroller**/
132     } WIFI;
133 } EnrolleeInfo_t;
134
135
136 /**
137  * @brief Network Information
138  */
139 typedef struct
140 {
141     EnrolleeInfo_t netAddressInfo;          /**< Enroller Network Info**/
142     OCConnectivityType connType;            /**< Connectivity Type**/
143     bool isSecured;                         /**< Secure connection**/
144 } EnrolleeNWProvInfo_t;
145
146 /**
147  * Client applications implement this callback to consume responses received from Servers.
148  */
149 typedef void (*OCProvisioningStatusCB)(ProvisioningInfo *provInfo);
150
151 #endif