mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Fix ScanNetworks list
This commit is contained in:
parent
e3749c2dbf
commit
b6490ad458
@ -152,7 +152,17 @@ uint8_t WiFiClass::encryptionType()
|
||||
|
||||
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)
|
||||
|
@ -399,6 +399,7 @@ int SpiDrv::waitResponse(uint8_t cmd, uint8_t* numParamRead, uint8_t** params, u
|
||||
} else
|
||||
{
|
||||
WARN("Error numParams == 0");
|
||||
readAndCheckChar(END_CMD, &_data);
|
||||
return 0;
|
||||
}
|
||||
readAndCheckChar(END_CMD, &_data);
|
||||
|
@ -299,7 +299,28 @@ uint8_t WiFiDrv::getCurrentEncryptionType()
|
||||
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();
|
||||
|
||||
|
@ -38,7 +38,7 @@ private:
|
||||
public:
|
||||
|
||||
/*
|
||||
* Driver initialization
|
||||
* Driver initialization
|
||||
*/
|
||||
static void wifiDriverInit();
|
||||
|
||||
@ -82,7 +82,7 @@ public:
|
||||
/*
|
||||
* Disconnect from the network
|
||||
*
|
||||
* return: WL_SUCCESS or WL_FAILURE
|
||||
* return: WL_SUCCESS or WL_FAILURE
|
||||
*/
|
||||
static uint8_t disconnect();
|
||||
|
||||
@ -156,7 +156,14 @@ public:
|
||||
*
|
||||
* 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.
|
||||
|
@ -47,6 +47,7 @@ enum {
|
||||
GET_IDX_ENCT_CMD = 0x33,
|
||||
REQ_HOST_BY_NAME_CMD= 0x34,
|
||||
GET_HOST_BY_NAME_CMD= 0x35,
|
||||
START_SCAN_NETWORKS = 0x36,
|
||||
|
||||
// All command with DATA_FLAG 0x40 send a 16bit Len
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user