Added AP channel config

master
martin-ger 2019-01-27 17:37:33 +01:00
rodzic 2d613c3f90
commit 3e1e72f763
10 zmienionych plików z 51 dodań i 20 usunięć

16
.vscode/c_cpp_properties.json vendored 100644
Wyświetl plik

@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}

Wyświetl plik

@ -48,6 +48,7 @@ WiFi and network related commands:
- set [ssid|password] _value_: changes the settings for the uplink AP (WiFi config of your home-router) - set [ssid|password] _value_: changes the settings for the uplink AP (WiFi config of your home-router)
- set [ap_ssid|ap_password] _value_: changes the settings for the soft-AP of the ESP (for your stations) - set [ap_ssid|ap_password] _value_: changes the settings for the soft-AP of the ESP (for your stations)
- set ap_channel [1-13]: sets the channel of the SoftAP (default 1)
- set ap_on [0|1]: selects, whether the soft-AP is disabled (ap_on=0) or enabled (ap_on=1, default) - set ap_on [0|1]: selects, whether the soft-AP is disabled (ap_on=0) or enabled (ap_on=1, default)
- set ap_open [0|1]: selects, whether the soft-AP uses WPA2 security (ap_open=0, automatic, if an ap_password is set) or open (ap_open=1) - set ap_open [0|1]: selects, whether the soft-AP uses WPA2 security (ap_open=0, automatic, if an ap_password is set) or open (ap_open=1)
- set auto_connect [0|1]: selects, whether the WiFi client should automatically retry to connect to the uplink AP (default: on=1) - set auto_connect [0|1]: selects, whether the WiFi client should automatically retry to connect to the uplink AP (default: on=1)

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -1,2 +1,2 @@
834399a6fc66a609ab06b6ac58e0e371d853d256 0x00000.bin 37945197125bf88858db1d45157f6b44bfa712be 0x00000.bin
bad4fb09c6ac1b86e06de459e570fe3aee8186e0 0x10000.bin 6c2b41b31e46c4498114174796de0322d5bd7e1b 0x10000.bin

Wyświetl plik

