diff --git a/README.md b/README.md index 379d90b..935f6ab 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,17 @@ # LoRa Modulation Jam + +Programmatically send packets between two stations across a set of LoRa radio configurations. + +Given nodes at two different locations with computers attached via USB, run one of these commands within a few minutes of each other on each computer: + +`python modjam.py run --this-station=A` and `python modjam.py run --this-station=B` + +Each station will iterate through the full permutation of LoRa radio settings. + +Use the parameters to change the set of settings used: + +This will run for all BWs, but only test SF 7 and 11, coding rate 5, and power level 1. +``` +python3 ./modjam.py run --this-station=A --spread-factor=7 --spread-factor=11 --coding-rate=5 --power=1 +``` diff --git a/modjam.py b/modjam.py index edefc39..a708eb9 100644 --- a/modjam.py +++ b/modjam.py @@ -162,10 +162,10 @@ def log (**parts): if not logfile: raise Exception('No logfile') ts = time() - msg = '\t'.join(map(lambda x: str(x), parts)) + msg = '\t'.join(map(lambda x: str(x), parts.values())) line = f'{ts}\t{msg}\n'; print(line) - logfile.write(json.dumps({**parts, 'ts': ts})) + logfile.write(json.dumps({**parts, 'ts': ts}) + '\n') def configureRadio (conf: RadioConfig): @@ -307,9 +307,11 @@ async def runCues (cuesheet: Cuesheet, run_config: RunConfig): scenario_prefix = f'{scenario['freq']},{scenario['bw']},{scenario['sf']},{scenario['cr']},{scenario['pow']}' configureRadio(scenario) reconnectRadio() + print('waiting for start') while t < scenario['start']: t = time() - start sleep(0.1) + print('starting scenario') while t < scenario['end']: t = time() - start @@ -321,6 +323,7 @@ async def runCues (cuesheet: Cuesheet, run_config: RunConfig): # Wait until the next scenario and just listen wait_for_s = max(scenario['end'] - t,0.5) await asyncio.sleep(wait_for_s) + print('scenario complete') def sleepUntilStart (config): @@ -334,16 +337,15 @@ def sleepUntilStart (config): def main (): config, run_config = prepareConfig() + global interface + interface = SerialInterface(run_config['port'], noNodes=True) # Confirm radio is connectable cuesheet = buildCueSheet(config) # Do this before sleeping so the timing is displayed + sleepUntilStart(config) pub.subscribe(onStatus, 'meshtastic.log') pub.subscribe(onReceiveText, 'meshtastic.receive.text') - - global interface - interface = SerialInterface(run_config['port'], noNodes=True) - global logfile station = run_config['this_station'] logfile = open('./' + station + '-' + str(time()) + '.jsonl', 'a')