mirror of
https://github.com/jeelabs/esp-link.git
synced 2026-03-18 23:16:51 +01:00
fix pin changes and hostname change
This commit is contained in:
@@ -403,7 +403,7 @@ static void ICACHE_FLASH_ATTR debugIP() {
|
||||
#endif
|
||||
|
||||
// configure Wifi, specifically DHCP vs static IP address based on flash config
|
||||
static void ICACHE_FLASH_ATTR configWifiIP() {
|
||||
void ICACHE_FLASH_ATTR configWifiIP() {
|
||||
if (flashConfig.staticip == 0) {
|
||||
// let's DHCP!
|
||||
wifi_station_set_hostname(flashConfig.hostname);
|
||||
|
||||
@@ -13,6 +13,7 @@ int cgiWiFiConnect(HttpdConnData *connData);
|
||||
int cgiWiFiSetMode(HttpdConnData *connData);
|
||||
int cgiWiFiConnStatus(HttpdConnData *connData);
|
||||
int cgiWiFiSpecial(HttpdConnData *connData);
|
||||
void configWifiIP();
|
||||
void wifiInit(void);
|
||||
void wifiAddStateChangeCb(WifiStateChangeCb cb);
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ ajaxLog(HttpdConnData *connData) {
|
||||
return HTTPD_CGI_DONE;
|
||||
}
|
||||
|
||||
static char *dbg_mode[] = { "auto", "off", "on u0", "on u1" };
|
||||
static char *dbg_mode[] = { "auto", "off", "on0", "on1" };
|
||||
|
||||
int ICACHE_FLASH_ATTR
|
||||
ajaxLogDbg(HttpdConnData *connData) {
|
||||
|
||||
@@ -129,14 +129,22 @@ static int ICACHE_FLASH_ATTR cgiSystemInfo(HttpdConnData *connData) {
|
||||
return HTTPD_CGI_DONE;
|
||||
}
|
||||
|
||||
static ETSTimer reassTimer;
|
||||
|
||||
// Cgi to update system info (name/description)
|
||||
static int ICACHE_FLASH_ATTR cgiSystemSet(HttpdConnData *connData) {
|
||||
if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up.
|
||||
|
||||
int8_t status = 0;
|
||||
status |= getStringArg(connData, "name", flashConfig.hostname, sizeof(flashConfig.hostname));
|
||||
status |= getStringArg(connData, "description", flashConfig.sys_descr, sizeof(flashConfig.sys_descr));
|
||||
if (status < 0) return HTTPD_CGI_DONE; // getStringArg has produced an error response
|
||||
int8_t n = getStringArg(connData, "name", flashConfig.hostname, sizeof(flashConfig.hostname));
|
||||
int8_t d = getStringArg(connData, "description", flashConfig.sys_descr, sizeof(flashConfig.sys_descr));
|
||||
if (n < 0 || d < 0) return HTTPD_CGI_DONE; // getStringArg has produced an error response
|
||||
|
||||
if (n > 0) {
|
||||
// schedule hostname change-over
|
||||
os_timer_disarm(&reassTimer);
|
||||
os_timer_setfn(&reassTimer, configWifiIP, NULL);
|
||||
os_timer_arm(&reassTimer, 1000, 0); // 1 second for the response of this request to make it
|
||||
}
|
||||
|
||||
if (configSave()) {
|
||||
httpdStartResponse(connData, 204);
|
||||
|
||||
@@ -418,10 +418,10 @@ function createPresets(sel) {
|
||||
setPP("ser", pp[3]);
|
||||
setPP("swap", pp[4]);
|
||||
$("#pin-rxpup").checked = !!pp[5];
|
||||
sel.value = 0;
|
||||
};
|
||||
|
||||
bnd(sel, "change", function(ev) {
|
||||
console.log("preset change:", sel.value);
|
||||
ev.preventDefault();
|
||||
applyPreset(sel.value);
|
||||
});
|
||||
@@ -431,6 +431,7 @@ function displayPins(resp) {
|
||||
function createSelectForPin(name, v) {
|
||||
var sel = $("#pin-"+name);
|
||||
addClass(sel, "pure-button");
|
||||
sel.innerHTML = "";
|
||||
[-1,0,1,2,3,4,5,12,13,14,15].forEach(function(i) {
|
||||
var opt = document.createElement("option");
|
||||
opt.value = i;
|
||||
@@ -464,7 +465,8 @@ function fetchPins() {
|
||||
});
|
||||
}
|
||||
|
||||
function setPins(v, name) {
|
||||
function setPins(ev) {
|
||||
ev.preventDefault();
|
||||
var url = "/pins";
|
||||
var sep = "?";
|
||||
["reset", "isp", "conn", "ser", "swap"].forEach(function(p) {
|
||||
@@ -472,6 +474,7 @@ function setPins(v, name) {
|
||||
sep = "&";
|
||||
});
|
||||
url += "&rxpup=" + ($("#pin-rxpup").selected ? "1" : "0");
|
||||
console.log("set pins: " + url);
|
||||
ajaxSpin("POST", url, function() {
|
||||
showNotification("Pin assignment changed");
|
||||
}, function(status, errMsg) {
|
||||
|
||||
Reference in New Issue
Block a user