Network APIPUBLIC

Network API v1.1 — Settings, Variables and Delivery Modes

This document defines exactly how Network API subscription variables are interpreted and in what order they are applied.

API: beanalyzer.network.v1 Revision: 1.1 Scope: subscription filtering and telemetry delivery Status: IMPLEMENTED / CI TESTED

This document defines exactly how Network API subscription variables are interpreted and in what order they are applied.


1. Processing pipeline

For every published event, the server processes a subscription in this order:

source event
   |
   v
1. stream filter
   |
2. direction filter
   |
3. BEAN / CAN identifier filters
   |
4. requested signal-name filter
   |
5. per-signal delivery policy
      mode
      deadband
      update frequency / min interval
      heartbeat
   |
6. signal batching
   |
7. event/signal field projection
   |
8. output encoding
      JSON
      compact JSON
      binary
   |
   v
client

This order matters.

For example, a signal excluded by signals:[...] never reaches deadband, batching or encoding.


2. Complete subscription-variable reference

VariableTypeDefaultScopeMeaning
typestringrequiredcommandUse "subscribe"
request_idany JSON scalaromittedcommandEchoed in acknowledgement/errors
streamsstring/listall 3 streams if emptyfilterbean, can, signals
directionsstring/listno direction filterfilterUsually RX, TX
signalsstring/listall decoded signalssignal filterExact decoded signal names
beanobjectno BEAN ID filterBEAN filterContext/DID/MID selectors
canobjectno CAN ID filterCAN filterCAN ID selectors
profilestringstandarddeliverystandard or low
low_profileboolfalsedeliveryConvenience alias selecting low
formatstringprofile-dependentencodingjson, compact_json, binary
output_formatstringprofile-dependentencodingAlias of format
modestringprofile-dependentdeliveryDelivery policy
update_hznumberprofile-dependentrateMaximum update frequency
update_frequency_hznumberprofile-dependentrateAlias of update_hz
frequency_hznumberprofile-dependentrateAlias of update_hz
min_interval_msnumberderived / 0rateMinimum time between emitted values
heartbeat_msnumber1000deliveryStable-value resend interval in heartbeat mode
deadbandnumber/object/booldisabledchange filterThreshold and optional offset
deadband_enabledboolabsentchange filterExplicit global enable/disable
deadband_valuenumber0 when neededchange filterThreshold used with boolean enable
deadband_offsetnumber0change filterShifts deadband centre
batch_msnumberprofile-dependentpacket reductionSignal accumulation window
numeric_idsboolprofile-dependentencodingUse deterministic 32-bit signal IDs
event_fieldslist[string]all / profile-dependentprojectionRequested top-level event metadata
signal_fieldslist[string]all / profile-dependentprojectionRequested fields inside signal objects
fieldslist[string]absentprojectionAlias of signal_fields
signal_optionsobjectemptyper-signalPer-signal mode/rate/deadband overrides
ttl_sinteger60UDP onlySubscription lifetime, clamped to 5..3600 s

3. Profile defaults

3.1 Standard

{
  "profile":"standard"
}

Effective defaults:

format          = json
mode            = every_update
update_hz       = unlimited
min_interval_ms = 0
heartbeat_ms    = 1000
batch_ms        = 0
deadband        = disabled
deadband_offset = 0
numeric_ids     = false
event_fields    = all
signal_fields   = all

This is the backwards-compatible API behavior.

3.2 Low

{
  "profile":"low"
}

or:

{
  "low_profile":true
}

Effective defaults:

format          = compact_json
mode            = on_change_heartbeat
update_hz       = 10
min_interval_ms = 100
heartbeat_ms    = 1000
batch_ms        = 100
deadband        = disabled
deadband_offset = 0
numeric_ids     = true
event_fields    = type,stream,sequence,signals
signal_fields   = id,value

Important: low profile does not enable deadband automatically.


4. Precedence rules

The effective configuration is built in layers.

Global layer

built-in defaults
        ↓
profile defaults
        ↓
explicit subscription fields

Example:

{
  "profile":"low",
  "format":"json",
  "update_hz":20,
  "batch_ms":0
}