@ -747,20 +747,31 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) {
} }
if (strcmp(tokens[1], "ap_password") == 0) { if (strcmp(tokens[1], "ap_password") == 0) {
if (os_strlen(tokens[2]) < 8) { if (os_strlen(tokens[2]) < 8) {
os_sprintf_flash(response, "Password to short (min. 8)\r\n"); os_sprintf_flash(response, "Password to short (min. 8)\r\n");
} else { } else {
os_sprintf(config.ap_password, "%s", tokens[2]); os_sprintf(config.ap_password, "%s", tokens[2]);
config.ap_open = 0; config.ap_open = 0;
os_sprintf_flash(response, "AP Password set\r\n"); os_sprintf_flash(response, "AP Password set\r\n");
} }
goto command_handled; goto command_handled;
} }
if (strcmp(tokens[1],"ap_channel") == 0) {
uint8_t chan = atoi(tokens[2]);
if (chan >= 1 && chan <= 13) {
config.ap_channel = chan;
os_sprintf(response, "AP channel set to %d\r\n", config.ap_channel);
} else {
os_sprintf_flash(response, "Invalid channel (1-13)\r\n");
}
goto command_handled;
}
if (strcmp(tokens[1], "ap_open") == 0) { if (strcmp(tokens[1], "ap_open") == 0) {
config.ap_open = atoi(tokens[2]); config.ap_open = atoi(tokens[2]);
os_sprintf_flash(response, "Open Auth set\r\n"); os_sprintf_flash(response, "Open Auth set\r\n");
goto command_handled; goto command_handled;
} }
if (strcmp(tokens[1], "ap_on") == 0) { if (strcmp(tokens[1], "ap_on") == 0) {
@ -774,7 +785,6 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) {
} else { } else {
os_sprintf_flash(response, "AP already on\r\n"); os_sprintf_flash(response, "AP already on\r\n");
} }
} else { } else {
if (config.ap_on) { if (config.ap_on) {
wifi_set_opmode(STATION_MODE); wifi_set_opmode(STATION_MODE);

Wyświetl plik

@ -19,6 +19,7 @@ void ICACHE_FLASH_ATTR config_load_default(sysconfig_p config) {
config->auto_connect = 0; config->auto_connect = 0;
os_sprintf(config->ap_ssid, "%s", WIFI_AP_SSID); os_sprintf(config->ap_ssid, "%s", WIFI_AP_SSID);
os_sprintf(config->ap_password, "%s", WIFI_AP_PASSWORD); os_sprintf(config->ap_password, "%s", WIFI_AP_PASSWORD);
config->ap_channel = WIFI_AP_CHANNEL;
config->ap_open = 1; config->ap_open = 1;
config->ap_on = 1; config->ap_on = 1;

Wyświetl plik

@ -13,7 +13,7 @@
#define FLASH_BLOCK_NO 0xc #define FLASH_BLOCK_NO 0xc
#define MAGIC_NUMBER 0x015005fd #define MAGIC_NUMBER 0x015034fd
#define SYSTEM_OUTPUT_INFO 2 #define SYSTEM_OUTPUT_INFO 2
#define SYSTEM_OUTPUT_CMD 1 #define SYSTEM_OUTPUT_CMD 1
@ -37,8 +37,9 @@ typedef struct
uint8_t ap_ssid[32]; // SSID of the own AP uint8_t ap_ssid[32]; // SSID of the own AP
uint8_t ap_password[64]; // Password of the own network uint8_t ap_password[64]; // Password of the own network
uint8_t ap_channel; // Channel of the AP
uint8_t ap_open; // Should we use no WPA? uint8_t ap_open; // Should we use no WPA?
uint8_t ap_on; // AP enabled? uint8_t ap_on; // AP enabled?
uint8_t locked; // Should we allow for config changes uint8_t locked; // Should we allow for config changes
uint8_t lock_password[32]; // Password of config lock uint8_t lock_password[32]; // Password of config lock

Wyświetl plik

@ -1,13 +1,14 @@
#ifndef _USER_CONFIG_ #ifndef _USER_CONFIG_
#define _USER_CONFIG_ #define _USER_CONFIG_
#define ESP_UBROKER_VERSION "V2.0.8" #define ESP_UBROKER_VERSION "V2.0.9"
#define WIFI_SSID "ssid" #define WIFI_SSID "ssid"
#define WIFI_PASSWORD "password" #define WIFI_PASSWORD "password"
#define WIFI_AP_SSID "MyAP" #define WIFI_AP_SSID "MyAP"
#define WIFI_AP_PASSWORD "none" #define WIFI_AP_PASSWORD "none"
#define WIFI_AP_CHANNEL 1
#define MAX_CLIENTS 8 #define MAX_CLIENTS 8

Wyświetl plik

@ -659,12 +659,13 @@ void ICACHE_FLASH_ATTR user_set_softap_wifi_config(void) {
os_sprintf(apConfig.ssid, "%s", config.ap_ssid); os_sprintf(apConfig.ssid, "%s", config.ap_ssid);
os_memset(apConfig.password, 0, 64); os_memset(apConfig.password, 0, 64);
os_sprintf(apConfig.password, "%s", config.ap_password); os_sprintf(apConfig.password, "%s", config.ap_password);
apConfig.channel = config.ap_channel;
if (!config.ap_open) if (!config.ap_open)
apConfig.authmode = AUTH_WPA_WPA2_PSK; apConfig.authmode = AUTH_WPA_WPA2_PSK;
else else
apConfig.authmode = AUTH_OPEN; apConfig.authmode = AUTH_OPEN;
apConfig.ssid_len = 0; // or its actual length apConfig.ssid_len = 0; // or its actual length
apConfig.max_connection = MAX_CLIENTS; // how many stations can connect to ESP8266 softAP at most. apConfig.max_connection = MAX_CLIENTS; // how many stations can connect to ESP8266 softAP at most.
// Set ESP8266 softap config // Set ESP8266 softap config