version.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct Version Version;
  8. /** Get current running firmware version handle.
  9. *
  10. * You can store it somewhere. But if you want to retrieve data, you have to use
  11. * 'version_*_get()' set of functions. Also, 'version_*_get()' imply to use this
  12. * handle if no handle (NULL_PTR) provided.
  13. *
  14. * @return pointer to Version data.
  15. */
  16. const Version* version_get(void);
  17. /** Get git commit hash.
  18. *
  19. * @param v pointer to Version data. NULL for currently running
  20. * software.
  21. *
  22. * @return git hash
  23. */
  24. const char* version_get_githash(const Version* v);
  25. /** Get git branch.
  26. *
  27. * @param v pointer to Version data. NULL for currently running
  28. * software.
  29. *
  30. * @return git branch
  31. */
  32. const char* version_get_gitbranch(const Version* v);
  33. /** Get number of commit in git branch.
  34. *
  35. * @param v pointer to Version data. NULL for currently running
  36. * software.
  37. *
  38. * @return number of commit
  39. */
  40. const char* version_get_gitbranchnum(const Version* v);
  41. /** Get build date.
  42. *
  43. * @param v pointer to Version data. NULL for currently running
  44. * software.
  45. *
  46. * @return build date
  47. */
  48. const char* version_get_builddate(const Version* v);
  49. /** Get build version. Build version is last tag in git history.
  50. *
  51. * @param v pointer to Version data. NULL for currently running
  52. * software.
  53. *
  54. * @return build date
  55. */
  56. const char* version_get_version(const Version* v);
  57. /** Get hardware target this firmware was built for
  58. *
  59. * @param v pointer to Version data. NULL for currently running
  60. * software.
  61. *
  62. * @return build date
  63. */
  64. uint8_t version_get_target(const Version* v);
  65. /** Get flag indicating if this build is "dirty" (source code had uncommited changes)
  66. *
  67. * @param v pointer to Version data. NULL for currently running
  68. * software.
  69. *
  70. * @return build date
  71. */
  72. bool version_get_dirty_flag(const Version* v);
  73. #ifdef __cplusplus
  74. }
  75. #endif