Although low normally chooses compact JSON at 10 Hz with 100 ms batching, this request becomes:

format    = json
update_hz = 20
batch_ms  = 0

Per-signal layer

For a decoded signal:

effective global settings
        ↓
signal_options.<signal name>

Example:

{
  "profile":"low",
  "streams":["signals"],
  "signals":["rpm","coolant_temp"],
  "signal_options":{
    "rpm":{"update_hz":20,"deadband":25},
    "coolant_temp":{"update_hz":1,"deadband":1}
  }
}

The exact signal name is used as the lookup key.


5. Delivery modes

5.1 every_update

Every source update that survives filters is eligible for transmission.

{
  "mode":"every_update"
}

With no rate limit:

source event -> emit
source event -> emit
source event -> emit

With update_hz or min_interval_ms, updates inside the interval are suppressed.

Example:

{
  "mode":"every_update",
  "update_hz":10
}

means an emitted value can occur at most every 100 ms for that state key.

5.2 on_change

An event is eligible only when its value differs from the last accepted / emitted reference value.

{
  "mode":"on_change"
}

With deadband disabled, normal equality comparison is used.

With a rate limit, a changed sample can still be suppressed by min_interval_ms. In that case the reference is not advanced, so a later sample is still compared against the last emitted reference.

5.3 on_change_heartbeat

Combination of change-triggered delivery and stable-value keepalive.

{
  "mode":"on_change_heartbeat",
  "heartbeat_ms":1000
}

Behavior:

changed value -> eligible immediately
stable value  -> normally suppressed
stable value  -> eligible after heartbeat_ms

The normal minimum interval still applies.

Important: heartbeat is evaluated when new source events arrive. The current implementation does not synthesize a signal sample from nothing. If the source itself stops producing that signal entirely, no independent heartbeat packet is created for it.

5.4 periodic

Ignores change state and emits only when the effective minimum interval has elapsed.

{
  "mode":"periodic",
  "update_hz":2
}

or:

{
  "mode":"periodic",
  "min_interval_ms":500
}

As with heartbeat, periodic delivery is driven by incoming source events. It is not a synthetic timer that recreates values when the source is silent.


6. Update-frequency variables

Three frequency names are accepted:

"update_hz":10
"update_frequency_hz":10
"frequency_hz":10

They describe the same setting.

Conversion:

min_interval_ms = 1000 / update_hz

Examples:

FrequencyEffective interval
50 Hz20 ms
20 Hz50 ms
10 Hz100 ms
5 Hz200 ms
2 Hz500 ms
1 Hz1000 ms

If min_interval_ms is explicitly supplied, it overrides the frequency form for interval calculation.

{
  "update_hz":20,
  "min_interval_ms":200
}

effective behavior:

min_interval_ms = 200
effective maximum rate ≈ 5 Hz

A non-positive frequency disables the frequency-derived interval.


7. Deadband

Deadband is optional and disabled by default.

Shorthand

{
  "deadband":5
}

Object form

{
  "deadband":{
    "enabled":true,
    "value":5,
    "offset":0
  }
}

Boolean control

{
  "deadband_enabled":true,
  "deadband_value":5
}

Disable explicitly:

{
  "deadband_enabled":false
}

or:

{
  "deadband":{"enabled":false}
}

A deadband value of zero behaves like exact change detection.


8. Deadband calculation and offset

For numeric values:

L = last emitted/reference value
N = new value
D = deadband threshold
O = deadband_offset

delta = N - L

significant change when:

abs(delta - O) >= D

Symmetric example

L = 100
D = 5
O = 0

Values whose absolute delta remains below 5 are suppressed.

Offset example

L = 100
D = 5
O = +2

The comparison is centred around a +2 shift relative to the last emitted value.

Approximate no-send window:

97 < N < 107

The exact threshold boundary is emitted because the comparison uses >= D.

Example:

{
  "mode":"on_change",
  "deadband":5,
  "deadband_offset":2
}

The offset can be useful for deliberately asymmetric hysteresis.

