From 0250816a403a74aac3e41b01cd9cfd8dece77842 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Sat, 11 Jul 2026 19:21:11 +0200 Subject: [PATCH] config: git-ignored BLE PIN secret + SenseCap SHT41/INA226 + nRF52 framework symlink Co-Authored-By: Claude Opus 4.8 --- platformio.ini | 10 ++++++- variants/sensecap_solar/build_version.py | 25 +++++++++++++++++ variants/sensecap_solar/platformio.ini | 35 +++++++++++++++++++++++- variants/t1000-e/platformio.ini | 2 +- 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 variants/sensecap_solar/build_version.py diff --git a/platformio.ini b/platformio.ini index e16f7b83..eef5bb61 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,6 +13,12 @@ extra_configs = variants/*/platformio.ini platformio.local.ini +; Default BLE pairing PIN. This is a non-secret placeholder; override it with +; your real PIN in the git-ignored platformio.local.ini ([secrets] ble_pin=...) +; so the real value never lands in the committed tree. +[secrets] +ble_pin = 123456 + [arduino_base] framework = arduino monitor_speed = 115200 @@ -84,7 +90,9 @@ platform_packages = ; use internal fork that includes patch to ble stack to prevent firmware lockup during rapid connect/disconnect ; https://github.com/meshcore-dev/MeshCore/pull/1177 ; https://github.com/meshcore-dev/MeshCore/pull/1295 - framework-arduinoadafruitnrf52 @ https://github.com/meshcore-dev/Adafruit_nRF52_Arduino#d541301 + ; LOKÁLNÍ build hack (TeTeHacko): shallow git fetch krátkého SHA neumí, tak plný klon + symlink. + ; upstream: framework-arduinoadafruitnrf52 @ https://github.com/meshcore-dev/Adafruit_nRF52_Arduino#d541301 + framework-arduinoadafruitnrf52 @ symlink:///home/user/projects/meshcore-nrf52-fw extra_scripts = create-uf2.py build_flags = ${arduino_base.build_flags} -D NRF52_PLATFORM diff --git a/variants/sensecap_solar/build_version.py b/variants/sensecap_solar/build_version.py new file mode 100644 index 00000000..0a5e4378 --- /dev/null +++ b/variants/sensecap_solar/build_version.py @@ -0,0 +1,25 @@ +# CUSTOM (TeTeHacko): custom version and build date/time for the `ver` command. +# Injects FIRMWARE_VERSION (v1.16.0-tth-, '+' = dirty tree) and +# FIRMWARE_BUILD_DATE (compile time). NOTE: the define changes every build = +# full rebuild each time (~10-30 s) -- the price for an always-fresh timestamp. +Import("env") +import subprocess +from datetime import datetime + +sha = "nogit" +dirty = "" +try: + cwd = env.subst("$PROJECT_DIR") + sha = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], cwd=cwd).decode().strip() + if subprocess.call(["git", "diff", "--quiet"], cwd=cwd) != 0: + dirty = "+" +except Exception: + pass + +version = "v1.16.0-tth-%s%s" % (sha, dirty) +build_date = datetime.now().strftime("%d %b %Y %H:%M") +env.Append(CPPDEFINES=[ + ("FIRMWARE_VERSION", env.StringifyMacro(version)), + ("FIRMWARE_BUILD_DATE", env.StringifyMacro(build_date)), +]) +print("build_version.py: %s (Build: %s)" % (version, build_date)) diff --git a/variants/sensecap_solar/platformio.ini b/variants/sensecap_solar/platformio.ini index effef38c..f3d6c72a 100644 --- a/variants/sensecap_solar/platformio.ini +++ b/variants/sensecap_solar/platformio.ini @@ -51,6 +51,39 @@ build_flags = build_src_filter = ${SenseCap_Solar.build_src_filter} +<../examples/simple_repeater/*.cpp> +; CUSTOM (TeTeHacko): repeater + BLE UART console (wireless querying, no USB). +; The s140 SoftDevice is already linked by the SenseCap_Solar base, so the BLE stack is available. +[env:SenseCap_Solar_repeater_ble] +extends = SenseCap_Solar +board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld +board_upload.maximum_size = 708608 +; custom version + build timestamp for `ver` (see build_version.py) +extra_scripts = ${nrf52_base.extra_scripts} + pre:variants/sensecap_solar/build_version.py +build_flags = + ${SenseCap_Solar.build_flags} + -D ADVERT_NAME='"SenseCap_Solar Repeater"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' + -D MAX_NEIGHBOURS=50 + ; Real BLE PIN lives ONLY in the git-ignored platformio.local.ini ([secrets] ble_pin). + ; The committed default (123456) is a non-secret placeholder. + -D BLE_PIN_CODE=${secrets.ble_pin} + ; INA226 defaults to 0x44 in EnvironmentSensorManager = collision with SHT41 + ; (false detection, garbage in telemetry). 0x40 is the real INA226 HW default. + -D TELEM_INA226_ADDRESS=0x40 + ; GPS detection (1 s window for NMEA after power-on) is a race and randomly + ; fails. When it loses, the gps setting is not exposed and the persisted + ; _prefs.gps_enabled cannot be applied at boot -> GPS (and RTC sync!) stays + ; dead until the next lucky boot. The P1-Pro always has GPS -> skip detection. + ; GPS on/off itself persists via the `gps on|off` CLI command (NodePrefs). + ; Note: the L76K draws ~25-35 mA — plan for the extra power on a solar node. + -D ENV_SKIP_GPS_DETECT=1 +; -D MESH_PACKET_LOGGING=1 +build_src_filter = ${SenseCap_Solar.build_src_filter} + +<../examples/simple_repeater/*.cpp> + [env:SenseCap_Solar_room_server] extends = SenseCap_Solar build_flags = @@ -72,7 +105,7 @@ build_flags = ${SenseCap_Solar.build_flags} -D MAX_CONTACTS=350 -D MAX_GROUP_CHANNELS=40 - -D BLE_PIN_CODE=123456 + -D BLE_PIN_CODE=${secrets.ble_pin} -D OFFLINE_QUEUE_SIZE=256 ; -D BLE_DEBUG_LOGGING=1 ; -D MESH_PACKET_LOGGING=1 diff --git a/variants/t1000-e/platformio.ini b/variants/t1000-e/platformio.ini index 43a3d93f..bfd9d554 100644 --- a/variants/t1000-e/platformio.ini +++ b/variants/t1000-e/platformio.ini @@ -99,7 +99,7 @@ build_flags = ${t1000-e.build_flags} -I examples/companion_radio/ui-orig -D MAX_CONTACTS=350 -D MAX_GROUP_CHANNELS=40 - -D BLE_PIN_CODE=123456 + -D BLE_PIN_CODE=${secrets.ble_pin} -D BLE_TX_POWER=0 ; -D BLE_DEBUG_LOGGING=1 ; -D MESH_PACKET_LOGGING=1