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..bb8a53b50 --- /dev/null +++ b/bin/platformio-custom.py @@ -0,0 +1,21 @@ + +Import("projenv") + +import configparser +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}" + ]) 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..7c76b12b3 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 +* 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 * make hello world example service * make python ping command @@ -27,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: 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 // ----------------------------------------------------------------------------- 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(); 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