For non-numeric values, deadband magnitude is not applied; normal inequality is used.


9. Per-signal options

signal_options applies only to decoded signals stream items.

Example:

{
  "type":"subscribe",
  "streams":["signals"],
  "signals":["rpm","speed","coolant_temp"],
  "profile":"low",
  "signal_options":{
    "rpm":{
      "mode":"on_change_heartbeat",
      "update_hz":20,
      "heartbeat_ms":1000,
      "deadband":25,
      "deadband_offset":5
    },
    "speed":{
      "update_hz":10,
      "deadband":1
    },
    "coolant_temp":{
      "update_hz":1,
      "deadband":1,
      "heartbeat_ms":5000
    }
  }
}

Accepted per-signal override fields:

mode
update_hz
update_frequency_hz
frequency_hz
min_interval_ms
heartbeat_ms
deadband
deadband_enabled
deadband_value
deadband_offset

Format, batching and field projection are subscription-wide rather than per-signal.


10. Batching

batch_ms is implemented for the signals stream.

Example:

{
  "batch_ms":100
}

During the batch window, BEANalyzer stores the latest signal object for each signal name.

Example source sequence:

0 ms    rpm=900
20 ms   speed=25
40 ms   rpm=930
70 ms   coolant_temp=90

batch result:

rpm=930
speed=25
coolant_temp=90

The older rpm=900 sample is replaced inside the pending batch.

Current batching properties:

  • applies to signals only;
  • batch_ms <= 0 disables it;
  • keeps the latest value per signal name;
  • top-level batch metadata follows the latest event added to the pending batch;
  • batches are checked/flushed by the Network API selector loop;
  • the selector loop normally wakes at approximately 50 ms cadence, so actual

emission may occur slightly after the exact requested batch boundary;

  • CAN and BEAN raw event streams are not combined by this signal batcher.

11. Filters

11.1 Stream filter

{
  "streams":["signals"]
}

Allowed:

signals
bean
can

If streams is omitted or empty, all three are selected.

11.2 Direction

{
  "directions":["RX"]
}

The filter is case-normalized to uppercase.

If no direction filter is supplied, both directions are eligible when published.

11.3 Signal names

{
  "signals":["rpm","speed","coolant_temp"]
}

Names are exact string names produced by the active BEAN-DBC.

Use list_signals to discover them.

11.4 BEAN routing fields

Plural:

{
  "bean":{
    "contexts":["0x53"],
    "dids":["0xFE"],
    "mids":["0x24"]
  }
}

Singular aliases:

{
  "bean":{
    "context":"0x53",
    "did":"0xFE",
    "mid":"0x24"
  }
}

All populated BEAN selectors are ANDed.

11.5 CAN IDs

{
  "can":{
    "ids":["0x520","0x5B4"]
  }
}

Singular:

{
  "can":{"id":"0x520"}
}

12. Numeric identifier parsing

Identifier helper parsing accepts:

  • JSON integer;
  • decimal numeric string;
  • 0x-prefixed hexadecimal string;
  • a string containing hexadecimal alphabetic digits.

For clarity, hexadecimal identifiers should use 0x.

Recommended:

{"can":{"ids":["0x520","0x5B4"]}}

13. Numeric signal IDs

Enable:

{
  "numeric_ids":true
}

Signal IDs are deterministic:

unsigned CRC32(UTF-8 signal name)

Example subscription acknowledgement:

{
  "type":"subscribed",
  "subscription":{
    "delivery":{
      "numeric_ids":true,
      "signal_ids":{
        "rpm":123456789,
        "speed":987654321
      }
    }
  }
}

Numbers above are illustrative.

list_signals also exposes signal_id.

A 32-bit CRC collision is theoretically possible. A client requiring collision-proof identity should retain signal names or validate its mapping.

Binary format always forces numeric IDs.


14. Event-field selection

Standard JSON

Example:

{
  "event_fields":["sequence","source","replay"],
  "signal_fields":["name","value"]
}

For standard JSON, type and stream are preserved so an event remains self-describing. The signals payload is also produced for a signals event.

Signal fields

