1

I have been working for a while with the ESP8266 I have a question:

According to the online documentation of GitHub from the esp8266wifi library I can initialize the WiFi in Station mode to (obviously) connect to a nearby AP, I can initialize the station mode in 3 "different ways":

  • WiFi.begin (): The module initializes the Station mode and connects to the last network that is connected, because the credentials (SSID and Password) are stored in its internal memory (flash?).

  • WiFi.begin (ssid, password): The module initializes the Station mode and connects to the network with "ssid" and "password".

  • WiFi.begin (ssid, password, channel, bssid, connect): The same as the previous one, only that you pass more parameters: the one that interests me is the bssid, which is the MAC address of the AP to which I am going to connect.

Now comes the question: if I wanted to use the last mode, because I want to make sure that the ESP connects ONLY to an AP (a kind of MAC filtering), I also have to specify the channel and set the connect parameter? Or I can simply use something like this:

WiFi.begin ("MyOwnNetwork", "123456789", "00: 1B: 44: 11: 3A: B7")

I can not prove it right now, I do not have the module in my hands.

gre_gor
1,6824 gold badges18 silver badges28 bronze badges
asked Feb 23, 2018 at 14:21
5
  • type of parameter bssid is const uint8_t* (byte array) Commented Feb 23, 2018 at 15:14
  • the configuration is saved to flash media.readthedocs.org/pdf/arduino-esp8266/docs_to_readthedocs/… Commented Feb 23, 2018 at 15:17
  • the configuration is saved including the bssid Commented Feb 23, 2018 at 15:19
  • What do you mean with: "type of parameter bssid is const uint8_t* (byte array)", the way I wrote the sentence is wrong? Could you give some example? Thanks! Commented Feb 23, 2018 at 15:42
  • anything inside quote marks "" is a string .... google c++ byte array ... stackoverflow.com/questions/2240405/byte-array-assignment Commented Feb 23, 2018 at 18:10

1 Answer 1

0

This is the function prototype:

Function

Per C++ rules, in order to supply an argument for bssid, you have to pass an argument for channel as well, but connect is optional since it's positioned after your target argument. This should not be a problem though since you can just pass the default value of channel (i.e. 0) into the function; the channel argument is only relevant if you enter a value between 1 and 13 inclusive.

So your call should basically look like:

char ssid[] = "ssid";
char pwd[] = "pwd";
uint8_t bssid[] = {0x00, 0x1b, 0x44, 0x11, 0x3a, 0xb7};
WiFi.begin(ssid, pwd, 0, bssid);
answered Feb 23, 2018 at 17:42
1
  • Great answer!!! Just the one I was looking for!!! Thanks!!!!! Commented Feb 23, 2018 at 18:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.