blob: b9c981c9199dbe2b5c8ac09faa8eb5dc743c1d8f [file] [log] [blame]
San Mehatdc266072009-05-06 11:16:52 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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#ifndef _WIFI_CONTROLLER_H
17#define _WIFI_CONTROLLER_H
18
19#include <sys/types.h>
20
21#include "Controller.h"
22
23class NetInterface;
24class Supplicant;
San Mehat1441e762009-05-07 11:37:10 -070025class WifiScanner;
26
27#include "ScanResult.h"
San Mehat82a21162009-05-12 17:26:28 -070028#include "WifiNetwork.h"
San Mehatdc266072009-05-06 11:16:52 -070029
30class WifiController : public Controller {
31public:
32 static const uint32_t SCAN_ENABLE_MASK = 0x01;
33 static const uint32_t SCAN_ACTIVE_MASK = 0x02;
34 static const uint32_t SCAN_REPEAT_MASK = 0x04;
35
36 static const uint32_t SCANMODE_NONE = 0;
37 static const uint32_t SCANMODE_PASSIVE_ONESHOT = SCAN_ENABLE_MASK;
38 static const uint32_t SCANMODE_PASSIVE_CONTINUOUS = SCAN_ENABLE_MASK | SCAN_REPEAT_MASK;
39 static const uint32_t SCANMODE_ACTIVE_ONESHOT = SCAN_ENABLE_MASK | SCAN_ACTIVE_MASK;
40 static const uint32_t SCANMODE_ACTIVE_CONTINUOUS = SCAN_ENABLE_MASK | SCAN_ACTIVE_MASK | SCAN_REPEAT_MASK;
41
42private:
43 Supplicant *mSupplicant;
44 char mModulePath[255];
45 char mModuleName[64];
46 char mModuleArgs[255];
San Mehat1441e762009-05-07 11:37:10 -070047 uint32_t mCurrentScanMode;
48 WifiScanner *mScanner;
San Mehatdc266072009-05-06 11:16:52 -070049
50public:
51 WifiController(char *modpath, char *modname, char *modargs);
52 virtual ~WifiController() {}
53
54 int start();
55 int stop();
56
57 int enable();
58 int disable();
59
San Mehat82a21162009-05-12 17:26:28 -070060 int addNetwork();
61 int removeNetwork(int networkId);
62 WifiNetworkCollection *createNetworkList();
San Mehat1441e762009-05-07 11:37:10 -070063
San Mehat82a21162009-05-12 17:26:28 -070064 int getScanMode() { return mCurrentScanMode; }
65 int setScanMode(uint32_t mode);
66 ScanResultCollection *createScanResults();
San Mehatdc266072009-05-06 11:16:52 -070067
68 char *getModulePath() { return mModulePath; }
69 char *getModuleName() { return mModuleName; }
70 char *getModuleArgs() { return mModuleArgs; }
71
72 Supplicant *getSupplicant() { return mSupplicant; }
73
San Mehatdc266072009-05-06 11:16:52 -070074protected:
75 virtual int powerUp() = 0;
76 virtual int powerDown() = 0;
77 virtual int loadFirmware();
San Mehat1441e762009-05-07 11:37:10 -070078
79 virtual bool isFirmwareLoaded() = 0;
San Mehatdc266072009-05-06 11:16:52 -070080 virtual bool isPoweredUp() = 0;
81
San Mehat69772dc2009-05-10 09:27:07 -070082 void sendStatusBroadcast(char *msg);
San Mehatdc266072009-05-06 11:16:52 -070083};
84
85#endif