mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-19 09:42:11 +03:00
Fix ScanNetworks list
This commit is contained in:
@ -152,7 +152,17 @@ uint8_t WiFiClass::encryptionType()
|
|||||||
|
|
||||||
uint8_t WiFiClass::scanNetworks()
|
uint8_t WiFiClass::scanNetworks()
|
||||||
{
|
{
|
||||||
return WiFiDrv::scanNetworks();
|
uint8_t attempts = 10;
|
||||||
|
uint8_t numOfNetworks = 0;
|
||||||
|
|
||||||
|
WiFiDrv::startScanNetworks();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
delay(2000);
|
||||||
|
numOfNetworks = WiFiDrv::getScanNetworks();
|
||||||
|
}
|
||||||
|
while (( numOfNetworks == 0)&&(--attempts>0));
|
||||||
|
return numOfNetworks;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* WiFiClass::SSID(uint8_t networkItem)
|
char* WiFiClass::SSID(uint8_t networkItem)
|
||||||
|
@ -399,6 +399,7 @@ int SpiDrv::waitResponse(uint8_t cmd, uint8_t* numParamRead, uint8_t** params, u
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
WARN("Error numParams == 0");
|
WARN("Error numParams == 0");
|
||||||
|
readAndCheckChar(END_CMD, &_data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
readAndCheckChar(END_CMD, &_data);
|
readAndCheckChar(END_CMD, &_data);
|
||||||
|
@ -299,7 +299,28 @@ uint8_t WiFiDrv::getCurrentEncryptionType()
|
|||||||
return encType;
|
return encType;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WiFiDrv::scanNetworks()
|
uint8_t WiFiDrv::startScanNetworks()
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(START_SCAN_NETWORKS, PARAM_NUMS_0);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
uint8_t result = SpiDrv::waitResponseCmd(START_SCAN_NETWORKS, PARAM_NUMS_1, &_data, &_dataLen);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t WiFiDrv::getScanNetworks()
|
||||||
{
|
{
|
||||||
WAIT_FOR_SLAVE_SELECT();
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Driver initialization
|
* Driver initialization
|
||||||
*/
|
*/
|
||||||
static void wifiDriverInit();
|
static void wifiDriverInit();
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ public:
|
|||||||
/*
|
/*
|
||||||
* Disconnect from the network
|
* Disconnect from the network
|
||||||
*
|
*
|
||||||
* return: WL_SUCCESS or WL_FAILURE
|
* return: WL_SUCCESS or WL_FAILURE
|
||||||
*/
|
*/
|
||||||
static uint8_t disconnect();
|
static uint8_t disconnect();
|
||||||
|
|
||||||
@ -156,7 +156,14 @@ public:
|
|||||||
*
|
*
|
||||||
* return: Number of discovered networks
|
* return: Number of discovered networks
|
||||||
*/
|
*/
|
||||||
static uint8_t scanNetworks();
|
static uint8_t startScanNetworks();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the networks available
|
||||||
|
*
|
||||||
|
* return: Number of discovered networks
|
||||||
|
*/
|
||||||
|
static uint8_t getScanNetworks();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the SSID discovered during the network scan.
|
* Return the SSID discovered during the network scan.
|
||||||
|
@ -47,6 +47,7 @@ enum {
|
|||||||
GET_IDX_ENCT_CMD = 0x33,
|
GET_IDX_ENCT_CMD = 0x33,
|
||||||
REQ_HOST_BY_NAME_CMD= 0x34,
|
REQ_HOST_BY_NAME_CMD= 0x34,
|
||||||
GET_HOST_BY_NAME_CMD= 0x35,
|
GET_HOST_BY_NAME_CMD= 0x35,
|
||||||
|
START_SCAN_NETWORKS = 0x36,
|
||||||
|
|
||||||
// All command with DATA_FLAG 0x40 send a 16bit Len
|
// All command with DATA_FLAG 0x40 send a 16bit Len
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user