mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2024-11-22 14:04:21 +00:00
update
This commit is contained in:
parent
2e503268fa
commit
7bfffd015c
4 changed files with 85 additions and 35 deletions
|
@ -21,9 +21,9 @@
|
|||
| BID_WIFI_AP_CFG \
|
||||
| BID_WIFI_ST_CFG \
|
||||
| BID_AP_DHCP_CFG \
|
||||
| BID_ST_DHCP_CFG \
|
||||
| BID_WIFI_CFG \
|
||||
)
|
||||
| BID_ST_DHCP_CFG )//\
|
||||
// | BID_WIFI_CFG \
|
||||
//)
|
||||
#define DEF_SAVE_CFG ( 0 \
|
||||
| BID_WIFI_AP_CFG \
|
||||
| BID_WIFI_ST_CFG \
|
||||
|
@ -34,7 +34,12 @@
|
|||
//==== Interface 0 - wlan0 = AP ===========
|
||||
#define DEF_AP_SSID "RTL871X"
|
||||
#define DEF_AP_PASSWORD "0123456789"
|
||||
#define DEF_AP_SECURITY RTW_SECURITY_WPA2_AES_PSK // or RTW_SECURITY_OPEN
|
||||
/* 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
|
||||
|
|
|
@ -53,7 +53,7 @@ LOCAL void fATPN(int argc, char *argv[]){
|
|||
}
|
||||
if(argc > 3) {
|
||||
if(pswlen > 7) {
|
||||
wifi_st_cfg.security_type = translate_val_to_rtw_security(atoi(argv[3]));
|
||||
wifi_st_cfg.security_type = idx_to_rtw_security(atoi(argv[3]));
|
||||
}
|
||||
else {
|
||||
printf("password len < 8!\n");
|
||||
|
@ -214,31 +214,7 @@ LOCAL void fATSF(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* -------- WiFi Scan ------------------------------- */
|
||||
unsigned char *tab_txt_rtw_secyrity[] = {
|
||||
"OPEN ",
|
||||
"WEP ",
|
||||
"WPA TKIP",
|
||||
"WPA AES",
|
||||
"WPA2 AES",
|
||||
"WPA2 TKIP",
|
||||
"WPA2 Mixed",
|
||||
"WPA/WPA2 AES",
|
||||
"Unknown"
|
||||
};
|
||||
unsigned int *tab_code_rtw_secyrity[] = {
|
||||
RTW_SECURITY_OPEN,
|
||||
RTW_SECURITY_WEP_PSK,
|
||||
RTW_SECURITY_WPA_TKIP_PSK,
|
||||
RTW_SECURITY_WPA_AES_PSK,
|
||||
RTW_SECURITY_WPA2_AES_PSK,
|
||||
RTW_SECURITY_WPA2_TKIP_PSK,
|
||||
RTW_SECURITY_WPA2_MIXED_PSK,
|
||||
RTW_SECURITY_WPA_WPA2_MIXED,
|
||||
RTW_SECURITY_UNKNOWN
|
||||
};
|
||||
|
||||
volatile uint8_t scan_end;
|
||||
|
||||
/* -------- WiFi Scan ------------------------------- */
|
||||
LOCAL rtw_result_t _scan_result_handler( rtw_scan_handler_result_t* malloced_scan_result )
|
||||
{
|
||||
|
@ -255,9 +231,11 @@ LOCAL rtw_result_t _scan_result_handler( rtw_scan_handler_result_t* malloced_sca
|
|||
printf("\t%d\t", record->signal_strength);
|
||||
printf("%d\t", record->channel);
|
||||
printf("%d\t", record->wps_type);
|
||||
int i = 0;
|
||||
for(; record->security != tab_code_rtw_secyrity[i] && tab_code_rtw_secyrity[i] != RTW_SECURITY_UNKNOWN; i++);
|
||||
printf("%s \t", tab_txt_rtw_secyrity[i]);
|
||||
{
|
||||
uint8 * s = rtw_security_to_str(record->security);
|
||||
printf("%s\t", s);
|
||||
if(strlen(s) < 8) printf("\t");
|
||||
}
|
||||
printf("%s\n", record->SSID.val);
|
||||
} else {
|
||||
scan_end = 0;
|
||||
|
@ -313,7 +291,6 @@ extern void cmd_wifi_p2p_auto_go_start(int argc, char **argv);
|
|||
extern void cmd_p2p_peers(int argc, char **argv);
|
||||
#endif //CONFIG_ENABLE_P2P
|
||||
|
||||
|
||||
MON_RAM_TAB_SECTION COMMAND_TABLE console_cmd_wifi_api[] = {
|
||||
{"ATPN", 1, fATPN, "=<SSID>[,password[,encryption[,auto-reconnect[,reconnect pause]]]: WIFI Connect to AP"},
|
||||
{"ATPA", 1, fATPA, "=<SSID>[,password[,encryption[,channel[,hidden[,max connections]]]]]: Start WIFI AP"},
|
||||
|
@ -340,6 +317,8 @@ MON_RAM_TAB_SECTION COMMAND_TABLE console_cmd_wifi_api[] = {
|
|||
{"ATSF", 0, fATSF, ": Test TSF value"},
|
||||
#endif
|
||||
{"ATSN", 0, fATSN, ": Scan networks"}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "webfs/webfs.h"
|
||||
#include "rtl8195a/rtl_libc.h"
|
||||
#include "user/sys_cfg.h"
|
||||
#include "wifi_conf.h"
|
||||
#include "wifi_api.h"
|
||||
#include "sys_api.h"
|
||||
#include "esp_comp.h"
|
||||
|
@ -55,6 +56,71 @@
|
|||
|
||||
extern struct netif xnetif[NET_IF_NUM]; /* network interface structure */
|
||||
|
||||
#if 0
|
||||
/******************************************************************************
|
||||
* FunctionName : WiFi scan
|
||||
* Description : Processing scan network
|
||||
* Parameters : none (Calback)
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
#define scan_channels 14
|
||||
volatile uint8_t scan_end;
|
||||
|
||||
/* -------- WiFi Scan ------------------------------- */
|
||||
LOCAL rtw_result_t _scan_result_handler( rtw_scan_handler_result_t* malloced_scan_result )
|
||||
{
|
||||
if (malloced_scan_result->scan_complete != RTW_TRUE) {
|
||||
rtw_scan_result_t* record = &malloced_scan_result->ap_details;
|
||||
record->SSID.val[record->SSID.len] = 0; /* Ensure the SSID is null terminated */
|
||||
if(scan_end == 1) {
|
||||
printf("\nScan networks:\n\n");
|
||||
printf("N\tType\tMAC\t\t\tSignal\tCh\tWPS\tSecyrity\tSSID\n\n");
|
||||
};
|
||||
printf("%d\t", scan_end++);
|
||||
printf("%s\t", (record->bss_type == RTW_BSS_TYPE_ADHOC)? "Adhoc": "Infra");
|
||||
printf(MAC_FMT, MAC_ARG(record->BSSID.octet));
|
||||
printf("\t%d\t", record->signal_strength);
|
||||
printf("%d\t", record->channel);
|
||||
printf("%d\t", record->wps_type);
|
||||
int i = 0;
|
||||
for(; record->security != tab_code_rtw_secyrity[i] && tab_code_rtw_secyrity[i] != RTW_SECURITY_UNKNOWN; i++);
|
||||
printf("%s \t", tab_txt_rtw_secyrity[i]);
|
||||
printf("%s\n", record->SSID.val);
|
||||
} else {
|
||||
scan_end = 0;
|
||||
printf("\n");
|
||||
}
|
||||
return RTW_SUCCESS;
|
||||
}
|
||||
/* -------- WiFi Scan ------------------------------- */
|
||||
void web_wifi_scan(void) {
|
||||
int i;
|
||||
u8 *channel_list = (u8*)pvPortMalloc(scan_channels*2);
|
||||
if(channel_list) {
|
||||
scan_end = 1;
|
||||
u8 * pscan_config = &channel_list[scan_channels];
|
||||
//parse command channel list
|
||||
for(i = 1; i <= scan_channels; i++){
|
||||
*(channel_list + i - 1) = i;
|
||||
*(pscan_config + i - 1) = PSCAN_ENABLE;
|
||||
};
|
||||
if(wifi_set_pscan_chan(channel_list, pscan_config, scan_channels) < 0){
|
||||
printf("ERROR: wifi set partial scan channel fail\n");
|
||||
} else if(wifi_scan_networks(_scan_result_handler, NULL ) != RTW_SUCCESS){
|
||||
printf("ERROR: wifi scan failed\n");
|
||||
} else {
|
||||
i = 300;
|
||||
while(i-- && scan_end) {
|
||||
vTaskDelay(10);
|
||||
};
|
||||
};
|
||||
vPortFree(channel_list);
|
||||
} else {
|
||||
printf("ERROR: Can't malloc memory for channel list\n");
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
//#define TEST_SEND_WAVE
|
||||
|
||||
#ifdef TEST_SEND_WAVE
|
||||
|
@ -580,7 +646,7 @@ void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr)
|
|||
#if LWIP_NETIF_HOSTNAME
|
||||
else ifcmp("hostname") tcp_strcpy(lwip_host_name[WLAN_ST_NETIF_NUM]);
|
||||
#endif
|
||||
else ifcmp("auth") tcp_puts("%u", translate_rtw_security_to_val(wifi_st_cfg.security_type));
|
||||
else ifcmp("auth") tcp_puts("%u", rtw_security_to_idx(wifi_st_cfg.security_type));
|
||||
else ifcmp("dhcp") tcp_puts("%u", wifi_st_dhcp.mode);
|
||||
else ifcmp("ip") tcp_puts(IPSTR, IP2STR(&wifi_st_dhcp.ip));
|
||||
else ifcmp("gw") tcp_puts(IPSTR, IP2STR(&wifi_st_dhcp.gw));
|
||||
|
|
|
@ -259,7 +259,7 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *
|
|||
else os_memset(wifi_st_cfg.password, 0, sizeof(wifi_st_cfg.password));
|
||||
os_memcpy(wifi_st_cfg.password, pvar, len);
|
||||
}
|
||||
else ifcmp("auth") wifi_st_cfg.security_type = translate_val_to_rtw_security(val);
|
||||
else ifcmp("auth") wifi_st_cfg.security_type = idx_to_rtw_security(val);
|
||||
else ifcmp("bssid") strtomac(pvar, wifi_st_cfg.bssid);
|
||||
else ifcmp("sbss") wifi_st_cfg.flg = val;
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
|
|
Loading…
Reference in a new issue