mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
Fix issues on get encryptionType for the current associated network.
Fix issue related to retrieve encription type and RSSI for the available networks
This commit is contained in:
parent
1d1f647ed6
commit
514a694c8a
@ -40,13 +40,6 @@ uint8_t WiFiClass::getSocket()
|
||||
return NO_SOCKET_AVAIL;
|
||||
}
|
||||
|
||||
int WiFiClass::begin()
|
||||
{
|
||||
// Add procedure to read the latest configuration from eeprom/dataflash
|
||||
// and start the wifi connection
|
||||
return WL_IDLE_STATUS;
|
||||
}
|
||||
|
||||
int WiFiClass::begin(char* ssid)
|
||||
{
|
||||
uint8_t status = WL_IDLE_STATUS;
|
||||
@ -188,11 +181,4 @@ uint8_t WiFiClass::status()
|
||||
return WiFiDrv::getConnectionStatus();
|
||||
}
|
||||
|
||||
uint8_t WiFiClass::test()
|
||||
{
|
||||
return WiFiDrv::testCmd();
|
||||
}
|
||||
|
||||
|
||||
|
||||
WiFiClass WiFi;
|
||||
|
36
WiFi/WiFi.h
36
WiFi/WiFi.h
@ -5,6 +5,7 @@
|
||||
|
||||
extern "C" {
|
||||
#include "utility/wl_definitions.h"
|
||||
#include "utility/wl_types.h"
|
||||
}
|
||||
|
||||
#include "IPAddress.h"
|
||||
@ -28,20 +29,31 @@ public:
|
||||
|
||||
WiFiClass();
|
||||
|
||||
// Get thefirst socket available
|
||||
// Get the first socket available
|
||||
static uint8_t getSocket();
|
||||
|
||||
// Start Wifi connection with latest settings
|
||||
int begin();
|
||||
|
||||
// Start Wifi connection with no encryption
|
||||
/* Start Wifi connection for OPEN networks
|
||||
*
|
||||
* param ssid: Pointer to the SSID string.
|
||||
*/
|
||||
int begin(char* ssid);
|
||||
|
||||
// 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)
|
||||
* is determined by the size of the key (5 bytes for WEP-40, 13 bytes for WEP-104).
|
||||
*
|
||||
* param ssid: Pointer to the SSID string.
|
||||
* param key_idx: The key index to set. Valid values are 0-3.
|
||||
* param key: Key input buffer.
|
||||
*/
|
||||
int begin(char* ssid, uint8_t key_idx, const char* key);
|
||||
|
||||
// Start Wifi connection with passphrase
|
||||
// the most secure supported mode will be automatically selected
|
||||
/* Start Wifi connection with passphrase
|
||||
* the most secure supported mode will be automatically selected
|
||||
*
|
||||
* param passphrase: Passphrase. Valid characters in a passphrase
|
||||
* must be between ASCII 32-126 (decimal).
|
||||
*/
|
||||
int begin(char* ssid, const char *passphrase);
|
||||
|
||||
// Disconnect from the network
|
||||
@ -83,12 +95,12 @@ public:
|
||||
// Return the current RSSI /Received Signal Strength in dBm) associated with the network identified with networkItem
|
||||
int32_t RSSI(uint8_t networkItem);
|
||||
|
||||
// Return Connection status
|
||||
/* Return Connection status.
|
||||
*
|
||||
* return: one of the value defined in wl_status_t
|
||||
*/
|
||||
uint8_t status();
|
||||
|
||||
// function used for test
|
||||
uint8_t test();
|
||||
|
||||
friend class WiFiClient;
|
||||
friend class WiFiServer;
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "Arduino.h"
|
||||
#include "spi_drv.h"
|
||||
#include "pins_arduino.h"
|
||||
#define _DEBUG_
|
||||
//#define _DEBUG_
|
||||
extern "C" {
|
||||
#include "debug.h"
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ extern "C" {
|
||||
}
|
||||
|
||||
char WiFiDrv::_networkSsid[][WL_SSID_MAX_LENGTH] = {{"1"},{"2"},{"3"},{"4"},{"5"}};
|
||||
int32_t WiFiDrv::_networkRssi[WL_NETWORKS_LIST_MAXNUM] = { 0 };
|
||||
uint8_t WiFiDrv::_networkEncr[WL_NETWORKS_LIST_MAXNUM] = { 0 };
|
||||
|
||||
char WiFiDrv::_ssid[] = {0};
|
||||
uint8_t WiFiDrv::_bssid[] = {0};
|
||||
uint8_t WiFiDrv::_mac[] = {0};
|
||||
@ -289,7 +292,7 @@ uint8_t WiFiDrv::getCurrentEncryptionType()
|
||||
// Wait for reply
|
||||
uint8_t dataLen = 0;
|
||||
uint8_t encType = 0;
|
||||
SpiDrv::waitResponseCmd(GET_CURR_ENCT_CMD, PARAM_NUMS_1, (uint8_t*)encType, &dataLen);
|
||||
SpiDrv::waitResponseCmd(GET_CURR_ENCT_CMD, PARAM_NUMS_1, (uint8_t*)&encType, &dataLen);
|
||||
|
||||
SpiDrv::spiSlaveDeselect();
|
||||
|
||||
@ -303,9 +306,6 @@ uint8_t WiFiDrv::scanNetworks()
|
||||
// Send Command
|
||||
SpiDrv::sendCmd(SCAN_NETWORKS, PARAM_NUMS_0);
|
||||
|
||||
// uint8_t _dummy = DUMMY_DATA;
|
||||
// SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
|
||||
|
||||
//Wait the reply elaboration
|
||||
SpiDrv::waitForSlaveReady();
|
||||
|
||||
@ -330,10 +330,25 @@ uint8_t WiFiDrv::getEncTypeNetowrks(uint8_t networkItem)
|
||||
{
|
||||
if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
|
||||
return NULL;
|
||||
uint8_t networkEncType = 0;
|
||||
|
||||
//TODO make an RPC call to get the encryption type associated with networkItem
|
||||
return networkEncType;
|
||||
WAIT_FOR_SLAVE_SELECT();
|
||||
|
||||
// Send Command
|
||||
SpiDrv::sendCmd(GET_IDX_ENCT_CMD, PARAM_NUMS_1);
|
||||
|
||||
SpiDrv::sendParam(&networkItem, 1, LAST_PARAM);
|
||||
|
||||
//Wait the reply elaboration
|
||||
SpiDrv::waitForSlaveReady();
|
||||
|
||||
// Wait for reply
|
||||
uint8_t dataLen = 0;
|
||||
uint8_t encType = 0;
|
||||
SpiDrv::waitResponseCmd(GET_IDX_ENCT_CMD, PARAM_NUMS_1, (uint8_t*)&encType, &dataLen);
|
||||
|
||||
SpiDrv::spiSlaveDeselect();
|
||||
|
||||
return encType;
|
||||
}
|
||||
|
||||
int32_t WiFiDrv::getRSSINetoworks(uint8_t networkItem)
|
||||
@ -342,29 +357,23 @@ int32_t WiFiDrv::getRSSINetoworks(uint8_t networkItem)
|
||||
return NULL;
|
||||
int32_t networkRssi = 0;
|
||||
|
||||
//TODO make an RPC call to get the rssi associated with networkItem
|
||||
return networkRssi;
|
||||
}
|
||||
|
||||
uint8_t WiFiDrv::testCmd()
|
||||
{
|
||||
WAIT_FOR_SLAVE_SELECT();
|
||||
|
||||
// Send Command
|
||||
SpiDrv::sendCmd(TEST_CMD, PARAM_NUMS_0);
|
||||
SpiDrv::sendCmd(GET_IDX_RSSI_CMD, PARAM_NUMS_1);
|
||||
|
||||
SpiDrv::sendParam(&networkItem, 1, LAST_PARAM);
|
||||
|
||||
//Wait the reply elaboration
|
||||
SpiDrv::waitForSlaveReady();
|
||||
|
||||
// Wait for reply
|
||||
uint8_t _data = 0;
|
||||
uint8_t _dataLen = 0;
|
||||
SpiDrv::waitResponseCmd(TEST_CMD, PARAM_NUMS_1, &_data, &_dataLen);
|
||||
uint8_t dataLen = 0;
|
||||
SpiDrv::waitResponseCmd(GET_IDX_RSSI_CMD, PARAM_NUMS_1, (uint8_t*)&networkRssi, &dataLen);
|
||||
|
||||
SpiDrv::spiSlaveDeselect();
|
||||
|
||||
return _data;
|
||||
return networkRssi;
|
||||
}
|
||||
|
||||
|
||||
WiFiDrv wiFiDrv;
|
||||
|
@ -14,6 +14,8 @@ class WiFiDrv
|
||||
private:
|
||||
// settings of requested network
|
||||
static char _networkSsid[WL_NETWORKS_LIST_MAXNUM][WL_SSID_MAX_LENGTH];
|
||||
static int32_t _networkRssi[WL_NETWORKS_LIST_MAXNUM];
|
||||
static uint8_t _networkEncr[WL_NETWORKS_LIST_MAXNUM];
|
||||
|
||||
// settings of current selected network
|
||||
static char _ssid[WL_SSID_MAX_LENGTH];
|
||||
@ -63,7 +65,6 @@ public:
|
||||
|
||||
static uint8_t getEncTypeNetowrks(uint8_t networkItem);
|
||||
|
||||
static uint8_t testCmd();
|
||||
};
|
||||
|
||||
extern WiFiDrv wiFiDrv;
|
||||
|
@ -41,8 +41,11 @@ enum {
|
||||
START_CLIENT_TCP_CMD= 0x2D,
|
||||
STOP_CLIENT_TCP_CMD = 0x2E,
|
||||
GET_CLIENT_STATE_TCP_CMD= 0x2F,
|
||||
|
||||
DISCONNECT_CMD = 0x30,
|
||||
GET_IDX_SSID_CMD = 0x31,
|
||||
GET_IDX_RSSI_CMD = 0x32,
|
||||
GET_IDX_ENCT_CMD = 0x33,
|
||||
|
||||
// All command with DATA_FLAG 0x40 send a 16bit Len
|
||||
|
||||
SEND_DATA_TCP_CMD = 0x44,
|
||||
|
@ -35,5 +35,15 @@ typedef enum {
|
||||
WL_DISCONNECTED
|
||||
} wl_status_t;
|
||||
|
||||
/* Encryption modes */
|
||||
enum wl_enc_type { /* Values map to 802.11 encryption suites... */
|
||||
ENC_TYPE_WEP = 5,
|
||||
ENC_TYPE_TKIP = 2,
|
||||
ENC_TYPE_CCMP = 4,
|
||||
/* ... except these two, 7 and 8 are reserved in 802.11-2007 */
|
||||
ENC_TYPE_NONE = 7,
|
||||
ENC_TYPE_AUTO = 8
|
||||
};
|
||||
|
||||
|
||||
#endif /* WL_DEFINITIONS_H_ */
|
||||
|
@ -28,15 +28,4 @@ enum wl_auth_mode {
|
||||
AUTH_MODE_WPA2_PSK
|
||||
};
|
||||
|
||||
|
||||
/* Encryption modes */
|
||||
enum wl_enc_type { /* Values map to 802.11 encryption suites... */
|
||||
ENC_TYPE_WEP = 5,
|
||||
ENC_TYPE_TKIP = 2,
|
||||
ENC_TYPE_CCMP = 4,
|
||||
/* ... except these two, 7 and 8 are reserved in 802.11-2007 */
|
||||
ENC_TYPE_NONE = 7,
|
||||
ENC_TYPE_AUTO = 8
|
||||
};
|
||||
|
||||
#endif //_WL_TYPES_H_
|
||||
|
Loading…
x
Reference in New Issue
Block a user