B4R Library ESP8266extras Library

bdunkleysmith

Active Member
Licensed User
Longtime User
As per the inline code in post #7 here Use of ESP8266 WiFi.BSSID in inline code
I updated the ESP8266extras library to include the function:

GetAPMacAddress

which returns the MAC address of the access point to which the ESP8266 is connected.

The library updated to version 1.06 is attached.

Usage:

B4X:
Sub Process_Globals

    Private MacArray(6) As Byte

End Sub

Sub ConnectToNetwork

        esp.GetAPMacAddress(MacArray)
        Log("MAC address of AP connected to: ", bc.HexFromBytes(MacArray))

End Sub
 

Attachments

  • rESP8266extras 1-06.zip
    9.4 KB · Views: 410
Last edited:

BertI

Member
Licensed User
Longtime User
I have tried using the following inline C to get the current WiFi mode:
B4X:
  void WiFiGetMode(B4R::Object* o) {
  b4r_main::_wifimode = WiFi.getMode();
  }
However the results from this seem not to be the same as the values used in the rESP8266extras library. Specifically, in the library, AP mode has a value of 1 and STA mode a value of 2 whereas the values returned by the code above are 2 and 1 respectively. Although I can see the switch statement in the library's cpp file I don't know where the constants WIFI_AP and WIFI_STA are defined. I noted that at the AT command level the ESP8266 documentation defines Station mode as a value of 1 and AP mode a value of 2 (so like the return from the inline C). Is there a reason for this discrepancy?
 

Starchild

Active Member
Licensed User
Longtime User

Yes. The WIFI_MODE_AP and WIFI_MODE_STA constants declared in the rESP8266extras library were swapped by mistake. This wouldn't have caused any problems calling the declared functions in ESP826extras, but they did not match those returned by Wifi.getMode();

I have updated the library in the top post to v1.06 and fixed this mistake.
 

BertI

Member
Licensed User
Longtime User
Ah yes, thanks, I understand now. BTW there is already a version 1.06 (post 22) which contains additional functions introduced by another user so maybe have to incorporate these into your update and make into v1.07?
 

Starchild

Active Member
Licensed User
Longtime User
Ah yes, thanks, I understand now. BTW there is already a version 1.06 (post 22) which contains additional functions introduced by another user so maybe have to incorporate these into your update and make into v1.07?
Yep. I grabbed the v1.06 from post 22 and made the same changes to that one.
Now updated this new version 1.07 in my top post of this tread.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…