Skip to content

Commit 6ac4fba

Browse files
Added command for getting firmware version as uint32
The intent is to provide a version number compatible with semver/semver#516 (comment) which could be more useful for numerical operations
1 parent ec59215 commit 6ac4fba

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

UNOR4USBBridge/cmds_esp_generic.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ extern "C" {
66
#include "esp32-hal-tinyusb.h"
77
}
88

9+
static const uint8_t version[4] = {
10+
(FIRMWARE_MAJOR & 0xff),
11+
(FIRMWARE_MINOR & 0xff),
12+
(FIRMWARE_PATCH & 0xff),
13+
0
14+
};
15+
916
void CAtHandler::add_cmds_esp_generic() {
1017

1118
/* ....................................................................... */
@@ -71,6 +78,26 @@ void CAtHandler::add_cmds_esp_generic() {
7178
}
7279
};
7380

81+
/* ....................................................................... */
82+
command_table[_FWVERSION_U32] = [this](auto & srv, auto & parser) {
83+
/* ....................................................................... */
84+
switch (parser.cmd_mode) {
85+
case chAT::CommandMode::Read: {
86+
srv.write_response_prompt();
87+
88+
89+
90+
log_e("version 0x%X, 0x%X", *((uint32_t*)version), &version);
91+
92+
srv.write_data(version, sizeof(version));
93+
srv.write_line_end();
94+
return chAT::CommandStatus::OK;
95+
}
96+
default:
97+
return chAT::CommandStatus::ERROR;
98+
}
99+
};
100+
74101
/* ....................................................................... */
75102
command_table[_FILESYSTEM] = [this](auto & srv, auto & parser) {
76103
/* ....................................................................... */

UNOR4USBBridge/commands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ enum file_op {
105105
#define _UDPSTOP "+UDPSTOP"
106106

107107
#define _FWVERSION "+FWVERSION"
108+
#define _FWVERSION_U32 "+FWVERSION_U32"
108109

109110
#define _SOFTAPCONFIG "+SOFTAPCONFIG"
110111
#define _SERVERWRITE "+SERVERWRITE"

0 commit comments

Comments
 (0)