San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame^] | 1 | /* |
| 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 | |
| 23 | class NetInterface; |
| 24 | class Supplicant; |
| 25 | |
| 26 | class WifiController : public Controller { |
| 27 | public: |
| 28 | static const uint32_t SCAN_ENABLE_MASK = 0x01; |
| 29 | static const uint32_t SCAN_ACTIVE_MASK = 0x02; |
| 30 | static const uint32_t SCAN_REPEAT_MASK = 0x04; |
| 31 | |
| 32 | static const uint32_t SCANMODE_NONE = 0; |
| 33 | static const uint32_t SCANMODE_PASSIVE_ONESHOT = SCAN_ENABLE_MASK; |
| 34 | static const uint32_t SCANMODE_PASSIVE_CONTINUOUS = SCAN_ENABLE_MASK | SCAN_REPEAT_MASK; |
| 35 | static const uint32_t SCANMODE_ACTIVE_ONESHOT = SCAN_ENABLE_MASK | SCAN_ACTIVE_MASK; |
| 36 | static const uint32_t SCANMODE_ACTIVE_CONTINUOUS = SCAN_ENABLE_MASK | SCAN_ACTIVE_MASK | SCAN_REPEAT_MASK; |
| 37 | |
| 38 | private: |
| 39 | Supplicant *mSupplicant; |
| 40 | char mModulePath[255]; |
| 41 | char mModuleName[64]; |
| 42 | char mModuleArgs[255]; |
| 43 | int mCurrentScanMode; |
| 44 | |
| 45 | |
| 46 | public: |
| 47 | WifiController(char *modpath, char *modname, char *modargs); |
| 48 | virtual ~WifiController() {} |
| 49 | |
| 50 | int start(); |
| 51 | int stop(); |
| 52 | |
| 53 | int enable(); |
| 54 | int disable(); |
| 55 | |
| 56 | int getType(); |
| 57 | |
| 58 | char *getModulePath() { return mModulePath; } |
| 59 | char *getModuleName() { return mModuleName; } |
| 60 | char *getModuleArgs() { return mModuleArgs; } |
| 61 | |
| 62 | Supplicant *getSupplicant() { return mSupplicant; } |
| 63 | |
| 64 | int getScanMode() { return mCurrentScanMode; } |
| 65 | int setScanMode(int mode); |
| 66 | |
| 67 | protected: |
| 68 | virtual int powerUp() = 0; |
| 69 | virtual int powerDown() = 0; |
| 70 | virtual int loadFirmware(); |
| 71 | virtual bool isPoweredUp() = 0; |
| 72 | |
| 73 | private: |
| 74 | int startPeriodicScan(); |
| 75 | int stopPeriodicScan(); |
| 76 | }; |
| 77 | |
| 78 | #endif |