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

Implement BSSID #15

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ivanhercaz
Copy link
Collaborator

@ivanhercaz ivanhercaz commented Sep 30, 2024

Hi @ogabrielinacio,
In one of my projects I need to check the BSSID of the WiFi networks of the scan results. I research the ESP32 firmware I am using and it seems ESP32 manage the BSSID internally in case it is required and ESP32 also seems to return the BSSID in the scan results.

Then I research a bit more and it seems the default behavior, so the ESP32 apparently always send the BSSID of each scanned network.

In the code of this package, it seems easy to implement the BSSID, because it is already available in the proto code and it seems correctly generated by you (take a quick lookup to the search results of "bssid".

Tasks

  • Get the BSSID of a network in the scan results.
  • Send configuration with the BSSID in case it is provided.
  • Test nothing is broken!
  • Update example.
  • Update docs.
  • Update changelog and release version.

Get the BSSID in the scan results

I think the first step must be to get the BSSID of a network in the scan results:

message WiFiScanResult {
bytes ssid = 1;
uint32 channel = 2;
int32 rssi = 3;
bytes bssid = 4;
WifiAuthMode auth = 5;
}

So it seems as easy as to add the bssid parameter in the WifiAP mode and then decode entry.bssid in the scanResultResponse method, where a network is added to the scan results.

I already did this in the commit 1ad70dc of this PR.

Malformed UTF8

However, it seems the obtained bssid can't be decoded because of a FormatException. For example, in one of my networks I am getting this [80, 145, 227, 205, 77, 243] for the entry.bssid and, when trying to decode it:

FormatException: Unexpected extension byte (at offset 1)

What I think it is that I must be misunderstanding something, but I think you know better the internals of this package and how works the ESP32 provisioning, and maybe you see it and catch it!

Both, ssid and bssid, seems to be the same type, a list of bytes that must be decoded according to the proto and according to the generateds files.

I also check if it happens with one network, what could indicates a bad configuration of a specific network, or if it happens with any network. And it happens with any network.

Update:

I think I have made some progress! utf8.decode may not work because a BSSID is represented as a MAC, the bytes are representing a hexadecimal composition, as Wikipedia's article for MAC address describes:

As typically represented, MAC addresses are recognizable as six groups of two hexadecimal digits, separated by hyphens, colons, or without a separator.

I decode manually one bssid I get from the log using:

var bssid =
    [80, 145, 227, 205, 77, 243].map((e) => e.toRadixString(16)).toList();

As it was just a test, I am going to develop a little decode function for this case and check how to implement the rest of the stuff in the package.

Update:

Issue solved, check the comment #15 (comment) and the commit 73af8bd.

@ivanhercaz ivanhercaz added enhancement New feature or request help wanted Extra attention is needed labels Sep 30, 2024
@ivanhercaz ivanhercaz self-assigned this Sep 30, 2024
@ivanhercaz
Copy link
Collaborator Author

ivanhercaz commented Sep 30, 2024

73af8bd implements _decodeBssid as I suggested at the end of the main PR's message. Now I am going to continue with the use of this BSSID.

This commit also adds the method `_encodeBssid` to conver the hexadecimal string into its binary form.
@ivanhercaz
Copy link
Collaborator Author

With b41180b I achieve to send the WiFi configuration to the ESP32 in case it is provided without fails by the application side nor by the ESP32 firmware. At least, at this step, all seems to work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant