read stm version

Former-commit-id: 5e2648dc894f0e9d5a991a6503be4337bcc5872b
master
Ondřej Hruška 9 years ago
parent 485a383e6d
commit 2ad7e059f7
  1. 2
      Makefile
  2. 13
      html/pages/about.tpl
  3. 13
      html_src/page_about.php
  4. 24
      libesphttpd/include/logging.h
  5. 1
      user/datalink.h
  6. 2
      user/fw_version.h
  7. 48
      user/page_about.c
  8. 12
      user/user_main.c

@ -73,7 +73,7 @@ LIBS += esphttpd
# compiler flags using during compilation of source files # compiler flags using during compilation of source files
CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \ CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \
-nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \ -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 #-Wno-strict-aliasing
# linker flags used to generate the main object file # linker flags used to generate the main object file

@ -33,7 +33,7 @@
<p>&copy; Ondřej Hruška, 2016 &lt;<a href="mailto:ondra@ondrovo.com" target="blank">ondra@ondrovo.com</a>&gt;</p> <p>&copy; Ondřej Hruška, 2016 &lt;<a href="mailto:ondra@ondrovo.com" target="blank">ondra@ondrovo.com</a>&gt;</p>
<p><a href="http://measure.feld.cvut.cz/" target="blank">Katedra měření FEL ČVUT</a><br>Department of Measurement, FEE CTU</p> <p><a href="http://measure.feld.cvut.cz/" target="blank">Katedra měření, FEL ČVUT</a><br>Department of Measurement, FEE CTU</p>
</div> </div>
<div class="Box"> <div class="Box">
@ -45,18 +45,21 @@
<td>v%vers_fw%, build <i>%date%</i> at <i>%time%</i></td> <td>v%vers_fw%, build <i>%date%</i> at <i>%time%</i></td>
</tr> </tr>
<tr> <tr>
<th>HTTPD</th> <th>esp-httpd&nbsp;lib</th>
<td>v%vers_httpd%</td> <td>v%vers_httpd%</td>
</tr> </tr>
<tr> <tr>
<th>SBMP</th> <th>SBMP&nbsp;lib</th>
<td>v%vers_sbmp%</td> <td>v%vers_sbmp%</td>
</tr> </tr>
<tr> <tr>
<th>IoT SDK</th> <th>ESP&nbsp;IoT&nbsp;SDK</th>
<td>v%vers_sdk%</td> <td>v%vers_sdk%</td>
</tr> </tr>
<!-- Read & show version of the stm32 firmware --> <tr>
<th>STM32&nbsp;firmware</th>
<td>v%vers_stm%</td>
</tr>
</table> </table>
<p> <p>

@ -10,7 +10,7 @@
<p>&copy; Ondřej Hruška, 2016 &lt;<a href="mailto:ondra@ondrovo.com" target="blank">ondra@ondrovo.com</a>&gt;</p> <p>&copy; Ondřej Hruška, 2016 &lt;<a href="mailto:ondra@ondrovo.com" target="blank">ondra@ondrovo.com</a>&gt;</p>
<p><a href="http://measure.feld.cvut.cz/" target="blank">Katedra měření FEL ČVUT</a><br>Department of Measurement, FEE CTU</p> <p><a href="http://measure.feld.cvut.cz/" target="blank">Katedra měření, FEL ČVUT</a><br>Department of Measurement, FEE CTU</p>
</div> </div>
<div class="Box"> <div class="Box">
@ -22,18 +22,21 @@
<td>v%vers_fw%, build <i>%date%</i> at <i>%time%</i></td> <td>v%vers_fw%, build <i>%date%</i> at <i>%time%</i></td>
</tr> </tr>
<tr> <tr>
<th>HTTPD</th> <th>esp-httpd&nbsp;lib</th>
<td>v%vers_httpd%</td> <td>v%vers_httpd%</td>
</tr> </tr>
<tr> <tr>
<th>SBMP</th> <th>SBMP&nbsp;lib</th>
<td>v%vers_sbmp%</td> <td>v%vers_sbmp%</td>
</tr> </tr>
<tr> <tr>
<th>IoT SDK</th> <th>ESP&nbsp;IoT&nbsp;SDK</th>
<td>v%vers_sdk%</td> <td>v%vers_sdk%</td>
</tr> </tr>
<!-- Read & show version of the stm32 firmware --> <tr>
<th>STM32&nbsp;firmware</th>
<td>v%vers_stm%</td>
</tr>
</table> </table>
<p> <p>

