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 @@ -717,14 +717,23 @@ String WiFiSTAClass::psk() const
717
717
* Return the current bssid / mac associated with the network if configured
718
718
* @return bssid uint8_t *
719
719
*/
720
- uint8_t * WiFiSTAClass::BSSID (void )
720
+ uint8_t * WiFiSTAClass::BSSID (uint8_t * buff )
721
721
{
722
722
static uint8_t bssid[6 ];
723
723
wifi_ap_record_t info;
724
724
if (WiFiGenericClass::getMode () == WIFI_MODE_NULL){
725
725
return NULL ;
726
726
}
727
- if (!esp_wifi_sta_get_ap_info (&info)) {
727
+ esp_err_t err = esp_wifi_sta_get_ap_info (&info);
728
+ if (buff != NULL ) {
729
+ if (err) {
730
+ memset (buff, 0 , 6 );
731
+ } else {
732
+ memcpy (buff, info.bssid , 6 );
733
+ }
734
+ return buff;
735
+ }
736
+ if (!err) {
728
737
memcpy (bssid, info.bssid , 6 );
729
738
return reinterpret_cast <uint8_t *>(bssid);
730
739
}
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