Skip to content

Commit 4c86ebf

Browse files
added scanforap method
1 parent f911f67 commit 4c86ebf

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

libraries/lwIpWrapper/src/CNetIf.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ CNetIf::CNetIf(NetworkDriver *driver)
292292
}
293293

294294
int CNetIf::begin(const IPAddress &ip, const IPAddress &nm, const IPAddress &gw) {
295+
CLwipIf::getInstance(); // This call is required in order to setup the network stack
295296
driver->begin();
296297

297298
ip_addr_t _ip = fromArduinoIP(ip);
@@ -631,6 +632,23 @@ int CWifiStation::connectToAP(const char* ssid, const char *passphrase) {
631632
return rv;
632633
}
633634

635+
int CWifiStation::scanForAp() {
636+
// arduino::lock();
637+
access_points.clear(); // FIXME create access_points vector
638+
639+
int res = CEspControl::getInstance().getAccessPointScanList(access_points);
640+
if (res == ESP_CONTROL_OK) {
641+
res = WL_SCAN_COMPLETED;
642+
}
643+
// else {
644+
// res = WL_NO_SSID_AVAIL; // TODO
645+
// }
646+
647+
// arduino::unlock();
648+
649+
return res;
650+
}
651+
634652
// disconnect
635653
int CWifiStation::disconnectFromAp() {
636654
return CEspControl::getInstance().disconnectAccessPoint();
@@ -880,10 +898,6 @@ int CWifiSoftAp::startSoftAp(const char* ssid, const char* passphrase, uint8_t c
880898
return rv;
881899
}
882900

883-
int CWifiSoftAp::stopSoftAp() {
884-
885-
}
886-
887901
err_t CWifiSoftAp::init(struct netif* ni) {
888902
// Setting up netif
889903
#if LWIP_NETIF_HOSTNAME
@@ -922,7 +936,7 @@ err_t CWifiSoftAp::output(struct netif* _ni, struct pbuf* p) {
922936
// p may be a chain of pbufs
923937
if(p->next != nullptr) {
924938
buf = (uint8_t*) malloc(size*sizeof(uint8_t));
925-
if(buf == nullptr) {\
939+
if(buf == nullptr) {
926940
// NETIF_STATS_INCREMENT_ERROR(this->stats, ERR_MEM);
927941
// NETIF_STATS_INCREMENT_TX_TRANSMIT_FAILED_CALLS(this->stats);
928942
errval = ERR_MEM;

0 commit comments

Comments
 (0)