Răsfoiți Sursa

httpd: allow status refresh down to 2 s

Allow any second granularity; arbitrarily restrict to 2 s for now
H. Peter Anvin 2 ani în urmă
părinte
comite
33ac49c4fe
5 a modificat fișierele cu 4 adăugiri și 5 ștergeri
  1. 3 4
      esp32/max80/httpd.c
  2. BIN
      esp32/output/max80.ino.bin
  3. 1 1
      esp32/www/status.html
  4. BIN
      fpga/output/v1.fw
  5. BIN
      fpga/output/v2.fw

+ 3 - 4
esp32/max80/httpd.c

@@ -357,24 +357,23 @@ static esp_err_t httpd_set_config(httpd_req_t *req, const char *query)
     return httpd_update_done(req, "Configuration", rv1 ? rv1 : rv2);
 }
 
-#define MIN_STATUS_REF 2	/* Minimum refresh time in ms */
+#define MIN_STATUS_REF 1	/* Minimum refresh time in s */
 
 static void httpd_get_status_extra(FILE *f, httpd_req_t *req)
 {
     static const char refresh_time_config[] = "http.status.refresh";
-    const unsigned long min_status_ref = 5;
     char timebuf[64];
     size_t len;
     struct timeval tv;
 
     unsigned long statref;
-    statref = Max(getenv_ul(refresh_time_config, 0), min_status_ref);
+    statref = Max(getenv_ul(refresh_time_config, 0), MIN_STATUS_REF);
 
     if (httpd_req_get_url_query_str(req, timebuf, sizeof timebuf) == ESP_OK &&
 	*timebuf) {
 	char *ep;
 	unsigned long newstatref = strtoul(timebuf, &ep, 10);
-	if (!*ep && newstatref >= min_status_ref && newstatref != statref) {
+	if (!*ep && newstatref >= MIN_STATUS_REF && newstatref != statref) {
 	    statref = newstatref;
 	    setenv_config(refresh_time_config, timebuf);
 	    read_config(NULL, true); /* Save changed config */

BIN
esp32/output/max80.ino.bin


+ 1 - 1
esp32/www/status.html

@@ -127,7 +127,7 @@
 	<label class="refresh">
 	  <span>Refresh interval:</span>
 	  <input class="noro" id="refresh_time" type="number"
-		 name="http.status.refresh" value="10" step="5" min="5"
+		 name="http.status.refresh" value="10" step="1" min="2"
 		 onchange="ref_status(true)" />&nbsp;s
 	</label>
       </fieldset>

BIN
fpga/output/v1.fw


BIN
fpga/output/v2.fw