Why not make esp_wifi_set_country take only the cc code?

axellin
Posts: 200
Joined: Mon Sep 17, 2018 9:09 am

Why not make esp_wifi_set_country take only the cc code?

Postby axellin » Mon Dec 09, 2019 9:10 am

Hi,
The esp_wifi_set_country takes const wifi_country_t *country as argument.
This seems a little bit odd because the caller needs to set all fields
of wifi_country_t.
I thought the schan/nchan/max_tx_power fields are fixed and determinate by
the cc fields. Why not just take cc fields as argument. (or maybe just cc and policy fields).

In additional, I'm wondering why not using enum for the cc field instead of
char. It's easier to find the supported country code by enum instead of guessing
the supported char field for cc.

ESP_Sprite
Posts: 9732
Joined: Thu Nov 26, 2015 4:08 am

Re: Why not make esp_wifi_set_country take only the cc code?

Postby ESP_Sprite » Tue Dec 10, 2019 3:54 am

Because this would imply having a database of country codes and parameters that gets linked within every project compiled with ESP-IDF. The merits and disadvantages of having such a database can be discussed, but at the moment it is not implemented so you need to supply all parameters by hand.

axellin
Posts: 200
Joined: Mon Sep 17, 2018 9:09 am

Re: Why not make esp_wifi_set_country take only the cc code?

Postby axellin » Tue Dec 10, 2019 5:39 am

Is there any good reference for the settings of each count code?
i.e. cc/schan/nchan/max_tx_power fields

ESP_Sprite
Posts: 9732
Joined: Thu Nov 26, 2015 4:08 am

Re: Why not make esp_wifi_set_country take only the cc code?

Postby ESP_Sprite » Wed Dec 11, 2019 3:02 am

You could look at e.g. the database the Linux people maintain.

andyn_ff
Posts: 18
Joined: Mon Jun 10, 2019 4:34 pm

Re: Why not make esp_wifi_set_country take only the cc code?

Postby andyn_ff » Wed Sep 20, 2023 5:15 pm

This is an old thread but the information here is useful to me. Please could you help me check my understanding as I think the current situation has changed since the above answers.

Now there is a 'esp_wifi_set_country_code' API and esp_wifi.h contains a warning to use esp_wifi_set_country_code instead of esp_wifi_set_country because esp_wifi_set_country_code validates the per-country rules. I think this means that ESP-IDF now uses a database of the regulatory rules for each country code.

Is there any info for the database that ESP-IDF uses? Can I assume safely that it is the same as the database documented by the linux kernel project that Sprite linked above? https://git.kernel.org/pub/scm/linux/ke ... ree/db.txt

Who is online

Users browsing this forum: cdollar and 117 guests