Skip to content

Commit

Permalink
information: add firmware-version
Browse files Browse the repository at this point in the history
  • Loading branch information
blocktrron committed Apr 5, 2024
1 parent 491cb5d commit 2f29c7a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions openwrt/node-whisperer/files/node-whisperer.uci
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ config settings 'settings'
list information 'site_code'
list information 'domain'
list information 'system_load'
list information 'firmware_version'
list information 'batman_adv'
38 changes: 38 additions & 0 deletions src/information.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,27 @@ int node_whisperer_information_system_load_collect(uint8_t *buffer, size_t buffe
return 1;
}

int node_whisperer_information_firmware_version_collect(uint8_t *buffer, size_t buffer_size) {
char *firmware_version;
size_t firmware_version_len;
int ret;

ret = nw_read_file("/lib/gluon/release", &firmware_version, &firmware_version_len);
if (ret) {
return ret;
}

if (firmware_version_len > buffer_size) {
free(firmware_version);
return -1;
}

memcpy(buffer, firmware_version, firmware_version_len);
free(firmware_version);

return firmware_version_len;
}

#else

int node_whisperer_information_hostname_parse(const uint8_t *ie_buf, size_t ie_len) {
Expand Down Expand Up @@ -306,6 +327,22 @@ int node_whisperer_information_system_load_parse(const uint8_t *ie_buf, size_t i
return 0;
}

int node_whisperer_information_firmware_version_parse(const uint8_t *ie_buf, size_t ie_len) {
char *tmp;

tmp = malloc(ie_len + 1);
if (!tmp)
return -1;

memcpy(tmp, ie_buf, ie_len);
tmp[ie_len] = '\0';

printf("Firmware version: %s\n", tmp);
free(tmp);

return 0;
}

#endif


Expand All @@ -316,6 +353,7 @@ struct nw_information_source information_sources[] = {
INFORMATION_SOURCE(site_code, 3),
INFORMATION_SOURCE(domain, 4),
INFORMATION_SOURCE(system_load, 5),
INFORMATION_SOURCE(firmware_version, 6),
INFORMATION_SOURCE(batman_adv, 20),
{},
};

0 comments on commit 2f29c7a

Please sign in to comment.