This commit is contained in:
Victor 2018-04-20 10:53:32 +03:00
parent 8529849a5a
commit d1e4ee31f1
70 changed files with 523 additions and 2274 deletions

View file

@ -31,35 +31,19 @@ LOCAL void fATPN(int argc, char *argv[]){
show_wifi_st_cfg();
}
else {
strncpy(wifi_st_cfg.ssid, argv[1], NDIS_802_11_LENGTH_SSID);
int pswlen;
strncpy(wifi_st_cfg.ssid, argv[1], sizeof(wifi_st_cfg.ssid));
wifi_st_cfg.security = IDX_SECURITY_OPEN;
int pswlen = strlen(strncpy(wifi_st_cfg.password, argv[2], sizeof(wifi_st_cfg.password)));
if(argc > 2) {
pswlen = strlen(wifi_st_cfg.password);
strncpy(wifi_st_cfg.password, argv[2], NDIS_802_11_LENGTH_SSID);
if(pswlen > 7) {
wifi_st_cfg.security = IDX_SECURITY_WPA2_AES_PSK;
}
else if(!pswlen) {
wifi_st_cfg.security = IDX_SECURITY_OPEN;
}
else {
}
else if(pswlen != 0) {
printf("password len < 8!\n");
wifi_st_cfg.security = IDX_SECURITY_OPEN;
}
}
else {
// default
wifi_st_cfg.password[0] = 0;
wifi_st_cfg.security = IDX_SECURITY_OPEN;
}
if(argc > 3) {
if(pswlen > 7) {
wifi_st_cfg.security = atoi(argv[3]);
}
else {
printf("password len < 8!\n");
wifi_st_cfg.security = IDX_SECURITY_OPEN;
}
wifi_st_cfg.security = atoi(argv[3]);
}
if(argc > 4) {
wifi_st_cfg.autoreconnect = atoi(argv[4]);
@ -85,25 +69,17 @@ LOCAL void fATPA(int argc, char *argv[]){
show_wifi_ap_cfg();
}
else {
strncpy(wifi_ap_cfg.ssid, argv[1], NDIS_802_11_LENGTH_SSID);
strncpy(wifi_ap_cfg.ssid, argv[1], sizeof(wifi_ap_cfg.ssid));
wifi_ap_cfg.security = 0; // IDX_SECURITY_OPEN;
int pswlen = strlen(strncpy(wifi_ap_cfg.password, argv[2], sizeof(wifi_ap_cfg.password)));
if(argc > 2) {
strncpy(wifi_ap_cfg.password, argv[2], NDIS_802_11_LENGTH_SSID);
int i = strlen(wifi_ap_cfg.password);
if(i > 7) {
if(pswlen > 7) {
wifi_ap_cfg.security = 1; // IDX_SECURITY_WPA2_AES_PSK;
}
else if(i == 0) {
wifi_ap_cfg.security = 0; // IDX_SECURITY_OPEN;
}
else {
else if(pswlen != 0) {
printf("password len < 8!\n");
wifi_ap_cfg.security = 0; // IDX_SECURITY_OPEN;
}
}
else {
wifi_ap_cfg.password[0] = 0;
wifi_ap_cfg.security = 0; // IDX_SECURITY_OPEN;
}
if(argc > 3) {
wifi_ap_cfg.security = (argv[3][0] == '0')? 0 : 1; //RTW_SECURITY_OPEN : RTW_SECURITY_WPA2_AES_PSK;
}

View file

@ -384,6 +384,36 @@ void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr)
#endif
ifcmp("start") tcp_puts("0x%08x", web_conn->udata_start);
else ifcmp("stop") tcp_puts("0x%08x", web_conn->udata_stop);
#ifdef WEB_INA219_DRV
else ifcmp("ina219") {
if(CheckSCB(SCB_WEBSOC)) {
extern int ina219_ws(TCP_SERV_CONN *ts_conn, char cmd);
int x = ina219_ws(ts_conn, cstr[6]);
if(x < 0) SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
else tcp_puts("%d", x);
}
}
#endif
#ifdef WEB_MLX90614_DRV
else ifcmp("mlx90614") {
if(CheckSCB(SCB_WEBSOC)) {
extern int mlx90614_ws(TCP_SERV_CONN *ts_conn, char cmd);
int x = mlx90614_ws(ts_conn, cstr[8]);
if(x < 0) SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
else tcp_puts("%d", x);
}
}
#endif
#ifdef WEB_ADC_DRV
else ifcmp("adc") {
if(CheckSCB(SCB_WEBSOC)) {
extern int adc_ws(TCP_SERV_CONN *ts_conn, char cmd);
int x = adc_ws(ts_conn, cstr[3]);
if(x < 0) SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
else tcp_puts("%d", x);
}
}
#endif
#if USE_WEB_AUTH_LEVEL
else ifcmp("realm") tcp_puts("%u", web_conn->auth_realm);
else ifcmp("auth") tcp_puts("%u", web_conn->auth_level);
@ -441,7 +471,7 @@ void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr)
else ifcmp("rdec") tcp_puts("%d", *((uint32 *)(ahextoul(cstr+4)&(~3))));
#endif // #if WEB_DEBUG_FUNCTIONS
else ifcmp("ip") {
uint32 cur_ip;
uint32 cur_ip = 0;
if(netif_default != NULL) cur_ip = netif_default->ip_addr.addr;
tcp_puts(IPSTR, IP2STR(&cur_ip));
}
@ -452,36 +482,6 @@ void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr)
#endif
else tcp_put('?');
}
#ifdef WEB_INA219_DRV
else ifcmp("ina219") {
if(CheckSCB(SCB_WEBSOC)) {
extern int ina219_ws(TCP_SERV_CONN *ts_conn, char cmd);
int x = ina219_ws(ts_conn, cstr[6]);
if(x < 0) SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
else tcp_puts("%d", x);
}
}
#endif
#ifdef WEB_MLX90614_DRV
else ifcmp("mlx90614") {
if(CheckSCB(SCB_WEBSOC)) {
extern int mlx90614_ws(TCP_SERV_CONN *ts_conn, char cmd);
int x = mlx90614_ws(ts_conn, cstr[8]);
if(x < 0) SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
else tcp_puts("%d", x);
}
}
#endif
#ifdef WEB_ADC_DRV
else ifcmp("adc") {
if(CheckSCB(SCB_WEBSOC)) {
extern int adc_ws(TCP_SERV_CONN *ts_conn, char cmd);
int x = adc_ws(ts_conn, cstr[3]);
if(x < 0) SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
else tcp_puts("%d", x);
}
}
#endif
else ifcmp("cfg_") {
cstr += 4;
ifcmp("web_") {

View file

@ -214,7 +214,7 @@ WebsocketTxFrame(TCP_SERV_CONN *ts_conn, uint32 opcode, uint8 *raw_data, uint32
head_len = 2;
};
if(opcode & (WS_MASK_FLG << 8)) {
mask.ud ^= rand();
mask.ud = rand();
head.uc[1] |= WS_MASK_FLG;
head.uc[head_len] = mask.uc[0];
head.uc[head_len+1] = mask.uc[1];