MakeReady

Shot timers

Architecture

apps/tablet/src/timer/TimerAdapter.ts defines a small interface: connect/disconnect/subscribe/source plus optional start/stop for timers the tablet can control, with events start, shot {index, time, split}, final {time, shots}, resume, battery, error. The scoring screen only knows that interface. Every timer is an adapter:

AdapterStatus
ManualTimerdone — the RO types in the time
SgTimer (Shooters Global SG Timer Sport / GO, BLE API 3.2)done — scan, connect, start/stop/pause/resume, live shots, PAR setup, shot recovery
AmgTimer (AMG Lab Commander, BLE)done — scan, connect, remote start, live shots (BLE push), sensitivity, shot list after a stop
SpTimer (Special Pie M1A2 / M1A2+, BLE)done — scan, connect, live shots; no remote start/stop and no read-back (pull uses the last run the tablet saw)

apps/tablet/src/timer/timers.ts keeps the active timer of the tablet: manual entry by default, or the connected Bluetooth timer. The last timer is remembered and reconnected when the app starts. The Timer button on the event list opens the timer screen, which scans for all models at once.

Lost connection: when the link drops without the RO disconnecting (out of range, timer asleep) the tablet reconnects by itself after 2, 4 and 8 s and then every 15 s for about five minutes; the scoring screen shows "reconnecting…" and has a Reconnect button for an immediate attempt. There is only ever one attempt at a time on a device: an automatic attempt, the Reconnect button and a disconnect reported meanwhile all join the same one (two attempts on one Bluetooth device cancel each other, which showed as a link flipping between connected and not connected). Before connecting, a link left over from before is closed. When the app comes back to the foreground the link is checked at once, and a link that drops three times within seconds of coming up gets a fresh Bluetooth manager (what restarting the app used to do).

START / STOP buttons (timer screen, remembered on the tablet): the scoring screen can hide the START timer and STOP timer buttons, for ROs who start and stop on the timer itself. The AMG Commander keeps "Finish run", because it has no stop of its own.

Timing mode (timer screen, remembered on the tablet):

  • Push: shots and the stage time appear on the scoring screen during the run (default).
  • Pull: the scoring screen does not follow the run. After "range is clear" the RO taps Pull next to the time field, which reads the last run from the timer (fetchLast()): the SG Timer's shot list of the last session (the session the tablet saw start, otherwise the newest saved session), the AMG Commander's current string, the Special Pie's last run as the tablet received it (that timer cannot be read back). The time can still be typed in by hand.

Typing a time: the time field takes digits with two implied decimals (2430 is 24.30 s, 567 is 5.67 s) on a numeric keypad; a typed . or , is also accepted. The time counts as soon as it is typed, there is no button; emptying the field takes it back.

