From c778abceab214ec6f1e502c39960c8b095eee74e Mon Sep 17 00:00:00 2001 From: mikecarper Date: Wed, 28 Oct 2026 03:52:08 -0700 Subject: [PATCH] Shorten Companion help descriptions while retaining every command --- examples/companion_radio/CompanionHelp.inc | 57 ++++---- .../companion_help_output.sha256.json | 128 +++++++++--------- test/test_companion_help_writer.py | 59 +++++++- test/test_companion_reader.py | 2 +- test/test_companion_terminal_profile.py | 8 +- test/test_companion_usb_logging.py | 2 +- test/test_nrf52_extrafs_contract.py | 4 +- 7 files changed, 152 insertions(+), 108 deletions(-) diff --git a/examples/companion_radio/CompanionHelp.inc b/examples/companion_radio/CompanionHelp.inc index f8ee8f179..2ef6685ef 100644 --- a/examples/companion_radio/CompanionHelp.inc +++ b/examples/companion_radio/CompanionHelp.inc @@ -7,16 +7,16 @@ MESH_COMPANION_HELP_BEGIN "Commands:\r\n" " stats-core / stats-radio / stats-radio-diag / stats-packets\r\n" - " get prv.key (if export enabled)\r\n" + " get prv.key\r\n" #if defined(ESP32_PLATFORM) && defined(WIFI_SSID) " password (shared setup WiFi, WebConfig and WiFi OTA)\r\n" " get password (management password status)\r\n" #else - " get password (no admin password)\r\n" + " get password\r\n" #endif MESH_COMPANION_HELP_END MESH_COMPANION_HELP_BEGIN - " erase (settings and identity)\r\n" + " erase (settings+identity)\r\n" " board\r\n" " version\r\n" " get storage.layout\r\n" @@ -31,24 +31,23 @@ MESH_COMPANION_HELP_END MESH_COMPANION_HELP_BEGIN " get mt.status / get mt.region / get mt.slot / get mt.hops\r\n" " get mt.node / get mt.shortname\r\n" - " get mt.rebroadcast / set mt.rebroadcast (saved; default off)\r\n" - " Relay decoded channel text only; adds 5 packet airtimes before TX\r\n" + " get mt.rebroadcast / set mt.rebroadcast (default off)\r\n" MESH_COMPANION_HELP_END MESH_COMPANION_HELP_BEGIN " set mt.region \r\n" " set mt.slot <0|1-based frequency slot>\r\n" - " set mt.hops <0..7> (saved; default 7)\r\n" - " set mt.node (saved; use a unique ID)\r\n" + " set mt.hops <0..7> (default 7)\r\n" + " set mt.node \r\n" MESH_COMPANION_HELP_END MESH_COMPANION_HELP_BEGIN - " set mt.shortname <1..4 UTF-8 characters|default> (saved; NodeInfo uses 4 bytes)\r\n" - " send mt.nodeinfo (GPS-free; also automatic after first chat)\r\n" - " set mt.preset (saved manual radio2)\r\n" + " set mt.shortname <1..4 UTF-8 characters|default>\r\n" + " send mt.nodeinfo (auto after first chat)\r\n" + " set mt.preset \r\n" MESH_COMPANION_HELP_END MESH_COMPANION_HELP_BEGIN " set mt.channel <32/64 hex digits|AQ==>\r\n" " get mt.channel / delete mt.channel \r\n" - " Join #mt-longfast or #mt-shortturbo in the app for automatic radio2\r\n" + " App #mt-longfast/#mt-shortturbo: radio2\r\n" MESH_COMPANION_HELP_END #endif #if defined(NRF52_PLATFORM) && defined(EXTRAFS) && !defined(QSPIFLASH) @@ -58,12 +57,12 @@ MESH_COMPANION_HELP_END #endif #if COMPANION_FEATURE_READER MESH_COMPANION_HELP_BEGIN - " get reader [:[-]] [page] (World English Bible, offline)\r\n" + " get reader [:[-]] [page]\r\n" MESH_COMPANION_HELP_END #endif MESH_COMPANION_HELP_BEGIN - " get/set tx.media auto|radio|radio2|both|off (binary media)\r\n" - " get/set tx.ssh auto|radio|radio2|both|off (tagged tunnel data)\r\n" + " get/set tx.media auto|radio|radio2|both|off\r\n" + " get/set tx.ssh auto|radio|radio2|both|off\r\n" MESH_COMPANION_HELP_END #if MESH_ENABLE_ETHERNET_TUNNEL MESH_COMPANION_HELP_BEGIN @@ -74,19 +73,19 @@ MESH_COMPANION_HELP_END #endif #if defined(OTA_RAK15002_SD_STORE) && defined(ETHERNET_USE_RAK13800) MESH_COMPANION_HELP_BEGIN - " get eth / set eth on|off (physical RAK13800; default off, this boot)\r\n" + " get eth / set eth on|off (default off; boot)\r\n" MESH_COMPANION_HELP_END #endif #if defined(NRF52_PLATFORM) && defined(OTA_SD_STORE) MESH_COMPANION_HELP_BEGIN " get sdcard [free|ls|dir [page]|format|erase|*]\r\n" " set sdcard format|erase [--force]\r\n" - " ota cache [on|off] (SD archive)\r\n" + " ota cache [on|off]\r\n" MESH_COMPANION_HELP_END #endif MESH_COMPANION_HELP_BEGIN " power / get pwrmgt.support / get pwrmgt.source / get pwrmgt.bootmv\r\n" - " get system.watchdog (hardware status)\r\n" + " get system.watchdog\r\n" " get bootloader.ver\r\n" MESH_COMPANION_HELP_END MESH_COMPANION_HELP_BEGIN @@ -100,7 +99,7 @@ MESH_COMPANION_HELP_BEGIN " get/set display.night.delay <-180..180> (minutes after sunset; default 60)\r\n" #endif #if defined(OLED_AUTO_DETECT) && OLED_AUTO_DETECT && defined(DISPLAY_CLASS) - " get/set display.controller (saved; restart to apply)\r\n" + " get/set display.controller (restart)\r\n" #endif #ifdef PIN_BUZZER " get/set buzzer on|off\r\n" @@ -116,26 +115,26 @@ MESH_COMPANION_HELP_BEGIN " set notify. \r\n" MESH_COMPANION_HELP_END MESH_COMPANION_HELP_BEGIN - " set notify.remote on|off (!notify, max 15s, no GPIO)\r\n" + " set notify.remote on|off (!notify, <=15s, no GPIO)\r\n" " notify.test / notify.stop / notify.delete \r\n" MESH_COMPANION_HELP_END #endif MESH_COMPANION_HELP_BEGIN " get/set display.inbox \r\n" - " get/set display.touch (this boot)\r\n" + " get/set display.touch (boot)\r\n" " get public.key\r\n" " set {name|lat|lon|freq|tx|af} {value}\r\n" " get wifi|espnow|2.4ghz\r\n" - " set wifi|espnow on|off [force] (force only with off)\r\n" + " set wifi|espnow on|off [force] (force: off)\r\n" MESH_COMPANION_HELP_END MESH_COMPANION_HELP_BEGIN - " set 2.4ghz on [all|force]|off [force] (this boot)\r\n" + " set 2.4ghz on [all|force]|off [force] (boot)\r\n" " get/set bluetooth.name \r\n" MESH_COMPANION_HELP_END #if defined(BLE_PIN_CODE) MESH_COMPANION_HELP_BEGIN - " get bluetooth (alias: get ble)\r\n" - " set bluetooth [force] (saved; force only with off)\r\n" + " get bluetooth / get ble\r\n" + " set bluetooth [force] (force: off)\r\n" " get bluetooth.mac\r\n" " set bluetooth.mac \r\n" " get/set bluetooth.stealth on|off\r\n" @@ -152,7 +151,7 @@ MESH_COMPANION_HELP_BEGIN " get/set usb.debug \r\n" #if MESH_USB_CONSOLE_COOPERATIVE " get usb.watchdog.last\r\n" - " get/set usb.watchdog (saved; default auto)\r\n" + " get/set usb.watchdog (default auto)\r\n" #endif #endif MESH_COMPANION_HELP_END @@ -236,7 +235,7 @@ MESH_COMPANION_HELP_END // Keep native USB producer writes within 256 bytes. #if !defined(MESH_RADIO_SWITCH_TUNING) || MESH_RADIO_SWITCH_TUNING MESH_COMPANION_HELP_BEGIN - " get radio.fast / get radio.fast.caps (supported saved controls)\r\n" + " get radio.fast / get radio.fast.caps\r\n" " set radio.fast / set radio.fast.spi <0|2|4|8|9|16>\r\n" MESH_COMPANION_HELP_END #endif @@ -249,7 +248,7 @@ MESH_COMPANION_HELP_BEGIN MESH_COMPANION_HELP_END MESH_COMPANION_HELP_BEGIN " get rxps.wd\r\n" - " get/set radio.rxps.rfrx_disabled (this boot)\r\n" + " get/set radio.rxps.rfrx_disabled (boot)\r\n" " clear stats\r\n" MESH_COMPANION_HELP_END MESH_COMPANION_HELP_BEGIN @@ -286,10 +285,10 @@ MESH_COMPANION_HELP_BEGIN MESH_COMPANION_HELP_END #if defined(NRF52_PLATFORM) && defined(EXTRAFS) && !defined(QSPIFLASH) MESH_COMPANION_HELP_BEGIN - " repair extrafs (erases/rebuilds internal ExtraFS)\r\n" + " repair extrafs (erases ExtraFS)\r\n" MESH_COMPANION_HELP_END MESH_COMPANION_HELP_BEGIN - " scan extrafs erase (USB only; reboot for destructive page test)\r\n" + " scan extrafs erase (USB; reboot; erases pages)\r\n" MESH_COMPANION_HELP_END #endif #if COMPANION_FEATURE_TEMP_RADIO || COMPANION_FEATURE_OTA_CLI diff --git a/test/fixtures/companion_help_output.sha256.json b/test/fixtures/companion_help_output.sha256.json index 96551a395..20234e4b2 100644 --- a/test/fixtures/companion_help_output.sha256.json +++ b/test/fixtures/companion_help_output.sha256.json @@ -30,12 +30,12 @@ "MESH_ENABLE_LOST_REPLY=0" ], "output_bytes": [ - 4946, - 4938 + 4491, + 4483 ], "output_sha256": [ - "bb14e81de08d1e49d30fd23aac0b32bbbe89e233021c7772ed00ff439fa4e530", - "abb5cd540b09c9b8c7451e0a2c1ec4afbd06a3c51203e0c747f32aa8f9c2bdab" + "90da76bd3a33bb8ca4e3212475850f090bf7bc8372e5d2838603cca904fef03b", + "d1ef09f3f08a1f588e751531c1423456813ccfb9cbb723a5ca5171a73b062318" ] }, "all-options-native0-lost1": { @@ -68,12 +68,12 @@ "MESH_ENABLE_LOST_REPLY=1" ], "output_bytes": [ - 4981, - 4973 + 4526, + 4518 ], "output_sha256": [ - "ff5e938adf128262f499720545073f775293cf867d7e78be46256ab3326e0ab7", - "93f43a333536b43ae308ab8dedcd929eec11b109901818aecfa66abad204b3cc" + "29dbb3af9b59fa6d207d296ea0bb3da839b5655417fb7c74d00ea6ad9bea90d9", + "7a578f8a4c43c962bcbfadaadd452b5ab8ff1c2e8db86ad403b5242773a8e4d2" ] }, "all-options-native1-lost0": { @@ -106,12 +106,12 @@ "MESH_ENABLE_LOST_REPLY=0" ], "output_bytes": [ - 5031, - 5023 + 4569, + 4561 ], "output_sha256": [ - "65b1c10004b7f43587eba91698e6f0d281e811c22114b77401fc34248364d603", - "14d510af8083cbf03b7ac77af8bb51fca947a050a4953132e6239a3a5bf17ca7" + "9264906abd107d191dc3448be96ae74e8508bf662f28279f38a838049d2b8922", + "ec30fe0bcd47547aa7115ea0f111873c366a541f4c892cee2584331ca5c6c4bd" ] }, "all-options-native1-lost1": { @@ -144,12 +144,12 @@ "MESH_ENABLE_LOST_REPLY=1" ], "output_bytes": [ - 5066, - 5058 + 4604, + 4596 ], "output_sha256": [ - "693e01f6ee384f9d3c96ef1e43148fdc3528a30dafd137515a3e77d1c900bf48", - "4437daf200af4bd6bb8ab651c0315ddd8743c7a880c07b8d9c82b3d5a9774dcb" + "752cdd07d45a7e02580794b6d1c6267b711622f366dbbbeee649a2e29d9ff614", + "59b7d18da893b30d2c60f6a7bc59679a6222d672cb58aa5b6d71bfcc23e0e7f3" ] }, "full-native0-lost0": { @@ -173,12 +173,12 @@ "MESH_ENABLE_LOST_REPLY=0" ], "output_bytes": [ - 3603, - 3595 + 3363, + 3355 ], "output_sha256": [ - "8bfd3694e0bc33aa808895f6e4a76b082bb159c882b8d3937c14e51880dca78d", - "786c12671e62289d8468c43fdc3776f6e3299aa6e8d0006fd8ad5613840bd78c" + "4f8d3a26b611f3bb6f12f93ec3c81f728701a96762f9febdd60ac030ca8388e5", + "6214ce35ca15bcd6e11c1ba83ddb58f1ce42d0ad88eb047c655d639a4f9bc4f6" ] }, "full-native0-lost1": { @@ -202,12 +202,12 @@ "MESH_ENABLE_LOST_REPLY=1" ], "output_bytes": [ - 3638, - 3630 + 3398, + 3390 ], "output_sha256": [ - "ae3b7cf29e9892a554d04ba5558ad89aa3ff94478a1bd434ed498b1435f8b0d0", - "17528343802f445c17dda60c803cc469aa0d8b9ce4c492fb64fd45cfabd5f56a" + "7d070794c5fd04f2e7cd366d1d2a871e199384fcaef93908c6aacf15cdbf4dea", + "0ac6e2df584259d55e3f27e80a16da04ae26bdf2f0480098139921dbe2745352" ] }, "full-native1-lost0": { @@ -231,12 +231,12 @@ "MESH_ENABLE_LOST_REPLY=0" ], "output_bytes": [ - 3688, - 3680 + 3441, + 3433 ], "output_sha256": [ - "83b832f5de59fbfe04a49fb550245b8256a9dd924b50215f72e64b76b0e59cdf", - "52c5b5821c64d4100462d4ef08b8cef85b350150372e74abd3c2047836cb1954" + "3ff627f73f95d1ecbcae35057bde3c311075888a812f1f134d40a5338ba34a14", + "e40417cdf8b76e942d75649396cb805e16e7013a7043f446caa07ba5bbcf5b6f" ] }, "full-native1-lost1": { @@ -260,12 +260,12 @@ "MESH_ENABLE_LOST_REPLY=1" ], "output_bytes": [ - 3723, - 3715 + 3476, + 3468 ], "output_sha256": [ - "525c50beeb01595634f469b38c265000f6ad6d6ad5443b4dad6d3e36db0b5a8e", - "dd4d7390ba42b655c8cc78b9da25048328c921c14eb8d2b4c3eccf343142d8ac" + "9fc5c27d49b1b71d6d93a28f83a4dab5806e4037bfe5eaa5901fee31f224386c", + "c0776838ce268bb5f0a0bf4f597e4668bff4540768a683c77abe80a0e7624d3b" ] }, "minimal-native0-lost0": { @@ -275,12 +275,12 @@ "MESH_ENABLE_LOST_REPLY=0" ], "output_bytes": [ - 2046, - 2038 + 1897, + 1889 ], "output_sha256": [ - "5571a06d789dff50aebd53777095cc8f0f74e5fd4226ed399bd25050e9e5a02e", - "9328e546b561bc1d965f8036d73c862cfed9d5077111c0b5c8744822235740bb" + "fda1d107a7bba40a0211e22e04ea0102a5deb46d27fef9fae15d3b3302fe092e", + "b345253e4a2713f6a5f8afbaf29d8d3db79e374176cce53cb1335d3593a7a75b" ] }, "minimal-native0-lost1": { @@ -290,12 +290,12 @@ "MESH_ENABLE_LOST_REPLY=1" ], "output_bytes": [ - 2081, - 2073 + 1932, + 1924 ], "output_sha256": [ - "9ee93b7a588ce48c647b9871dc7bec5c3f307c06c29a65cb6ff66a55060247b6", - "449353daa515ede8c6528782406b3f4a101d60bee46412aa934ea94e922ed5a5" + "d27fa5b890700841f77a815fdeabe6850cd6cc4bf6ea4066f71bd0bf59245c74", + "02d853b9b49358dadf412c165654accd9b7dfd5cdd37d469fea71db85fc5ad92" ] }, "minimal-native1-lost0": { @@ -305,12 +305,12 @@ "MESH_ENABLE_LOST_REPLY=0" ], "output_bytes": [ - 2046, - 2038 + 1897, + 1889 ], "output_sha256": [ - "5571a06d789dff50aebd53777095cc8f0f74e5fd4226ed399bd25050e9e5a02e", - "9328e546b561bc1d965f8036d73c862cfed9d5077111c0b5c8744822235740bb" + "fda1d107a7bba40a0211e22e04ea0102a5deb46d27fef9fae15d3b3302fe092e", + "b345253e4a2713f6a5f8afbaf29d8d3db79e374176cce53cb1335d3593a7a75b" ] }, "minimal-native1-lost1": { @@ -320,12 +320,12 @@ "MESH_ENABLE_LOST_REPLY=1" ], "output_bytes": [ - 2081, - 2073 + 1932, + 1924 ], "output_sha256": [ - "9ee93b7a588ce48c647b9871dc7bec5c3f307c06c29a65cb6ff66a55060247b6", - "449353daa515ede8c6528782406b3f4a101d60bee46412aa934ea94e922ed5a5" + "d27fa5b890700841f77a815fdeabe6850cd6cc4bf6ea4066f71bd0bf59245c74", + "02d853b9b49358dadf412c165654accd9b7dfd5cdd37d469fea71db85fc5ad92" ] }, "qspi-native0-lost0": { @@ -359,12 +359,12 @@ "MESH_ENABLE_LOST_REPLY=0" ], "output_bytes": [ - 4806, - 4798 + 4386, + 4378 ], "output_sha256": [ - "4cc6eed0758a5f99006b17d3d6b4564665d86e4cd65f3b0365926a78f562356e", - "9d6cc39d8b397abd81543346fd88786517fb385a44abb317ac2cf1e7b2cbd8a9" + "21bd11864860334b87c27d24b36d513ae858dd1da4f1df6b8c5e25f822cc23c9", + "3086b361ed519ec91fb9f31ecb6d22f71180d8fb064bb2f6f51c151c1b4c4c35" ] }, "qspi-native0-lost1": { @@ -398,12 +398,12 @@ "MESH_ENABLE_LOST_REPLY=1" ], "output_bytes": [ - 4841, - 4833 + 4421, + 4413 ], "output_sha256": [ - "3bfd0dc32ba035ea4254e72fe21fde8e18a0b26d6621eec6df4e077ddc1069b9", - "ff22590ebdb6ed569fff20b9680050b7ac746d76ccc87cac85034b8f49adc0c4" + "10fcc7eba146e50131f34487a8d118befc3b4f32024a8762adbe6772e04f9294", + "5529438f4b22e556d1d00bc8c4633923b089d49211e5fee0b9b2b533d5fb88ba" ] }, "qspi-native1-lost0": { @@ -437,12 +437,12 @@ "MESH_ENABLE_LOST_REPLY=0" ], "output_bytes": [ - 4891, - 4883 + 4464, + 4456 ], "output_sha256": [ - "6dc1e3ab146948fa9c59c8eca47cd0ca3171281c161dc7fd66a3e17eb5d966b4", - "ddec9acf0156c143bbf40d8372002c6eadcdac355ebc567dbb18ec627bbc992c" + "1b2d35692f9e8bfaee60a1f60620d116860d605e339bdd7a58f183b6cd7503db", + "cc056e777ea8bd7ae0d4581595467b1835d9a5e91f3b341c588fa86245591459" ] }, "qspi-native1-lost1": { @@ -476,12 +476,12 @@ "MESH_ENABLE_LOST_REPLY=1" ], "output_bytes": [ - 4926, - 4918 + 4499, + 4491 ], "output_sha256": [ - "5cb4b4679630e65a8a6739158fc31c8830b393cdf18a69a259f3e31f6e4c0a74", - "9883ae8a436098ac6c6d2edf03164d19a0f07624ddcec74b598e79243387060e" + "378af0b3efc64bbd65585772928d9e1a031afa10cedcf2409dcda40a48ac7e32", + "5653195e250d7588b5df16c99a795fcf78ca6999ef4b4cf8f88821db5cdd6b44" ] } }, diff --git a/test/test_companion_help_writer.py b/test/test_companion_help_writer.py index 03a80bf8d..85b101637 100644 --- a/test/test_companion_help_writer.py +++ b/test/test_companion_help_writer.py @@ -1,9 +1,10 @@ #!/usr/bin/env python3 -"""Execute actual help branches; preserve807 UI and bounded partial writes.""" +"""Execute actual help branches; preserve commands and bounded partial writes.""" from pathlib import Path import hashlib import json import os +import re import shutil import subprocess import sys @@ -34,15 +35,40 @@ PROFILES = { 'MESH_PRIMARY_ESPNOW=1', 'BLE_PIN_CODE=123456', 'PIN_BUZZER', 'PIN_VIBRATION', *FEATURES], } -# Generated from807's original literal groups, including its dynamic TERM-STOP -# suffix. Non-RAK call hashes bind print/println order as well as all text bytes. -GOLDEN = {'rak_full': {'text': '9a68ce5a10905a201c3bddeb19f4819ce03c6dcaff248cff9c140803b70b14a7', 'calls': '56ed09dee7d53881b2c9fcf3f4ec9b6223e1562ce63e110a065e46706702b53b'}, 'nrf_full': {'text': 'b114ac12ae2ea01b7c47609b72f7eafb616c1dbeb7fb796a95b1377465fd9105', 'calls': '4973a7f21887d07b129cce4ae4cc8145f3f35e664bae09be658957210440d52e'}, 'nrf_minimal': {'text': '15fa8f290cd8c75cfde2fd2ac1cb5b5151a6755c68448fb2793dde3f27669033', 'calls': '6063fd1a699f9c0b588252bd8ce5922e0ff31cec6bbd24522789284ab2a37644'}, 'esp_full': {'text': '1e3b6781c81b5603f7092108e5e309543c60cef8ff4d7cb41a891f67396f716f', 'calls': 'b6335df2bd05b9cab44a7933469b76c5b2611c4b81057436a959feaf3bfbaf60'}} +# Complete text and print/println order, including the dynamic TERM-STOP suffix. +GOLDEN = { + 'rak_full': {'text': '482e6d1a78e676fe295c066e6dea9d33d16cf3d63788c4f225ca235451b9c5d0'}, + 'nrf_full': {'text': '97520f83770adbcd8bfe6f3f7c9b7b5f204b62d112aeeb9d9692ee35ba6c98a4', + 'calls': 'ddc85fafb3f655e589c045e2ee91fac95b3926624c4ac91b657a7de346e27098'}, + 'nrf_minimal': {'text': '633d0e5e67abed482f64ca2563011ba263f169e039e1d89190de06668f975395', + 'calls': 'd550ea873fb4408c2796b439736b205fea1ab985c3da58a06fb69cc557347ae5'}, + 'esp_full': {'text': 'ccfc453a97260b5efba38b3a01b1c738ec03dcd90e72d24ecd80bc2592154757', + 'calls': 'c46a0cd8d83af284eba9243806349938577d03a20ca56474a4abc5ab3e8d57f7'}, + 'stm32_wl_usb': {'text': 'e23a0514d2d52091196cd689b88c984db52642df8e9fd67a878c74a6312c520d'}, +} +# Snapshots taken before shortening the English descriptions. These bind every +# command, alias, argument and option independently of the wording around them. +COMMAND_INVENTORY = { + 'rak_full': '42159b2857691728524e247f8590cbcb3972724aedffeddc5e50bd8b105e64cb', + 'nrf_full': '90321d86ecd2a04efff4c95aee0578935c84439786a9725383a21287808ec8f0', + 'nrf_minimal': '420617a933aec1f81c90c9b78b0457e3509b6da62b649969b4ffa9b8418538c5', + 'stm32_wl_usb': '36e6972aefe8fc2355d937c06ecae1656224618529c2f7a18f459008856476e7', + 'esp_full': '8c952ccf44824bc2e473e1a560714cd27dc91365abb484d9411e779720df3350', +} -GOLDEN['stm32_wl_usb'] = {'text': '9e587ac9f287c8f8fe64fe5c899fe635b6de5d6cf436c4c43a27ffd4add42474'} - -FAST_HELP = (b' get radio.fast / get radio.fast.caps (supported saved controls)\r\n' +FAST_HELP = (b' get radio.fast / get radio.fast.caps\r\n' b' set radio.fast / set radio.fast.spi <0|2|4|8|9|16>\r\n') + +def command_inventory(data): + commands = [] + for line in data.decode().splitlines(): + if not line.startswith(' ') or line.startswith((' ', ' Join ', ' App ')): + continue + line = line.replace(' (alias: get ble)', ' / get ble') + commands.append(re.sub(r' \([^)]*\)', '', line)) + return '\n'.join(commands).encode() + HARNESS = r''' #include "CompanionHelpWriter.h" #include @@ -222,6 +248,25 @@ class CompanionHelpWriterTests(unittest.TestCase): self.assertEqual(result.returncode,0,result.stdout+result.stderr) result = subprocess.run([str(work/'test')],capture_output=True) self.assertEqual(result.returncode,0,result.stderr.decode(errors='replace')) + self.assertEqual(hashlib.sha256(command_inventory(result.stdout)).hexdigest(), + COMMAND_INVENTORY[name]) + for command, detail in ( + (b'set beacon.interval', b'(default 24h)'), + (b'set mt.rebroadcast', b'(default off)'), + (b'set mt.hops', b'(default 7)'), + (b'get eth / set eth', b'(default off; boot)'), + (b'get/set usb.watchdog', b'(default auto)'), + (b'get/set display.controller', b'(restart)'), + (b'get/set display.touch', b'(boot)'), + (b'set 2.4ghz', b'(boot)'), + (b'radio.rxps.rfrx_disabled', b'(boot)'), + (b'set wifi|espnow', b'(force: off)'), + (b'set bluetooth <', b'(force: off)'), + (b'repair extrafs', b'(erases ExtraFS)'), + (b'scan extrafs erase', b'(USB; reboot; erases pages)')): + for line in result.stdout.splitlines(): + if command in line: + self.assertIn(detail, line) self.assertEqual(result.stdout.count(FAST_HELP), 0 if name == 'stm32_wl_usb' else 1) previous_help = result.stdout.replace(FAST_HELP, b'') self.assertEqual(hashlib.sha256(previous_help).hexdigest(),GOLDEN[name]['text']) diff --git a/test/test_companion_reader.py b/test/test_companion_reader.py index 0fb1eeeec..45b0a6291 100644 --- a/test/test_companion_reader.py +++ b/test/test_companion_reader.py @@ -342,7 +342,7 @@ int main() { self.assertLess(terminal.index("mesh::handleReaderCommand("), terminal.index("char local_reply[160]")) help_text = (ROOT / "examples/companion_radio/CompanionHelp.inc").read_text() - self.assertIn("get reader [:[-]] [page] (World English Bible, offline)", help_text) + self.assertIn("get reader [:[-]] [page]", help_text) self.assertIn('#include "CompanionHelp.inc"', terminal) self.assertIn("mesh::companion::writePackedCompanionHelp(output)", terminal) packed_help = (ROOT / "examples/companion_radio/CompanionHelpPacked.cpp").read_text() diff --git a/test/test_companion_terminal_profile.py b/test/test_companion_terminal_profile.py index e04cbeddf..dc72b5276 100644 --- a/test/test_companion_terminal_profile.py +++ b/test/test_companion_terminal_profile.py @@ -94,11 +94,11 @@ assert '#include "CompanionHelp.inc"' in packed_help help_fragments = (root / "examples/companion_radio/CompanionHelp.inc").read_text() for help_line in (' board\\r\\n', ' version\\r\\n', ' get pwrmgt.bootreason\\r\\n', ' set pin <0-999999>\\r\\n', - ' set mt.hops <0..7> (saved; default 7)\\r\\n', + ' set mt.hops <0..7> (default 7)\\r\\n', ' get mt.node / get mt.shortname\\r\\n', - ' set mt.node (saved; use a unique ID)\\r\\n', - ' set mt.shortname <1..4 UTF-8 characters|default> (saved; NodeInfo uses 4 bytes)\\r\\n', - ' send mt.nodeinfo (GPS-free; also automatic after first chat)\\r\\n'): + ' set mt.node \\r\\n', + ' set mt.shortname <1..4 UTF-8 characters|default>\\r\\n', + ' send mt.nodeinfo (auto after first chat)\\r\\n'): assert help_line in help_fragments # Explicit NodeInfo remains available, but first successful chat also arms # separate GPS-free metadata. Do not restore the obsolete manual-only policy. diff --git a/test/test_companion_usb_logging.py b/test/test_companion_usb_logging.py index 51545fd8e..8942939b5 100644 --- a/test/test_companion_usb_logging.py +++ b/test/test_companion_usb_logging.py @@ -504,7 +504,7 @@ int main(){ assert(text.find("usb.debug")==std::string::npos); #endif #if MESH_USB_LOGGING_AVAILABLE && MESH_USB_CONSOLE_COOPERATIVE - assert(text.find(" get usb.watchdog.last\r\n get/set usb.watchdog (saved; default auto)\r\n")!=std::string::npos); + assert(text.find(" get usb.watchdog.last\r\n get/set usb.watchdog (default auto)\r\n")!=std::string::npos); #else assert(text.find("usb.watchdog")==std::string::npos); #endif diff --git a/test/test_nrf52_extrafs_contract.py b/test/test_nrf52_extrafs_contract.py index bd6a87198..47a56258d 100644 --- a/test/test_nrf52_extrafs_contract.py +++ b/test/test_nrf52_extrafs_contract.py @@ -1037,12 +1037,12 @@ class Nrf52ExtraFsContractTest(unittest.TestCase): self.assertIn("mesh::companion::writePackedCompanionHelp(output);", terminal) help_fragments = (MESH.parent / "CompanionHelp.inc").read_text(encoding="ascii") self.assertIn( - "repair extrafs (erases/rebuilds internal ExtraFS)", help_fragments + "repair extrafs (erases ExtraFS)", help_fragments ) self.assertRegex(help_fragments, r"#if defined\(NRF52_PLATFORM\) && defined\(EXTRAFS\) && !defined\(QSPIFLASH\)" r"\s+MESH_COMPANION_HELP_BEGIN\s+" - r'" repair extrafs \(erases/rebuilds internal ExtraFS\)\\r\\n"') + r'" repair extrafs \(erases ExtraFS\)\\r\\n"') packed_help = (MESH.parent / "CompanionHelpPacked.cpp").read_text(encoding="ascii") self.assertIn('#include "CompanionHelp.inc"', packed_help)