diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..0b0eed0 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "c11", + "cppStandard": "c++17", + "intelliSenseMode": "clang-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/README.md b/README.md index fb3905c..1db27ea 100644 --- a/README.md +++ b/README.md @@ -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 [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_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) diff --git a/firmware/0x00000.bin b/firmware/0x00000.bin index a9fbf0a..0f3ea70 100644 Binary files a/firmware/0x00000.bin and b/firmware/0x00000.bin differ diff --git a/firmware/0x10000.bin b/firmware/0x10000.bin index 788962f..d59c8c7 100644 Binary files a/firmware/0x10000.bin and b/firmware/0x10000.bin differ diff --git a/firmware/sha1sums b/firmware/sha1sums index b8881ee..29c1b93 100644 --- a/firmware/sha1sums +++ b/firmware/sha1sums @@ -1,2 +1,2 @@ -834399a6fc66a609ab06b6ac58e0e371d853d256 0x00000.bin -bad4fb09c6ac1b86e06de459e570fe3aee8186e0 0x10000.bin +37945197125bf88858db1d45157f6b44bfa712be 0x00000.bin +6c2b41b31e46c4498114174796de0322d5bd7e1b 0x10000.bin diff --git a/user/cli.c b/user/cli.c index e25e2dd..0f253bf 100644 --- a/user/cli.c +++ b/user/cli.c @@ -747,20 +747,31 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) { } if (strcmp(tokens[1], "ap_password") == 0) { - if (os_strlen(tokens[2]) < 8) { - os_sprintf_flash(response, "Password to short (min. 8)\r\n"); - } else { - os_sprintf(config.ap_password, "%s", tokens[2]); - config.ap_open = 0; - os_sprintf_flash(response, "AP Password set\r\n"); - } - goto command_handled; + if (os_strlen(tokens[2]) < 8) { + os_sprintf_flash(response, "Password to short (min. 8)\r\n"); + } else { + os_sprintf(config.ap_password, "%s", tokens[2]); + config.ap_open = 0; + os_sprintf_flash(response, "AP Password set\r\n"); + } + 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) { - config.ap_open = atoi(tokens[2]); - os_sprintf_flash(response, "Open Auth set\r\n"); - goto command_handled; + config.ap_open = atoi(tokens[2]); + os_sprintf_flash(response, "Open Auth set\r\n"); + goto command_handled; } if (strcmp(tokens[1], "ap_on") == 0) { @@ -774,7 +785,6 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) { } else { os_sprintf_flash(response, "AP already on\r\n"); } - } else { if (config.ap_on) { wifi_set_opmode(STATION_MODE); diff --git a/user/config_flash.c b/user/config_flash.c index 0c459f7..eb34a83 100644 --- a/user/config_flash.c +++ b/user/config_flash.c @@ -19,6 +19,7 @@ void ICACHE_FLASH_ATTR config_load_default(sysconfig_p config) { config->auto_connect = 0; os_sprintf(config->ap_ssid, "%s", WIFI_AP_SSID); os_sprintf(config->ap_password, "%s", WIFI_AP_PASSWORD); + config->ap_channel = WIFI_AP_CHANNEL; config->ap_open = 1; config->ap_on = 1; diff --git a/user/config_flash.h b/user/config_flash.h index ec793d1..231cf74 100644 --- a/user/config_flash.h +++ b/user/config_flash.h @@ -13,7 +13,7 @@ #define FLASH_BLOCK_NO 0xc -#define MAGIC_NUMBER 0x015005fd +#define MAGIC_NUMBER 0x015034fd #define SYSTEM_OUTPUT_INFO 2 #define SYSTEM_OUTPUT_CMD 1 @@ -37,8 +37,9 @@ typedef struct uint8_t ap_ssid[32]; // SSID of the own AP 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_on; // AP enabled? + uint8_t ap_on; // AP enabled? uint8_t locked; // Should we allow for config changes uint8_t lock_password[32]; // Password of config lock diff --git a/user/user_config.h b/user/user_config.h index 171bbf5..86ab232 100644 --- a/user/user_config.h +++ b/user/user_config.h @@ -1,13 +1,14 @@ #ifndef _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_PASSWORD "password" #define WIFI_AP_SSID "MyAP" #define WIFI_AP_PASSWORD "none" +#define WIFI_AP_CHANNEL 1 #define MAX_CLIENTS 8 diff --git a/user/user_main.c b/user/user_main.c index c3d7a43..84abc78 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -659,12 +659,13 @@ void ICACHE_FLASH_ATTR user_set_softap_wifi_config(void) { os_sprintf(apConfig.ssid, "%s", config.ap_ssid); os_memset(apConfig.password, 0, 64); os_sprintf(apConfig.password, "%s", config.ap_password); + apConfig.channel = config.ap_channel; if (!config.ap_open) - apConfig.authmode = AUTH_WPA_WPA2_PSK; + apConfig.authmode = AUTH_WPA_WPA2_PSK; else - apConfig.authmode = AUTH_OPEN; + apConfig.authmode = AUTH_OPEN; + apConfig.ssid_len = 0; // or its actual length - apConfig.max_connection = MAX_CLIENTS; // how many stations can connect to ESP8266 softAP at most. // Set ESP8266 softap config