From 41ef416a15a4097caaa2b8177212bc101e794044 Mon Sep 17 00:00:00 2001 From: Harith Jamadi <114632577+harithjamadi@users.noreply.github.com> Date: Wed, 4 Nov 2026 14:33:56 +0800 Subject: [PATCH 01/22] DEV-1410: draft iOS BLE throughput test automation Draft runner for TestApp that connects to a Shimmer3 or Shimmer3R by name and runs the BLE-Throughput matrix (CRC, rate, sensors) with a packet-size check, writing a CSV. tools/throughput/update_wiki.py turns the CSV into new per-release tables on the wiki page; it commits locally and never pushes. Adds small public accessors to Shimmer3Protocol (sendSetCRCMode, currentCRCMode, currentSamplingRate, packetSizeBytes, public numberOfPackets). Draft: not compiled or run. ThroughputRunner.swift is not yet in project.pbxproj, so CI does not build it. --- .../ShimmerBluetooth/Shimmer3Protocol.swift | 17 +- TestApp/TestApp/ThroughputRunner.swift | 150 ++++++++++++++++ docs/THROUGHPUT_AUTOMATION.md | 75 ++++++++ tools/throughput/update_wiki.py | 167 ++++++++++++++++++ 4 files changed, 408 insertions(+), 1 deletion(-) create mode 100644 TestApp/TestApp/ThroughputRunner.swift create mode 100644 docs/THROUGHPUT_AUTOMATION.md create mode 100644 tools/throughput/update_wiki.py diff --git a/ShimmerBluetooth/ShimmerBluetooth/Shimmer3Protocol.swift b/ShimmerBluetooth/ShimmerBluetooth/Shimmer3Protocol.swift index b581edd..d3d67d4 100644 --- a/ShimmerBluetooth/ShimmerBluetooth/Shimmer3Protocol.swift +++ b/ShimmerBluetooth/ShimmerBluetooth/Shimmer3Protocol.swift @@ -26,7 +26,8 @@ public class Shimmer3Protocol : NSObject, ShimmerProtocol { } var startTime = Date() - var numberOfPackets = 0 + /// Packets received since streaming started; the numerator of the trial PRR. + public private(set) var numberOfPackets = 0 public var REV_HW_MAJOR: Int = -1 public var REV_HW_MINOR: Int = -1 @@ -1658,6 +1659,20 @@ public class Shimmer3Protocol : NSObject, ShimmerProtocol { return true } + /// Select the link CRC. Refused if this firmware cannot carry it (see strongestSafeCRCMode). + /// connect() already picks the strongest safe mode; this lets a caller choose a weaker one, + /// e.g. to measure throughput with a 1-byte CRC. + public func sendSetCRCMode(_ crcMode: BTCRCMode) async -> Bool { + return await sendCRCCommand(crcMode: crcMode) ?? false + } + /// The CRC mode in force on this link. + public var currentCRCMode: BTCRCMode { return CRCMode } + /// The sampling rate (Hz) the PRR expectation is calculated from. + public var currentSamplingRate: Double { return CurrentSamplingRate } + /// Streaming packet length in bytes on the wire: start byte, payload and CRC. + /// Zero until sensors have been initialised. + public var packetSizeBytes: Int { return PacketSize + 1 } + private func sendCRCCommand(crcMode:BTCRCMode) async ->Bool?{ // Refused rather than sent when this firmware cannot carry it (strongestSafeCRCMode). let strongestSafe = strongestSafeCRCModeForDevice() diff --git a/TestApp/TestApp/ThroughputRunner.swift b/TestApp/TestApp/ThroughputRunner.swift new file mode 100644 index 0000000..03d9d44 --- /dev/null +++ b/TestApp/TestApp/ThroughputRunner.swift @@ -0,0 +1,150 @@ +// +// ThroughputRunner.swift +// TestApp +// +// DRAFT. Not compiled, not in project.pbxproj, never run. See docs/THROUGHPUT_AUTOMATION.md. +// +// Runs the BLE-Throughput wiki matrix against one Shimmer3 / Shimmer3R, found by name, with no +// taps: scan, connect, record versions, then for each config set CRC -> rate -> sensors, stream, +// count, stop. Writes a CSV and the wiki rows. +// +import Foundation +import CoreBluetooth +import ShimmerBluetooth + +struct ThroughputConfig { + let label: String // "LN Accel, GSR, PPG" + let sensorBitmap: UInt32 // for sendSetSensorsCommand + let payloadBytes: Int // sensor bytes excluding start byte, timestamp and CRC (the check) + let rateHz: Double + let crc: Shimmer3Protocol.BTCRCMode + let seconds: Int + let repeats: Int +} + +struct ThroughputRow { + var device = "", fw = "", hw = "", expBoard = "", ios = "", app = "" + var config = "", crc = 0, rateHz = 0.0, seconds = 0, run = 0 + var packetBytes = 0, expectedPacketBytes = 0 + var received = 0, expected = 0 + var prrApi = 0.0 // the API's own trial PRR, clamped to 100 + var prrRaw = 0.0 // received / expected, NOT clamped, so >100% is visible + var wallSeconds = 0.0 + var status = "ok" // ok | connect-failed | config-failed | size-mismatch | stalled +} + +@MainActor +final class ThroughputRunner: NSObject, ShimmerProtocolDelegate, BluetoothManagerDelegate { + private let central = CBCentralManager() + private lazy var manager = BluetoothManager(centralmanager: central) + private var radio: BleByteRadio? + private var proto: Shimmer3Protocol? + private var scanContinuation: CheckedContinuation? + private var clusters = 0 + + // MARK: matrix (mirrors wiki Test Results 3 and 4) + static func wikiMatrix() -> [ThroughputConfig] { + let bitmap = Shimmer3Protocol.SensorBitmapShimmer3.SENSOR_LN_ACCEL.rawValue + | Shimmer3Protocol.SensorBitmapShimmer3.SENSOR_GSR.rawValue + | Shimmer3Protocol.SensorBitmapShimmer3.SENSOR_INT_A1.rawValue // PPG (A13) - VERIFY bit + // 6 accel + 2 GSR + 2 PPG = 10 payload bytes (the wiki's 15 / 16 bytes = 1 start + 3 ts + 10 + CRC) + return [Shimmer3Protocol.BTCRCMode.ONE_BYTE, Shimmer3Protocol.BTCRCMode.TWO_BYTE].map { + ThroughputConfig(label: "LN Accel, GSR, PPG", sensorBitmap: bitmap, payloadBytes: 10, + rateHz: 128, crc: $0, seconds: 60, repeats: 3) + } + } + + // MARK: connect by name + func connect(deviceName: String, scanSeconds: Double = 15) async -> Bool { + manager.delegate = self + guard manager.startScanning(deviceName: deviceName, timeout: scanSeconds) else { return false } + await withCheckedContinuation { scanContinuation = $0 } // resumed by scanCompleted() + guard let peripheral = manager.getPeripheral(deviceName: deviceName) else { return false } + let radio = BleByteRadio(deviceName: deviceName, cbperipheral: peripheral, bluetoothManager: manager) + let proto = Shimmer3Protocol(radio: radio) + proto.delegate = self + self.radio = radio; self.proto = proto + return await proto.connect() + } + func disconnect() async { _ = await proto?.disconnect() } + + // MARK: run + func run(deviceName: String, matrix: [ThroughputConfig], appVersion: String, ios: String) async -> [ThroughputRow] { + var rows: [ThroughputRow] = [] + var base = ThroughputRow(); base.device = deviceName; base.ios = ios; base.app = appVersion + var connected = false + for _ in 0..<2 where !connected { connected = await connect(deviceName: deviceName) } // one retry + guard connected, let p = proto else { + base.status = "connect-failed"; return [base] + } + base.fw = "\(p.REV_FW_MAJOR).\(p.REV_FW_MINOR).\(p.REV_FW_INTERNAL)" + base.hw = p.REV_HW_MAJOR == Shimmer3Protocol.HardwareType.Shimmer3R.rawValue ? "Shimmer3R" : "Shimmer3" + base.expBoard = "SR\(p.EXPANSION_BOARD_ID)-\(p.EXPANSION_BOARD_REV).\(p.EXPANSION_BOARD_REV_SPECIAL)" + + for cfg in matrix { + for run in 1...cfg.repeats { + var r = base + r.config = cfg.label; r.crc = Int(cfg.crc.rawValue); r.rateHz = cfg.rateHz + r.seconds = cfg.seconds; r.run = run + rows.append(await runOne(p, cfg, r)) + } + } + await disconnect() + return rows + } + + private func runOne(_ p: Shimmer3Protocol, _ cfg: ThroughputConfig, _ rowIn: ThroughputRow) async -> ThroughputRow { + var r = rowIn + // Order matters: PacketSize is fixed at inquiry and includes the CRC, so the CRC goes first + // and the sensor command (which re-runs inquiry) goes last. + guard await p.sendSetCRCMode(cfg.crc), + await p.sendSetSamplingRateCommand(samplingRate: cfg.rateHz) == true, + await p.sendSetSensorsCommand(sensorBitmap: cfg.sensorBitmap) else { + r.status = "config-failed"; return r + } + // Accuracy gate: the packet on the wire must be the size the config implies. + r.expectedPacketBytes = 1 + p.TimeStampPacketByteSize + cfg.payloadBytes + Int(cfg.crc.rawValue) + r.packetBytes = p.packetSizeBytes + guard r.packetBytes == r.expectedPacketBytes, p.currentCRCMode == cfg.crc, + p.currentSamplingRate == cfg.rateHz else { + r.status = "size-mismatch"; return r // wrong sensors enabled: do not report a PRR + } + + clusters = 0 + let t0 = Date() + guard await p.sendStartStreamingCommand() == true else { r.status = "config-failed"; return r } + try? await Task.sleep(nanoseconds: UInt64(cfg.seconds) * 1_000_000_000) + r.wallSeconds = Date().timeIntervalSince(t0) + r.received = p.numberOfPackets + r.prrApi = p.packetReceptionRateOverall + _ = await p.sendStopStreamingCommand() + + // Same expectation the API uses (device timestamps), but kept unclamped. + r.expected = Int(Double(cfg.seconds) * cfg.rateHz) + r.prrRaw = r.expected > 0 ? Double(r.received) / Double(r.expected) * 100 : 0 + if r.received == 0 { r.status = "stalled" } + try? await Task.sleep(nanoseconds: 2_000_000_000) // settle between runs + return r + } + + // MARK: output + static func csv(_ rows: [ThroughputRow]) -> String { + let head = "device,hw,fw,exp_board,app,ios,config,crc,rate_hz,seconds,run,packet_bytes,expected_packet_bytes,received,expected,prr_api,prr_raw,wall_s,status" + let lines = rows.map { r in + [r.device, r.hw, r.fw, r.expBoard, r.app, r.ios, "\"\(r.config)\"", "\(r.crc)", "\(r.rateHz)", "\(r.seconds)", "\(r.run)", + "\(r.packetBytes)", "\(r.expectedPacketBytes)", "\(r.received)", "\(r.expected)", + String(format: "%.1f", r.prrApi), String(format: "%.1f", r.prrRaw), String(format: "%.1f", r.wallSeconds), r.status].joined(separator: ",") + } + return ([head] + lines).joined(separator: "\n") + } + + // Wiki rows are built by tools/throughput/update_wiki.py from this CSV. + + // MARK: delegates + func scanCompleted() { scanContinuation?.resume(); scanContinuation = nil } + func isConnected() {} + func isDisconnected() {} + func shimmerProtocolNewMessage(message: String) {} + func shimmerProtocolNewObjectCluster(message: ObjectCluster) { clusters += 1 } + func shimmerBTStateChange(message: Shimmer3Protocol.Shimmer3BTState) {} +} diff --git a/docs/THROUGHPUT_AUTOMATION.md b/docs/THROUGHPUT_AUTOMATION.md new file mode 100644 index 0000000..e787c01 --- /dev/null +++ b/docs/THROUGHPUT_AUTOMATION.md @@ -0,0 +1,75 @@ +# BLE throughput test automation (draft) + +Goal: fill the wiki's BLE-Throughput tables for a new Shimmer3 / Shimmer3R firmware with one command +and almost no human steps. Status: **draft, never compiled or run.** This repo only compiles in CI +(`AGENTS.md`), and `ThroughputRunner.swift` is not yet in `project.pbxproj`. + +## Human steps (all that remain) +1. Flash the firmware under test (Shimmer3 v1.01.009, Shimmer3R v1.01.025) and power the board on. +2. Plug in and unlock the iPhone; put the board about 2.5 m away. Tap Allow on the first-launch + Bluetooth prompt, once per install. +3. Run the command below with the device name. +4. Run `tools/throughput/update_wiki.py` (below), read the diff, then push the wiki yourself. + +## Automated +- Scan and connect by BLE name (`BluetoothManager.startScanning(deviceName:)`), one retry. +- Record FW, hardware, expansion board, iOS and app version from the device, not from typing. +- For each config and each of N repeats: set CRC, then rate, then sensors, stream, count, stop. +- Write a CSV with every run. +- `tools/throughput/update_wiki.py` turns the CSV into new wiki tables (median of the runs). + +## Accuracy rules +- **Order is CRC, rate, sensors.** `PacketSize` includes the CRC and is fixed at inquiry, and + `sendSetSensorsCommand` re-runs inquiry. Setting CRC last would leave a stale size. +- **Packet-size gate.** Wire size must equal `1 + 3 + payload + CRC` (15 / 16 bytes for LN Accel + + GSR + PPG, as on the wiki). A mismatch means the wrong sensors are on, and the run is rejected, not + reported. +- **Unclamped PRR.** The API clamps PRR to 100%. The CSV also keeps received, expected and the raw + ratio, so over-100% (a timing or rate fault) is visible. +- **Repeats and median.** 3 runs per config. The wiki notes a +/-8% tolerance at high throughput; one + run is not a result. +- **Failures are rows.** Connect, config and stall failures are written with a status, never dropped. +- **Wall time recorded** next to the nominal duration. + +## Required API change (in this branch) +`Shimmer3Protocol` keeps `sendCRCCommand`, `CRCMode`, `CurrentSamplingRate` and `PacketSize` private +or internal, and `connect()` always picks the strongest safe CRC. The wiki rows need 1-byte and +2-byte CRC. Added: `sendSetCRCMode`, `currentCRCMode`, `currentSamplingRate`, `packetSizeBytes`, +and `numberOfPackets` is now `public private(set)`. + +Note: Shimmer3R v1.01.025 is above v1.00.050, so 2-byte is its strongest safe CRC and 1-byte is +allowed. Shimmer3 always allows 2-byte. + +## To finish +- Add `ThroughputRunner.swift` to the TestApp target (four hand-written pbxproj entries). +- A `ThroughputUITests` XCUITest that reads the device name from `launchEnvironment`, calls the + runner, and writes the CSV to the test attachments. +- Verify the PPG sensor bit (`SENSOR_INT_A1`) gives the wiki's A13 PPG channel, and the payload + size of 10 bytes. +- Radio version (RN4678 / IF820) is not read by the API; pass it in as a launch argument. +- Keep the phone awake: set `UIApplication.shared.isIdleTimerDisabled = true` for the run. +- Check that a CRC change after connect survives `sendSetSensorsCommand`'s inquiry on both boards. + +## Run +``` +xcodebuild test -project TestApp/TestApp.xcodeproj -scheme TestApp \ + -destination 'platform=iOS,name=' \ + -only-testing:TestAppUITests/ThroughputUITests \ + SHIMMER_DEVICE_NAME=Shimmer3R-XXXX +``` + +## Wiki update (`tools/throughput/update_wiki.py`) +Python 3, stdlib only, runs on the Mac. Adds one table per hardware per release, above `# Notes`: +`# Test Results N ... (Shimmer3, ShimmerSwiftAPI_vX.Y.Z)`. Old tables are never touched. A hidden +marker comment per table makes a re-run replace that table instead of duplicating it. + +``` +python tools/throughput/update_wiki.py --csv results.csv --release ShimmerSwiftAPI_v1.1.0 --phone "iPhone 12" --radio Shimmer3="RN4678 v1.23" --radio Shimmer3R="IF820 v01.04.16.16" +``` +- Dry run by default: prints the diff, changes nothing. `--commit` commits in the local wiki clone. + **It never pushes.** Review the diff, then `git -C push` yourself. +- Only `ok` runs count. Each config needs `--min-runs` (default 3) ok runs, and the runs must agree on + firmware and packet size. Anything skipped is listed as a warning. +- `--wiki ` uses an existing clone (must be clean); otherwise it clones to a temp folder. +- Tested on Windows against a copy of the real wiki with a made-up CSV: dry run, commit, no-op re-run + and in-place replace all behave. It has not seen real runner output yet. diff --git a/tools/throughput/update_wiki.py b/tools/throughput/update_wiki.py new file mode 100644 index 0000000..08cd16d --- /dev/null +++ b/tools/throughput/update_wiki.py @@ -0,0 +1,167 @@ +#!/usr/bin/env python3 +"""Turn a ThroughputRunner CSV into new tables on the BLE-Throughput wiki page. + +One table per hardware (Shimmer3, Shimmer3R) per release, inserted above "# Notes". Old tables are +never touched. Re-running for the same release and hardware replaces that table, so there are no +duplicates. + +Dry run by default: prints the diff and changes nothing. --commit commits in the local wiki clone. +It never pushes. Push the wiki yourself after reading the diff. + + python update_wiki.py --csv results.csv --release ShimmerSwiftAPI_v1.1.0 --phone "iPhone 12" \ + --radio Shimmer3="RN4678 v1.23" --radio Shimmer3R="IF820 v01.04.16.16" --wiki ./SwiftAPI.wiki +""" +import argparse +import csv +import re +import statistics +import subprocess +import sys +import tempfile +from collections import defaultdict +from pathlib import Path + +WIKI_URL = "https://github.com/ShimmerResearch/SwiftAPI.wiki.git" +PAGE = "BLE-Throughput.md" +HW_ORDER = ["Shimmer3", "Shimmer3R"] +COLUMNS = ["Equipment", "Shimmer Device", "FW Version", "Radio Type", "Sensors Enabled", "CRC Bytes", + "Number of Bytes", "Sampling Rate", "Streaming Duration", "Packet Reception Rate", + "OS Version", "Distance between devices (approximate)"] + + +def marker(release: str, hw: str) -> str: + return f"" + + +def fw_cell(hw: str, fw: str) -> str: + """CSV holds major.minor.internal, e.g. 1.1.9. The wiki writes v1.01.009.""" + major, minor, internal = (int(x) for x in fw.split(".")) + return f"L&S {hw} v{major}.{minor:02d}.{internal:03d}" + + +def num(x: float) -> str: + return f"{x:g}" + + +def build_rows(rows, release, phone, radios, distance, min_runs): + """Group ok runs by hardware. Return ({hw: [row cells]}, [problems]).""" + problems = [] + skipped = [r for r in rows if r["status"] != "ok"] + for r in skipped: + problems.append(f"skipped {r['hw'] or '?'} {r['config']} crc={r['crc']} run={r['run']}: {r['status']}") + + groups = defaultdict(list) + for r in rows: + if r["status"] == "ok": + groups[(r["hw"], r["config"], int(r["crc"]), float(r["rate_hz"]), int(r["seconds"]))].append(r) + + tables = defaultdict(list) + for (hw, config, crc, rate, secs), g in sorted(groups.items(), key=lambda kv: (HW_ORDER.index(kv[0][0]), kv[0][2])): + if len(g) < min_runs: + problems.append(f"{hw} {config} crc={crc}: {len(g)} ok run(s), need {min_runs}") + continue + if len({x["fw"] for x in g}) != 1 or len({x["packet_bytes"] for x in g}) != 1: + problems.append(f"{hw} {config} crc={crc}: runs disagree on firmware or packet size") + continue + if hw not in radios: + problems.append(f"no --radio given for {hw}") + continue + prr = statistics.median(float(x["prr_api"]) for x in g) + first = g[0] + tables[hw].append([ + phone, hw, fw_cell(hw, first["fw"]), radios[hw], config, + f"{crc} byte" + ("" if crc == 1 else "s"), f"{first['packet_bytes']} bytes", + f"{num(rate)} Hz", f"{secs} s", f"{round(prr)}%", first["ios"], distance, + ]) + return tables, problems + + +def render(hw, release, number, cells): + head = f"# Test Results {number} For Different Sensor Configurations ({hw}, {release})" + lines = [marker(release, hw), head, + "| " + " | ".join(COLUMNS) + " |", + "| " + " | ".join("---" for _ in COLUMNS) + " |"] + lines += ["| " + " | ".join(c) + " |" for c in cells] + return "\n".join(lines) + "\n" + + +def apply(text, release, tables): + """Replace this release's tables, or insert new ones above '# Notes'.""" + numbers = [int(n) for n in re.findall(r"^# Test Results (\d+)", text, re.M)] + next_n = max(numbers, default=0) + 1 + for hw in HW_ORDER: + if hw not in tables: + continue + m = marker(release, hw) + existing = re.search(re.escape(m) + r"\n# Test Results (\d+).*?(?=\n\n|\n# |\Z)", text, re.S) + if existing: + n = int(existing.group(1)) + text = text[:existing.start()] + render(hw, release, n, tables[hw]).rstrip("\n") + text[existing.end():] + else: + block = render(hw, release, next_n, tables[hw]) + "\n" + next_n += 1 + notes = re.search(r"^# Notes", text, re.M) + if notes: + text = text[:notes.start()] + block + text[notes.start():] + else: + text = text.rstrip("\n") + "\n\n" + block + return text + + +def git(wiki, *args, check=True): + return subprocess.run(["git", "-C", str(wiki), *args], capture_output=True, text=True, check=check) + + +def main(): + ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + ap.add_argument("--csv", required=True, type=Path) + ap.add_argument("--release", required=True, help="e.g. ShimmerSwiftAPI_v1.1.0") + ap.add_argument("--phone", required=True, help='Equipment cell, e.g. "iPhone 12"') + ap.add_argument("--radio", action="append", default=[], metavar="HW=VERSION", + help='e.g. Shimmer3="RN4678 v1.23" (repeat per hardware)') + ap.add_argument("--distance", default="2.5 m") + ap.add_argument("--min-runs", type=int, default=3, help="ok runs needed per config (default 3)") + ap.add_argument("--wiki", type=Path, help="existing wiki clone (default: clone to a temp dir)") + ap.add_argument("--commit", action="store_true", help="commit in the wiki clone. Never pushes.") + a = ap.parse_args() + + radios = dict(r.split("=", 1) for r in a.radio) + with a.csv.open(newline="", encoding="utf-8") as f: + rows = list(csv.DictReader(f)) + if not rows: + sys.exit("CSV has no rows") + + tables, problems = build_rows(rows, a.release, a.phone, radios, a.distance, a.min_runs) + for p in problems: + print("WARNING:", p, file=sys.stderr) + if not tables: + sys.exit("nothing to write: no hardware had a complete set of ok runs") + + wiki = a.wiki + if wiki is None: + wiki = Path(tempfile.mkdtemp(prefix="swiftapi-wiki-")) / "wiki" + subprocess.run(["git", "clone", "--quiet", WIKI_URL, str(wiki)], check=True) + page = wiki / PAGE + if git(wiki, "status", "--porcelain").stdout.strip(): + sys.exit(f"{wiki} has uncommitted changes; clean it first") + + old = page.read_text(encoding="utf-8") + new = apply(old, a.release, tables) + if new == old: + print("No change: this release is already on the page with these values.") + return + page.write_text(new, encoding="utf-8", newline="\n") + print(git(wiki, "diff", "--", PAGE).stdout) + + if not a.commit: + git(wiki, "checkout", "--", PAGE) + print("Dry run: nothing changed. Add --commit to commit locally.") + return + git(wiki, "add", PAGE) + hws = ", ".join(h for h in HW_ORDER if h in tables) + git(wiki, "commit", "-m", f"BLE throughput results for {a.release} ({hws})") + print(f"Committed in {wiki}. Not pushed. Review, then: git -C \"{wiki}\" push") + + +if __name__ == "__main__": + main() From becdca747799c20b5d8b12d80204bb40e3671469 Mon Sep 17 00:00:00 2001 From: Harith Jamadi Date: Wed, 4 Nov 2026 14:43:02 +0800 Subject: [PATCH 02/22] DEV-1410: build ThroughputRunner in TestApp, fix TestApp and update_wiki.py on macOS Add ThroughputRunner.swift to the TestApp target (four pbxproj entries). TestApp did not compile on main: ViewModel awaited nothing on the async sendStopStreamingCommand(). update_wiki.py used Path.write_text(newline=), which needs Python 3.10; macOS ships 3.9.6. Built locally: ShimmerBluetoothTests pass (xcodebuild test, as CI), TestApp builds for the iOS simulator. update_wiki.py checked against a scratch wiki clone with a synthetic CSV. Not yet run against a Shimmer. --- TestApp/TestApp.xcodeproj/project.pbxproj | 4 ++++ TestApp/TestApp/ViewModel.swift | 2 +- tools/throughput/update_wiki.py | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/TestApp/TestApp.xcodeproj/project.pbxproj b/TestApp/TestApp.xcodeproj/project.pbxproj index d0392c6..b7bb3b4 100644 --- a/TestApp/TestApp.xcodeproj/project.pbxproj +++ b/TestApp/TestApp.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 3A780CCB2AE12CC500EAF050 /* TestAppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A780CCA2AE12CC500EAF050 /* TestAppUITests.swift */; }; 3A780CCD2AE12CC500EAF050 /* TestAppUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A780CCC2AE12CC500EAF050 /* TestAppUITestsLaunchTests.swift */; }; 3A780CDC2AE12F2C00EAF050 /* ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A780CDB2AE12F2C00EAF050 /* ViewModel.swift */; }; + 3A780CDE2AE1300000EAF050 /* ThroughputRunner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A780CDF2AE1300000EAF050 /* ThroughputRunner.swift */; }; 3AD18D8A2AE1436800AE7475 /* ShimmerBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AD18D892AE1436800AE7475 /* ShimmerBluetooth.framework */; }; 3AD18D8B2AE1436800AE7475 /* ShimmerBluetooth.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3AD18D892AE1436800AE7475 /* ShimmerBluetooth.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ @@ -65,6 +66,7 @@ 3A780CCA2AE12CC500EAF050 /* TestAppUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestAppUITests.swift; sourceTree = ""; }; 3A780CCC2AE12CC500EAF050 /* TestAppUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestAppUITestsLaunchTests.swift; sourceTree = ""; }; 3A780CDB2AE12F2C00EAF050 /* ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModel.swift; sourceTree = ""; }; + 3A780CDF2AE1300000EAF050 /* ThroughputRunner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThroughputRunner.swift; sourceTree = ""; }; 3AD18D892AE1436800AE7475 /* ShimmerBluetooth.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = ShimmerBluetooth.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -121,6 +123,7 @@ 3A7712932AE2BAF9006213A8 /* Info.plist */, 3A7712922AE2B5C9006213A8 /* TestAppDebug.entitlements */, 3A780CDB2AE12F2C00EAF050 /* ViewModel.swift */, + 3A780CDF2AE1300000EAF050 /* ThroughputRunner.swift */, 3A780CAE2AE12CC400EAF050 /* TestAppApp.swift */, 3A780CB02AE12CC400EAF050 /* ContentView.swift */, 3A780CB22AE12CC500EAF050 /* Assets.xcassets */, @@ -296,6 +299,7 @@ files = ( 3A780CB12AE12CC400EAF050 /* ContentView.swift in Sources */, 3A780CDC2AE12F2C00EAF050 /* ViewModel.swift in Sources */, + 3A780CDE2AE1300000EAF050 /* ThroughputRunner.swift in Sources */, 3A780CAF2AE12CC400EAF050 /* TestAppApp.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/TestApp/TestApp/ViewModel.swift b/TestApp/TestApp/ViewModel.swift index 3974544..3697cca 100644 --- a/TestApp/TestApp/ViewModel.swift +++ b/TestApp/TestApp/ViewModel.swift @@ -86,7 +86,7 @@ class ViewModel: NSObject, ObservableObject { } func sendStopStreamingCommandDev2() async { - shimmer3Protocol!.sendStopStreamingCommand() + await shimmer3Protocol!.sendStopStreamingCommand() } func sendInfoMemIMU() async{ diff --git a/tools/throughput/update_wiki.py b/tools/throughput/update_wiki.py index 08cd16d..27bf6eb 100644 --- a/tools/throughput/update_wiki.py +++ b/tools/throughput/update_wiki.py @@ -150,7 +150,8 @@ def main(): if new == old: print("No change: this release is already on the page with these values.") return - page.write_text(new, encoding="utf-8", newline="\n") + with page.open("w", encoding="utf-8", newline="\n") as f: # write_text(newline=) needs 3.10 + f.write(new) print(git(wiki, "diff", "--", PAGE).stdout) if not a.commit: From f95377480857d45eed3057bd5e03bf89ec719777 Mon Sep 17 00:00:00 2001 From: Harith Jamadi Date: Wed, 4 Nov 2026 14:45:15 +0800 Subject: [PATCH 03/22] DEV-1410: Throughput Test screen in TestApp, multi-device scan and run TestApp gets a Throughput Test screen: scan lists every advertising Shimmer, tick one or more, and the BLE-Throughput matrix runs on each in turn into one CSV in the app's Documents folder (Share CSV, or Finder file sharing). A quick check mode (10 s x 1 run) for smoke tests. The phone is kept awake while running. Builds for the iOS simulator. Not yet run against a Shimmer. --- TestApp/TestApp.xcodeproj/project.pbxproj | 8 ++ TestApp/TestApp/ContentView.swift | 8 +- TestApp/TestApp/ThroughputRunner.swift | 34 +++++- TestApp/TestApp/ThroughputView.swift | 121 ++++++++++++++++++++++ docs/THROUGHPUT_AUTOMATION.md | 39 +++---- 5 files changed, 185 insertions(+), 25 deletions(-) create mode 100644 TestApp/TestApp/ThroughputView.swift diff --git a/TestApp/TestApp.xcodeproj/project.pbxproj b/TestApp/TestApp.xcodeproj/project.pbxproj index b7bb3b4..3e669f8 100644 --- a/TestApp/TestApp.xcodeproj/project.pbxproj +++ b/TestApp/TestApp.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 3A780CCD2AE12CC500EAF050 /* TestAppUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A780CCC2AE12CC500EAF050 /* TestAppUITestsLaunchTests.swift */; }; 3A780CDC2AE12F2C00EAF050 /* ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A780CDB2AE12F2C00EAF050 /* ViewModel.swift */; }; 3A780CDE2AE1300000EAF050 /* ThroughputRunner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A780CDF2AE1300000EAF050 /* ThroughputRunner.swift */; }; + 3A780CE02AE1300000EAF050 /* ThroughputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A780CE12AE1300000EAF050 /* ThroughputView.swift */; }; 3AD18D8A2AE1436800AE7475 /* ShimmerBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AD18D892AE1436800AE7475 /* ShimmerBluetooth.framework */; }; 3AD18D8B2AE1436800AE7475 /* ShimmerBluetooth.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3AD18D892AE1436800AE7475 /* ShimmerBluetooth.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ @@ -67,6 +68,7 @@ 3A780CCC2AE12CC500EAF050 /* TestAppUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestAppUITestsLaunchTests.swift; sourceTree = ""; }; 3A780CDB2AE12F2C00EAF050 /* ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModel.swift; sourceTree = ""; }; 3A780CDF2AE1300000EAF050 /* ThroughputRunner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThroughputRunner.swift; sourceTree = ""; }; + 3A780CE12AE1300000EAF050 /* ThroughputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThroughputView.swift; sourceTree = ""; }; 3AD18D892AE1436800AE7475 /* ShimmerBluetooth.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = ShimmerBluetooth.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -124,6 +126,7 @@ 3A7712922AE2B5C9006213A8 /* TestAppDebug.entitlements */, 3A780CDB2AE12F2C00EAF050 /* ViewModel.swift */, 3A780CDF2AE1300000EAF050 /* ThroughputRunner.swift */, + 3A780CE12AE1300000EAF050 /* ThroughputView.swift */, 3A780CAE2AE12CC400EAF050 /* TestAppApp.swift */, 3A780CB02AE12CC400EAF050 /* ContentView.swift */, 3A780CB22AE12CC500EAF050 /* Assets.xcassets */, @@ -300,6 +303,7 @@ 3A780CB12AE12CC400EAF050 /* ContentView.swift in Sources */, 3A780CDC2AE12F2C00EAF050 /* ViewModel.swift in Sources */, 3A780CDE2AE1300000EAF050 /* ThroughputRunner.swift in Sources */, + 3A780CE02AE1300000EAF050 /* ThroughputView.swift in Sources */, 3A780CAF2AE12CC400EAF050 /* TestAppApp.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -471,6 +475,8 @@ INFOPLIST_FILE = TestApp/Info.plist; INFOPLIST_KEY_LSApplicationCategoryType = ""; INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "Allow for Bluetooth use"; + INFOPLIST_KEY_LSSupportsOpeningDocumentsInPlace = YES; + INFOPLIST_KEY_UIFileSharingEnabled = YES; INFOPLIST_KEY_NSBluetoothPeripheralUsageDescription = "Please allow using Blueooth for discovering peripherals"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; @@ -522,6 +528,8 @@ INFOPLIST_FILE = TestApp/Info.plist; INFOPLIST_KEY_LSApplicationCategoryType = ""; INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "Allow for Bluetooth use"; + INFOPLIST_KEY_LSSupportsOpeningDocumentsInPlace = YES; + INFOPLIST_KEY_UIFileSharingEnabled = YES; INFOPLIST_KEY_NSBluetoothPeripheralUsageDescription = "Please allow using Blueooth for discovering peripherals"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; diff --git a/TestApp/TestApp/ContentView.swift b/TestApp/TestApp/ContentView.swift index dfe68b7..3ad4f24 100644 --- a/TestApp/TestApp/ContentView.swift +++ b/TestApp/TestApp/ContentView.swift @@ -9,7 +9,8 @@ import SwiftUI struct ContentView: View { @StateObject var viewModel = ViewModel() - + @State private var showThroughput = false + var body: some View { VStack { Image(systemName: "globe") @@ -19,8 +20,9 @@ struct ContentView: View { } .padding() - - + + Button("Throughput Test", action: { showThroughput = true }) + .sheet(isPresented: $showThroughput) { ThroughputView() } Button("Scan Veri",action: { viewModel.test()}) Button("Connect Dev1",action: { Task { do { diff --git a/TestApp/TestApp/ThroughputRunner.swift b/TestApp/TestApp/ThroughputRunner.swift index 03d9d44..34363fc 100644 --- a/TestApp/TestApp/ThroughputRunner.swift +++ b/TestApp/TestApp/ThroughputRunner.swift @@ -2,11 +2,11 @@ // ThroughputRunner.swift // TestApp // -// DRAFT. Not compiled, not in project.pbxproj, never run. See docs/THROUGHPUT_AUTOMATION.md. +// Not yet run against a Shimmer. See docs/THROUGHPUT_AUTOMATION.md. // -// Runs the BLE-Throughput wiki matrix against one Shimmer3 / Shimmer3R, found by name, with no -// taps: scan, connect, record versions, then for each config set CRC -> rate -> sensors, stream, -// count, stop. Writes a CSV and the wiki rows. +// Runs the BLE-Throughput wiki matrix against one or more Shimmer3 / Shimmer3R, found by name, one +// device after another: scan, connect, record versions, then for each config set CRC -> rate -> +// sensors, stream, count, stop. Writes a CSV for tools/throughput/update_wiki.py. // import Foundation import CoreBluetooth @@ -41,6 +41,8 @@ final class ThroughputRunner: NSObject, ShimmerProtocolDelegate, BluetoothManage private var proto: Shimmer3Protocol? private var scanContinuation: CheckedContinuation? private var clusters = 0 + /// Called with a one-line status as the run moves on (device, config, run number). + var onProgress: ((String) -> Void)? // MARK: matrix (mirrors wiki Test Results 3 and 4) static func wikiMatrix() -> [ThroughputConfig] { @@ -54,6 +56,16 @@ final class ThroughputRunner: NSObject, ShimmerProtocolDelegate, BluetoothManage } } + // MARK: scan for every Shimmer in range + /// Names of the Shimmers advertising within `seconds`, sorted. Empty if Bluetooth is off. + func scanShimmers(seconds: Double = 8) async -> [String] { + manager.delegate = self + guard manager.startScanning(timeout: seconds) else { return [] } + await withCheckedContinuation { scanContinuation = $0 } // resumed by scanCompleted() + let names = manager.getDiscoveredPeripherals().compactMap { $0.name }.filter { $0.hasPrefix("Shimmer") } + return Array(Set(names)).sorted() + } + // MARK: connect by name func connect(deviceName: String, scanSeconds: Double = 15) async -> Bool { manager.delegate = self @@ -69,12 +81,24 @@ final class ThroughputRunner: NSObject, ShimmerProtocolDelegate, BluetoothManage func disconnect() async { _ = await proto?.disconnect() } // MARK: run + /// Runs the matrix on each device in turn. A device that fails to connect gives one + /// connect-failed row and the run moves on to the next. + func run(deviceNames: [String], matrix: [ThroughputConfig], appVersion: String, ios: String) async -> [ThroughputRow] { + var rows: [ThroughputRow] = [] + for name in deviceNames { + rows += await run(deviceName: name, matrix: matrix, appVersion: appVersion, ios: ios) + } + return rows + } + func run(deviceName: String, matrix: [ThroughputConfig], appVersion: String, ios: String) async -> [ThroughputRow] { var rows: [ThroughputRow] = [] var base = ThroughputRow(); base.device = deviceName; base.ios = ios; base.app = appVersion var connected = false + onProgress?("\(deviceName): connecting") for _ in 0..<2 where !connected { connected = await connect(deviceName: deviceName) } // one retry guard connected, let p = proto else { + onProgress?("\(deviceName): connect failed") base.status = "connect-failed"; return [base] } base.fw = "\(p.REV_FW_MAJOR).\(p.REV_FW_MINOR).\(p.REV_FW_INTERNAL)" @@ -86,7 +110,9 @@ final class ThroughputRunner: NSObject, ShimmerProtocolDelegate, BluetoothManage var r = base r.config = cfg.label; r.crc = Int(cfg.crc.rawValue); r.rateHz = cfg.rateHz r.seconds = cfg.seconds; r.run = run + onProgress?("\(deviceName): \(cfg.crc.rawValue)-byte CRC, run \(run)/\(cfg.repeats), \(cfg.seconds) s") rows.append(await runOne(p, cfg, r)) + onProgress?("\(deviceName): \(rows.last!.status), PRR \(String(format: "%.1f", rows.last!.prrApi))%") } } await disconnect() diff --git a/TestApp/TestApp/ThroughputView.swift b/TestApp/TestApp/ThroughputView.swift new file mode 100644 index 0000000..743b3aa --- /dev/null +++ b/TestApp/TestApp/ThroughputView.swift @@ -0,0 +1,121 @@ +// +// ThroughputView.swift +// TestApp +// +// Scan for Shimmers, tick the ones to test, run the BLE-Throughput matrix on each in turn, and +// save one CSV to the app's Documents folder (visible in Finder and the Files app). +// +import SwiftUI +#if os(iOS) +import UIKit +#endif + +@MainActor +struct ThroughputView: View { + @State private var runner = ThroughputRunner() + @State private var found: [String] = [] + @State private var selected: Set = [] + @State private var scanning = false + @State private var running = false + @State private var quick = true + @State private var log: [String] = [] + @State private var csvURL: URL? + + var body: some View { + NavigationView { + List { + Section { + Button(scanning ? "Scanning..." : "Scan for Shimmers") { Task { await scan() } } + .disabled(scanning || running) + ForEach(found, id: \.self) { name in + Button { + if selected.contains(name) { selected.remove(name) } else { selected.insert(name) } + } label: { + HStack { + Text(name) + Spacer() + if selected.contains(name) { Image(systemName: "checkmark") } + } + } + .disabled(running) + } + } header: { Text("Devices") } + + Section { + Toggle("Quick check (10 s, 1 run)", isOn: $quick).disabled(running) + Button(running ? "Running..." : "Run on \(selected.count) device(s)") { Task { await run() } } + .disabled(selected.isEmpty || running || scanning) + if let csvURL { + Text(csvURL.lastPathComponent).font(.footnote) + if #available(iOS 16.0, macOS 13.0, *) { + ShareLink(item: csvURL) { Label("Share CSV", systemImage: "square.and.arrow.up") } + } + } + } header: { Text("Run") } footer: { + Text(quick ? "Quick check: a smoke test, not wiki results." + : "Full: 3 runs x 60 s per CRC mode, about 7 min per device.") + } + + Section { ForEach(Array(log.enumerated()), id: \.offset) { Text($0.element).font(.footnote) } } + header: { Text("Log") } + } + .navigationTitle("Throughput") + } + } + + private func scan() async { + scanning = true + found = await runner.scanShimmers() + selected = selected.intersection(found) + log.append(found.isEmpty ? "No Shimmers found. Is Bluetooth on and the device powered?" + : "Found \(found.count): \(found.joined(separator: ", "))") + scanning = false + } + + private func run() async { + running = true + csvURL = nil + setIdleTimerDisabled(true) // a locked phone stops the run + runner.onProgress = { log.append($0) } + + var matrix = ThroughputRunner.wikiMatrix() + if quick { + matrix = matrix.map { + ThroughputConfig(label: $0.label, sensorBitmap: $0.sensorBitmap, payloadBytes: $0.payloadBytes, + rateHz: $0.rateHz, crc: $0.crc, seconds: 10, repeats: 1) + } + } + let app = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "?" + let rows = await runner.run(deviceNames: selected.sorted(), matrix: matrix, + appVersion: app, ios: osVersion()) + csvURL = save(ThroughputRunner.csv(rows)) + log.append(csvURL.map { "Saved \($0.lastPathComponent)" } ?? "Could not save the CSV") + + setIdleTimerDisabled(false) + running = false + } + + private func save(_ csv: String) -> URL? { + let stamp = DateFormatter() + stamp.dateFormat = "yyyyMMdd_HHmmss" + guard let docs = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return nil } + let url = docs.appendingPathComponent("throughput_\(stamp.string(from: Date()))\(quick ? "_quick" : "").csv") + return (try? csv.write(to: url, atomically: true, encoding: .utf8)) == nil ? nil : url + } + + /// As the wiki writes it, e.g. "iOS 16.7.1". + private func osVersion() -> String { + #if os(iOS) + return "iOS \(UIDevice.current.systemVersion)" + #else + let v = ProcessInfo.processInfo.operatingSystemVersion + return "macOS \(v.majorVersion).\(v.minorVersion).\(v.patchVersion)" + #endif + } + + private func setIdleTimerDisabled(_ disabled: Bool) { + #if os(iOS) + UIApplication.shared.isIdleTimerDisabled = disabled + #endif + } +} diff --git a/docs/THROUGHPUT_AUTOMATION.md b/docs/THROUGHPUT_AUTOMATION.md index e787c01..957f042 100644 --- a/docs/THROUGHPUT_AUTOMATION.md +++ b/docs/THROUGHPUT_AUTOMATION.md @@ -1,18 +1,20 @@ # BLE throughput test automation (draft) Goal: fill the wiki's BLE-Throughput tables for a new Shimmer3 / Shimmer3R firmware with one command -and almost no human steps. Status: **draft, never compiled or run.** This repo only compiles in CI -(`AGENTS.md`), and `ThroughputRunner.swift` is not yet in `project.pbxproj`. +and almost no human steps. Status: TestApp builds with the runner (checked locally on a Mac with Xcode 26.6). **Not yet run +against a Shimmer.** ## Human steps (all that remain) 1. Flash the firmware under test (Shimmer3 v1.01.009, Shimmer3R v1.01.025) and power the board on. 2. Plug in and unlock the iPhone; put the board about 2.5 m away. Tap Allow on the first-launch Bluetooth prompt, once per install. -3. Run the command below with the device name. +3. In TestApp tap **Throughput Test**, then **Scan for Shimmers**, tick one or more devices, and tap + **Run**. Devices are tested one after another into one CSV. 4. Run `tools/throughput/update_wiki.py` (below), read the diff, then push the wiki yourself. ## Automated -- Scan and connect by BLE name (`BluetoothManager.startScanning(deviceName:)`), one retry. +- Scan lists every advertising device whose name starts with `Shimmer`; connect by BLE name + (`BluetoothManager.startScanning(deviceName:)`), one retry. - Record FW, hardware, expansion board, iOS and app version from the device, not from typing. - For each config and each of N repeats: set CRC, then rate, then sensors, stream, count, stop. - Write a CSV with every run. @@ -41,22 +43,23 @@ Note: Shimmer3R v1.01.025 is above v1.00.050, so 2-byte is its strongest safe CR allowed. Shimmer3 always allows 2-byte. ## To finish -- Add `ThroughputRunner.swift` to the TestApp target (four hand-written pbxproj entries). -- A `ThroughputUITests` XCUITest that reads the device name from `launchEnvironment`, calls the - runner, and writes the CSV to the test attachments. -- Verify the PPG sensor bit (`SENSOR_INT_A1`) gives the wiki's A13 PPG channel, and the payload - size of 10 bytes. -- Radio version (RN4678 / IF820) is not read by the API; pass it in as a launch argument. -- Keep the phone awake: set `UIApplication.shared.isIdleTimerDisabled = true` for the run. -- Check that a CRC change after connect survives `sendSetSensorsCommand`'s inquiry on both boards. +- Radio version (RN4678 / IF820) is not read by the API; it is passed to `update_wiki.py --radio`. +- Check that a CRC change after connect survives `sendSetSensorsCommand`'s inquiry on both boards + (a run with the wrong CRC is caught by the packet-size gate and written as `size-mismatch`). +- A connect that fails at the CoreBluetooth level never resumes `BluetoothManager.connect`, so the + run hangs rather than writing `connect-failed`. Kill the app and untick that device. + +Checked: `SENSOR_INT_A1` (0x0100) enables channel `InternalAdc1` (0x12), which is internal ADC A13, +the wiki's PPG channel. 6 accel + 2 GSR + 2 PPG = 10 payload bytes. ## Run -``` -xcodebuild test -project TestApp/TestApp.xcodeproj -scheme TestApp \ - -destination 'platform=iOS,name=' \ - -only-testing:TestAppUITests/ThroughputUITests \ - SHIMMER_DEVICE_NAME=Shimmer3R-XXXX -``` +Open `Shimmer.xcworkspace`, select the **TestApp** scheme and the iPhone, set a team under Signing & +Capabilities, and Run. **Quick check** (on by default) does 10 s x 1 run per CRC mode as a smoke test; +turn it off for the wiki matrix (3 x 60 s per CRC mode, about 7 min per device). The phone is kept +awake during a run. + +The CSV is saved as `throughput__