Skip to content

Commit

Permalink
Add reasonCode() API to retrieve the deauthentication reason code
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepmistry committed Apr 9, 2019
1 parent 042b4d4 commit cc0563e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ WiFiUDP KEYWORD1

firmwareVersion KEYWORD2
status KEYWORD2
reasonCode KEYWORD2
connect KEYWORD2
write KEYWORD2
available KEYWORD2
Expand Down
5 changes: 5 additions & 0 deletions src/WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ uint8_t WiFiClass::status()
return WiFiDrv::getConnectionStatus();
}

uint8_t WiFiClass::reasonCode()
{
return WiFiDrv::getReasonCode();
}

int WiFiClass::hostByName(const char* aHostname, IPAddress& aResult)
{
return WiFiDrv::getHostByName(aHostname, aResult);
Expand Down
7 changes: 7 additions & 0 deletions src/WiFi.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ class WiFiClass
*/
uint8_t status();

/*
* Return The deauthentication reason code.
*
* return: the deauthentication reason code
*/
uint8_t reasonCode();

/*
* Resolve the given hostname to an IP address.
* param aHostname: Name to be resolved
Expand Down
22 changes: 22 additions & 0 deletions src/utility/wifi_drv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,28 @@ int8_t WiFiDrv::disconnect()
return result;
}

uint8_t WiFiDrv::getReasonCode()
{
WAIT_FOR_SLAVE_SELECT();

// Send Command
SpiDrv::sendCmd(GET_REASON_CODE_CMD, PARAM_NUMS_0);

SpiDrv::spiSlaveDeselect();
//Wait the reply elaboration
SpiDrv::waitForSlaveReady();
SpiDrv::spiSlaveSelect();

// Wait for reply
uint8_t _data = 1;
uint8_t _dataLen = 0;
SpiDrv::waitResponseCmd(GET_REASON_CODE_CMD, PARAM_NUMS_1, &_data, &_dataLen);

SpiDrv::spiSlaveDeselect();

return _data;
}

uint8_t WiFiDrv::getConnectionStatus()
{
WAIT_FOR_SLAVE_SELECT();
Expand Down
2 changes: 2 additions & 0 deletions src/utility/wifi_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ class WiFiDrv
*/
static int8_t disconnect();

static uint8_t getReasonCode();

/*
* Disconnect from the network
*
Expand Down
1 change: 1 addition & 0 deletions src/utility/wifi_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum {
SET_AP_PASSPHRASE_CMD = 0x19,
SET_DEBUG_CMD = 0x1A,
GET_TEMPERATURE_CMD = 0x1B,
GET_REASON_CODE_CMD = 0x1F,

GET_CONN_STATUS_CMD = 0x20,
GET_IPADDR_CMD = 0x21,
Expand Down

0 comments on commit cc0563e

Please sign in to comment.