Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WiFiMulti and ESPhost STA connection w/BSSID #2001

Merged
merged 1 commit into from
Feb 12, 2024
Merged

Conversation

earlephilhower
Copy link
Owner

WiFiMulti specifies a specific BSSID, in addition to the AP name and password. In the WiFi core the BSSID is stored as the raw 6-byte MAC address, but the ESPHostedFG firmware expects a formatted C-String (i.e. "ab:cd:ef:01:02:03" instead of {0xab, 0xcd, 0xef, 1, 2, 3})

Convert the raw bytes to the string format expected in the ESP FW.

WiFiMulti specifies a specific BSSID, in addition to the AP name and
password.  In the WiFi core the BSSID is stored as the raw 6-byte MAC
address, but the ESPHostedFG firmware expects a formatted C-String
(i.e. "ab:cd:ef:01:02:03" instead of {0xab, 0xcd, 0xef, 1, 2, 3})

Convert the raw bytes to the string format expected in the ESP FW.
@earlephilhower earlephilhower merged commit 40e52f8 into master Feb 12, 2024
13 checks passed
@JAndrassy
Copy link
Contributor

it doesn't connect now without bssid specified, because it can't connect to 00:00:00:00:00:00

@earlephilhower
Copy link
Owner Author

Ah, poop. Can you try this diff?

My setup is literally two USB based dev boards with multiple USB cables and about 8 dupont wires of different lengths but identical colors between the two and I just cleaned my desk so don't trust the wiring stuck. :(

diff --git a/libraries/lwIP_ESPHost/src/lwIP_ESPHost.cpp b/libraries/lwIP_ESPHost/src/lwIP_ESPHost.cpp
index 43f505749..d3b13f46b 100644
--- a/libraries/lwIP_ESPHost/src/lwIP_ESPHost.cpp
+++ b/libraries/lwIP_ESPHost/src/lwIP_ESPHost.cpp
@@ -51,7 +51,7 @@ void ESPHostLwIP::setSSID(const char *ssid) {
 }
 
 void ESPHostLwIP::setBSSID(const uint8_t *bssid) {
-    if (bssid == nullptr) {
+    if (bssid == nullptr || !(bssid[0] | bssid[1] | bssid[2] | bssid[3] | bssid[4] | !bssid[5])) {
         ap.bssid[0] = 0;
     } else {
         snprintf((char *)ap.bssid, sizeof(ap.bssid), "%02x:%02x:%02x:%02x:%02x:%02x", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]);

@JAndrassy
Copy link
Contributor

yes it works. only remove the ! next to bssid[5]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants