2 * Network Configuration Module
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 * This file implements wifi direct state functions.
23 * @file wifi-direct-state.c
24 * @author Gibyoung Kim (lastkgb.kim@samsung.com)
30 #include <wifi-direct.h>
32 #include "wifi-direct-ipc.h"
33 #include "wifi-direct-manager.h"
34 #include "wifi-direct-state.h"
35 #include "wifi-direct-util.h"
36 #include "wifi-direct-log.h"
39 static char *_wfd_state_string(int state)
42 case WIFI_DIRECT_STATE_DEACTIVATED:
44 case WIFI_DIRECT_STATE_DEACTIVATING:
45 return "DEACTIVATING";
46 case WIFI_DIRECT_STATE_ACTIVATING:
48 case WIFI_DIRECT_STATE_ACTIVATED:
50 case WIFI_DIRECT_STATE_DISCOVERING:
52 case WIFI_DIRECT_STATE_CONNECTING:
54 case WIFI_DIRECT_STATE_DISCONNECTING:
55 return "DISCONNECTING";
56 case WIFI_DIRECT_STATE_CONNECTED:
58 case WIFI_DIRECT_STATE_GROUP_OWNER:
61 return "Unknown State";
65 int wfd_state_set(wfd_manager_s *manager, int state)
67 __WDS_LOG_FUNC_ENTER__;
69 if (!manager || state < WIFI_DIRECT_STATE_DEACTIVATED || state > WIFI_DIRECT_STATE_GROUP_OWNER) {
70 WDS_LOGE("Invalid parameter");
74 WDS_LOGI("wifi-direct-manager state set [%s] -> [%s]",
75 _wfd_state_string(manager->state), _wfd_state_string(state));
77 manager->state = state;
79 __WDS_LOG_FUNC_EXIT__;
83 int wfd_state_get(wfd_manager_s *manager, int *state)
85 __WDS_LOG_FUNC_ENTER__;
87 if (!manager || !state) {
88 WDS_LOGE("Invalid parameter");
92 *state = manager->state;
93 WDS_LOGD("wifi-direct-manager state is %d", *state);
95 __WDS_LOG_FUNC_EXIT__;