B4R Library ESP8266extras Library

Siam

Active Member
Licensed User
i found a issue if the esp core library 2.4.2 is installed the following error message appears:

rESP8266extras.cpp.o:(.text._ZN3B4R16B4RESP8266extras10ConnectWPSEv+0x8): undefined reference to `WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool'

now i switched back to core 2.4.1 and all works fine
 

bdunkleysmith

Active Member
Licensed 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

Last edited:

BertI

Member
Licensed 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
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?
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
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.
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
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.
 
Top