Skip to content

Dev 1410 ios throughput automation - #28

Open
harithjamadi wants to merge 23 commits into
mainfrom
DEV-1410_ios_throughput_automation
Open

harithjamadi wants to merge 23 commits into
mainfrom
DEV-1410_ios_throughput_automation

Conversation

@harithjamadi

Copy link
Copy Markdown
Contributor

No description provided.

harithjamadi and others added 23 commits November 4, 2026 14:33
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.
…iki.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 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.
…oughput screen

Shimmer3Protocol calls its delegate from its background processing queue, but
ThroughputRunner's conformance was main-actor isolated (the compiler warned).
The callbacks are now nonisolated; scanCompleted hops to the main actor.

The screen shows the current step with a ticking timer and lists the log
newest first, so progress is visible without scrolling.

Prompted by a SIGABRT on a background thread during a run on an iPhone X
(iOS 16); the root cause is not yet confirmed from the crash log.
…command

On an iPhone X a Shimmer3R link dropped mid-stream; the runner slept out the
run, sent stop to a disconnected peripheral (CoreBluetooth API MISUSE), and
waited forever for its ACK, because Shimmer3Protocol has no command timeout.

Every command now has a timeout. The stream wait checks the link each second,
so a drop ends the run at once with status "disconnected" (counts kept). The
next run reconnects first; if that fails the device's remaining runs are
skipped and the next device starts.
…reaming

processData appends incoming bytes to receivedBytes under a barrier on
`queue`, but the processing loop read and removed from the same array on
processingQueue with no synchronization. Mid-stream on an iPhone X the two
overlapped and the app aborted in the append ("Object ... deallocated with
retain count 2", SIGABRT).

Each pass of the processing loop now runs as a barrier block on `queue`, and
startProcessing's removeAll does too, so the buffer has one writer at a time.
Appends stay async, so the Bluetooth thread is never blocked.

ShimmerBluetoothTests pass; Shimmer3Protocol itself cannot be unit tested
(AGENTS.md), so the fix is exercised only on hardware. Shimmer3SpeedTestProtocol
has the same pattern and is not changed here.
…e buffer

e8e0b7b made each processing pass hold `queue`, but three reply handlers
(calib dump, infomem, BMP280 calibration) waited for the rest of a long reply
with a 0.5 s Thread.sleep inside the pass. Holding `queue`, nothing could
arrive during it: on an iPhone X a calib dump chunk was read at 107 of 135
bytes, failed its CRC, and getCalibrationDump force-unwrapped the nil.

Those handlers now end the pass until the whole reply (length byte + header +
CRC) is buffered, and the next pass, 1 ms later, looks again.

ShimmerBluetoothTests pass; this code is only exercised on hardware.
Shimmer3Protocol.sendReadBtFwVersionCommand() sends GET_BT_FW_VERSION_STR
(0xA1) and stores the reply's text in btModuleVersion, e.g. "RN4678 V1.23
06/30/2021 (c)Microchip Technology Inc" or "CYW20820 app=v01.04.16.16". The
reply ([ACK][0xA2][len][text][CRC]) spans BLE notifications, so the handler
waits for all of it. Supported from Shimmer3 LogAndStream v0.13.7 and on every
Shimmer3R, as in the Java API (ShimmerBluetooth.readBtFwVersion); connect()
does not send it.

ShimmerUtilities.btModuleDisplayName() gives the wiki's short form
("RN4678 v1.23", "IF820 v01.04.16.16") from the string itself, avoiding two
slips in Java's lookup table (V1.22 -> "v1.23", V1.13.5 -> "v1.15.5").

ShimmerBluetoothTests pass, including the new name test; the 0xA2 reply
handling is only exercised on hardware.
The runner reads the radio version after connecting and writes it in a new
radio column; update_wiki.py takes the Radio Type cell from it, with --radio
kept as an override for older CSVs.

A run that is not ok is tried again up to 3 times, reconnecting first if the
link dropped. Only the last try is written, with an attempts column, so a
retried success replaces its failures and a run that never succeeds is still
recorded with its status.

TestApp builds; update_wiki.py checked against a scratch wiki clone with the
real 2026-11-04 CSV and a new-format copy of it. Not yet run on hardware.
A Shimmer3R (FW v1.01.025) puts a comma after the IF820 version, so the radio
came out as "IF820 v01.04.16.16," and split its CSV field: every Shimmer3R row
shifted by one column and update_wiki.py read its status as "60.5" and skipped
it. btModuleDisplayName now keeps only the version's digits and dots, and the
runner quotes the radio field, which is free text from the device.
Runner:
- A stream the device ends itself is recorded as device-stopped, not ok.
- A refused stop is recorded as stop-failed and forces a reconnect.
- The first-connect retry disconnects the failed attempt first.
- Uses the existing setCRCMode/getCRCMode; the duplicate
  sendSetCRCMode/currentCRCMode are removed.

Library:
- BluetoothManager: a failed or abandoned connect resumes its continuation
  with false, so it no longer takes the next device's didConnect.
- Shimmer3Protocol: ACK and version/daughter-card/FW/BMP280 replies wait
  until the whole reply is buffered instead of indexing past the end.
- sendReadBtFwVersionCommand refuses while another command is pending and
  stores its continuation before writing.
The app writes a phone column from the iOS model identifier (iPhone10,3 ->
"iPhone X"; unknown models keep the raw identifier). update_wiki.py takes the
Equipment cell from it, so --phone is only needed to override it or for older
CSVs.
The app now exports the wiki table itself: its 12 columns, one row per
device and CRC setting, PRR the median of the runs when all ended ok and
"incomplete (n/m ok: reasons)" otherwise. Distance is a field in the app.
update_wiki.py copies the publishable rows as they are and skips
incomplete, quick-check and unnamed-phone rows with a warning.
Both boards now go into the next Test Results number instead of one table
each. A re-run for the same release replaces the rows of the devices it
tested and keeps the others.
The wiki is a log of test runs: a release tested again gets a new table
with the API release in its heading, and earlier tables are never
replaced. Publishing the same run twice still changes nothing.
A run for a release already on the page adds its rows to that release's
table, grouped by device, without repeating rows or removing any. A new
release starts the next Test Results number.
The wiki table gets an API Release column after Equipment, filled from
--release (the app cannot know which release it was built from). The
heading no longer repeats it.
Each CRC setting is run once; a failed run is retried up to 3 times and
only the ok run is reported. A setting that never passes says
"failed after n tries: reason" in the PRR cell. A full test drops from
about 7 to about 3 minutes per device.
update_wiki.py <csv> --push clones the live wiki fresh, shows the change,
asks once, then commits and pushes. The API release defaults to the
latest ShimmerSwiftAPI_v* tag on GitHub.
The steps now run from building TestApp to publishing with --push.
Stale parts are corrected: the run status, retries, CSV contents, and
the old to-do list, which is replaced by the known issues.
- BleByteRadio.connect returns false when BluetoothManager's connect
  fails, instead of waiting for service discovery that never comes. The
  earlier BluetoothManager fix did not reach callers without this.
- update_wiki.py: a re-run of the same setting on the same phone and
  firmware replaces that row in its release's table, so a setting never
  shows two results.
- The throughput sheet cannot be swiped away while a run is going.
…--yes

Run through a shell with no keyboard input, the confirmation prompt
raised EOFError. It now cancels with a hint, and --yes skips the
question once the change has been checked. Document the one-time git
credential setup that pushing needs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant