Electra Link
A developer's guide to the protocol, the firmware APIs, and building your own Electra Link or primary. Protocol version 8.
This is the document src/Link/LinkRecords.h refers to. The header is the single source of truth for the numbers; when this text and a compiled header disagree, the header wins.
1. What the link is
One controller — the primary — owns everything: the preset, the parameter map, the Lua state, the router, the MIDI. An Electra Link owns nothing. It is sent a view — a list of things to draw and the values they hold — and it reports what the user did to it. It never decides anything, so there is only ever one copy of the state and nothing to reconcile.
An Electra Link can be:
- another Electra One mk2 or mini running the Electra Link image (
make TARGET=electralink), plugged into the primary's USB host port; - an Electra One mk1 running its Electra Link program (
apps/linkin the firmware-mk1 repository, built withmake APPPATH=apps/link), plugged into the same socket. It compiles the very samesrc/Linksources and is functionally the Electra Link image on that hardware; only the panel idiom differs (six buttons in two columns, a touch on the knob under a chooser item), and it claims modelMk1; - a computer program on the primary's USB device port — anything that speaks the protocol.
Three design rules explain most of the protocol:
- The primary decides. An Electra Link requests a page or a preset; the primary answers with a view, or doesn't. An Electra Link never applies an input to its own copy of a value — it reports the input and waits for the value to come back.
- Everything travels in the display domain. An Electra Link has no message definitions, no formatters, no overlays of its own. A value that should read as "warm" arrives as the word, because the primary is the only end that can produce it.
- An Electra Link cannot do anything its owner did not configure the controller to do. Context buttons report which button, never a command. Requests are requests.
One session, last hello wins
A primary holds one session. A new hello replaces the old session — a program on a computer saying hello while a hardware Electra Link is attached steals the session from it (the hardware Electra Link notices the silence and takes it back). Do not run both while testing.
2. Getting connected
Topologies
Electra in the host port. Plug an Electra Link unit's USB device port into the primary's USB host port. Nothing to configure: the Electra Link says hello on its CTRL cable every 2 s until the primary answers. Note the Electra Link is bus-powered — rebooting or reflashing the primary reboots it.
Computer on the device port. Open the primary's Electra CTRL MIDI port and speak the protocol; the primary learns where the hello came from and answers on the same interface and port. This is how any integration works.
Two units both on a computer. They cannot hear each other; forward everything between the two CTRL ports. tools/linkbridge.c does exactly that, and counts traffic per opcode while it is at it:
clang -O2 -o linkbridge linkbridge.c -framework CoreMIDI -framework CoreFoundation
./linkbridge list # find the two CTRL port indices
./linkbridge 4 7 # bridge them, print counters every 2 sThe handshake
Electra Link primary
| -- Hello (0x01) ------------> | every 2 s until answered
| <----------- Welcome (0x02) -- | session accepted
| <-- View, Overlay, Element ... | the current view follows
| -- Ping (0x09) -------------> | every 2 s
| <------------- Pong (0x0A) -- |The hello carries what the Electra Link is — model, screen size, knob and button counts, and a capability mask of the element types it can draw. The primary lays out for exactly what is claimed and the Electra Link never scales or reflows, so a wrong number is a page laid out for a screen that does not exist.
The keepalive is symmetric in vocabulary, asymmetric in duty: the Electra Link pings, the primary answers. Both time against the shared constants (pingIntervalMs = 2000, pingMissesAllowed = 3, livenessTimeoutMs = 8000). Anything arriving counts as the other end being alive. An Electra Link that loses the primary goes back to saying hello; a primary that loses the Electra Link closes the session and releases what it was holding (a watched preset's parameter map stays enabled only while somebody watches).
Version negotiation
Both ends state their protocol version (hello and welcome). Features are gated on the other end's number, never assumed:
- the primary omits overlays a v6+ Electra Link already holds;
- the primary sends
Primitivesframes and the pot mask only to v7+; - an Electra Link sends
Gestureonly to a v7+ primary.
The negotiated ElementType mechanism (section 5) is what keeps mixed versions drawing something sensible in all other cases.
3. Transport and framing
Every link message is one Electra SysEx message:
F0 00 21 45 0A <opcode> <base64 payload> F70x0A is the Link command byte. The byte after it is the link opcode — it sits where an object byte would in other Electra commands, but it is an opcode, not an object (see §12, Pitfalls). The payload is the record bytes, base64-encoded; a message with no payload (Ping, Pong, Bye) ends right after the opcode.
Sizes. A decoded payload is at most maxPayloadLength = 320 bytes. The bound exists because an Electra One acting as the link reads SysEx into a 512-byte buffer and base64 costs a third again. This is why a view travels as a header plus one message per element, and why big things (overlays, subscriptions, primitive frames) travel in sequenced pieces — no chunking layer has to exist.
Byte order. Every multi-byte field is little-endian. Strings are a length byte followed by that many bytes of text, no terminator, at most maxStringLength = 63 bytes (senders truncate; a receiver treats a longer claim as a malformed message).
Safety. Read with a bounds-checked reader: a read past the end must fail the whole message, not walk the buffer. The firmware's Link::Reader sets a sticky failed flag and every later read answers false — one isValid() check at the end covers the message. Whatever arrives on a MIDI port is input you did not choose.
USB transfer detail. The firmware sends SysEx in 126-byte USB-MIDI chunks (a multiple of 3) with only the tail carrying the end-of-SysEx packet. Historical note: it used to terminate every chunk, which CoreMIDI forgave for years and a spec-honouring parser truncated at exactly one chunk. If your parser sees >128-byte messages arriving cut short, you have reimplemented that bug from the other side.
4. Message catalogue
| Opcode | Name | Direction | Payload |
|---|---|---|---|
| 0x01 | Hello | link → pri | HelloRecord |
| 0x02 | Welcome | pri → link | WelcomeRecord |
| 0x03 | View | pri → link | ViewHeaderRecord + PageRecord × pageCount |
| 0x0B | Element | pri → link | viewId u16 + ElementRecord + ValueRecord × valueCount + potMask u16 ⁽ᵛ⁷⁾ |
| 0x04 | Update | pri → link | viewId u16, count u16, then per change: elementId u16, ChangeKind u8, ValueRecord |
| 0x0F | Overlay | pri → link | OverlayHeaderRecord + OverlayItemRecord × count |
| 0x12 | OverlayBitmap | pri → link | OverlayBitmapRecord |
| 0x05 | Primitives | pri → link | PrimitivesHeaderRecord + op bytes ⁽ᵛ⁷⁾ |
| 0x0C | Presets | pri → link | PresetRecord (one per message; index/count delimit the set) |
| 0x10 | Banks | pri → link | BankRecord × count, one message |
| 0x11 | ContextButtons | pri → link | ContextButtonRecord × count, one message |
| 0x0E | SubscriptionUpdate | pri → link | SubscriptionUpdateRecord |
| 0x07 | Input | link → pri | count u8 + InputRecord × count |
| 0x13 | Gesture | link → pri | GestureRecord ⁽ᵛ⁷⁾ |
| 0x08 | Request | link → pri | RequestRecord |
| 0x0D | Subscribe | link → pri | SubscribeHeaderRecord + SubscriptionEntry × count |
| 0x09 / 0x0A | Ping / Pong | link → pri / pri → link | empty |
| 0x06 | Command | pri → link | reserved — defined (Brightness, Sleep, Message, Clear) but not currently handled |
| 0x7F | Bye | either | empty |
Field-by-field record layouts are in §11.
5. Views
A view is everything the Electra Link shows, replaced whole:
- View (0x03): the header — view id, kind, preset slot, page number, active control set, preset title and project id — plus the page list riding along (the Electra Link's page chooser needs them all at once). The page list starts at page 1: page 0 is the performance page, which the firmware reaches through a dedicated button (mk2) or not at all (mini), never from a page list.
- Overlay (0x0F) messages, before the elements that reference them, in pieces — sequence 0 restarts an overlay,
finalcompletes it. Overlays are content-addressed per session: the primary hashes each overlay and skips ones a v6+ Electra Link already holds, so the Electra Link must keep every overlay it was sent until the next Welcome. - OverlayBitmap (0x12) messages after an overlay's items: the packed 1-bpp 48×18 source bytes of any item that has a picture, addressed by
(overlayId, item value). - One Element (0x0B) message per element. The Electra Link draws nothing until all
elementCountof them have arrived (no page assembling itself on screen). Each is prefixed with the view id so a stale element cannot be drawn into a newer view.
viewId counts sends, not content. If a re-sent view is structurally identical, refresh values in place instead of rebuilding — the firmware Electra Link hashes structure for exactly this.
Elements: the negotiated type and the native truth
Each element carries two descriptions:
type— the negotiatedElementType, chosen from what the Electra Link's hello claimed it can draw: Fader, Vfader, List, Pad, Dial, Envelope, XyPad, Group, or Opaque ("a labelled box, drawn with no graphics" — the honest fallback, still playable because its values are sent like anyone else's).nativeType/nativeVariant/nativeMode— the control as the controller holds it (Control::Typeetc.), for an Electra Link that builds the controller's own components. Ignorable; zero means an older primary did not say.
This is what lets the two ends upgrade independently: an Electra Link that knows nothing new still gets a shape it claimed.
potId says which knob drives the element (on a mini, pot ids 8–11 are the hardware buttons under the screen — a control there is drawn as that button, not as a control adrift on the page). Since v7 the element message ends with a pot mask (u16, bit per pot id 0–15): a custom control may take several knobs, and potId is only the first of them. The mask is trailing — an older reader stops before it; a newer reader falls back to potId when an older primary did not send it.
Values
A ValueRecord per value handle: min, max, current — display domain — plus flags: Known (clear = the primary does not know either; show that, not an invented number), HasLabel (a string follows and is what to show), Switch (pressed and released, not set — see Inputs). overlayId names the overlay the value reads its words from, or 0.
Updates
When values move, the primary batches them: Update = viewId, change count, then per change the element id, a ChangeKind (only Value = 1 is used), and a fresh ValueRecord. Changes are coalesced — a knob swept across its range is one message per pass with where the value ended up, not every step. An update for a view you are no longer showing is dropped.
6. Driving controls from an Electra Link
Inputs
Input (0x07) carries a count and that many InputRecords. The kinds in actual use:
- ValueSet (7): "the user arrived at this display value." The primary clamps it, translates to MIDI, and sets it through the parameter map — so the MIDI goes out, the primary's screen repaints, and the preset's
onChangeruns exactly as if a local knob had turned. The firmware Electra Link's knobs are relative encoders: it sends last-told value + turn, which needs no takeover and cannot jump. - Button (6): a switch went down (
a= 1) or up (a= 0). Both travel; neither says what the control becomes — latch or momentary is the primary's rule to apply.
Addressing: an element id means different things on different views (a control id on a preset page, a subscription index on a master performance). So every input either carries the viewId it was made against — the primary discards inputs naming a view it is no longer showing — or sets InputFlag::ViaSubscription, which addresses the standing subscription and needs no view at all.
Subscriptions and the master performance
An Electra Link may Subscribe (0x0D) to up to 128 controls — (presetId, controlId, handle) triples, sent in sequenced pieces, sequence 0 replacing the set. The order is the addressing: index in this list is the id used by subscription-flagged inputs and by the feed coming back.
The primary answers with a standing SubscriptionUpdate (0x0E) feed: every subscribed control's movement, whatever is being shown, whoever caused it. That is what takeover needs — a knob assigned to a preset running in the background still knows where its control stands.
Request(MasterPerformance) asks the primary to compose a view of the subscription: one Tile element per entry, laid out by the primary for the Electra Link's screen.
Requests
RequestRecord = kind + two byte arguments:
| Kind | Meaning |
|---|---|
| CurrentView (1) | send me whatever you'd show me |
| Page (2) | show page argument of the bound preset |
| Resync (3) | send everything again |
| Preset (4) | bind me to live preset slot argument (refused if not running) |
| PresetList (5) | send the preset list |
| SwitchPreset (6) | load slot argument — a bigger ask, said plainly |
| PinPreset (7) | pin (argument2=1) or unpin slot argument |
| MasterPerformance (8) | show my subscriptions |
| ContextAction (9) | run whatever context button argument does on the controller |
| ControlSet (10) | drive row argument (1–3) of the shown page; 0 hands the choice back ⁽ᵛ⁸⁾ |
The Electra Link's page is its own: turning a page there does not turn one on the primary, which is what lets the two show different pages of one preset — or two different presets entirely, one of them pinned in the background. Since v8 its row is its own as well: a page has three rows on the same twelve knobs, and Request(ControlSet) says which row the Electra Link's knobs drive. The primary answers with the view again, the elements of that row flagged Active; an Electra Link should prefer an active element when several sit on one knob (the firmware Electra Links do). Without the request the primary sends its own set for the preset on its screen and every element playable for one in the background, as before. The mk1 asks with its left-hand buttons, the mk2 Electra Link with a touch on the page between the controls. While an Electra Link watches a background preset, the primary keeps that preset's parameter map enabled (and re-asserts that on every preset change; see Pitfalls).
7. Custom controls: drawings out, gestures back
A custom control is painted by its preset's Lua and its behaviour is its script's — and the script runs only on the primary. So neither the look nor the input can be described; both travel raw. Protocol v7, both directions.
Primitives (0x05): the captured paint
When a custom control on a page an Electra Link is showing calls repaint(), the primary runs its paint callback into a recorder instead of the screen: each graphics.* call becomes one op, arguments verbatim, in the control-relative coordinates the callback drew in. The op list is the frame.
- Frames are throttled (default 10 per second, settable 1–50, see §8 — the ceiling is the primary's own screen: a capture runs the paint under the lock its display thread and timer share, and past ~10 a second the collisions read as stutter on both panels), content-hashed (an identical repaint costs nothing on the wire), capped at
maxPrimitiveBytes= 1536 (truncated at a whole op, and logged). - A frame travels in pieces under the 320-byte payload:
PrimitivesHeaderRecord= viewId, elementId, sequence, final, byte count — sequence 0 starts a frame,finalcommits it. Never draw a frame you only have the front of. - The Electra Link replays the ops inside its own component's paint, where the display's active window supplies the translation — the frame lands wherever its layout put the element. The negotiated element type stays Opaque, so an older Electra Link still draws the named frame.
The op vocabulary is the Lua graphics library, one to one. Each op is an opcode byte followed by its arguments (coordinates i16, colours u24 RGB888):
| Op | # | Arguments |
|---|---|---|
| SetColour | 1 | colour u24 |
| SetBackgroundColour | 2 | colour u24 |
| Pixel | 3 | x, y |
| Line | 4 | x1, y1, x2, y2 |
| Rect / FillRect | 5 / 6 | x, y, w, h |
| RoundRect / FillRoundRect | 7 / 8 | x, y, w, h, radius |
| Triangle / FillTriangle | 9 / 10 | x1, y1, x2, y2, x3, y3 |
| Circle / FillCircle | 11 / 12 | x, y, radius |
| Ellipse / FillEllipse | 13 / 14 | x, y, radiusX, radiusY |
| Curve | 15 | x, y, radius, segment |
| 16 | x, y, width i16; align, face, size, spacing u8; text string |
Print enums: align left/center/right = 0/1/2; face regular/bold = 0/1; size small/medium/large/huge = 0–3; spacing proportional/monospaced = 0/1. Text colour is whatever the last SetColour op left, exactly as on the controller. A replayer that meets an opcode it does not know must stop — the size is unknown too, and misreading the rest is worse than dropping it.
Gesture (0x13): the raw input
A gesture on an Electra Link's custom control travels as itself and the primary replays it into the preset's Lua callbacks with the same ownership rules the controller's own CustomControl applies — a script cannot tell which panel was touched. One fixed GestureRecord for all kinds; fields a kind does not use are zero:
| Kind | # | Fields used | Replayed as |
|---|---|---|---|
| PotTurn | 1 | potId, delta | pot callback, Change, delta as the accelerated change |
| PotTouch | 2 | potId, event (Down=1/Up=3) | pot-touch callback if the script set one — subscribing takes the gesture over — else the pot callback |
| Switch | 3 | potId, event (1 press / 0 release) | switch callback if set; else the plain button rule on the control's value |
| Touch | 4 | event, touchId, x, y, downX, downY | touch callback, coordinates control-relative |
Touch event types are the controller's own gesture system's: Start=1, Move=2, End=3, LongHold=4, Click=5, DoubleClick=6 (swipes are not forwarded). Gestures carry the view id and are discarded stale, like inputs. What does not fire from an Electra Link gesture: the preset's declared control events (the events array) — those are a component behaviour.
On the firmware Electra Link, screen touches are banked from the touch thread and sent from the application pass; knob turns and switches go directly from the surface, which routes any pot in the element's pot mask.
8. The primary's Lua API
The electraLink module drives the second screen from a preset or from electraone lua exec. Every call answers false when it cannot act, so a preset behaves the same whether or not an Electra Link is plugged in.
electraLink.isConnected() -- true while a session is up
electraLink.page(3) -- show page 3 of the bound preset (the link only)
electraLink.preset(2) -- bind the link to live preset slot 2
electraLink.controlSet(2) -- its knobs drive row 2 of that page; 0 = default
electraLink.frameRate(30) -- custom-control frames per second, 1..50
electraLink.status() -- { connected, presetId, pageId, controlSetId, frameRate }Example — a performance split. The primary plays page 1; the second screen holds the modulation page of the same preset:
function preset.onReady()
electraLink.page(4)
endExample — two presets at once. Pin a synth editor in the background (preset pin, or the PIN PRESET button), keep playing the drum preset on the primary, and point the Electra Link at the editor:
electraLink.preset(3) -- slot 3 is pinned and running in the background
electraLink.page(2)Its values stream live (the background preset's timers and MIDI keep running), and the Electra Link's knobs drive it — the primary keeps a watched preset's parameter map enabled for exactly this.
Example — pace an animation. A busy custom control can ask for more frames, a mostly-static page for fewer:
electraLink.frameRate(30) -- smoother animation, ~7 kB/s on the wire;
-- best for a page not on the primary's own screen
electraLink.frameRate(5) -- a VU meter that only breathes9. Writing a preset that plays well on both panels
Nothing special is required: paint callbacks, touch callbacks, pot and switch callbacks all work unchanged, because the Electra Link replays their inputs into the same functions. The rules that matter:
Draw control-relative. You already do — control:getBounds() and fillRect(0, 0, w, h) — and it is what makes the frame land correctly on a panel that put the control somewhere else. (Cross-model replay — a mini page shown on an mk2 or the reverse — currently replays primary-geometry coordinates unscaled; same-model pairs are pixel-exact.)
Say when you changed. control:repaint() is the one trigger the link has. A value that changes repaints a custom control on its own panel, but it tells the link nothing.
local cube = controls.get(1)
function preset.onReady()
cube:setPaintCallback(paintCube)
cube:setTouchCallback(function(ctrl, ev)
-- ev.type, ev.x, ev.y, ev.touchDownX, ev.touchDownY:
-- identical whether the finger was here or on the Electra Link
angle = math.atan(ev.y - 61, ev.x - 87)
ctrl:repaint() -- both screens follow
end)
cube:setPotCallback(function(ctrl, ev)
-- ev.id is the pot, ev.delta the scaled turn - from either panel
speed = speed + ev.delta
end)
cube:setSwitchCallback(function(ctrl, ev)
if ev.type == 1 then latch = not latch end
end)
end
function timer.onTick()
step()
cube:repaint() -- captured, hashed, throttled, sent
endBudget the drawing. A frame is roughly 9 bytes per line/rect op. The rotating cube — clear, twelve lines, a marker — is ~150 bytes, under 4 kB/s at 10 Hz. A plot drawn drawPixel by drawPixel will hit the 1536-byte cap and be truncated (the primary logs it). Prefer lines and fills; they are cheaper on both the wire and the display.
10. Building your own Electra Link (or primary)
The shared sources are deliberately dependency-free and compile anywhere:
| File | What it gives you |
|---|---|
src/Link/LinkRecords.h | every constant, opcode and enum |
src/Link/LinkCodec.{h,cpp} | bounds-checked reader/writer + all records |
src/Link/LinkPrimitives.{h,cpp} | the drawing-op vocabulary and recorder |
src/Link/LinkView.h | a ready-made client-side view model |
src/Link/LinkClient.{h,cpp} | a whole Electra Link client: session, views, overlays, frames, inputs |
src/Link/LinkTransport.h | the one interface you must supply: sendLink(opcode, payload, length) |
A minimal Electra Link on a computer is: open the primary's CTRL port, wrap LinkClient with a transport that base64s the payload into the SysEx envelope, unwrap inbound messages and feed handleMessage(opcode, payload, length), call keepAlive(nowMs) in your loop, and render getView() however you like. ElectraLinkProgram — the very program the hardware Electra Link runs — is in the firmware tree, and is what an Electra Link of any kind puts behind that transport.
Going the other way — being a primary — is what deep integration means: answer an Electra Link's hello with a Welcome, send View/Overlay/Element messages describing whatever you want on its screen, stream Primitives frames for free-form drawing, and read knobs, switches and touches back as Input/Gesture messages. The Electra Link does not know what a "primary" is beyond "the thing that answered my hello"; a DAW bridge qualifies. Respect three things: answer pings, resend views on request, and never exceed the 320-byte payload.
Bench recipes
electraone lua exec 'electraLink.status()'-style probes work on the primary's CTRL — rememberlua execneeds the current preset to have a script loaded, andOKonly means the SysEx arrived.- With the Electra Link in the host port, the CLI reaches it through the primary's router (the standing bridge config routes the Electra Link's Port 1 to the computer): send on one bridged port, receive on another, never the same one, or the primary's own reply masquerades as the Electra Link's.
- The Electra Link image answers
infoand serves screenshots through its own SysexApi — the serial number, not the version string, is what tells the two units apart.
11. Wire reference
All integers little-endian. str = length byte + bytes (≤ 63). colour = u24, RGB888.
HelloRecord — version u8, model u8 (Mk2=1, Mini=2, Host=3, Mk1=4), screenWidth u16, screenHeight u16, colourDepth u8, potCount u8, buttonCount u8, flags u8 (bit 0 = TouchScreen), elementTypes u32 (capability mask, bit n−1 for type n; bit 31 = Opaque), name str.
WelcomeRecord — version u8, sessionId u16, flags u8, name str.
ViewHeaderRecord — viewId u16, kind u8 (PresetPage=1, ControllerScreen=2, MasterPerformance=3), presetId u8, pageNumber u8, activeSet u8 (0 = every element playable), title str, projectId str, pageCount u8, elementCount u16. Followed in the same message by pageCount × PageRecord (id u8, name str).
ElementRecord — id u16, presetId u8, type u8, nativeType u8, nativeVariant u8, nativeMode u8, flags u8 (bit 0 Visible, bit 1 Active), x u16, y u16, width u16, height u16, colour u24, potId u8, name str, valueCount u8. The Element message wraps it: viewId u16 first, then the record, then valueCount × ValueRecord, then potMask u16 (v7, trailing).
ValueRecord — handle u8, overlayId u8, min i16, max i16, current i16, flags u8 (bit 0 Known, bit 1 HasLabel, bit 2 Switch), then label str only when HasLabel is set.
PresetRecord — index u8, count u8, presetId u8, bankNumber u8, slot u8, flags u8 (bit 0 Live, bit 1 Pinned, bit 2 OnScreen, bit 3 Shown), name str, projectId str. Index 0 restarts the Electra Link's copy of the list; act on it only when all count have landed.
BankRecord — index u8, count u8, colour u24, name str.
ContextButtonRecord — index u8, count u8, label str.
OverlayHeaderRecord — id u8, sequence u8, final u8, count u8; followed by count × OverlayItemRecord (value i16, colour u24, colourIsSet u8, label str).
OverlayBitmapRecord — overlayId u8, value i16, length u8 (≤ 128), bytes — the packed 1-bpp source exactly as a preset document carries it.
PrimitivesHeaderRecord — viewId u16, elementId u16, sequence u8, final u8, count u16; count op bytes follow (§7).
SubscriptionUpdateRecord — index u16, presetId u8, controlId u16, name str, ValueRecord.
InputRecord (wire order) — kind u8, flags u8 (bit 0 ViaSubscription), viewId u16, elementId u16, handle u8, a i16, b i16.
GestureRecord — viewId u16, elementId u16, kind u8, event u8, potId u8, touchId u8, x i16, y i16, downX i16, downY i16, delta i16.
RequestRecord — kind u8, argument u8, argument2 u8.
SubscribeHeaderRecord — sequence u8, final u8, count u8; followed by count × SubscriptionEntry (presetId u8, controlId u16, handle u8).
Constants
| Name | Value |
|---|---|
| protocolVersion | 8 |
| maxPayloadLength / maxEncodedLength | 320 / 432 |
| maxStringLength | 63 |
| maxPrimitiveBytes | 1536 |
| maxOverlayBitmapBytes | 128 |
| maxOverlaysPerView / maxSubscriptions | 32 / 128 |
| pingIntervalMs / pingMissesAllowed / livenessTimeoutMs | 2000 / 3 / 8000 |
| custom frame rate | default 10 Hz, settable 1–50 |
12. Version history and pitfalls
Versions. 2: native element fields, replies on the arriving interface. 3: overlays. 4: preset banks. 5: context buttons. 6: per-session overlay cache, overlay item bitmaps. 7: custom-control primitives out, gestures back, settable frame rate, element pot mask. 8: the control set request, the mk1 Electra Link model, the client's own resync of a stalled view.
Pitfalls, each learned the expensive way:
- New opcodes and the object table. The link opcode rides in the SysEx object byte's position. Firmware older than v7 translated that byte through the command object table, which folds unknown values into 0x3F — opcodes 0x01–0x12 only ever worked because the table is contiguous there. Any parser between the wire and your dispatch must pass the byte raw.
viewIdcounts sends, not content. Guard inputs with it; do not use it to decide whether to rebuild.- Order is guaranteed, delivery is not acknowledged. Overlays precede the elements that use them; a frame's pieces are contiguous; there are no ACKs. Anything can be re-requested (
Resync), and streams self-heal. Since v8LinkClientdoes that itself: a view still assembling a second and a half after its header — an element was lost — is asked for again, once per interval, instead of being assembled forever while every update for it is dropped and the screen sits on the old page looking right. - A link message is not a request. The primary's SysEx API used to answer every one with an ACK, which the Electra Link then had to read and throw away — a nine-byte message back for each ping, input and frame. It no longer does. An Electra Link must not expect one.
- An Electra Link that stops reading its port stalls the primary. A host OUT transfer to a device that only NAKs used to be waited for without limit; the host thread parked, the queue behind it filled, and every sender into it — the application thread among them — waited its full bound. The wait is now two hundred milliseconds and the transfer is abandoned. On the Electra Link side, the mk1 reads its port through repaints and file transfers for the same reason; an Electra Link of your own must never leave its port unread for long.
- A watched preset's map must stay enabled. If you are implementing a primary: whatever your equivalent of "the screen left this preset" is, an Electra Link watching it still needs its values dispatched — knobs going dead and values freezing on the Electra Link is the symptom.
- Page 0 is the performance page. Never offer it in a page list.
- A second Electra Link steals the session. One at a time; the last hello wins.
lua exectraps (bench): it needs a loaded script in the current preset, andOKacknowledges receipt, not execution.