blob: 38aea816bf73d6a011994e266234f580914c03bf [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 Mehatdc266072009-05-06 11:16:52 -070028
29class WifiController : public Controller {
30public:
31 static const uint32_t SCAN_ENABLE_MASK = 0x01;
32 static const uint32_t SCAN_ACTIVE_MASK = 0x02;
33 static const uint32_t SCAN_REPEAT_MASK = 0x04;
34
35 static const uint32_t SCANMODE_NONE = 0;
36 static const uint32_t SCANMODE_PASSIVE_ONESHOT = SCAN_ENABLE_MASK;
37 static const uint32_t SCANMODE_PASSIVE_CONTINUOUS = SCAN_ENABLE_MASK | SCAN_REPEAT_MASK;
38 static const uint32_t SCANMODE_ACTIVE_ONESHOT = SCAN_ENABLE_MASK | SCAN_ACTIVE_MASK;
39 static const uint32_t SCANMODE_ACTIVE_CONTINUOUS = SCAN_ENABLE_MASK | SCAN_ACTIVE_MASK | SCAN_REPEAT_MASK;
40
41private:
42 Supplicant *mSupplicant;
43 char mModulePath[255];
44 char mModuleName[64];
45 char mModuleArgs[255];
San Mehat1441e762009-05-07 11:37:10 -070046 uint32_t mCurrentScanMode;
47 WifiScanner *mScanner;
San Mehatdc266072009-05-06 11:16:52 -070048
49public:
50 WifiController(char *modpath, char *modname, char *modargs);
51 virtual ~WifiController() {}
52
53 int start();
54 int stop();
55
56 int enable();
57 int disable();
58
San Mehat1441e762009-05-07 11:37:10 -070059 ScanResultCollection *createScanResults();
60
San Mehatdc266072009-05-06 11:16:52 -070061 int getType();
62
63 char *getModulePath() { return mModulePath; }
64 char *getModuleName() { return mModuleName; }
65 char *getModuleArgs() { return mModuleArgs; }
66
67 Supplicant *getSupplicant() { return mSupplicant; }
68
69 int getScanMode() { return mCurrentScanMode; }
San Mehat1441e762009-05-07 11:37:10 -070070 int setScanMode(uint32_t mode);
San Mehatdc266072009-05-06 11:16:52 -070071
72protected:
73 virtual int powerUp() = 0;
74 virtual int powerDown() = 0;
75 virtual int loadFirmware();
San Mehat1441e762009-05-07 11:37:10 -070076
77 virtual bool isFirmwareLoaded() = 0;
San Mehatdc266072009-05-06 11:16:52 -070078 virtual bool isPoweredUp() = 0;
79
San Mehat1441e762009-05-07 11:37:10 -070080 void sendStatusBroadcast(const char *msg);
San Mehatdc266072009-05-06 11:16:52 -070081};
82
83#endif