@ -4,23 +4,33 @@
#include <esp8266.h> #include <esp8266.h>
#include "uptime.h" #include "uptime.h"
#define VERBOSE 0
// logging functions // logging functions
#define LOG_EOL "\n" #define LOG_EOL "\n"
#define banner(fmt, ...) \
do { \
printf(LOG_EOL "\x1b[32;1m"); \
uptime_print(); \
printf(" [i] "fmt"\x1b[0m" LOG_EOL LOG_EOL, ##__VA_ARGS__); \
} while(0)
#define dbg(fmt, ...) \ // same as 'info', except enabled even if verbose is disabled
#define banner_info(fmt, ...) \
do { \ do { \
printf("\x1b[32m"); \
uptime_print(); \ uptime_print(); \
printf(" [ ] "fmt LOG_EOL, ##__VA_ARGS__); \ printf(" [i] "fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__); \
} while(0) } while(0)
#define banner(fmt, ...) \ #if VERBOSE
#define dbg(fmt, ...) \
do { \ do { \
printf(LOG_EOL "\x1b[32;1m"); \
uptime_print(); \ uptime_print(); \
printf(" [i] "fmt"\x1b[0m" LOG_EOL LOG_EOL, ##__VA_ARGS__); \ printf(" [ ] "fmt LOG_EOL, ##__VA_ARGS__); \
} while(0) } while(0)
@ -30,6 +40,10 @@
uptime_print(); \ uptime_print(); \
printf(" [i] "fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__); \ printf(" [i] "fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__); \
} while(0) } while(0)
#else
#define dbg(fmt, ...)
#define info(fmt, ...)
#endif
#define error(fmt, ...) \ #define error(fmt, ...) \

@ -17,6 +17,7 @@
#define DG_WPS_START 45 // start WPS #define DG_WPS_START 45 // start WPS
#define DG_WIFI_STATUS 46 // WiFi status report #define DG_WIFI_STATUS 46 // WiFi status report
#define DG_REQUEST_STM_VERSION 47 // Get acquisition module firmware version
extern SBMP_Endpoint *dlnk_ep; extern SBMP_Endpoint *dlnk_ep;

@ -1,6 +1,6 @@
#ifndef FW_VERSION_H #ifndef FW_VERSION_H
#define FW_VERSION_H #define FW_VERSION_H
#define FIRMWARE_VERSION "0.1.3" #define FIRMWARE_VERSION "1.0.0"
#endif // FW_VERSION_H #endif // FW_VERSION_H

@ -3,6 +3,26 @@
#include "page_about.h" #include "page_about.h"
#include "fw_version.h" #include "fw_version.h"
#include "sbmp.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 */ /** "About" page */
httpd_cgi_state FLASH_FN tplAbout(HttpdConnData *connData, char *token, void **arg) 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")) { } else if (streq(token, "vers_sdk")) {
httpdSend(connData, STR(ESP_SDK_VERSION), -1); 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; return HTTPD_CGI_DONE;

@ -85,11 +85,11 @@ void user_init(void)
uptime_timer_init(); uptime_timer_init();
banner("*** AC current analyser - WiFi module ***"); banner("*** AC current analyser - WiFi module ***");
info("(c) Ondrej Hruska, 2016"); banner_info("(c) Ondrej Hruska, 2016");
info("Katedra mereni FEL CVUT"); banner_info("Katedra mereni FEL CVUT");
info(""); banner_info("");
info("Version "FIRMWARE_VERSION", built "__DATE__" at "__TIME__); banner_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("HTTPD v."HTTPDVER", SBMP v."SBMP_VER", IoT SDK v."STR(ESP_SDK_VERSION));
printf(LOG_EOL); printf(LOG_EOL);
// reset button etc // reset button etc
@ -117,7 +117,7 @@ void user_init(void)
reporting_cfg_load(); reporting_cfg_load();
printf(LOG_EOL); printf(LOG_EOL);
info("Ready"); banner_info("Ready");
printf(LOG_EOL); printf(LOG_EOL);
wificontrol_init(); wificontrol_init();

Loading…
Cancel
Save