mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-14 11:29:26 +01:00
Added check if wifi shield is not present
This commit is contained in:
parent
28a453783f
commit
a1fa79aa24
@ -150,12 +150,13 @@ uint8_t WiFiClass::encryptionType()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t WiFiClass::scanNetworks()
|
int8_t WiFiClass::scanNetworks()
|
||||||
{
|
{
|
||||||
uint8_t attempts = 10;
|
uint8_t attempts = 10;
|
||||||
uint8_t numOfNetworks = 0;
|
uint8_t numOfNetworks = 0;
|
||||||
|
|
||||||
WiFiDrv::startScanNetworks();
|
if (WiFiDrv::startScanNetworks() == WL_FAILURE)
|
||||||
|
return WL_FAILURE;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
delay(2000);
|
delay(2000);
|
||||||
|
@ -123,7 +123,7 @@ public:
|
|||||||
*
|
*
|
||||||
* return: Number of discovered networks
|
* return: Number of discovered networks
|
||||||
*/
|
*/
|
||||||
uint8_t scanNetworks();
|
int8_t scanNetworks();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the SSID discovered during the network scan.
|
* Return the SSID discovered during the network scan.
|
||||||
|
@ -59,7 +59,7 @@ void WiFiDrv::wifiDriverInit()
|
|||||||
SpiDrv::begin();
|
SpiDrv::begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WiFiDrv::wifiSetNetwork(char* ssid, uint8_t ssid_len)
|
int8_t WiFiDrv::wifiSetNetwork(char* ssid, uint8_t ssid_len)
|
||||||
{
|
{
|
||||||
WAIT_FOR_SLAVE_SELECT();
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
// Send Command
|
// Send Command
|
||||||
@ -75,13 +75,14 @@ uint8_t WiFiDrv::wifiSetNetwork(char* ssid, uint8_t ssid_len)
|
|||||||
if (!SpiDrv::waitResponseCmd(SET_NET_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
if (!SpiDrv::waitResponseCmd(SET_NET_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
{
|
{
|
||||||
WARN("error waitResponse");
|
WARN("error waitResponse");
|
||||||
|
return WL_FAILURE;
|
||||||
}
|
}
|
||||||
SpiDrv::spiSlaveDeselect();
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
return(_data == WIFI_SPI_ACK) ? WL_SUCCESS : WL_FAILURE;
|
return(_data == WIFI_SPI_ACK) ? WL_SUCCESS : WL_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WiFiDrv::wifiSetPassphrase(char* ssid, uint8_t ssid_len, const char *passphrase, const uint8_t len)
|
int8_t WiFiDrv::wifiSetPassphrase(char* ssid, uint8_t ssid_len, const char *passphrase, const uint8_t len)
|
||||||
{
|
{
|
||||||
WAIT_FOR_SLAVE_SELECT();
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
// Send Command
|
// Send Command
|
||||||
@ -98,13 +99,14 @@ uint8_t WiFiDrv::wifiSetPassphrase(char* ssid, uint8_t ssid_len, const char *pas
|
|||||||
if (!SpiDrv::waitResponseCmd(SET_PASSPHRASE_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
if (!SpiDrv::waitResponseCmd(SET_PASSPHRASE_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
{
|
{
|
||||||
WARN("error waitResponse");
|
WARN("error waitResponse");
|
||||||
|
return WL_FAILURE;
|
||||||
}
|
}
|
||||||
SpiDrv::spiSlaveDeselect();
|
SpiDrv::spiSlaveDeselect();
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t WiFiDrv::wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const void *key, const uint8_t len)
|
int8_t WiFiDrv::wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const void *key, const uint8_t len)
|
||||||
{
|
{
|
||||||
WAIT_FOR_SLAVE_SELECT();
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
// Send Command
|
// Send Command
|
||||||
@ -122,12 +124,13 @@ uint8_t WiFiDrv::wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const
|
|||||||
if (!SpiDrv::waitResponseCmd(SET_KEY_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
if (!SpiDrv::waitResponseCmd(SET_KEY_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
{
|
{
|
||||||
WARN("error waitResponse");
|
WARN("error waitResponse");
|
||||||
|
return WL_FAILURE;
|
||||||
}
|
}
|
||||||
SpiDrv::spiSlaveDeselect();
|
SpiDrv::spiSlaveDeselect();
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WiFiDrv::disconnect()
|
int8_t WiFiDrv::disconnect()
|
||||||
{
|
{
|
||||||
WAIT_FOR_SLAVE_SELECT();
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
// Send Command
|
// Send Command
|
||||||
@ -142,7 +145,7 @@ uint8_t WiFiDrv::disconnect()
|
|||||||
// Wait for reply
|
// Wait for reply
|
||||||
uint8_t _data = 0;
|
uint8_t _data = 0;
|
||||||
uint8_t _dataLen = 0;
|
uint8_t _dataLen = 0;
|
||||||
uint8_t result = SpiDrv::waitResponseCmd(DISCONNECT_CMD, PARAM_NUMS_1, &_data, &_dataLen);
|
int8_t result = SpiDrv::waitResponseCmd(DISCONNECT_CMD, PARAM_NUMS_1, &_data, &_dataLen);
|
||||||
|
|
||||||
SpiDrv::spiSlaveDeselect();
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
@ -299,7 +302,7 @@ uint8_t WiFiDrv::getCurrentEncryptionType()
|
|||||||
return encType;
|
return encType;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WiFiDrv::startScanNetworks()
|
int8_t WiFiDrv::startScanNetworks()
|
||||||
{
|
{
|
||||||
WAIT_FOR_SLAVE_SELECT();
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
@ -312,11 +315,16 @@ uint8_t WiFiDrv::startScanNetworks()
|
|||||||
// Wait for reply
|
// Wait for reply
|
||||||
uint8_t _data = 0;
|
uint8_t _data = 0;
|
||||||
uint8_t _dataLen = 0;
|
uint8_t _dataLen = 0;
|
||||||
uint8_t result = SpiDrv::waitResponseCmd(START_SCAN_NETWORKS, PARAM_NUMS_1, &_data, &_dataLen);
|
|
||||||
|
if (!SpiDrv::waitResponseCmd(START_SCAN_NETWORKS, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
return WL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
SpiDrv::spiSlaveDeselect();
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
return result;
|
return WL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
* param ssid_len: Lenght of ssid string.
|
* param ssid_len: Lenght of ssid string.
|
||||||
* return: WL_SUCCESS or WL_FAILURE
|
* return: WL_SUCCESS or WL_FAILURE
|
||||||
*/
|
*/
|
||||||
static uint8_t wifiSetNetwork(char* ssid, uint8_t ssid_len);
|
static int8_t wifiSetNetwork(char* ssid, uint8_t ssid_len);
|
||||||
|
|
||||||
/* Start Wifi connection with passphrase
|
/* Start Wifi connection with passphrase
|
||||||
* the most secure supported mode will be automatically selected
|
* the most secure supported mode will be automatically selected
|
||||||
@ -64,7 +64,7 @@ public:
|
|||||||
* param len: Lenght of passphrase string.
|
* param len: Lenght of passphrase string.
|
||||||
* return: WL_SUCCESS or WL_FAILURE
|
* return: WL_SUCCESS or WL_FAILURE
|
||||||
*/
|
*/
|
||||||
static uint8_t wifiSetPassphrase(char* ssid, uint8_t ssid_len, const char *passphrase, const uint8_t len);
|
static int8_t wifiSetPassphrase(char* ssid, uint8_t ssid_len, const char *passphrase, const uint8_t len);
|
||||||
|
|
||||||
/* Start Wifi connection with WEP encryption.
|
/* Start Wifi connection with WEP encryption.
|
||||||
* Configure a key into the device. The key type (WEP-40, WEP-104)
|
* Configure a key into the device. The key type (WEP-40, WEP-104)
|
||||||
@ -77,14 +77,14 @@ public:
|
|||||||
* param len: Lenght of key string.
|
* param len: Lenght of key string.
|
||||||
* return: WL_SUCCESS or WL_FAILURE
|
* return: WL_SUCCESS or WL_FAILURE
|
||||||
*/
|
*/
|
||||||
static uint8_t wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const void *key, const uint8_t len);
|
static int8_t wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const void *key, const uint8_t len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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 int8_t disconnect();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disconnect from the network
|
* Disconnect from the network
|
||||||
@ -156,7 +156,7 @@ public:
|
|||||||
*
|
*
|
||||||
* return: Number of discovered networks
|
* return: Number of discovered networks
|
||||||
*/
|
*/
|
||||||
static uint8_t startScanNetworks();
|
static int8_t startScanNetworks();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the networks available
|
* Get the networks available
|
||||||
|
Loading…
x
Reference in New Issue
Block a user