BEANalyzer UltraPro 5 — Network API v1.1 Low-Resource Delivery Profiles
Network API v1.1 keeps the original API fully compatible while adding optional delivery controls for low-power and low-resource clients such as ESP32, ESP8266-class devices, Nintendo DS homebrew, old PCs, VB6 applications, microcontroller gateways and small embedded displays.
Historical / implementation-specific document.
Canonical current documentation:docs/network_api/README.md
Variable/mode reference:docs/network_api/SETTINGS_AND_MODES.md
Wire protocol reference:docs/network_api/PROTOCOL_V1_1.md
Date: 2026-10-03 Branch: feature/network-api-low-resource-profile Base / last known-good branch: feature/aend-ui-theme API identifier: beanalyzer.network.v1 Protocol revision: 1.1 Status: IMPLEMENTED / AUTOMATED REGRESSION TESTED / DEVICE-SIDE VALIDATION PENDING
1. Objective
Network API v1.1 keeps the original API fully compatible while adding optional delivery controls for low-power and low-resource clients such as ESP32, ESP8266-class devices, Nintendo DS homebrew, old PCs, VB6 applications, microcontroller gateways and small embedded displays.
The design principle is:
- keep the JSON control plane simple and human-readable;
- send only the data a client actually needs;
- let each subscriber choose its own rate, filters and output format;
- avoid making Network API part of CAN/BEAN gateway scheduling;
- keep the previous Network API v1 behavior when no new option is requested.
A legacy subscription such as:
{"type":"subscribe","streams":["signals"],"signals":["rpm","speed"]}continues to use full newline-delimited JSON and every_update behavior.
2. Available delivery profiles
2.1 Standard profile
Explicit form:
{
"type":"subscribe",
"profile":"standard",
"streams":["signals"],
"signals":["rpm","speed"]
}Defaults:
format = json
mode = every_update
batch_ms = 0
deadband = disabled
numeric_ids = false
field selection = full eventThis is the backwards-compatible behavior.
2.2 Low profile
{
"type":"subscribe",
"profile":"low",
"streams":["signals"],
"signals":["rpm","speed","coolant_temp"]
}Alias:
{
"type":"subscribe",
"low_profile":true,
"streams":["signals"],
"signals":["rpm","speed","coolant_temp"]
}Current low-profile defaults:
format = compact_json
mode = on_change_heartbeat
update_hz = 10
heartbeat_ms = 1000
batch_ms = 100
deadband = disabled unless requested
numeric_ids = true
signal_fields = id,valueEvery default may be overridden by the subscription.
Example: low profile but 20 Hz and no batching:
{
"type":"subscribe",
"profile":"low",
"streams":["signals"],
"signals":["rpm","speed"],
"update_hz":20,
"batch_ms":0
}3. Delivery modes
3.1 every_update
Send every eligible source update, subject to any configured update-frequency limit.
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm"],
"mode":"every_update"
}Useful for diagnostics and high-detail logging.
3.2 on_change
Send only when the selected value changes.
{
"type":"subscribe",
"streams":["signals"],
"signals":["speed"],
"mode":"on_change"
}Without deadband, equality is exact.
3.3 on_change_heartbeat
Send on change, plus a periodic heartbeat even when the value is stable.
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm","speed"],
"mode":"on_change_heartbeat",
"heartbeat_ms":1000
}This is useful for displays because a client can distinguish “stable value” from “connection alive but no change”.
3.4 periodic
Send at a fixed maximum update period whenever fresh source samples are available.
{
"type":"subscribe",
"streams":["signals"],
"signals":["coolant_temp"],
"mode":"periodic",
"update_hz":2
}Equivalent interval:
{
"type":"subscribe",
"streams":["signals"],
"signals":["coolant_temp"],
"mode":"periodic",
"min_interval_ms":500
}Aliases accepted by the parser include all, every, onchange, heartbeat, fixed and frequency.
4. Update frequency / rate control
Global frequency
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm","speed"],
"update_hz":10
}Aliases:
"update_frequency_hz":10or:
"frequency_hz":10Interval form
"min_interval_ms":100When both a frequency alias and min_interval_ms are supplied, min_interval_ms is authoritative.
Typical examples:
20 Hz -> 50 ms
10 Hz -> 100 ms
5 Hz -> 200 ms
2 Hz -> 500 ms
1 Hz -> 1000 ms5. Optional deadband
Deadband is disabled by default, including in the low profile.
Numeric shorthand
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm"],
"mode":"on_change",
"deadband":10
}If the last accepted RPM was 900, changes inside the configured deadband are suppressed until the threshold is reached.
Explicit object form
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm"],
"mode":"on_change",
"deadband":{
"enabled":true,
"value":10,
"offset":0
}
}Explicitly disabled
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm"],
"deadband":{
"enabled":false
}
}Alternative:
{
"deadband_enabled":false
}6. Deadband offset
deadband_offset shifts the centre of the no-send window.
Definitions:
L = last accepted/transmitted reference value
D = deadband
O = deadband_offsetThe no-send window is centred around:
L + Oand extends approximately:
(L + O - D) ... (L + O + D)The implementation uses:
abs((new_value - L) - O) >= D -> significant changeWith:
L = 100
D = 5
O = 0the deadband is symmetric around 100.
With:
L = 100
D = 5
O = +2the no-send window is shifted upward and is approximately:
97 ... 107This allows asymmetric hysteresis where a noisy signal behaves differently in the increasing and decreasing directions.
Example:
{
"type":"subscribe",
"streams":["signals"],
"signals":["fuel_level_candidate"],
"mode":"on_change_heartbeat",
"deadband":1.5,
"deadband_offset":0.3,
"heartbeat_ms":5000
}7. Per-signal overrides
A single subscription can give each signal a different rate and deadband.
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm","speed","coolant_temp"],
"profile":"low",
"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
}
}
}Per-signal options override the global subscription options for that signal.
Supported per-signal keys include:
mode
update_hz
update_frequency_hz
frequency_hz
min_interval_ms
heartbeat_ms
deadband
deadband_enabled
deadband_value
deadband_offset8. Batching
Batching combines the latest values received during a short interval into one outgoing signal event.
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm","speed","coolant_temp"],
"batch_ms":100
}If the source produces:
t=0 ms rpm=900
t=20 ms speed=25
t=40 ms rpm=920
t=60 ms coolant=90the batch keeps the latest value for each signal and may emit approximately:
{
"type":"event",
"stream":"signals",
"signals":[
{"name":"rpm","value":920},
{"name":"speed","value":25},
{"name":"coolant_temp","value":90}
]
}This reduces packet count and is particularly useful for Wi-Fi power saving.
Disable batching with:
"batch_ms":09. Selecting event fields
Full JSON normally preserves all event metadata. A subscriber may request only specific top-level fields:
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm"],
"event_fields":["sequence","source","replay"],
"signal_fields":["name","value"]
}For standard JSON, type, stream and the signal payload remain available so the event stays self-describing.
Example compact signal-field selection:
{
"signal_fields":["name","value","unit"]
}Raw/diagnostic signal fields may also be requested:
{
"signal_fields":[
"name",
"value",
"unit",
"kind",
"raw",
"raw_bytes",
"offset",
"timestamp",
"context",
"did",
"mid"
]
}10. Existing stream filters
Signals
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm","speed","coolant_temp"]
}Direction
{
"type":"subscribe",
"streams":["bean","can"],
"directions":["RX"]
}BEAN context / DID / MID
{
"type":"subscribe",
"streams":["bean"],
"bean":{
"contexts":["0x53"],
"dids":["0xFE"],
"mids":["0x24"]
}
}Singular aliases are also accepted:
{
"bean":{
"context":"0x53",
"did":"0xFE",
"mid":"0x24"
}
}CAN IDs
{
"type":"subscribe",
"streams":["can"],
"can":{
"ids":["0x5B4","0x520","0x201"]
}
}or:
{
"can":{
"id":"0x5B4"
}
}11. Numeric signal IDs
Enable deterministic numeric IDs:
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm","speed"],
"numeric_ids":true
}IDs are:
unsigned CRC32 of the UTF-8 signal nameThey are deterministic for the same signal name.
The subscribed response includes a session-useful mapping for explicitly requested signals:
{
"type":"subscribed",
"subscription":{
"delivery":{
"numeric_ids":true,
"signal_ids":{
"rpm":123456789,
"speed":987654321
}
}
}
}The actual numbers above are illustrative.
list_signals now also reports signal_id for every known signal.
A CRC32 collision is theoretically possible. Clients that require collision-proof identity may retain the original signal name when using JSON.
12. Compact JSON
Request:
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm","speed"],
"format":"compact_json",
"numeric_ids":true
}Compact events use short keys. Example structure:
{
"t":"e",
"s":"sig",
"q":1234,
"v":[
[123456789,901.2],
[987654321,25]
]
}Key summary:
t type
s stream
q sequence
ts timestamp
b bus
d direction
src source
r replay flag
c BEAN context
di BEAN DID
m BEAN MID
id CAN ID
x CAN extended flag
l DLC
data data bytes
v signal valuesIf additional signal fields are requested, compact signal entries become short-key objects instead of two-element arrays.
Example:
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm"],
"format":"compact_json",
"numeric_ids":true,
"signal_fields":["id","value","unit","raw"]
}Possible event:
{
"t":"e",
"s":"sig",
"q":10,
"v":[
{"i":123456789,"v":901.2,"u":"rpm","r":4614}
]
}13. Binary telemetry
Request:
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm","speed"],
"format":"binary"
}The control plane remains JSON:
client -> auth JSON
client -> subscribe JSON
server -> subscribed JSONAfter the acknowledgement, telemetry for that subscription is binary.
Binary header
Every packet begins with:
offset size field
0 2 magic = ASCII "BN" = 0x42 0x4E
2 1 binary version = 1
3 1 packet type
4 2 payload length, unsigned big-endian
6 N payloadPacket types:
0x01 signals
0x02 CAN
0x03 BEAN
0x7F future/unknown compact fallbackSignal packet payload
u32be sequence
u8 flags
u8 signal count
repeat:
u32be signal ID
u8 value type
... encoded valueSignal flags:
bit 0 = Replay source
bit 1 = TX directionValue types:
0x00 = null
0x01 = bool, followed by u8
0x02 = signed int32 big-endian
0x03 = IEEE-754 float32 big-endian
0x04 = UTF-8 string: u16be length + bytesCAN packet payload
u32be sequence
u8 flags
u32be CAN ID
u8 DLC
u8[] dataCAN flags:
bit 0 = extended ID
bit 1 = Replay source
bit 2 = TX directionBEAN packet payload
u32be sequence
u8 flags
u8 context (0xFF if unknown)
u8 DID (0xFF if unknown)
u8 MID (0xFF if unknown)
u8 data length
u8[] decoded dataBEAN flags:
bit 0 = Replay source
bit 1 = TX directionTCP binary framing
The receiver reads exactly six bytes first, then reads the payload length from bytes 4-5 and reads exactly that many additional bytes.
JSON control messages can still appear on the same TCP connection after binary subscription, for example a get_status response. A binary-aware client should therefore distinguish:
'{' / JSON line -> JSON control message
'B','N' -> binary telemetry frameUDP binary framing
Each UDP datagram contains one complete binary packet. No newline is appended.
14. Combined optimized examples
ESP32 dashboard
{
"type":"subscribe",
"profile":"low",
"streams":["signals"],
"signals":["rpm","speed","coolant_temp","fuel_remaining_percent"],
"mode":"on_change_heartbeat",
"update_hz":10,
"heartbeat_ms":1000,
"batch_ms":100,
"deadband_enabled":false
}ESP32 dashboard with individual rates
{
"type":"subscribe",
"profile":"low",
"streams":["signals"],
"signals":["rpm","speed","coolant_temp"],
"signal_options":{
"rpm":{"update_hz":20,"deadband":20},
"speed":{"update_hz":10,"deadband":1},
"coolant_temp":{"update_hz":1,"deadband":1,"heartbeat_ms":5000}
}
}Nintendo DS minimal profile
{
"type":"subscribe",
"profile":"low",
"streams":["signals"],
"signals":["rpm","speed","coolant_temp"],
"format":"compact_json",
"numeric_ids":true,
"batch_ms":150,
"update_hz":8
}Very small binary client
{
"type":"subscribe",
"streams":["signals"],
"signals":["rpm","speed"],
"mode":"on_change_heartbeat",
"update_hz":10,
"heartbeat_ms":1000,
"batch_ms":100,
"format":"binary"
}Filtered CAN monitor
{
"type":"subscribe",
"streams":["can"],
"directions":["RX"],
"can":{"ids":["0x520","0x5A0","0x5A1","0x5A2","0x5A3"]},
"mode":"every_update",
"format":"binary"
}Filtered BEAN monitor
{
"type":"subscribe",
"streams":["bean"],
"directions":["RX"],
"bean":{
"contexts":["0x53"],
"dids":["0xFE"],
"mids":["0x24"]
},
"format":"compact_json"
}Diagnostic full-fidelity JSON
{
"type":"subscribe",
"profile":"standard",
"streams":["bean","can","signals"],
"mode":"every_update",
"format":"json",
"batch_ms":0
}15. Example Python compact-JSON client
import json
import socket
HOST = "192.168.1.100"
PORT = 35000
TOKEN = "YOUR_TOKEN"
sock = socket.create_connection((HOST, PORT))
file = sock.makefile("r", encoding="utf-8")
print(json.loads(file.readline())) # hello
sock.sendall(
(json.dumps({"type":"auth","token":TOKEN}) + "\n").encode()
)
print(json.loads(file.readline()))
subscribe = {
"type": "subscribe",
"profile": "low",
"streams": ["signals"],
"signals": ["rpm", "speed", "coolant_temp"],
}
sock.sendall((json.dumps(subscribe) + "\n").encode())
print(json.loads(file.readline()))
while True:
event = json.loads(file.readline())
if event.get("s") == "sig":
for signal_id, value in event.get("v", []):
print(signal_id, value)16. Example Python binary decoder
import json
import socket
import struct
def recv_exact(sock, count):
data = bytearray()
while len(data) < count:
chunk = sock.recv(count - len(data))
if not chunk:
raise ConnectionError("closed")
data += chunk
return bytes(data)
def recv_binary(sock):
header = recv_exact(sock, 6)
magic, version, packet_type, size = struct.unpack(">2sBBH", header)
if magic != b"BN":
raise ValueError("not a BN packet")
payload = recv_exact(sock, size)
return version, packet_type, payload
# For a dedicated telemetry-only loop after the JSON subscribed ACK:
version, packet_type, payload = recv_binary(sock)
if packet_type == 1:
sequence, flags, count = struct.unpack(">IBB", payload[:6])
pos = 6
for _ in range(count):
signal_id = struct.unpack(">I", payload[pos:pos+4])[0]
pos += 4
value_type = payload[pos]
pos += 1
if value_type == 2:
value = struct.unpack(">i", payload[pos:pos+4])[0]
pos += 4
elif value_type == 3:
value = struct.unpack(">f", payload[pos:pos+4])[0]
pos += 4
# Handle other value types as documented above.
print(sequence, signal_id, value)17. Example ESP32 / Arduino-style subscription
The Network API protocol is independent from a specific Arduino networking library. Conceptually:
client.connect(beanalyzerIp, 35000);
client.print(
"{\"type\":\"auth\",\"token\":\"YOUR_TOKEN\"}\n"
);
client.print(
"{\"type\":\"subscribe\","
"\"profile\":\"low\","
"\"streams\":[\"signals\"],"
"\"signals\":[\"rpm\",\"speed\",\"coolant_temp\"],"
"\"update_hz\":10,"
"\"batch_ms\":100"
"}\n"
);For compact JSON, each incoming line can be parsed with a small JSON document. For binary, read the fixed six-byte header and then exactly payload_len bytes.
18. TCP and UDP
Both transports support the same subscription options.
TCP:
- persistent connection;
- ordered delivery;
- easiest choice for dashboards and control;
- binary uses length-prefixed BN frames.
UDP:
- one command/event per datagram;
- lower protocol overhead;
- subscriptions expire unless refreshed;
- default TTL is 60 seconds;
ttl_smay be specified up to the server maximum;- binary uses one complete BN packet per datagram.
Example UDP subscription:
{
"type":"subscribe",
"token":"YOUR_TOKEN",
"streams":["signals"],
"signals":["rpm","speed"],
"profile":"low",
"ttl_s":60
}19. Error handling
Invalid profile/mode/format configuration returns:
{
"api":"beanalyzer.network.v1",
"type":"error",
"error":"invalid_subscription",
"detail":"..."
}A malformed subscription no longer needs to terminate the Network API server.
The existing per-endpoint command-rate limit remains in place.
20. Compatibility
No new option is mandatory.
Existing clients using:
TCP newline-delimited JSON
UDP one JSON object per datagramcontinue to work.
API_NAME intentionally remains:
beanalyzer.network.v1because this extension is backwards compatible. hello.capabilities.api_revision reports:
1.1Clients should inspect hello.capabilities before assuming low-resource or binary support when connecting to an older BEANalyzer release.
21. Tests and evidence
Automated GitHub Actions validation on this branch currently covers:
- Python syntax for
network_api.py; - Python syntax for
network_api_telemetry.py; - AST syntax validation of the main application;
- original Network API compatibility tests;
- stream filtering;
- TCP and UDP behavior;
- token-related regressions;
- Replay Network API regressions;
- low-profile defaults;
- optional deadband;
- deadband offset;
- on-change heartbeat;
- update-frequency limits;
- per-signal overrides;
- batching;
- event/signal field selection;
- deterministic numeric IDs;
- compact JSON;
- binary framing;
- invalid-subscription fail-safe behavior;
- TCP compact JSON streaming;
- TCP binary streaming.