mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
重新打开ap
This commit is contained in:
@@ -108,7 +108,7 @@ static int HttpGetTc1Status(httpd_request_t *req)
|
||||
char* tc1_status = malloc(412);
|
||||
sprintf(tc1_status, TC1_STATUS_JSON, sockets, ip_status.mode,
|
||||
sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key,
|
||||
ap_name, ELAND_AP_KEY, "MQTT.ADDR", 1883, VERSION, ip_status.ip, ip_status.mask, ip_status.gateway, 0L);
|
||||
ap_name, ap_key, "MQTT.ADDR", 1883, VERSION, ip_status.ip, ip_status.mask, ip_status.gateway, 0L);
|
||||
|
||||
OSStatus err = kNoErr;
|
||||
send_http(tc1_status, strlen(tc1_status), exit, &err);
|
||||
@@ -178,15 +178,22 @@ static int HttpSetWifiConfig(httpd_request_t *req)
|
||||
|
||||
int buf_size = 97;
|
||||
char *buf = malloc(buf_size);
|
||||
int mode = -1;
|
||||
char *wifi_ssid = malloc(32);
|
||||
char *wifi_key = malloc(64);
|
||||
char *wifi_key = malloc(32);
|
||||
|
||||
err = httpd_get_data(req, buf, buf_size);
|
||||
require_noerr(err, exit);
|
||||
|
||||
sscanf(buf, "%s %s", wifi_ssid, wifi_key);
|
||||
|
||||
WifiConnect(wifi_ssid, wifi_key);
|
||||
sscanf(buf, "%d %s %s", &mode, wifi_ssid, wifi_key);
|
||||
if (mode == 1)
|
||||
{
|
||||
WifiConnect(wifi_ssid, wifi_key);
|
||||
}
|
||||
else
|
||||
{
|
||||
ApConfig(wifi_ssid, wifi_key);
|
||||
}
|
||||
|
||||
send_http("OK", 2, exit, &err);
|
||||
|
||||
|
||||
@@ -415,18 +415,21 @@ function ChangeMode(m) {
|
||||
}
|
||||
|
||||
function ChangeInput(type) {
|
||||
if(mode != 1) {
|
||||
if (mode == 0) {
|
||||
ap_name = ssid_ipt.value;
|
||||
ap_pswd = pswd_ipt.value;
|
||||
} else {
|
||||
} else if (mode == 1) {
|
||||
station_name = ssid_ipt.value;
|
||||
station_pswd = pswd_ipt.value;
|
||||
} else {
|
||||
alert("mode error: " + mode);
|
||||
}
|
||||
}
|
||||
|
||||
//Quotation Marks
|
||||
function ContainQM(str) {
|
||||
if (str.indexOf("'") >= 0
|
||||
if (str == ""
|
||||
|| str.indexOf("'") >= 0
|
||||
|| str.indexOf('"') >= 0
|
||||
|| str.indexOf(' ') >= 0
|
||||
|| str.length > 32) {
|
||||
@@ -434,24 +437,35 @@ function ContainQM(str) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var qm_mess = "Sorry, can't use ' or \" or space.\n\nAlso, length <= 32."
|
||||
var qm_mess = "Sorry, can't use ' or \" or space or empty.\n\nAlso, length <= 32."
|
||||
var le_mess = "Sorry, length < 8."
|
||||
|
||||
function SubmitNetwork() {
|
||||
if(mode != 1) {
|
||||
if (mode == 0) {
|
||||
if (ContainQM(ap_name) || ContainQM(ap_pswd)) {
|
||||
alert(qm_mess);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (ap_pswd.length < 8) {
|
||||
alert(le_mess);
|
||||
}
|
||||
var params = mode + " " + ap_name+" "+ap_pswd;
|
||||
} else if (mode == 1) {
|
||||
if (ContainQM(station_name) || ContainQM(station_pswd)) {
|
||||
alert(qm_mess);
|
||||
return;
|
||||
}
|
||||
var params = station_name+" "+station_pswd;
|
||||
HttpPost("/wifi/config", function (re) {
|
||||
alert(re);
|
||||
}, params);
|
||||
if (station_pswd.length < 8) {
|
||||
alert(le_mess);
|
||||
}
|
||||
var params = mode + " " + station_name+" "+station_pswd;
|
||||
} else {
|
||||
alert("mode error: " + mode);
|
||||
return;
|
||||
}
|
||||
HttpPost("/wifi/config", function (re) {
|
||||
alert(re);
|
||||
}, params);
|
||||
}
|
||||
|
||||
function Rescan() {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user