diff --git a/Makefile b/Makefile index 94f7de4..f46c2dc 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,12 @@ TARGET = badgemagic-ch582 OPT = -Os +####################################### +# Get current version +####################################### +VERSION_ABBR = $(shell git describe --abbrev=0 --tags) +VERSION = $(shell git describe --tags --dirty) + ####################################### # paths ####################################### @@ -121,6 +127,7 @@ ifeq ($(DEBUG), 1) CFLAGS += -g -gdwarf-2 -DDEBUG=$(DEBUG) endif +CFLAGS += -DVERSION='"$(VERSION)"' -DVERSION_ABBR='"$(VERSION_ABBR)"' # Generate dependency information CFLAGS += -MMD -MP diff --git a/src/ble/profile/devinfo.c b/src/ble/profile/devinfo.c index f29526d..d68aea4 100644 --- a/src/ble/profile/devinfo.c +++ b/src/ble/profile/devinfo.c @@ -5,14 +5,14 @@ static const uint8_t systemId_val[] = {0, 0, 0, 0, 0, 0, 0, 0}; static const uint16_t systemId_UUID = SYSTEM_ID_UUID; -static const uint8_t modelNumber_val[] = "B1144"; +static const uint8_t modelNumber_val[] = "BM1144"; static const uint16_t modelNumber_UUID = MODEL_NUMBER_UUID; const uint16_t serialNumber_UUID = SERIAL_NUMBER_UUID; static const uint8_t serialNumber_val[] = "N/A"; const uint16_t firmwareRev_UUID = FIRMWARE_REV_UUID; -static const uint8_t firmwareRev_val[] = "v0.0.1"; +static const uint8_t firmwareRev_val[] = VERSION; const uint16_t hardwareRev_UUID = HARDWARE_REV_UUID; static const uint8_t hardwareRev_val[] = "221028"; diff --git a/src/main.c b/src/main.c index 4e13913..7ac2eda 100644 --- a/src/main.c +++ b/src/main.c @@ -412,7 +412,7 @@ static void disp_charging() if (is_charging()) { disp_bat_stt(blink ? percent : 0, 2, 2); if (ani_xbm_next_frame(&fabm_xbm, fb, 16, 0) == 0) { - fb_puts("v0.1", 4, 16, 2); // TODO: get version from git tag + fb_puts(VERSION_ABBR, sizeof(VERSION_ABBR), 16, 2); fb_putchar(' ', 40, 2); } blink = !blink; diff --git a/src/usb/dev.c b/src/usb/dev.c index fb28e43..78900c7 100644 --- a/src/usb/dev.c +++ b/src/usb/dev.c @@ -53,16 +53,23 @@ static uint16_t product_info[] = { 'M', 'a', 'g', 'i', 'c' }; -// TODO: auto update firmware version by CI here static uint16_t serial_number[] = { - 47 * 2 | /* bLength */ + (12 + sizeof(VERSION_ABBR) - 1) * 2 | /* bLength */ 0x03 << 8, /* bDescriptorType */ /* bString */ - 'N', 'o', 't', ' ', 'y', 'e', 't', ' ', - 'i', 'm', 'p', 'l', 'e', 'm', 'e', 'n', 't', 'e', 'd', '\n', - 'P', 'R', 'E', 'S', 'S', ' ', 'A', 'L', 'T', '+', 'F', '4', ' ', - 'T', 'O', ' ', 'C', 'O', 'N', 'T', 'I', 'N', 'U', 'E', '.' + 'B', 'M', '1', '1', '4', '4', ' ', + 'f', 'w', ':',' ', + /* vX.Y */ + VERSION[0], + VERSION[1], + VERSION[2], + VERSION[3], + VERSION[4], + VERSION[5], + VERSION[6], + VERSION[7], + VERSION[8] }; static void desc_dev(USB_SETUP_REQ *request)