diff --git a/Makefile b/Makefile index 94dc5fe..ef3b927 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ LIBS += esphttpd # compiler flags using during compilation of source files CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \ -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \ - -Wno-address -ffunction-sections -Wno-unused-value + -Wno-address -ffunction-sections -Wno-unused-value -Wno-unused-but-set-variable #-Wno-strict-aliasing # linker flags used to generate the main object file diff --git a/html/pages/about.tpl b/html/pages/about.tpl index de9417c..ef9c9cb 100644 --- a/html/pages/about.tpl +++ b/html/pages/about.tpl @@ -33,7 +33,7 @@

© Ondřej Hruška, 2016 <ondra@ondrovo.com>

-

Katedra měření FEL ČVUT
Department of Measurement, FEE CTU

+

Katedra měření, FEL ČVUT
Department of Measurement, FEE CTU

@@ -45,18 +45,21 @@ v%vers_fw%, build %date% at %time% - HTTPD + esp-httpd lib v%vers_httpd% - SBMP + SBMP lib v%vers_sbmp% - IoT SDK + ESP IoT SDK v%vers_sdk% - + + STM32 firmware + v%vers_stm% +

diff --git a/html_src/page_about.php b/html_src/page_about.php index 3af3d03..ccf6bcd 100644 --- a/html_src/page_about.php +++ b/html_src/page_about.php @@ -10,7 +10,7 @@

© Ondřej Hruška, 2016 <ondra@ondrovo.com>

-

Katedra měření FEL ČVUT
Department of Measurement, FEE CTU

+

Katedra měření, FEL ČVUT
Department of Measurement, FEE CTU

@@ -22,18 +22,21 @@ v%vers_fw%, build %date% at %time% - HTTPD + esp-httpd lib v%vers_httpd% - SBMP + SBMP lib v%vers_sbmp% - IoT SDK + ESP IoT SDK v%vers_sdk% - + + STM32 firmware + v%vers_stm% +

diff --git a/libesphttpd/include/logging.h b/libesphttpd/include/logging.h index 8cc999b..c582520 100644 --- a/libesphttpd/include/logging.h +++ b/libesphttpd/include/logging.h @@ -4,18 +4,12 @@ #include #include "uptime.h" +#define VERBOSE 0 + // logging functions #define LOG_EOL "\n" - -#define dbg(fmt, ...) \ - do { \ - uptime_print(); \ - printf(" [ ] "fmt LOG_EOL, ##__VA_ARGS__); \ - } while(0) - - #define banner(fmt, ...) \ do { \ printf(LOG_EOL "\x1b[32;1m"); \ @@ -23,8 +17,8 @@ printf(" [i] "fmt"\x1b[0m" LOG_EOL LOG_EOL, ##__VA_ARGS__); \ } while(0) - -#define info(fmt, ...) \ +// same as 'info', except enabled even if verbose is disabled +#define banner_info(fmt, ...) \ do { \ printf("\x1b[32m"); \ uptime_print(); \ @@ -32,6 +26,26 @@ } while(0) +#if VERBOSE + #define dbg(fmt, ...) \ + do { \ + uptime_print(); \ + printf(" [ ] "fmt LOG_EOL, ##__VA_ARGS__); \ + } while(0) + + + #define info(fmt, ...) \ + do { \ + printf("\x1b[32m"); \ + uptime_print(); \ + printf(" [i] "fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__); \ + } while(0) +#else + #define dbg(fmt, ...) + #define info(fmt, ...) +#endif + + #define error(fmt, ...) \ do { \ printf("\x1b[31;1m"); \ diff --git a/user/datalink.h b/user/datalink.h index 392a692..0b9ccb3 100644 --- a/user/datalink.h +++ b/user/datalink.h @@ -17,6 +17,7 @@ #define DG_WPS_START 45 // start WPS #define DG_WIFI_STATUS 46 // WiFi status report +#define DG_REQUEST_STM_VERSION 47 // Get acquisition module firmware version extern SBMP_Endpoint *dlnk_ep; diff --git a/user/fw_version.h b/user/fw_version.h index fbb2fb4..69f44fe 100644 --- a/user/fw_version.h +++ b/user/fw_version.h @@ -1,6 +1,6 @@ #ifndef FW_VERSION_H #define FW_VERSION_H -#define FIRMWARE_VERSION "0.1.3" +#define FIRMWARE_VERSION "1.0.0" #endif // FW_VERSION_H diff --git a/user/page_about.c b/user/page_about.c index fe987cb..791d7fb 100644 --- a/user/page_about.c +++ b/user/page_about.c @@ -3,6 +3,26 @@ #include "page_about.h" #include "fw_version.h" #include "sbmp.h" +#include "datalink.h" +#include "serial.h" + +static bool stm_vers_loaded = false; +static char stm_vers_buf[10]; + +static void readVersionCB(SBMP_Endpoint *ep, SBMP_Datagram *dg, void** arg) +{ + (void)ep; + (void)arg; + + if (dg->type != DG_SUCCESS) { + error("Response to REQUEST_VERSION not SUCCESS."); + return; + } + + sprintf(stm_vers_buf, "%d.%d.%d", dg->payload[0], dg->payload[1], dg->payload[2]); + stm_vers_loaded = true; +} + /** "About" page */ httpd_cgi_state FLASH_FN tplAbout(HttpdConnData *connData, char *token, void **arg) @@ -29,6 +49,34 @@ httpd_cgi_state FLASH_FN tplAbout(HttpdConnData *connData, char *token, void **a } else if (streq(token, "vers_sdk")) { httpdSend(connData, STR(ESP_SDK_VERSION), -1); + + } else if (streq(token, "vers_stm")) { + + if (stm_vers_loaded) { + httpdSend(connData, stm_vers_buf, -1); + } else { + + uint16_t sesn; + sbmp_ep_send_message(dlnk_ep, DG_REQUEST_STM_VERSION, NULL, 0, &sesn, NULL); + sbmp_ep_add_listener(dlnk_ep, sesn, readVersionCB, NULL); + + sprintf(stm_vers_buf, "???"); + + // poll & wait for response + const int timeout = 100; + for (uint32_t i = 0; i < timeout * 100; i++) { + uart_poll(); + + if (stm_vers_loaded) { + break; + } + + os_delay_us(10); + system_soft_wdt_feed(); // Feed the dog, or it'll bite. + } + + httpdSend(connData, stm_vers_buf, -1); // send to view + } } return HTTPD_CGI_DONE; diff --git a/user/user_main.c b/user/user_main.c index 7af3055..e6c78bc 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -85,11 +85,11 @@ void user_init(void) uptime_timer_init(); banner("*** AC current analyser - WiFi module ***"); - info("(c) Ondrej Hruska, 2016"); - info("Katedra mereni FEL CVUT"); - info(""); - info("Version "FIRMWARE_VERSION", built "__DATE__" at "__TIME__); - info("HTTPD v."HTTPDVER", SBMP v."SBMP_VER", IoT SDK v."STR(ESP_SDK_VERSION)); + banner_info("(c) Ondrej Hruska, 2016"); + banner_info("Katedra mereni FEL CVUT"); + banner_info(""); + banner_info("Version "FIRMWARE_VERSION", built "__DATE__" at "__TIME__); + banner_info("HTTPD v."HTTPDVER", SBMP v."SBMP_VER", IoT SDK v."STR(ESP_SDK_VERSION)); printf(LOG_EOL); // reset button etc @@ -117,7 +117,7 @@ void user_init(void) reporting_cfg_load(); printf(LOG_EOL); - info("Ready"); + banner_info("Ready"); printf(LOG_EOL); wificontrol_init();