diff --git a/arduino/libretuya/api/LibreTuyaAPI.h b/arduino/libretuya/api/LibreTuyaAPI.h index 2f59c7d..2f9b7f3 100644 --- a/arduino/libretuya/api/LibreTuyaAPI.h +++ b/arduino/libretuya/api/LibreTuyaAPI.h @@ -1,9 +1,18 @@ #pragma once #ifndef LT_VERSION -#define LT_VERSION "1.0.0" +#define LT_VERSION 1.0.0 #endif +#ifndef LT_BOARD +#define LT_BOARD unknown +#endif + +#define STRINGIFY(x) #x +#define STRINGIFY_MACRO(x) STRINGIFY(x) +#define LT_VERSION_STR STRINGIFY_MACRO(LT_VERSION) +#define LT_BOARD_STR STRINGIFY_MACRO(LT_BOARD) + #include #include "LibreTuyaConfig.h" @@ -19,4 +28,9 @@ extern "C" { #endif #define LT_BANNER() \ - LT_LOG(LT_LEVEL_INFO, "main.cpp", __LINE__, "LibreTuya v" LT_VERSION " compiled on " __DATE__ " " __TIME__) + LT_LOG( \ + LT_LEVEL_INFO, \ + "main.cpp", \ + __LINE__, \ + "LibreTuya v" LT_VERSION_STR " on " LT_BOARD_STR ", compiled at " __DATE__ " " __TIME__ \ + ) diff --git a/builder/arduino-common.py b/builder/arduino-common.py index cbca4b0..2e6d39d 100644 --- a/builder/arduino-common.py +++ b/builder/arduino-common.py @@ -19,7 +19,11 @@ env.Prepend( join(LT_API_DIR), join(LT_API_DIR, "compat"), # fmt: on - ] + ], + CPPDEFINES=[ + ("LT_VERSION", platform.version), + ("LT_BOARD", board.get("build.variant")), + ], ) sources_api = [ diff --git a/builder/main.py b/builder/main.py index 0c76a8a..8a1c4a6 100644 --- a/builder/main.py +++ b/builder/main.py @@ -24,12 +24,6 @@ env.Replace( SIZETOOL="arm-none-eabi-size", ) -env.Append( - CPPDEFINES=[ - ("LT_VERSION", "0.1.0"), - ] -) - # Flash layout defines flash_layout: dict = board.get("flash") if flash_layout: diff --git a/platform.json b/platform.json index d1b922a..d5a00e3 100644 --- a/platform.json +++ b/platform.json @@ -6,7 +6,7 @@ "type": "git", "url": "https://github.com/kuba2k2/platformio-libretuya" }, - "version": "1.0.0", + "version": "0.1.0", "frameworks": { "realtek-ambz-sdk": { "tilte": "Realtek AmebaZ - SDK",