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

Make WiFi maximum TX power configurable #947

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions airrohr-firmware/airrohr-cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum ConfigShapeId {
Config_current_lang,
Config_wlanssid,
Config_wlanpwd,
Config_wlanpower,
Config_www_username,
Config_www_password,
Config_fs_ssid,
Expand Down Expand Up @@ -97,6 +98,7 @@ enum ConfigShapeId {
static constexpr char CFG_KEY_CURRENT_LANG[] PROGMEM = "current_lang";
static constexpr char CFG_KEY_WLANSSID[] PROGMEM = "wlanssid";
static constexpr char CFG_KEY_WLANPWD[] PROGMEM = "wlanpwd";
static constexpr char CFG_KEY_WLANPOWER[] PROGMEM = "wlanpower";
static constexpr char CFG_KEY_WWW_USERNAME[] PROGMEM = "www_username";
static constexpr char CFG_KEY_WWW_PASSWORD[] PROGMEM = "www_password";
static constexpr char CFG_KEY_FS_SSID[] PROGMEM = "fs_ssid";
Expand Down Expand Up @@ -166,6 +168,7 @@ static constexpr ConfigShapeEntry configShape[] PROGMEM = {
{ Config_Type_String, sizeof(cfg::current_lang)-1, CFG_KEY_CURRENT_LANG, cfg::current_lang },
{ Config_Type_String, sizeof(cfg::wlanssid)-1, CFG_KEY_WLANSSID, cfg::wlanssid },
{ Config_Type_Password, sizeof(cfg::wlanpwd)-1, CFG_KEY_WLANPWD, cfg::wlanpwd },
{ Config_Type_Bool, 0, CFG_KEY_WLANPOWER, &cfg::wlanpower },
{ Config_Type_String, sizeof(cfg::www_username)-1, CFG_KEY_WWW_USERNAME, cfg::www_username },
{ Config_Type_Password, sizeof(cfg::www_password)-1, CFG_KEY_WWW_PASSWORD, cfg::www_password },
{ Config_Type_String, sizeof(cfg::fs_ssid)-1, CFG_KEY_FS_SSID, cfg::fs_ssid },
Expand Down
1 change: 1 addition & 0 deletions airrohr-firmware/airrohr-cfg.h.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
String current_lang
String wlanssid
Password wlanpwd
Bool wlanpower
String www_username
Password www_password
String fs_ssid
Expand Down
10 changes: 7 additions & 3 deletions airrohr-firmware/airrohr-firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ namespace cfg {
char www_username[LEN_WWW_USERNAME];
char www_password[LEN_CFG_PASSWORD];

// wifi credentials
// wifi settings
char wlanssid[LEN_WLANSSID];
char wlanpwd[LEN_CFG_PASSWORD];
bool wlanpower = true;

char static_ip[16];
char static_subnet[16];
Expand Down Expand Up @@ -1113,6 +1114,7 @@ static void webserver_config_send_body_get(String& page_content) {
server.sendContent(page_content);
page_content = emptyString;

add_form_checkbox(Config_wlanpower, FPSTR(INTL_WIFI_TXPOWER));
add_form_checkbox(Config_www_basicauth_enabled, FPSTR(INTL_BASICAUTH));
page_content += FPSTR(TABLE_TAG_OPEN);
add_form_input(page_content, Config_www_username, FPSTR(INTL_USER), LEN_WWW_USERNAME-1);
Expand Down Expand Up @@ -2179,8 +2181,10 @@ static void connectWifi() {
#if defined(ESP8266)
// Enforce Rx/Tx calibration
system_phy_set_powerup_option(1);
// 20dBM == 100mW == max tx power allowed in europe
WiFi.setOutputPower(20.0f);
if (cfg::wlanpower) {
// 20dBM == 100mW == max tx power allowed in europe
WiFi.setOutputPower(20.0f);
}
WiFi.setSleepMode(WIFI_NONE_SLEEP);
WiFi.setPhyMode(WIFI_PHY_MODE_11N);
delay(100);
Expand Down
1 change: 1 addition & 0 deletions airrohr-firmware/intl_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const char INTL_HEIGHT_ABOVE_SEALEVEL[] PROGMEM = "Above sea level (m)";
const char INTL_PRESSURE_AT_SEALEVEL[] PROGMEM = "pressure at sea level";
const char INTL_NEO6M[] PROGMEM = "GPS (NEO 6M)";
const char INTL_BASICAUTH[] PROGMEM = "Authentication";
const char INTL_WIFI_TXPOWER[] PROGMEM = "Maximum WiFi power";
#define INTL_REPORT_ISSUE "Report an issue"

const char INTL_FS_WIFI_DESCRIPTION[] PROGMEM = "WiFi Sensor in configuration mode";
Expand Down
1 change: 1 addition & 0 deletions airrohr-firmware/intl_nl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const char INTL_TEMP_CORRECTION[] PROGMEM = "Correctie in °C";
const char INTL_HEIGHT_ABOVE_SEALEVEL[] PROGMEM = "Hoogte boven zeeniveau (m)";
const char INTL_PRESSURE_AT_SEALEVEL[] PROGMEM = "Luchtdruk op zeeniveau";
const char INTL_NEO6M[] PROGMEM = "GPS (NEO 6M)";
const char INTL_WIFI_TXPOWER[] PROGMEM = "Maximaal WiFi-vermogen";
const char INTL_BASICAUTH[] PROGMEM = "Toegang beperken";
#define INTL_REPORT_ISSUE "Een probleem melden"

Expand Down