Skip to content

Commit cc0563e

Browse files
committed
Add reasonCode() API to retrieve the deauthentication reason code
1 parent 042b4d4 commit cc0563e

File tree

6 files changed

+38
-0
lines changed

6 files changed

+38
-0
lines changed

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ WiFiUDP KEYWORD1
2121

2222
firmwareVersion KEYWORD2
2323
status KEYWORD2
24+
reasonCode KEYWORD2
2425
connect KEYWORD2
2526
write KEYWORD2
2627
available KEYWORD2

src/WiFi.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ uint8_t WiFiClass::status()
301301
return WiFiDrv::getConnectionStatus();
302302
}
303303

304+
uint8_t WiFiClass::reasonCode()
305+
{
306+
return WiFiDrv::getReasonCode();
307+
}
308+
304309
int WiFiClass::hostByName(const char* aHostname, IPAddress& aResult)
305310
{
306311
return WiFiDrv::getHostByName(aHostname, aResult);

src/WiFi.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ class WiFiClass
243243
*/
244244
uint8_t status();
245245

246+
/*
247+
* Return The deauthentication reason code.
248+
*
249+
* return: the deauthentication reason code
250+
*/
251+
uint8_t reasonCode();
252+
246253
/*
247254
* Resolve the given hostname to an IP address.
248255
* param aHostname: Name to be resolved

src/utility/wifi_drv.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,28 @@ int8_t WiFiDrv::disconnect()
328328
return result;
329329
}
330330

331+
uint8_t WiFiDrv::getReasonCode()
332+
{
333+
WAIT_FOR_SLAVE_SELECT();
334+
335+
// Send Command
336+
SpiDrv::sendCmd(GET_REASON_CODE_CMD, PARAM_NUMS_0);
337+
338+
SpiDrv::spiSlaveDeselect();
339+
//Wait the reply elaboration
340+
SpiDrv::waitForSlaveReady();
341+
SpiDrv::spiSlaveSelect();
342+
343+
// Wait for reply
344+
uint8_t _data = 1;
345+
uint8_t _dataLen = 0;
346+
SpiDrv::waitResponseCmd(GET_REASON_CODE_CMD, PARAM_NUMS_1, &_data, &_dataLen);
347+
348+
SpiDrv::spiSlaveDeselect();
349+
350+
return _data;
351+
}
352+
331353
uint8_t WiFiDrv::getConnectionStatus()
332354
{
333355
WAIT_FOR_SLAVE_SELECT();

src/utility/wifi_drv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ class WiFiDrv
144144
*/
145145
static int8_t disconnect();
146146

147+
static uint8_t getReasonCode();
148+
147149
/*
148150
* Disconnect from the network
149151
*

src/utility/wifi_spi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ enum {
5656
SET_AP_PASSPHRASE_CMD = 0x19,
5757
SET_DEBUG_CMD = 0x1A,
5858
GET_TEMPERATURE_CMD = 0x1B,
59+
GET_REASON_CODE_CMD = 0x1F,
5960

6061
GET_CONN_STATUS_CMD = 0x20,
6162
GET_IPADDR_CMD = 0x21,

0 commit comments

Comments
 (0)