From b1c30f06509459e5afc5291de067b1946ae4ddd5 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 10 Dec 2020 11:28:15 +0800 Subject: [PATCH 1/6] Use a custom platformio py file to always set build version --- bin/build-all.sh | 2 +- bin/buildinfo.py | 11 +++++++++++ bin/platformio-custom.py | 17 +++++++++++++++++ bin/version.sh | 3 --- docs/software/TODO.md | 4 +++- platformio.ini | 5 +++-- src/configuration.h | 9 ++++++--- 7 files changed, 41 insertions(+), 10 deletions(-) create mode 100755 bin/buildinfo.py create mode 100644 bin/platformio-custom.py delete mode 100644 bin/version.sh diff --git a/bin/build-all.sh b/bin/build-all.sh index ab779e187..5021680c3 100755 --- a/bin/build-all.sh +++ b/bin/build-all.sh @@ -2,7 +2,7 @@ set -e -source bin/version.sh +VERSION=`bin/buildinfo.py` COUNTRIES="US EU433 EU865 CN JP ANZ KR" #COUNTRIES=US diff --git a/bin/buildinfo.py b/bin/buildinfo.py new file mode 100755 index 000000000..803b5bc7e --- /dev/null +++ b/bin/buildinfo.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +import configparser + +config = configparser.RawConfigParser() +config.read('version.properties') + +version = dict(config.items('VERSION')) + +verStr = "{}.{}.{}".format(version["major"], version["minor"], version["build"]) + +print(f"{verStr}") diff --git a/bin/platformio-custom.py b/bin/platformio-custom.py new file mode 100644 index 000000000..607906972 --- /dev/null +++ b/bin/platformio-custom.py @@ -0,0 +1,17 @@ +import configparser + +config = configparser.RawConfigParser() +config.read('version.properties') + +version = dict(config.items('VERSION')) + +verStr = "{}.{}.{}".format(version["major"], version["minor"], version["build"]) + +print(f"Using meshtastic platform-custom.py, firmare version {verStr}") + +Import("env", "projenv") + +# General options that are passed to the C and C++ compilers +projenv.Append(CCFLAGS=[ + f"-DAPP_VERSION={verStr}" + ]) \ No newline at end of file diff --git a/bin/version.sh b/bin/version.sh deleted file mode 100644 index 2e7677737..000000000 --- a/bin/version.sh +++ /dev/null @@ -1,3 +0,0 @@ - - -export VERSION=1.1.9 \ No newline at end of file diff --git a/docs/software/TODO.md b/docs/software/TODO.md index 822fbd4a4..6398e11fb 100644 --- a/docs/software/TODO.md +++ b/docs/software/TODO.md @@ -4,11 +4,13 @@ You probably don't care about this section - skip to the next one. For app cleanup: -* do fixed position bug https://github.com/meshtastic/Meshtastic-device/issues/536 +* make device build always have a valid version +* DONE do fixed position bug https://github.com/meshtastic/Meshtastic-device/issues/536 * check build guide * generate autodocs * write user guide * DONE update android code: https://developer.android.com/topic/libraries/view-binding/migration +* only do wantReplies once per packet type, if we change network settings force it again * make gpio watch work, use thread and setup * make hello world example service * make python ping command diff --git a/platformio.ini b/platformio.ini index 4f73d1955..015aa105b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -19,16 +19,17 @@ default_envs = tbeam # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you ; The following environment variables must be set in the shell if you'd like to override them. ; They are used in this ini file as systenv.VARNAME, so in your shell do export "VARNAME=fish" ; COUNTRY (default US), i.e. "export COUNTRY=EU865" -; APP_VERSION (default emptystring) ; HW_VERSION (default emptystring) [env] +; note: APP_VERSION now comes from bin/version.json +extra_scripts = bin/platformio-custom.py + ; note: we add src to our include search path so that lmic_project_config can override ; FIXME: fix lib/BluetoothOTA dependency back on src/ so we can remove -Isrc build_flags = -Wno-missing-field-initializers -Isrc -Isrc/mesh -Isrc/gps -Ilib/nanopb/include -Wl,-Map,.pio/build/output.map -DHW_VERSION_${sysenv.COUNTRY} - -DAPP_VERSION=${sysenv.APP_VERSION} -DHW_VERSION=${sysenv.HW_VERSION} -DUSE_THREAD_NAMES -DTINYGPSPLUS_OPTION_NO_CUSTOM_FIELDS diff --git a/src/configuration.h b/src/configuration.h index ed851ed8f..28eea052b 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -31,9 +31,12 @@ along with this program. If not, see . // If app version is not specified we assume we are not being invoked by the build script #ifndef APP_VERSION -#error APP_VERSION, HW_VERSION, and HW_VERSION_countryname must be set by the build environment -//#define APP_VERSION 0.0.0 // this def normally comes from build-all.sh -//#define HW_VERSION 1.0 - US // normally comes from build-all.sh and contains the region code +#error APP_VERSION must be set by the build environment +#endif + +// If app version is not specified we assume we are not being invoked by the build script +#ifndef HW_VERSION +#error HW_VERSION, and HW_VERSION_countryname must be set by the build environment #endif // ----------------------------------------------------------------------------- From df8b3ebbc70b1d02dfaf44658bd9aa4b357eac2b Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 10 Dec 2020 11:32:51 +0800 Subject: [PATCH 2/6] always pull min_app_version from appload --- src/mesh/NodeDB.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index de21cb58f..f6ef03f5d 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -165,7 +165,6 @@ void NodeDB::installDefaultDeviceState() // default to no GPS, until one has been found by probing myNodeInfo.has_gps = false; myNodeInfo.message_timeout_msec = FLOOD_EXPIRE_TIME; - myNodeInfo.min_app_version = 20120; // format is Mmmss (where M is 1+the numeric major number. i.e. 20120 means 1.1.20 generatePacketId(); // FIXME - ugly way to init current_packet_id; // Init our blank owner info to reasonable defaults @@ -200,6 +199,9 @@ void NodeDB::init() myNodeInfo.node_num_bits = sizeof(NodeNum) * 8; myNodeInfo.packet_id_bits = sizeof(PacketId) * 8; + // likewise - we always want the app requirements to come from the running appload + myNodeInfo.min_app_version = 20120; // format is Mmmss (where M is 1+the numeric major number. i.e. 20120 means 1.1.20 + // Note! We do this after loading saved settings, so that if somehow an invalid nodenum was stored in preferences we won't // keep using that nodenum forever. Crummy guess at our nodenum (but we will check against the nodedb to avoid conflicts) pickNewNodeNum(); From cabeacfa94d5053c6a89e9f70a79eba49f445724 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 10 Dec 2020 11:45:22 +0800 Subject: [PATCH 3/6] 1.1.21 --- docs/software/TODO.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/software/TODO.md b/docs/software/TODO.md index 6398e11fb..7c76b12b3 100644 --- a/docs/software/TODO.md +++ b/docs/software/TODO.md @@ -4,11 +4,11 @@ You probably don't care about this section - skip to the next one. For app cleanup: -* make device build always have a valid version +* DONE make device build always have a valid version * DONE do fixed position bug https://github.com/meshtastic/Meshtastic-device/issues/536 * check build guide * generate autodocs -* write user guide +* write devapi user guide * DONE update android code: https://developer.android.com/topic/libraries/view-binding/migration * only do wantReplies once per packet type, if we change network settings force it again * make gpio watch work, use thread and setup @@ -29,12 +29,11 @@ For app cleanup: * DONE Add SinglePortNumPlugin - as the new most useful baseclass * DONE move positions into regular data packets (use new app framework) * DONE move user info into regular data packets (use new app framework) -* test that positions, text messages and user info still work -* test that position, text messages and user info work properly with new android app and old device code +* DONE test that positions, text messages and user info still work +* DONE test that position, text messages and user info work properly with new android app and old device code * fix the RTC drift bug -* move ping functionality into device, reply with rxsnr info +* move python ping functionality into device, reply with rxsnr info * use channels for gpio security https://github.com/meshtastic/Meshtastic-device/issues/104 -* implement GPIO watch For high speed/lots of devices/short range tasks: From 45d72bd51b45333d44f44870dd9fd452bd233950 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 10 Dec 2020 12:44:35 +0800 Subject: [PATCH 4/6] fix CI build - make projectdir relative --- bin/platformio-custom.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bin/platformio-custom.py b/bin/platformio-custom.py index 607906972..b0749ea26 100644 --- a/bin/platformio-custom.py +++ b/bin/platformio-custom.py @@ -1,16 +1,14 @@ + +Import("projenv") + import configparser - config = configparser.RawConfigParser() -config.read('version.properties') - +config.read(projenv["PROJECT_DIR"] + "/version.properties") version = dict(config.items('VERSION')) - verStr = "{}.{}.{}".format(version["major"], version["minor"], version["build"]) print(f"Using meshtastic platform-custom.py, firmare version {verStr}") -Import("env", "projenv") - # General options that are passed to the C and C++ compilers projenv.Append(CCFLAGS=[ f"-DAPP_VERSION={verStr}" From 99c8df8e7d5f32459ac0f38c8cfd6d58ef6bea15 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 10 Dec 2020 13:17:43 +0800 Subject: [PATCH 5/6] try to fix CI again --- bin/platformio-custom.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bin/platformio-custom.py b/bin/platformio-custom.py index b0749ea26..bb8a53b50 100644 --- a/bin/platformio-custom.py +++ b/bin/platformio-custom.py @@ -2,14 +2,20 @@ Import("projenv") import configparser -config = configparser.RawConfigParser() -config.read(projenv["PROJECT_DIR"] + "/version.properties") -version = dict(config.items('VERSION')) -verStr = "{}.{}.{}".format(version["major"], version["minor"], version["build"]) +prefsLoc = projenv["PROJECT_DIR"] + "/version.properties" +print(f"Preferences in {prefsLoc}") +try: + config = configparser.RawConfigParser() + config.read(prefsLoc) + version = dict(config.items('VERSION')) + verStr = "{}.{}.{}".format(version["major"], version["minor"], version["build"]) +except: + print("Can't read preferences, using 0.0.0") + verStr = "0.0.0" print(f"Using meshtastic platform-custom.py, firmare version {verStr}") # General options that are passed to the C and C++ compilers projenv.Append(CCFLAGS=[ f"-DAPP_VERSION={verStr}" - ]) \ No newline at end of file + ]) From 4cbf0a0730a5998d3f487c7fc52be72821f12438 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 10 Dec 2020 13:19:00 +0800 Subject: [PATCH 6/6] oops - forgot to check in the new version file, broke CI --- version.properties | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 version.properties diff --git a/version.properties b/version.properties new file mode 100644 index 000000000..f903d2c5e --- /dev/null +++ b/version.properties @@ -0,0 +1,4 @@ +[VERSION] +major = 1 +minor = 1 +build = 20 \ No newline at end of file