File tree 4 files changed +23
-5
lines changed
4 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -716,14 +716,23 @@ String WiFiSTAClass::psk() const
716
716
* Return the current bssid / mac associated with the network if configured
717
717
* @return bssid uint8_t *
718
718
*/
719
- uint8_t * WiFiSTAClass::BSSID (void )
719
+ uint8_t * WiFiSTAClass::BSSID (uint8_t * buff )
720
720
{
721
721
static uint8_t bssid[6 ];
722
722
wifi_ap_record_t info;
723
723
if (WiFiGenericClass::getMode () == WIFI_MODE_NULL){
724
724
return NULL ;
725
725
}
726
- if (!esp_wifi_sta_get_ap_info (&info)) {
726
+ esp_err_t err = esp_wifi_sta_get_ap_info (&info);
727
+ if (buff != NULL ) {
728
+ if (err) {
729
+ memset (buff, 0 , 6 );
730
+ } else {
731
+ memcpy (buff, info.bssid , 6 );
732
+ }
733
+ return buff;
734
+ }
735
+ if (!err) {
727
736
memcpy (bssid, info.bssid , 6 );
728
737
return reinterpret_cast <uint8_t *>(bssid);
729
738
}
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ class WiFiSTAClass
98
98
String SSID () const ;
99
99
String psk () const ;
100
100
101
- uint8_t * BSSID ();
101
+ uint8_t * BSSID (uint8_t * bssid = NULL );
102
102
String BSSIDstr ();
103
103
104
104
int8_t RSSI ();
Original file line number Diff line number Diff line change @@ -243,11 +243,20 @@ int32_t WiFiScanClass::RSSI(uint8_t i)
243
243
/* *
244
244
* return MAC / BSSID of scanned wifi
245
245
* @param i specify from which network item want to get the information
246
+ * @param buff optional buffer for the result uint8_t array with length 6
246
247
* @return uint8_t * MAC / BSSID of scanned wifi
247
248
*/
248
- uint8_t * WiFiScanClass::BSSID (uint8_t i)
249
+ uint8_t * WiFiScanClass::BSSID (uint8_t i, uint8_t * buff )
249
250
{
250
251
wifi_ap_record_t * it = reinterpret_cast <wifi_ap_record_t *>(_getScanInfoByIndex (i));
252
+ if (buff != NULL ) {
253
+ if (!it) {
254
+ memset (buff, 0 , 6 );
255
+ } else {
256
+ memcpy (buff, it->bssid , 6 );
257
+ }
258
+ return buff;
259
+ }
251
260
if (!it) {
252
261
return 0 ;
253
262
}
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ class WiFiScanClass
42
42
String SSID (uint8_t networkItem);
43
43
wifi_auth_mode_t encryptionType (uint8_t networkItem);
44
44
int32_t RSSI (uint8_t networkItem);
45
- uint8_t * BSSID (uint8_t networkItem);
45
+ uint8_t * BSSID (uint8_t networkItem, uint8_t * bssid = NULL );
46
46
String BSSIDstr (uint8_t networkItem);
47
47
int32_t channel (uint8_t networkItem);
48
48
static void * getScanInfoByIndex (int i) { return _getScanInfoByIndex (i); };
You can’t perform that action at this time.
0 commit comments