diff options
| author | San Mehat <san@google.com> | 2009-05-12 17:26:28 -0700 |
|---|---|---|
| committer | San Mehat <san@google.com> | 2009-05-13 09:10:01 -0700 |
| commit | 82a2116e6b67db910bba22c4874e6ca5efd3eec0 (patch) | |
| tree | 0f08c363327859f3da5128b24743e0974edf5f55 /nexus/Supplicant.cpp | |
| parent | df6c1b91e3813886070f35929583c30cfaead918 (diff) | |
| download | system_core-82a2116e6b67db910bba22c4874e6ca5efd3eec0.tar.gz system_core-82a2116e6b67db910bba22c4874e6ca5efd3eec0.tar.bz2 system_core-82a2116e6b67db910bba22c4874e6ca5efd3eec0.zip | |
nexus: Initial support for manipulating wifi networks + change wifi scan notification msgs
Signed-off-by: San Mehat <san@google.com>
Diffstat (limited to 'nexus/Supplicant.cpp')
| -rw-r--r-- | nexus/Supplicant.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/nexus/Supplicant.cpp b/nexus/Supplicant.cpp index 94435987..22964bbc 100644 --- a/nexus/Supplicant.cpp +++ b/nexus/Supplicant.cpp @@ -229,7 +229,7 @@ int Supplicant::sendCommand(const char *cmd, char *reply, size_t *reply_len) return -1; } -// LOGD("sendCommand(): -> '%s'", cmd); + LOGD("sendCommand(): -> '%s'", cmd); int rc; if ((rc = wpa_ctrl_request(mCtrl, cmd, strlen(cmd), reply, reply_len, NULL)) == -2) { @@ -245,7 +245,7 @@ int Supplicant::sendCommand(const char *cmd, char *reply, size_t *reply_len) !strncmp(cmd, "SCAN_RESULTS", 12)) reply[*reply_len] = '\0'; -// LOGD("sendCommand(): <- '%s'", reply); + LOGD("sendCommand(): <- '%s'", reply); return 0; } @@ -355,7 +355,7 @@ int Supplicant::onScanResultsEvent(SupplicantEvent *evt) { mLatestScanResults->push_back(new ScanResult(linep)); char tmp[128]; - sprintf(tmp, "%d scan results ready", mLatestScanResults->size()); + sprintf(tmp, "Scan results ready (%d)", mLatestScanResults->size()); NetworkManager::Instance()->getBroadcaster()-> sendBroadcast(ErrorCode::UnsolicitedInformational, tmp, false); pthread_mutex_unlock(&mLatestScanResultsLock); @@ -412,6 +412,35 @@ ScanResultCollection *Supplicant::createLatestScanResults() { return d; } +WifiNetworkCollection *Supplicant::createNetworkList() { + WifiNetworkCollection *d = new WifiNetworkCollection(); + return d; +} + +int Supplicant::addNetwork() { + char reply[32]; + size_t len = sizeof(reply) -1; + + memset(reply, 0, sizeof(reply)); + if (sendCommand("ADD_NETWORK", reply, &len)) + return -1; + + return atoi(reply); +} + +int Supplicant::removeNetwork(int networkId) { + char req[64]; + + sprintf(req, "REMOVE_NETWORK %d", networkId); + char reply[32]; + size_t len = sizeof(reply) -1; + memset(reply, 0, sizeof(reply)); + + if (sendCommand(req, reply, &len)) + return -1; + return 0; +} + int Supplicant::setupConfig() { char buf[2048]; int srcfd, destfd; |
