Skip to content

Commit e48b015

Browse files
committed
Add version info
1 parent 7103086 commit e48b015

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

include/version.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define VERSION_MAJOR "1"
2+
#define VERSION_MINOR "0"
3+
#define VERSION_PATCH "0"
4+
#define VERSION_BUILD "0"

include/version_build.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define BUILD_BRANCH ""
2+
#define BUILD_COMMIT ""
3+
#define BUILD_DATE ""
4+
#define BUILD_TIME ""

platformio.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ board = pro8MHzatmega328
1717
framework = arduino
1818
monitor_speed = 115200
1919
upload_protocol = usbasp
20+
extra_scripts =
21+
pre:tools/platformio_versioning.py
2022

2123
upload_flags =
2224
-Pusb

src/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
#include "lorawan.h"
55
#include "global.h"
66
#include "powerdown.h"
7+
#include "version.h"
8+
#include "version_build.h"
79

810
void setup()
911
{
1012
Serial.begin(115200);
1113
Serial.println(F("Starting DHT ..."));
14+
Serial.println("Sketch: " VERSION_MAJOR "." VERSION_MINOR "." VERSION_PATCH "." BUILD_COMMIT "-" BUILD_BRANCH);
15+
Serial.println("Builddate: " BUILD_DATE " " BUILD_TIME);
1216
PrintResetReason();
1317
LoRaWANVersion();
1418
delay(3000);

tools/platformio_versioning.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
import os
3+
4+
# Optional: Define Path to your local verison of https://github.com/JackGruber/auto_buildnumber
5+
# If it is not located at a position same folder as `platformio_versioning.py`
6+
autoversion = 'C:\\git\\meine\\auto_buildnumber'
7+
8+
try:
9+
import versioning
10+
autver_ok = True
11+
except:
12+
if os.path.exists(autoversion):
13+
sys.path.insert(0, autoversion)
14+
try:
15+
import versioning
16+
autver_ok = True
17+
except:
18+
autver_ok = False
19+
else:
20+
autver_ok = False
21+
22+
if autver_ok == True:
23+
versioning.UpdateVersionFile("include/version.h", "DEFINEHEADER", False, "include/version_build.h")

0 commit comments

Comments
 (0)