replace value to macro for HTTP OK
[apps/native/tizen-things-daemon.git] / daemon / src / ttd-wifimgr.c
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <wifi-manager.h>
18
19 #include "ttd-log.h"
20 #include "ttd-wifimgr.h"
21
22 wifi_manager_h wifi_h;
23
24 int ttd_wifimgr_init(void)
25 {
26         if (wifi_manager_initialize(&wifi_h) != WIFI_MANAGER_ERROR_NONE) {
27                 _E("Failed to initialize wifi manager");
28                 return -1;
29         }
30
31         return 0;
32 }
33
34 void ttd_wifimgr_fini(void)
35 {
36         if (wifi_h) {
37                 wifi_manager_deinitialize(wifi_h);
38                 wifi_h = 0;
39         }
40 }
41
42 int ttd_wifimgr_get_mac_address(char **mac_addr)
43 {
44         char *addr = NULL;
45
46         if (!wifi_h) {
47                 if (ttd_wifimgr_init() < 0)
48                         return -1;
49         }
50
51         if (wifi_manager_get_mac_address(wifi_h, &addr) != WIFI_MANAGER_ERROR_NONE) {
52                 _E("Failed to get MAC Address from WIFI manager");
53                 return -1;
54         }
55
56         *mac_addr = addr;
57
58         return 0;
59 }