Common fields available from decoded signals include:

name
value
unit
kind
raw
raw_bytes
offset
timestamp
context
did
mid
id              generated when numeric_ids=true

If field projection would otherwise remove both name and id, the implementation restores one identifier so the signal is not anonymous.

Alias

"fields":["name","value"]

is accepted as an alias for:

"signal_fields":["name","value"]

15. Compact JSON

Request:

{
  "format":"compact_json"
}

Aliases accepted:

compact
compactjson
json_compact

Compact top-level keys:

KeyMeaning
ttype
sstream
qsequence
tstimestamp
bbus
ddirection
srcsource
rreplay flag, 0/1
cBEAN context
diBEAN DID
mBEAN MID
idCAN ID
xCAN extended flag, 0/1
lDLC
datadata bytes
vsignal values

When signal projection is only identity + value, v is compacted to pairs:

{
  "t":"e",
  "s":"sig",
  "q":100,
  "v":[
    [123456789,901.5],
    [987654321,25]
  ]
}

When additional signal fields are requested, v contains short-key objects.

Compact signal keys include:

i   id
n   name
v   value
u   unit
k   kind
r   raw
rb  raw_bytes
o   offset
ts  timestamp
c   context
d   did
m   mid

16. Binary mode

Request:

{
  "format":"binary"
}

Alias:

bin

Binary format forces numeric_ids=true.

event_fields and signal_fields do not redefine the fixed binary packet layout. Binary mode uses the protocol-defined compact packet structures documented in [PROTOCOLV11.md](PROTOCOLV11.md).

The JSON control plane remains active for auth, subscribe acknowledgements, status requests and errors.


17. Recommended settings by use case

Use caseProfile/modeSuggested rateBatchDeadbandFormat
PC diagnostic loggerstandard / every_updateunlimited0offJSON
ESP32 dashboardlow / onchangeheartbeat10–20 Hz50–100 msoptionalcompact JSON
Slow temperature displaylow / onchangeheartbeat1–2 Hz100–250 ms1 unit optionalcompact JSON
Nintendo DS dashboardlow / onchangeheartbeat5–10 Hz100–200 msoptionalcompact JSON or binary
High-efficiency MCU telemetrycustomsignal-dependent50–100 msoptionalbinary
Filtered raw CAN toolstandard / every_updatesource rate0N/Abinary
Filtered raw BEAN toolstandard / every_updatesource rate0N/Acompact JSON or binary

These are engineering starting points, not hard protocol requirements.


18. Invalid configuration

Invalid mode/profile/format values produce an API error:

{
  "api":"beanalyzer.network.v1",
  "type":"error",
  "error":"invalid_subscription",
  "detail":"..."
}

The server remains running.


19. Worked example: optimized dashboard

Request:

{
  "type":"subscribe",
  "request_id":100,
  "profile":"low",
  "streams":["signals"],
  "signals":["rpm","speed","coolant_temp"],
  "mode":"on_change_heartbeat",
  "update_hz":10,
  "heartbeat_ms":1000,
  "batch_ms":100,
  "deadband_enabled":false,
  "format":"compact_json",
  "numeric_ids":true,
  "event_fields":["sequence","source","replay"],
  "signal_fields":["id","value"],
  "signal_options":{
    "rpm":{
      "update_hz":20,
      "deadband":25,
      "deadband_offset":5
    },
    "speed":{
      "update_hz":10,
      "deadband":1
    },
    "coolant_temp":{
      "update_hz":1,
      "deadband":1,
      "heartbeat_ms":5000
    }
  }
}

Interpretation:

1. accept only signals stream
2. keep only rpm/speed/coolant_temp
3. start from low-profile defaults
4. global max rate becomes 10 Hz
5. global batch window remains 100 ms
6. global deadband is explicitly disabled
7. rpm override:
      20 Hz
      deadband 25
      offset +5
8. speed override:
      10 Hz
      deadband 1
9. coolant override:
      1 Hz
      deadband 1
      5 s heartbeat
10. batch latest accepted signal samples
11. encode compact JSON
12. identify signals by 32-bit numeric ID