All shot times are stored with the score (StageScore.shotTimes) and timerSource records which timer the time came from (sg_timer:<id>, amg_commander:<id>, special_pie:<id> or manual; manual also when the RO overrides a connected timer's time).

Shooters Global SG Timer

Implemented from the public Smart Shot Timer BLE API (version 3.2). Everything protocol-specific is in apps/tablet/src/timer/sgProtocol.ts (pure, unit-tested) and sgTimer.ts (the Bluetooth link).

Discovery

The timer advertises the main service 7520FFFF-14D2-4CDA-8B6B-697C554C9311 with the name SG-SST4<model><serial> (A = SG Timer Sport, B = SG Timer GO). The tablet scans for that service for six seconds and lists the timers by model and serial, strongest signal first.

Characteristics used

CharacteristicUUID (7520xxxx-14D2-4CDA-8B6B-697C554C9311)Use
COMMAND0000write len, cmd_id; the response (len, cmd_id, 0x00 ok / 0x01 error) arrives as a notification
EVENT0001notifications of the run (below)
SHOT_LIST0004write a session id, then read entry by entry (shot_number u16, shot_time u32 ms, 0xFFFFFFFF ends the list)
PAR_SETUP0005start_delay u16 (0.1 s, 0xFFFF = random 1–4 s), time_limit u16 (0.1 s, 0 = none), shot_limit u16 (0 = none)
UNIX_TIME0006the timer's clock; set on every connect so session ids are correct
API_VERSIONFFFEASCII string, shown on the timer screen

All multibyte values are big endian. Each command or event frame starts with a length byte, so several frames can share one notification; the decoder splits them.

Events → app

Timer eventPayloadApp
SESSION_STARTED (0x00)session id, start delaynew run: shots cleared, phase running
SESSION_SET_BEGIN (0x05)session idbuzzer; start timestamp
SHOT_DETECTED (0x04)session id, shot number, time in msshot appears live on the tablet and the dashboards
SESSION_SUSPENDED (0x01)session id, total shotsfinal with the last shot time (the RO can score)
SESSION_RESUMED (0x02)session id, total shotsresume: time open again, shots keep counting
SESSION_STOPPED (0x03)session id, total shotsfinal; when more shots are reported than received live, the missing ones are read from SHOT_LIST first

Commands: SESSION_START (0x00), SESSION_SUSPEND (0x01), SESSION_RESUME (0x02), SESSION_STOP (0x03). The scoring screen shows START timer / STOP timer when an SG Timer is connected; the start button on the timer itself works the same way because the events come from the timer. The RO can always override the time with the input field.

Timer screen

Scan and connect, disconnect or forget the timer, set the PAR configuration (start delay fixed or random, time limit, shot limit; saved on the timer) and run a test session with a log of the events.

Testing on hardware

BLE needs a development or store build on a real Android/iOS device (Expo Go and the emulator have no Bluetooth). This applies to both timers. On Android 12+ the app asks for the Nearby devices permission on the first scan; on Android 11 and older it asks for location (required by Android for BLE scans).

Not confirmed on hardware yet (see docs/open-questions.md): whether the shot number in SHOT_DETECTED starts at 0 or 1 (the app numbers shots by itself) and whether a suspended session is what the RO wants to score.

AMG Lab Commander

AMG Lab gives its protocol to developers on request but does not publish a specification. The adapter follows the protocol as used by open-source integrations of the Commander (a demo Android app on GitHub and the behaviour documented by other scoring apps); it is implemented in apps/tablet/src/timer/amgProtocol.ts (pure, unit-tested) and amgTimer.ts.

Prerequisites on the timer: Bluetooth on and BLE push on in the Commander's settings (BLE push sends every detected shot to the tablet).

Discovery

The Commander advertises the Nordic UART Service 6E400001-B5A3-F393-E0A9-E50E24DCCA9E with a name starting with AMG. Commands are written as ASCII text to 6E400002-… (RX); frames arrive as notifications on 6E400003-… (TX).

Commands

CommandEffect
COM STARTthe Commander runs its own standby delay (set on the timer: random or fixed) and sounds the buzzer
REQ STRING HEXsends the shots of the current string
SET SENSITIVITY 01…10microphone sensitivity (1 = very loud firearms, 10 = very quiet)

There is no remote stop and no pause: the RO stops the timer on the Commander (the tablet receives a stop frame), or presses FINISH run on the scoring screen, which takes the last shot as the stage time.

Frames (14 bytes, times in 1/100 s, big endian)

FrameLayoutApp
start01 05 …new run: shots cleared, phase running
shot (BLE push)01 03 shot total time(2) split(2) first(2) ?(2) series(2)shot appears live on the tablet and the dashboards
stop01 08 …the shot list is requested once to fill in missed pushes, then final
string chunk0A..1A count t1(2) t2(2) … (0A = first chunk)answer to REQ STRING HEX

A shot push without a preceding start frame (start pressed on the timer before the app connected) opens a run on the tablet as well.

Timer screen

Scan and connect, disconnect or forget the timer, set the sensitivity, run a test session (start, finish, read the shot list) with a log of the events.

Not confirmed on hardware yet (see docs/open-questions.md): the exact advertised name, the meaning of bytes 10–11 of a shot push and whether the stop frame also follows a time-out on the timer.

Special Pie M1A2 / M1A2+

The maker publishes no protocol; the adapter follows what the community reverse engineered (spProtocol.ts, with the documented example frames as tests). Discovery: service 0000FFF0-0000-1000-8000-00805F9B34FB (the M1A2+ advertises no telling name) or a name starting with SP M1A2. Every notification on characteristic FFF1 is one frame F8 F9 <type> … F9 F8: 34 start, 18 stop (both with a session number), 36 shot with the time as seconds and centiseconds (10 ms resolution, at most 255 s) and a 0-based shot index. The timer only pushes: the tablet cannot start or stop it, nor read a run back, so Pull returns the last run the tablet received while it was connected. Not tested on hardware yet.

Older timers without Bluetooth

The classic CED7000 has no Bluetooth and is not supported; the RO types in the time (manual entry). Another BLE timer is the same exercise as the two above: a frame decoder plus an adapter on TimerAdapter.

Android permissions

app.json requests BLUETOOTH_SCAN, BLUETOOTH_CONNECT and ACCESS_FINE_LOCATION (required for BLE scans on older Android versions). The react-native-ble-plx config plugin is set to central; the app requests the runtime permissions before a scan.