Preserve the compact STM32WL interface and profile storage path
This commit is contained in:
1 parent
cebd0fdbeb
commit
9d973d353a
5 files changed
+32
-6
No files matched your search
@@ -225,10 +225,12 @@ MESH_COMPANION_HELP_BEGIN
|
||||
MESH_COMPANION_HELP_END
|
||||
#endif
|
||||
// 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"
|
||||
" set radio.fast <on|off> / set radio.fast.spi <0|2|4|8|16>\r\n"
|
||||
MESH_COMPANION_HELP_END
|
||||
#endif
|
||||
MESH_COMPANION_HELP_BEGIN
|
||||
" get radio.rxps.config\r\n"
|
||||
" get/set radio.rxps <off|on|level 1-10 [preamble 16|32]|rx_us sleep_us>\r\n"
|
||||
|
||||
@@ -99,6 +99,7 @@ public:
|
||||
virtual void begin() { }
|
||||
virtual RadioProfiles* profiles() { return nullptr; }
|
||||
virtual const RadioProfiles* profiles() const { return nullptr; }
|
||||
#if MESH_RADIO_SWITCH_TUNING
|
||||
virtual RadioSwitchCapabilities switchTuningCapabilities() const { return {}; }
|
||||
virtual RadioSwitchTuning switchTuning() const { return {}; }
|
||||
virtual uint32_t switchSpiHz() const { return 0; }
|
||||
@@ -109,6 +110,7 @@ public:
|
||||
bool (*)(void*, const RadioSwitchTuning&) = nullptr, void* = nullptr) {
|
||||
return RadioParamApplyResult::FAILED;
|
||||
}
|
||||
#endif
|
||||
virtual bool validateProfile(const RadioProfileParams&) const { return false; }
|
||||
virtual bool supportsMeshtext() const { return false; }
|
||||
virtual bool supportsEthernetTunnel() const { return false; }
|
||||
|
||||
@@ -203,9 +203,24 @@ bool RadioProfileCLI::prepareSavedImage(const char* path, const RadioProfileConf
|
||||
}
|
||||
|
||||
bool RadioProfileCLI::commitSavedImage(const char* path) {
|
||||
#if MESH_RADIO_SWITCH_TUNING
|
||||
return commitImage(path, ImagePath, BackupPath, hold_);
|
||||
#else
|
||||
if (!fs_ || hold_) return false;
|
||||
if (fs_->exists(ImagePath)) {
|
||||
if (fs_->exists(BackupPath) && !fs_->remove(BackupPath)) return false;
|
||||
if (!fs_->rename(ImagePath, BackupPath)) return false;
|
||||
}
|
||||
if (!fs_->rename(path, ImagePath)) {
|
||||
if (fs_->exists(BackupPath) && !fs_->rename(BackupPath, ImagePath)) hold_ = true;
|
||||
return false;
|
||||
}
|
||||
if (fs_->exists(BackupPath)) fs_->remove(BackupPath);
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MESH_RADIO_SWITCH_TUNING
|
||||
bool RadioProfileCLI::commitImage(const char* path, const char* active,
|
||||
const char* backup, bool& hold, bool preserve_backup) {
|
||||
if (!fs_ || hold) return false;
|
||||
@@ -225,7 +240,6 @@ bool RadioProfileCLI::commitImage(const char* path, const char* active,
|
||||
return true;
|
||||
}
|
||||
|
||||
#if MESH_RADIO_SWITCH_TUNING
|
||||
bool RadioProfileCLI::validFastImage(const uint8_t* bytes, RadioSwitchTuning& value) const {
|
||||
if (bytes[2] != 1) return false;
|
||||
for (size_t n = 5; n < ImageSize - 4; ++n) if (bytes[n]) return false;
|
||||
|
||||
@@ -88,9 +88,9 @@ class RadioProfileCLI {
|
||||
bool prepareSavedImage(const char* path, const RadioProfileConfig& config,
|
||||
uint16_t preamble, RadioCrossMode cross, int8_t manual_secondary = -1);
|
||||
bool commitSavedImage(const char* path);
|
||||
#if MESH_RADIO_SWITCH_TUNING
|
||||
bool commitImage(const char* staged, const char* active, const char* backup,
|
||||
bool& hold, bool preserve_backup = false);
|
||||
#if MESH_RADIO_SWITCH_TUNING
|
||||
bool validFastImage(const uint8_t* bytes, RadioSwitchTuning& value) const;
|
||||
void loadFastSettings(bool boot = false);
|
||||
bool saveFastSettings(const RadioSwitchTuning& value);
|
||||
|
||||
@@ -3,6 +3,18 @@
|
||||
#define main existing_cli_main
|
||||
#include "cli_test.cpp"
|
||||
#undef main
|
||||
#include <type_traits>
|
||||
|
||||
#define CHECK_TUNING_MEMBER_ABSENT(name) \
|
||||
template<typename T, typename = void> struct Has_##name : std::false_type {}; \
|
||||
template<typename T> struct Has_##name<T, decltype((void)&T::name)> : std::true_type {}; \
|
||||
static_assert(!Has_##name<mesh::Radio>::value, "Unsupported radio API must be absent: " #name)
|
||||
CHECK_TUNING_MEMBER_ABSENT(switchTuningCapabilities);
|
||||
CHECK_TUNING_MEMBER_ABSENT(switchTuning);
|
||||
CHECK_TUNING_MEMBER_ABSENT(switchSpiHz);
|
||||
CHECK_TUNING_MEMBER_ABSENT(configureBootSwitchTuning);
|
||||
CHECK_TUNING_MEMBER_ABSENT(trySetSwitchTuning);
|
||||
#undef CHECK_TUNING_MEMBER_ABSENT
|
||||
|
||||
int main() {
|
||||
static_assert(MESH_RADIO_SWITCH_TUNING == 0, "Integrated STM32WL tuning must be absent");
|
||||
@@ -27,10 +39,6 @@ int main() {
|
||||
assert(fs.opened_paths.empty());
|
||||
assert(fs.files["/radio_fast"] == record);
|
||||
assert(fs.files.size() == 1);
|
||||
const auto capabilities = radio.switchTuningCapabilities();
|
||||
assert(capabilities.flags == 0 && capabilities.spi_clocks == 0);
|
||||
assert(!radio.configureBootSwitchTuning({}));
|
||||
assert(radio.trySetSwitchTuning({}) == mesh::RadioParamApplyResult::FAILED);
|
||||
// Existing radio2 configuration commands remain available.
|
||||
assert(cli.handle("get radio2", reply, sizeof(reply)));
|
||||
assert(!strncmp(reply, "> off", 5));
|
||||
|
||||
Reference in new issue
Block a user