aboutsummaryrefslogtreecommitdiffstats
path: root/nexus/WifiController.cpp
diff options
context:
space:
mode:
authorSan Mehat <san@google.com>2009-05-20 15:28:43 -0700
committerSan Mehat <san@google.com>2009-05-22 08:40:13 -0700
commit4876567cb9c6a69ce21fd2b1c5bcce5a6f274276 (patch)
treee08d76eed07e530884fb4e4d810a59ca4f017997 /nexus/WifiController.cpp
parent463de48fb05cb29388e7763f75f6cfa56a2f5cb1 (diff)
downloadsystem_core-4876567cb9c6a69ce21fd2b1c5bcce5a6f274276.tar.gz
system_core-4876567cb9c6a69ce21fd2b1c5bcce5a6f274276.tar.bz2
system_core-4876567cb9c6a69ce21fd2b1c5bcce5a6f274276.zip
nexus: Switch controllers to use abstracted properties and refactor command protocol
Also fixes a select() bug and removes debugging Signed-off-by: San Mehat <san@google.com> nexus: fix whitespace
Diffstat (limited to 'nexus/WifiController.cpp')
-rw-r--r--nexus/WifiController.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/nexus/WifiController.cpp b/nexus/WifiController.cpp
index 126db69e..72207ce2 100644
--- a/nexus/WifiController.cpp
+++ b/nexus/WifiController.cpp
@@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -26,7 +28,7 @@
#include "ErrorCode.h"
WifiController::WifiController(char *modpath, char *modname, char *modargs) :
- Controller("WIFI") {
+ Controller("WIFI", "wifi") {
strncpy(mModulePath, modpath, sizeof(mModulePath));
strncpy(mModuleName, modname, sizeof(mModuleName));
strncpy(mModuleArgs, modargs, sizeof(mModuleArgs));
@@ -34,6 +36,8 @@ WifiController::WifiController(char *modpath, char *modname, char *modargs) :
mSupplicant = new Supplicant();
mScanner = new WifiScanner(mSupplicant, 10);
mCurrentScanMode = 0;
+
+ registerProperty("scanmode");
}
int WifiController::start() {
@@ -94,7 +98,7 @@ out_powerdown:
return -1;
}
-void WifiController::sendStatusBroadcast(char *msg) {
+void WifiController::sendStatusBroadcast(const char *msg) {
NetworkManager::Instance()->
getBroadcaster()->
sendBroadcast(ErrorCode::UnsolicitedInformational, msg, false);
@@ -167,3 +171,20 @@ ScanResultCollection *WifiController::createScanResults() {
WifiNetworkCollection *WifiController::createNetworkList() {
return mSupplicant->createNetworkList();
}
+
+int WifiController::setProperty(const char *name, char *value) {
+ if (!strcmp(name, "scanmode"))
+ return setScanMode((uint32_t) strtoul(value, NULL, 0));
+
+ return Controller::setProperty(name, value);
+}
+
+const char *WifiController::getProperty(const char *name, char *buffer, size_t maxsize) {
+ if (!strcmp(name, "scanmode")) {
+ snprintf(buffer, maxsize, "0x%.8x", mCurrentScanMode);
+ return buffer;
+ }
+
+ return Controller::getProperty(name, buffer, maxsize);
+}
+