From 58093484e13d9e87d9030ca66436768a17308b3e Mon Sep 17 00:00:00 2001 From: pvvx Date: Mon, 24 Apr 2017 17:04:01 +0300 Subject: [PATCH] update --- WEBFiles/protect/wifi.htm | 16 +++---- flasher/file_info.jlink | 2 +- project/inc/wifi_user_set.h | 71 ++++++++++++++---------------- project/src/console/wifi_console.c | 8 +++- sdkset.mk | 1 + 5 files changed, 51 insertions(+), 47 deletions(-) diff --git a/WEBFiles/protect/wifi.htm b/WEBFiles/protect/wifi.htm index b2b615e..4963fd8 100644 --- a/WEBFiles/protect/wifi.htm +++ b/WEBFiles/protect/wifi.htm @@ -56,14 +56,14 @@ Auth Mode: diff --git a/flasher/file_info.jlink b/flasher/file_info.jlink index 103fba5..5143885 100644 --- a/flasher/file_info.jlink +++ b/flasher/file_info.jlink @@ -1,5 +1,5 @@ define call1 -set $ImageSize = 0xF140 +set $ImageSize = 0xF120 set $ImageAddr = 0x0D0000 end define call2 diff --git a/project/inc/wifi_user_set.h b/project/inc/wifi_user_set.h index 9448192..6ebc0c6 100644 --- a/project/inc/wifi_user_set.h +++ b/project/inc/wifi_user_set.h @@ -10,60 +10,57 @@ //========================================= //==== Wlan Config ======================== -#define DEF_WIFI_MODE RTW_MODE_STA // RTW_MODE_STA_AP, RTW_MODE_AP, RTW_MODE_STA -#define DEF_WIFI_AP_STATIONS 3 // Max number of STAs, should be 1..3, default is 3 -#define DEF_WIFI_COUNTRY RTW_COUNTRY_RU +#define DEF_WIFI_MODE RTW_MODE_STA // Стартовый режим WiFi: RTW_MODE_STA_AP, RTW_MODE_AP, RTW_MODE_STA, RTW_MODE_NONE +#define DEF_WIFI_AP_STATIONS 3 // Max number of STAs, should be 1..3, default is 3 +#define DEF_WIFI_COUNTRY RTW_COUNTRY_RU // Регион использования WiFi... #define DEF_WIFI_TX_PWR RTW_TX_PWR_PERCENTAGE_25 // RTW_TX_PWR_PERCENTAGE_75 // RTW_TX_PWR_PERCENTAGE_100 #define DEF_WIFI_BGN RTW_NETWORK_BGN // rtw_network_mode_t -#define DEF_WIFI_ST_SLEEP 0 // 0 - none, 1 - on -//#define USE_NETBIOS 3 // 0 - off, 1 - ST, 2 - AP, 3 - AP+ST -#define DEF_LOAD_CFG ( 0 \ - | BID_WIFI_AP_CFG \ - | BID_WIFI_ST_CFG \ - | BID_AP_DHCP_CFG \ - | BID_ST_DHCP_CFG )//\ -// | BID_WIFI_CFG \ -//) -#define DEF_SAVE_CFG ( 0 \ - | BID_WIFI_AP_CFG \ - | BID_WIFI_ST_CFG \ - | BID_AP_DHCP_CFG \ - | BID_ST_DHCP_CFG \ - | BID_WIFI_CFG \ -) +#define DEF_WIFI_ST_SLEEP 0 // 0 - none, 1 - on + +/* Опции загрузки конфигов по старту */ +//#define DEF_LOAD_CFG 0 // старт в назначенном конфигами режиме по умолчанию +//#define DEF_LOAD_CFG BID_ALL_WIFI_CFG // старт в назначенном конфигами режиме по умолчанию, с загрузками последних конфигураций ST и AP +#define DEF_LOAD_CFG (BID_ALL_WIFI_CFG | BID_WIFI_CFG) // старт в записанном режиме + +/* Опции разрешения записи конфигов по упешному соединению или выполнению операции установок режимов WiFi без ошибок */ +#define DEF_SAVE_CFG (BID_ALL_WIFI_CFG | BID_WIFI_CFG) // сохранение по успешному соединению/выполненю для всех конфигов: + // (для ST или AP пишутся раздельно) с проверкой на изменения //==== Interface 0 - wlan0 = AP =========== #define DEF_AP_SSID "RTL871X" #define DEF_AP_PASSWORD "0123456789" -/* RTW_SECURITY_OPEN - Open Security +/* Варианты типов Security для AP: + RTW_SECURITY_OPEN - Open Security RTW_SECURITY_WPA_TKIP_PSK - WPA Security RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers - WEP security is NOT IMPLEMENTED. It is NOT SECURE! */ -#define DEF_AP_SECURITY RTW_SECURITY_WPA2_AES_PSK -#define DEF_AP_BEACON 100 // 100...6000 ms -#define DEF_AP_CHANNEL 1 // 1..14 -#define DEF_AP_CHANNEL 1 // 1..14 -#define DEF_AP_DHCP_MODE 1 // =0 dhcp off, =1 - dhcp on + RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers */ +#define DEF_AP_SECURITY RTW_SECURITY_WPA2_AES_PSK // WEP security is NOT IMPLEMENTED. It is NOT SECURE! +#define DEF_AP_BEACON 100 // 100...6000 ms +#define DEF_AP_CHANNEL 1 // 1..14 +#define DEF_AP_CHANNEL 1 // 1..14 +#define DEF_AP_DHCP_MODE 1 // =0 dhcp off, =1 - dhcp on #define DEF_AP_IP IP4ADDR(192,168,4,1) #define DEF_AP_MSK IP4ADDR(255,255,255,0) #define DEF_AP_GW IP4ADDR(192,168,4,1) -#define DEF_AP_DHCP_START 2 -#define DEF_AP_DHCP_STOP 15 +#define DEF_AP_DHCP_START 2 // DHCP ip start xx.xx.xx.nn +#define DEF_AP_DHCP_STOP 15 // DHCP ip stop xx.xx.xx.nn //==== Interface 1 - wlan1 = STA ========== -#define DEF_ST_SSID "HOMEAP" -#define DEF_ST_PASSWORD "0123456789" -#define DEF_ST_SECURITY RTW_SECURITY_WPA_WPA2_MIXED +#define DEF_ST_SSID "HOMEAP" // Имя SSID AP (роутера) для присоединения по умолчанию (первый старт) +#define DEF_ST_PASSWORD "0123456789" // Пароль AP (роутера) для присоединения по умолчанию (первый старт) +#define DEF_ST_SECURITY RTW_SECURITY_WPA_WPA2_MIXED // Тип Security #define DEF_ST_BSSID { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } // If bssid set is not ff.ff.ff.ff.ff.ff, // station will connect to the router with both ssid[] and bssid[] matched. -#define DEF_ST_CHANNEL 1 // 1..14 -#define DEF_ST_AUTORECONNECT 1 // 0 - none, 1..254 - count, 255 - all -#define DEF_ST_RECONNECT_PAUSE 1 // 5 sec -#define DEF_ST_DHCP_MODE 1 // =0 dhcp off, =1 - dhcp on, =2 Static ip, =3 - auto +#define DEF_ST_CHANNEL 1 // 1..14 +#define DEF_ST_AUTORECONNECT 1 // 0 - none, 1..254 - count, 255 - all +#define DEF_ST_RECONNECT_PAUSE 1 // 5 sec +#define DEF_ST_DHCP_MODE 1 // =0 dhcp off, + // =1 - dhcp on, - динамический ip + // =2 Static ip, - fixed ip + // =3 - auto fix - старт в режиме "dhcp on", после получения ip - фиксация и переключение в режим рестартов со "Static ip" #define DEF_ST_IP IP4ADDR(192,168,1,100) #define DEF_ST_MSK IP4ADDR(255,255,255,0) #define DEF_ST_GW IP4ADDR(192,168,1,1) //==== Interface 2 - eth0 ================= -#define DEF_EH_DHCP_MODE 1 // =0 dhcp off, =1 - dhcp on +#define DEF_EH_DHCP_MODE 1 // =0 dhcp off, =1 - dhcp on #define DEF_EH_IP IP4ADDR(192,168,7,200) #define DEF_EH_MSK IP4ADDR(255,255,255,0) #define DEF_EH_GW IP4ADDR(192,168,7,1) diff --git a/project/src/console/wifi_console.c b/project/src/console/wifi_console.c index eacbe86..82c7e08 100644 --- a/project/src/console/wifi_console.c +++ b/project/src/console/wifi_console.c @@ -212,7 +212,7 @@ LOCAL void fATSF(int argc, char *argv[]) uint64_t tsf = get_tsf(); printf("\nTSF: %08x%08x\n", (uint32_t)(tsf>>32), (uint32_t)(tsf)); } - +#if 0 /* -------- WiFi Scan ------------------------------- */ volatile uint8_t scan_end; /* -------- WiFi Scan ------------------------------- */ @@ -245,8 +245,11 @@ LOCAL rtw_result_t _scan_result_handler( rtw_scan_handler_result_t* malloced_sca } /* -------- WiFi Scan ------------------------------- */ #define scan_channels 14 +#endif +void api_wifi_scan(void); LOCAL void fATSN(int argc, char *argv[]) { +#if 0 int i; u8 *channel_list = (u8*)pvPortMalloc(scan_channels*2); if(channel_list) { @@ -271,6 +274,9 @@ LOCAL void fATSN(int argc, char *argv[]) } else { printf("ERROR: Can't malloc memory for channel list\n"); }; +#else + api_wifi_scan(); +#endif } #if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP diff --git a/sdkset.mk b/sdkset.mk index e63151d..a9a1c5e 100644 --- a/sdkset.mk +++ b/sdkset.mk @@ -114,6 +114,7 @@ SRC_C += sdk/component/common/api/wifi/wifi_simple_config.c SRC_C += sdk/component/common/api/wifi/wifi_util.c SRC_C += sdk/component/common/api/lwip_netconf.c SRC_C += sdk/component/common/api/wifi_api.c +SRC_C += sdk/component/common/api/wifi_api_scan.c #network - app #SRC_C += sdk/component/common/utilities/ssl_client.c