mirror of
https://github.com/mikecarper/MeshCore.git
synced 2026-09-25 20:53:38 +00:00
docs(picker): publish verified runtime capabilities
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -51,6 +51,29 @@ def capacity_note(reductions, defines):
|
||||
return ' '.join(notes)
|
||||
|
||||
|
||||
def runtime_metadata(manifest, mqtt):
|
||||
"""Keep picker choices tied to capabilities proven in this exact image."""
|
||||
capabilities = set(manifest['capabilities'])
|
||||
verified = {check['capability'] for check in manifest.get('verification', [])
|
||||
if check.get('present') is True}
|
||||
packaged = {check['capability'] for check in manifest.get('verification', [])
|
||||
if check.get('present') is True and check.get('source') == 'packaged application'}
|
||||
if 'ota.update.lora' in capabilities and 'lora' in manifest.get('ota_update_methods', []):
|
||||
ota_role = 'lora-receiver'
|
||||
elif 'companion.mota_sender' in verified:
|
||||
ota_role = 'lora-source'
|
||||
else:
|
||||
ota_role = 'none'
|
||||
result = {'otaRole': ota_role}
|
||||
if {'logging.usb.packets', 'logging.usb.control'} <= packaged:
|
||||
result['loggingModes'] = ['none', 'usb', 'wifi', 'both'] if mqtt else ['none', 'usb']
|
||||
result['loggingControl'] = 'logging.output' if mqtt else 'usb.logging'
|
||||
result['loggingSource'] = manifest['source_commit']
|
||||
if 'companion.dedicated_usb_logging' in verified:
|
||||
result['dedicatedUsbLogging'] = True
|
||||
return result
|
||||
|
||||
|
||||
def generate(stage, config):
|
||||
plan = json.loads((stage / 'release-plan.json').read_text())
|
||||
envs = {name: dict(options) for name, options in config}
|
||||
@@ -98,6 +121,7 @@ def generate(stage, config):
|
||||
'snmp': enabled('WITH_SNMP'),
|
||||
'updateMethods': manifest.get('ota_update_methods', []),
|
||||
}
|
||||
controls.update(runtime_metadata(manifest, controls['mqtt']))
|
||||
if manifest.get('ota_update_requirements'):
|
||||
controls['updateRequirements'] = manifest['ota_update_requirements']
|
||||
note = capacity_note(manifest.get('reductions', []), defines)
|
||||
|
||||
@@ -11,6 +11,29 @@ SPEC.loader.exec_module(GENERATOR)
|
||||
|
||||
|
||||
class PickerControlsTests(unittest.TestCase):
|
||||
def test_runtime_metadata_uses_verified_image_capabilities(self):
|
||||
source = 'a' * 40
|
||||
manifest = dict(source_commit=source,
|
||||
capabilities=['companion.mota_sender', 'logging.usb.packets',
|
||||
'logging.usb.control', 'companion.dedicated_usb_logging'],
|
||||
ota_update_methods=[], verification=[
|
||||
dict(capability='companion.mota_sender', present=True, source='linked image'),
|
||||
dict(capability='companion.dedicated_usb_logging', present=True, source='linked image'),
|
||||
dict(capability='logging.usb.packets', present=True, source='packaged application'),
|
||||
dict(capability='logging.usb.control', present=True, source='packaged application'),
|
||||
])
|
||||
self.assertEqual(GENERATOR.runtime_metadata(manifest, False), dict(
|
||||
otaRole='lora-source', loggingModes=['none', 'usb'],
|
||||
loggingControl='usb.logging', loggingSource=source,
|
||||
dedicatedUsbLogging=True))
|
||||
self.assertEqual(GENERATOR.runtime_metadata(manifest, True)['loggingModes'],
|
||||
['none', 'usb', 'wifi', 'both'])
|
||||
manifest['verification'][-1]['source'] = 'linked image'
|
||||
self.assertNotIn('loggingModes', GENERATOR.runtime_metadata(manifest, False))
|
||||
manifest['capabilities'].append('ota.update.lora')
|
||||
manifest['ota_update_methods'] = ['lora']
|
||||
self.assertEqual(GENERATOR.runtime_metadata(manifest, False)['otaRole'], 'lora-receiver')
|
||||
|
||||
def generate(self, reductions, *, source=None, flags=(), verified=True):
|
||||
initial = 'a' * 40
|
||||
manifest = dict(target='sample_companion_radio_full', platformio_env='sample',
|
||||
|
||||
Reference in New Issue
Block a user