fix(nrf52): avoid CCCD flash reset on Full Companion

This commit is contained in:
mikecarper committed 2026-09-23 01:29:14 -07:00
1 parent ff50589b69
commit af86517059
3 files changed
+86

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
"""Guard the nRF52 Full Companion CCCD build-local workaround."""
from importlib.util import module_from_spec, spec_from_file_location
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[1]
SCRIPT = ROOT / "scripts/nrf52_ble_cccd_fix.py"
spec = spec_from_file_location("nrf52_ble_cccd_fix", SCRIPT)
module = module_from_spec(spec)
spec.loader.exec_module(module)
class Nrf52BleCccdFixTest(unittest.TestCase):
def test_only_full_companions_skip_persistence(self):
patched = module.patched_source("before\n" + module.OLD_SAVE + "after\n")
self.assertIn("!defined(COMPANION_RADIO_FULL) || !COMPANION_RADIO_FULL", patched)
self.assertIn("conn->saveCccd();", patched)
self.assertEqual(module.patched_source(patched), patched)
def test_unrecognized_core_fails_closed(self):
with self.assertRaises(RuntimeError):
module.patched_source("changed SDK layout")
def test_nrf52_base_loads_workaround(self):
ini = (ROOT / "platformio.ini").read_text(encoding="utf-8")
self.assertIn("pre:scripts/nrf52_ble_cccd_fix.py", ini)
if __name__ == "__main__":
unittest.main()