Get application version and git hash information

vanBassum
Posts: 68
Joined: Sun Jan 17, 2021 11:59 am

Get application version and git hash information

Postby vanBassum » Mon May 15, 2023 7:35 am

Hello,

Is it possible to use both a custom version and get the git commit hash as well?

Code: Select all

#pragma once
#include <string>
#include "esp_app_desc.h"
#include "icommand.h"

namespace Commands
{
	class AppInfo : public ICommand
	{
	public:
		virtual bool Execute(const std::string& input, std::string& result) override
		{
			const esp_app_desc_t* description = esp_app_get_description();
			result.append("Version: ");
			result.append(std::string(description->version));
			result.append("\nName: ");
			result.append(std::string(description->project_name));
			result.append("\nComileTime: ");
			result.append(std::string(description->time));
			result.append("\nComileDate: ");
			result.append(std::string(description->date));
			result.append("\nIDF Version: ");
			result.append(std::string(description->idf_ver));
			result.append("\nELF SHA256: ");
			result.append(hexStr(description->app_elf_sha256, 32));
			return true;
		}
	};
}

Code: Select all

Version: 0.0.1
Name: Pinpad
ComileTime: 09:29:38
ComileDate: May 15 2023
IDF Version: v5.0-dirty
ELF SHA256: 5a53e09293d940c3cb3141a95a6197d9bccbc1d7bbd16abd0a97eef9f977bacc

Who is online

Users browsing this forum: No registered users and 112 guests