blob: b2f45307001dc3ed2a676dcf8dcf1cbfbe30a13a [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 */
San Mehat3c5a6f02009-05-22 15:36:13 -070016
San Mehatdc266072009-05-06 11:16:52 -070017#ifndef _WIFI_CONTROLLER_H
18#define _WIFI_CONTROLLER_H
19
20#include <sys/types.h>
21
22#include "Controller.h"
23
24class NetInterface;
25class Supplicant;
San Mehat1441e762009-05-07 11:37:10 -070026class WifiScanner;
27
28#include "ScanResult.h"
San Mehat82a21162009-05-12 17:26:28 -070029#include "WifiNetwork.h"
San Mehatdc266072009-05-06 11:16:52 -070030
31class WifiController : public Controller {
32public:
33 static const uint32_t SCAN_ENABLE_MASK = 0x01;
34 static const uint32_t SCAN_ACTIVE_MASK = 0x02;
35 static const uint32_t SCAN_REPEAT_MASK = 0x04;
36
37 static const uint32_t SCANMODE_NONE = 0;
38 static const uint32_t SCANMODE_PASSIVE_ONESHOT = SCAN_ENABLE_MASK;
39 static const uint32_t SCANMODE_PASSIVE_CONTINUOUS = SCAN_ENABLE_MASK | SCAN_REPEAT_MASK;
40 static const uint32_t SCANMODE_ACTIVE_ONESHOT = SCAN_ENABLE_MASK | SCAN_ACTIVE_MASK;
41 static const uint32_t SCANMODE_ACTIVE_CONTINUOUS = SCAN_ENABLE_MASK | SCAN_ACTIVE_MASK | SCAN_REPEAT_MASK;
42
43private:
44 Supplicant *mSupplicant;
45 char mModulePath[255];
46 char mModuleName[64];
47 char mModuleArgs[255];
San Mehat1441e762009-05-07 11:37:10 -070048 uint32_t mCurrentScanMode;
49 WifiScanner *mScanner;
San Mehat3c5a6f02009-05-22 15:36:13 -070050 bool mEnabled;
San Mehatdc266072009-05-06 11:16:52 -070051
52public:
San Mehat3c5a6f02009-05-22 15:36:13 -070053 WifiController(PropertyManager *propmngr, char *modpath, char *modname, char *modargs);
San Mehatdc266072009-05-06 11:16:52 -070054 virtual ~WifiController() {}
55
56 int start();
57 int stop();
58
San Mehat3c5a6f02009-05-22 15:36:13 -070059 WifiNetwork *createNetwork();
San Mehat82a21162009-05-12 17:26:28 -070060 int removeNetwork(int networkId);
61 WifiNetworkCollection *createNetworkList();
San Mehat1441e762009-05-07 11:37:10 -070062
San Mehat3c5a6f02009-05-22 15:36:13 -070063 virtual int set(const char *name, const char *value);
64 virtual const char *get(const char *name, char *buffer, size_t maxlen);
San Mehat48765672009-05-20 15:28:43 -070065
San Mehat82a21162009-05-12 17:26:28 -070066 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:
San Mehat3c5a6f02009-05-22 15:36:13 -070075 // Move this crap into a 'driver'
San Mehatdc266072009-05-06 11:16:52 -070076 virtual int powerUp() = 0;
77 virtual int powerDown() = 0;
78 virtual int loadFirmware();
San Mehat1441e762009-05-07 11:37:10 -070079
80 virtual bool isFirmwareLoaded() = 0;
San Mehatdc266072009-05-06 11:16:52 -070081 virtual bool isPoweredUp() = 0;
82
San Mehat48765672009-05-20 15:28:43 -070083private:
San Mehat3c5a6f02009-05-22 15:36:13 -070084 void sendStatusBroadcast(const char *msg);
San Mehat48765672009-05-20 15:28:43 -070085 int setScanMode(uint32_t mode);
86 int enable();
87 int disable();
San Mehatdc266072009-05-06 11:16:52 -070088};
89
90#endif