(file, defines, config, moduletype, frequency, platform, device_name, rx_as_tx)
| 75 | firmware_file.write(b'\0') |
| 76 | |
| 77 | def doConfiguration(file, defines, config, moduletype, frequency, platform, device_name, rx_as_tx): |
| 78 | product_name = "Unified" |
| 79 | lua_name = "Unified" |
| 80 | layout = None |
| 81 | |
| 82 | targets = {} |
| 83 | with open('hardware/targets.json') as f: |
| 84 | targets = json.load(f) |
| 85 | |
| 86 | if config is not None: |
| 87 | config ='.'.join(map(lambda s: f'"{s}"', config.split('.'))) |
| 88 | config = jmespath.search(config, targets) |
| 89 | elif not sys.stdin.isatty(): |
| 90 | print('Not running in an interactive shell, leaving the firmware "bare".\n') |
| 91 | print('The current compile options (user defines) have been included.') |
| 92 | print('You will be able to configure the hardware via the web UI on the device.') |
| 93 | else: |
| 94 | products = [] |
| 95 | for k in jmespath.search(f'[*."{moduletype}_{frequency}".*][][?platform==`{platform}`][]', targets): |
| 96 | products.append(k) |
| 97 | if frequency == 'dual': |
| 98 | for k in jmespath.search(f'[*."{moduletype}_2400".*][][?platform==`{platform}`][]', targets): |
| 99 | if '_LR1121_' in k['firmware']: |
| 100 | products.append(k) |
| 101 | for k in jmespath.search(f'[*."{moduletype}_900".*][][?platform==`{platform}`][]', targets): |
| 102 | if '_LR1121_' in k['firmware']: |
| 103 | products.append(k) |
| 104 | # Sort the list by product name, case insensitive, and print the list |
| 105 | products = sorted(products, key=lambda p: p['product_name'].casefold()) |
| 106 | for i, p in enumerate(products): |
| 107 | print(f"{i+1}) {p['product_name']}") |
| 108 | print('Choose a configuration to load into the firmware file (press enter to leave bare)') |
| 109 | choice = input() |
| 110 | if choice != "": |
| 111 | config = products[int(choice)-1] |
| 112 | |
| 113 | if config is not None: |
| 114 | product_name = config['product_name'] |
| 115 | lua_name = config['lua_name'] |
| 116 | dir = 'TX' if moduletype == 'tx' else 'RX' |
| 117 | layout = f"hardware/{dir}/{config['layout_file']}" |
| 118 | |
| 119 | lua_name = lua_name if device_name is None else device_name |
| 120 | appendToFirmware(file, product_name, lua_name, defines, config, layout, rx_as_tx) |
| 121 | |
| 122 | def appendConfiguration(source, target, env): |
| 123 | target_name = env.get('PIOENV', '').upper() |
no test coverage detected