This example demonstrates that rate/deadband decisions occur per signal before the accepted values enter the batch.


20. Accepted aliases and normalization

The implementation normalizes selected user-facing values before validation.

Profile aliases

All of these select the low profile:

low
low_resource
lowresource
optimized
optimised

low_profile:true also selects low when an explicit profile is not supplied.

Format aliases

json:
  json
  full
  full_json
  normal

compact_json:
  compact_json
  compact
  compactjson
  json_compact

binary:
  binary
  bin

Hyphens are normalized to underscores before matching.

Mode aliases

every_update:
  every_update
  all
  every
  always

on_change:
  on_change
  onchange
  change

on_change_heartbeat:
  on_change_heartbeat
  onchange_heartbeat
  change_heartbeat
  heartbeat

periodic:
  periodic
  fixed
  frequency

Hyphens are normalized to underscores before matching.


21. Scope differences: signals vs raw BEAN/CAN

Not every delivery option has the same meaning on every stream.

OptionsignalsCANBEAN
stream/entity filtersyesyesyes
modeyesyesyes
update_hz / min_interval_msyesyesyes
heartbeat_msyesyesyes
numeric deadbandyesnono
signal_optionsyesnono
batch_msyesnono
signal_fieldsyesN/AN/A
event_fieldsyesJSON/compact projectionJSON/compact projection
compact JSONyesyesyes
binaryyesyesyes

For raw CAN, change state is based on the CAN ID's data tuple.

For raw BEAN, change state is based on Context/DID/MID and DATA/raw-frame content.

Numeric deadband is intentionally applied only to decoded signal values.


22. First-sample behavior

The first value seen for a state key is emitted immediately and establishes the reference value/time.

This is true even when a rate limit has been configured.

After that first emission, normal mode/deadband/minimum-interval logic applies.


23. JSON projection details

Full JSON

When event_fields is empty, the complete event is copied.

When event_fields is populated:

  • only requested top-level fields are selected;
  • type is restored if present;
  • stream is restored if present;
  • for signals events, the projected signals array is produced.

Full JSON also adds the canonical:

"api":"beanalyzer.network.v1"

if it is not already present.

Compact JSON

Compact JSON always emits at least:

t = type
s = stream

and emits the compact signal payload v for signal events.

event_fields controls optional metadata such as sequence/source/replay.

If signal_fields is empty or contains only identity/value fields, compact signals use pair form:

[[id_or_name,value], ...]

To retain unit/raw/kind/etc. in compact JSON, request those fields explicitly; the encoder then uses short-key signal objects.

Binary

Binary packet layouts are fixed by the protocol. JSON field-projection lists do not alter binary packet structure.


24. UDP authentication nuance

UDP has no persistent connection object.

A token may be included directly in a UDP command:

{
  "type":"get_status",
  "token":"YOUR_TOKEN"
}

or in a subscribe datagram.

Once an authenticated UDP subscription exists for the source IP/port endpoint, that endpoint is treated as authenticated until the subscription expires.

A standalone UDP auth request can return a successful authentication reply, but it does not by itself create a persistent authenticated UDP session. For persistent UDP use, authenticate as part of subscribe or include the token in individual commands.


25. Effective settings acknowledgement

A client should treat the subscribed response as the authoritative effective configuration.

Example:

{
  "type":"subscribed",
  "subscription":{
    "streams":["signals"],
    "signals":["rpm"],
    "delivery":{
      "profile":"low",
      "format":"compact_json",
      "mode":"on_change_heartbeat",
      "update_hz":10.0,
      "min_interval_ms":100.0,
      "heartbeat_ms":1000.0,
      "deadband":{
        "enabled":false,
        "value":null,
        "offset":0.0
      },
      "batch_ms":100.0,
      "numeric_ids":true,
      "event_fields":["sequence","signals","stream","type"],
      "signal_fields":["id","value"],
      "signal_ids":{
        "rpm":123456789
      }
    }
  }
}

The numeric ID above is illustrative.

Reading the acknowledgement is preferable to reproducing profile-default logic inside every client.