How to connect WiFi with certain channel?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
VladVons
Posts: 43
Joined: Sun Feb 12, 2017 6:49 pm
Location: Ukraine

How to connect WiFi with certain channel?

Post by VladVons » Sun Mar 15, 2020 12:54 pm

to speed up WiFi connection router should receive from ESP:
static IP, bssid, channel number

1) How to get from successful WiFi connection following data?
- channel number
- bssid

2) How to connect WiFi with certain channel number?
connect() has no such parameter

User avatar
jimmo
Posts: 1381
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: How to connect WiFi with certain channel?

Post by jimmo » Mon Mar 16, 2020 3:04 am

VladVons wrote:
Sun Mar 15, 2020 12:54 pm
connect() has no such parameter
I don't believe this is possible on the ESP8266 -- the config structure that MicroPython passes to the underlying WiFi APIs has no way to specify the channel.

Edit: Actually this is possible. You could implement this quite easily in ports/esp8266/modnetwork.c:

Code: Select all

STATIC mp_obj_t esp_connect(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
Add a channel kwarg, then you can add a call to wifi_set_channel(channel);

User avatar
jimmo
Posts: 1381
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: How to connect WiFi with certain channel?

Post by jimmo » Mon Mar 16, 2020 3:36 am

See https://github.com/esp8266/Arduino/blob ... A.cpp#L127 for a reference of how to use these APIs.

Post Reply