Add mbtk_version
Change-Id: I9f52b147f4f2a40af31eab9dd0014e7ae2402a44
diff --git a/mbtk/libmbtk_lib/src/mbtk_version.c b/mbtk/libmbtk_lib/src/mbtk_version.c
new file mode 100755
index 0000000..cbc2e68
--- /dev/null
+++ b/mbtk/libmbtk_lib/src/mbtk_version.c
@@ -0,0 +1,114 @@
+/*
+* mbtk_version.c
+*
+* mbtk_source compilation informations.
+*
+*/
+/******************************************************************************
+
+ EDIT HISTORY FOR FILE
+
+ WHEN WHO WHAT,WHERE,WHY
+-------- -------- -------------------------------------------------------
+2024/6/7 LiuBin Initial version
+
+******************************************************************************/
+#include "mbtk_version.h"
+
+#define STR_GET(str) (#str)
+
+static mbtk_build_def_info_t def_infos[MBTK_BUILD_DEF_NUM];
+static bool inited = FALSE;
+
+static void def_item_set(mbtk_build_define_enum def_id, char *name, char *value)
+{
+ switch(def_id)
+ {
+ case MBTK_BUILD_DEF_AF_SUPPORT:
+ {
+ strcpy(name, STR_GET(MBTK_BUILD_DEF_AF_SUPPORT));
+#ifdef MBTK_AF_SUPPORT
+ strcpy(value, "Y");
+#else
+ strcpy(value, "N");
+#endif
+ break;
+ }
+ case MBTK_BUILD_DEF_YX_SUPPORT:
+ {
+ strcpy(name, STR_GET(MBTK_BUILD_DEF_YX_SUPPORT));
+#ifdef MBTK_YX_SUPPORT
+ strcpy(value, "Y");
+#else
+ strcpy(value, "N");
+#endif
+ break;
+ }
+ case MBTK_BUILD_DEF_SG_SUPPORT:
+ {
+ strcpy(name, STR_GET(MBTK_BUILD_DEF_SG_SUPPORT));
+#ifdef MBTK_SG_SUPPORT
+ strcpy(value, "Y");
+#else
+ strcpy(value, "N");
+#endif
+ break;
+ }
+ case MBTK_BUILD_DEF_MBTK_ALL_CID_SUPPORT:
+ {
+ strcpy(name, STR_GET(MBTK_BUILD_DEF_MBTK_ALL_CID_SUPPORT));
+#ifdef MBTK_ALL_CID_SUPPORT
+ strcpy(value, "Y");
+#else
+ strcpy(value, "N");
+#endif
+ break;
+ }
+ case MBTK_BUILD_DEF_MBTK_GNSS_MODE:
+ {
+ strcpy(name, STR_GET(MBTK_BUILD_DEF_MBTK_GNSS_MODE));
+#if defined(MBTK_GNSS_6228)
+ strcpy(value, "6228");
+#elif defined(MBTK_GNSS_5311)
+ strcpy(value, "5311");
+#else
+ strcpy(value, "Unknown");
+#endif
+ break;
+ }
+ default:
+ {
+ strcpy(name, "Unknown");
+ strcpy(value, "Unknown");
+ break;
+ }
+ }
+}
+
+static void def_info_reset()
+{
+ if(!inited) {
+ int index = 0;
+ while(index < MBTK_BUILD_DEF_NUM) {
+ memset(&(def_infos[index]), 0, sizeof(mbtk_build_def_info_t));
+ def_item_set(index, def_infos[index].name, def_infos[index].value);
+ index++;
+ }
+ inited = TRUE;
+ }
+}
+
+void mbtk_build_def_get(char *buff, int buff_len)
+{
+ if(buff && buff_len > 0) {
+ def_info_reset();
+
+ int len = 0;
+ int index = 0;
+ while(index < MBTK_BUILD_DEF_NUM) {
+ len += snprintf(buff + len, buff_len - len, "%s:%s\n", def_infos[index].name, def_infos[index].value);
+ index++;
+ }
+ }
+}
+