Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / service / easy-setup / sdk / enrollee / arduino / wifi / networkHandler.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 /**
22  * @file
23  *
24  * This file contains IP network handling functionality for Enrollee device
25  */
26
27 #ifndef ES_NETWORK_HANDLER_H_
28 #define ES_NETWORK_HANDLER_H_
29
30 // Do not remove the include below
31 #include "Arduino.h"
32
33 // Arduino WiFi Shield includes
34 #include <SPI.h>
35 #include <WiFi.h>
36 #include <WiFiUdp.h>
37
38 #include <string.h>
39 #include "logger.h"
40 #include "escommon.h"
41
42 #define MAXSSIDLEN 33
43 #define MAXNETCREDLEN 20
44 #define MAXNUMTYPE 5
45 #define MAXADDRLEN 15
46
47 /*
48  * Callback function for updating the Network status to the subscribers
49  *
50  * @param esResult ESResult provides the current state of the network connection status
51  */
52 typedef void (*NetworkEventCallback)(ESResult esResult);
53
54 typedef struct
55 {
56     OCConnectivityType type;
57     // for WiFI
58     IPAddress ipaddr;
59     char ssid[MAXSSIDLEN];
60     // for BT, BLE
61     byte mac[6];
62 } NetworkInfo;
63
64 ESResult ConnectToWiFiNetwork(const char *ssid, const char *pass, NetworkEventCallback);
65 ESResult getCurrentNetworkInfo(OCConnectivityType targetType, NetworkInfo *info);
66
67 #endif