pyvisionect 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. pyvisionect/__init__.py +120 -0
  2. pyvisionect/devices/__init__.py +92 -0
  3. pyvisionect/devices/enums.py +403 -0
  4. pyvisionect/devices/panels.py +242 -0
  5. pyvisionect/devices/tclv.py +460 -0
  6. pyvisionect/imaging/README.md +175 -0
  7. pyvisionect/imaging/__init__.py +181 -0
  8. pyvisionect/imaging/checksum.py +114 -0
  9. pyvisionect/imaging/constants.py +131 -0
  10. pyvisionect/imaging/data/blue_noise_64.npy +0 -0
  11. pyvisionect/imaging/decode.py +172 -0
  12. pyvisionect/imaging/dither.py +357 -0
  13. pyvisionect/imaging/encoder.py +594 -0
  14. pyvisionect/imaging/geometry.py +129 -0
  15. pyvisionect/imaging/grey.py +104 -0
  16. pyvisionect/imaging/interlace.py +244 -0
  17. pyvisionect/imaging/pack.py +142 -0
  18. pyvisionect/imaging/panel.py +339 -0
  19. pyvisionect/imaging/partial.py +931 -0
  20. pyvisionect/imaging/rects.py +466 -0
  21. pyvisionect/io/__init__.py +33 -0
  22. pyvisionect/io/tcp.py +795 -0
  23. pyvisionect/io/usb/__init__.py +237 -0
  24. pyvisionect/io/usb/cli.py +278 -0
  25. pyvisionect/io/usb/commands.py +781 -0
  26. pyvisionect/io/usb/console.py +730 -0
  27. pyvisionect/io/usb/device.py +914 -0
  28. pyvisionect/io/usb/discovery.py +260 -0
  29. pyvisionect/io/usb/encryption.py +262 -0
  30. pyvisionect/io/usb/errors.py +175 -0
  31. pyvisionect/io/usb/fake.py +292 -0
  32. pyvisionect/io/usb/parsers.py +1464 -0
  33. pyvisionect/io/usb/provisioning.py +502 -0
  34. pyvisionect/packets/__init__.py +135 -0
  35. pyvisionect/packets/control.py +95 -0
  36. pyvisionect/packets/file.py +325 -0
  37. pyvisionect/packets/image.py +234 -0
  38. pyvisionect/packets/misc.py +202 -0
  39. pyvisionect/packets/param.py +284 -0
  40. pyvisionect/packets/status.py +518 -0
  41. pyvisionect/packets/stored.py +217 -0
  42. pyvisionect/py.typed +0 -0
  43. pyvisionect/session/__init__.py +100 -0
  44. pyvisionect/session/connection.py +1043 -0
  45. pyvisionect/session/device.py +587 -0
  46. pyvisionect/session/events.py +196 -0
  47. pyvisionect/session/filetransfer.py +251 -0
  48. pyvisionect/session/pending.py +425 -0
  49. pyvisionect/wire/__init__.py +91 -0
  50. pyvisionect/wire/blocks.py +350 -0
  51. pyvisionect/wire/checksum.py +115 -0
  52. pyvisionect/wire/errors.py +176 -0
  53. pyvisionect/wire/framing.py +334 -0
  54. pyvisionect-0.1.0.dist-info/METADATA +1030 -0
  55. pyvisionect-0.1.0.dist-info/RECORD +58 -0
  56. pyvisionect-0.1.0.dist-info/WHEEL +4 -0
  57. pyvisionect-0.1.0.dist-info/entry_points.txt +3 -0
  58. pyvisionect-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,120 @@
1
+ """pyvisionect -- a sans-io reimplementation of the Visionect sign wire protocol.
2
+
3
+ **You are the server.** A Visionect sign is a TCP *client*: it dials out to port
4
+ 11113 and speaks first. There is no handshake, no auth and no negotiation -- the
5
+ 16-byte UUID in the packet header is the entire identity claim, and registration
6
+ is auto-create on first connect. So this library replaces the vendor's server:
7
+ it listens, accepts whatever connects, and drives the sign directly. No VSS, no
8
+ licence server, no cloud.
9
+
10
+ Layering (each layer pure except the last)::
11
+
12
+ io/ asyncio TCP listener; pyserial USB provisioning <- only I/O
13
+ session/ DeviceConnection: bytes in -> Events out
14
+ packets/ per-type payload codecs
15
+ wire/ framing, LZ4 block chain, direction-dependent CRC
16
+
17
+ imaging/ PIL/numpy -> dithered, bit-packed rectangles (separate module)
18
+ devices/ capability tables: TCLV, status enums, panel geometry (data)
19
+
20
+ Quick start::
21
+
22
+ import asyncio
23
+ from pyvisionect.io import VisionectServer
24
+ from pyvisionect.session import DeviceConnected, StatusReceived
25
+
26
+ async def on_events(conn, events):
27
+ for e in events:
28
+ if isinstance(e, DeviceConnected):
29
+ print("sign online:", e.uuid, conn.state.panel.describe())
30
+ conn.apply_pending() # drain whatever was queued while it slept
31
+ elif isinstance(e, StatusReceived):
32
+ print("battery", e.status.fields().get("BatteryLevel"))
33
+
34
+ asyncio.run(VisionectServer(on_events=on_events).serve_forever())
35
+
36
+ The sign must be *pointed* at your listener first, either over USB
37
+ (:mod:`pyvisionect.io.usb`) or by re-pointing the DNS name it
38
+ already holds in flash. The server address is read-only over the network; see
39
+ :mod:`pyvisionect.devices.tclv`.
40
+
41
+ A sign is **absent most of the time**, so ``server.connection_for(uuid)``
42
+ returning ``None`` is the normal case. Queue work on
43
+ ``store.queue(uuid)`` -- a durable, coalescing
44
+ :class:`~pyvisionect.session.pending.PendingWork` register -- and let
45
+ :meth:`~pyvisionect.session.DeviceConnection.apply_pending` drain it, in the
46
+ right order, the next time the sign appears.
47
+ """
48
+
49
+ from __future__ import annotations
50
+
51
+ __version__ = "0.1.0"
52
+
53
+ from .devices import TCLV, Panel, panel_for
54
+ from .packets import (
55
+ ControlPacket,
56
+ ImagePacket,
57
+ ParamItem,
58
+ ParamPacket,
59
+ Rectangle,
60
+ StatusPacket,
61
+ )
62
+ from .session import (
63
+ PENDING_ORDER,
64
+ FileRead,
65
+ SyncStatus,
66
+ ConnectionConfig,
67
+ DeviceConnected,
68
+ DeviceConnection,
69
+ DeviceState,
70
+ DeviceStateStore,
71
+ Event,
72
+ PendingWork,
73
+ StatusReceived,
74
+ )
75
+ from .wire import (
76
+ STORED_ONLY,
77
+ DataHeader,
78
+ Direction,
79
+ Frame,
80
+ FrameDecoder,
81
+ ListenError,
82
+ ProtocolHeader,
83
+ ReadOnlyParameter,
84
+ VisionectError,
85
+ encode_frame,
86
+ )
87
+
88
+ __all__ = [
89
+ "ConnectionConfig",
90
+ "ControlPacket",
91
+ "DataHeader",
92
+ "DeviceConnected",
93
+ "DeviceConnection",
94
+ "DeviceState",
95
+ "DeviceStateStore",
96
+ "Direction",
97
+ "Event",
98
+ "FileRead",
99
+ "Frame",
100
+ "FrameDecoder",
101
+ "ImagePacket",
102
+ "ListenError",
103
+ "PENDING_ORDER",
104
+ "Panel",
105
+ "ParamItem",
106
+ "ParamPacket",
107
+ "PendingWork",
108
+ "ProtocolHeader",
109
+ "ReadOnlyParameter",
110
+ "STORED_ONLY",
111
+ "Rectangle",
112
+ "StatusPacket",
113
+ "StatusReceived",
114
+ "SyncStatus",
115
+ "TCLV",
116
+ "VisionectError",
117
+ "__version__",
118
+ "encode_frame",
119
+ "panel_for",
120
+ ]
@@ -0,0 +1,92 @@
1
+ """Capability tables: TCLV parameters, status enums, panel geometry.
2
+
3
+ Leaf package. Depends on nothing in :mod:`pyvisionect.wire` or
4
+ :mod:`pyvisionect.session` (except :mod:`pyvisionect.wire.errors`, for the
5
+ read-only-parameter error).
6
+ """
7
+
8
+ from .enums import (
9
+ CHARGING_STATUS,
10
+ CONNECT_REASON,
11
+ CONNECTIVITY_USED,
12
+ DCM_STATE,
13
+ ERROR_CODE,
14
+ HARDWARE_FAMILY,
15
+ JS_APP_TYPE,
16
+ PV2_FEATURE_BITS,
17
+ QSPI_FLASH_ID,
18
+ RENDERER,
19
+ SCPU_SENSOR_BITS,
20
+ TOUCH_TYPE,
21
+ CommandType,
22
+ ControlFlags,
23
+ EncodingType,
24
+ FileMode,
25
+ FileOperation,
26
+ ImageType,
27
+ PacketType,
28
+ ParamControl,
29
+ describe,
30
+ )
31
+ from .panels import (
32
+ DEFAULT_PANEL,
33
+ DISPLAY_TYPE_DRIVER,
34
+ DISPLAY_TYPE_NAMES,
35
+ DRIVERS,
36
+ PANELS,
37
+ Driver,
38
+ Panel,
39
+ display_type_name,
40
+ driver_for,
41
+ panel_for,
42
+ )
43
+ from .tclv import (
44
+ NETWORK_READ_ONLY,
45
+ TCLV,
46
+ USB_HINTS,
47
+ TclvEntry,
48
+ check_writable,
49
+ lookup,
50
+ name_of,
51
+ )
52
+
53
+ __all__ = [
54
+ "CHARGING_STATUS",
55
+ "CONNECTIVITY_USED",
56
+ "CONNECT_REASON",
57
+ "CommandType",
58
+ "ControlFlags",
59
+ "DCM_STATE",
60
+ "DEFAULT_PANEL",
61
+ "DISPLAY_TYPE_DRIVER",
62
+ "DISPLAY_TYPE_NAMES",
63
+ "DRIVERS",
64
+ "Driver",
65
+ "ERROR_CODE",
66
+ "EncodingType",
67
+ "FileMode",
68
+ "FileOperation",
69
+ "HARDWARE_FAMILY",
70
+ "ImageType",
71
+ "JS_APP_TYPE",
72
+ "NETWORK_READ_ONLY",
73
+ "PANELS",
74
+ "PV2_FEATURE_BITS",
75
+ "PacketType",
76
+ "Panel",
77
+ "ParamControl",
78
+ "QSPI_FLASH_ID",
79
+ "RENDERER",
80
+ "SCPU_SENSOR_BITS",
81
+ "TCLV",
82
+ "TOUCH_TYPE",
83
+ "TclvEntry",
84
+ "USB_HINTS",
85
+ "check_writable",
86
+ "describe",
87
+ "display_type_name",
88
+ "driver_for",
89
+ "lookup",
90
+ "name_of",
91
+ "panel_for",
92
+ ]
@@ -0,0 +1,403 @@
1
+ """Status-field enumerations, as data.
2
+
3
+ Every table here was read out of ``bin/gateway`` -- jump tables and compare
4
+ chains in the corresponding ``(*T).String`` methods. The Go *identifier* names
5
+ are not in the binary (constants carry no metadata), only the display strings,
6
+ so the strings below are verbatim and the Python names are ours.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ __all__ = [
12
+ "CONNECT_REASON",
13
+ "ERROR_CODE",
14
+ "CONNECTIVITY_USED",
15
+ "CHARGING_STATUS",
16
+ "TOUCH_TYPE",
17
+ "DCM_STATE",
18
+ "JS_APP_TYPE",
19
+ "HARDWARE_FAMILY",
20
+ "QSPI_FLASH_ID",
21
+ "RENDERER",
22
+ "PV2_FEATURE_BITS",
23
+ "SCPU_SENSOR_BITS",
24
+ "CommandType",
25
+ "FileOperation",
26
+ "FileMode",
27
+ "EncodingType",
28
+ "ImageType",
29
+ "ParamControl",
30
+ "ControlFlags",
31
+ "PacketType",
32
+ "describe",
33
+ ]
34
+
35
+
36
+ def describe(table: dict[int, str], value: int, fallback: str = "n/a") -> str:
37
+ """Look *value* up in *table*, mirroring the vendor's ``String()`` fallback."""
38
+ return table.get(value, fallback)
39
+
40
+
41
+ # ---------------------------------------------------------------- packet types
42
+
43
+ class PacketType:
44
+ """``packet.Type``.
45
+
46
+ Recovered two independent ways that agree: ``packet.Type.String``'s jump
47
+ table (12 entries, indexed by ``value - 1``) and ``packet.packetTypesFunc``
48
+ (a 13-entry array of constructor closures).
49
+
50
+ ``INPUT`` (4) and ``BOOTLOADER`` (0xFFFFFFFF) are genuine historical types
51
+ that survive in the v1 enum, but **this server build can neither construct
52
+ nor dispatch them**: ``packet.New`` rejects ``Type >= 13``,
53
+ ``packetTypesFunc[4]`` is nil, and the bootloader protocol moved out to its
54
+ own mux versions 0xF0000001 / 0xF0000002.
55
+ """
56
+
57
+ CONTROL = 1
58
+ COMMAND = 2
59
+ STATUS = 3
60
+ INPUT = 4 # hole in both v2 tables
61
+ IMAGE = 5
62
+ TOUCH = 6
63
+ GPS = 7
64
+ PARAM = 8
65
+ FILE = 10
66
+ BUTTON = 11
67
+ CBOR = 12
68
+ BOOTLOADER = 0xFFFFFFFF
69
+
70
+ NAMES: dict[int, str] = {
71
+ 1: "control",
72
+ 2: "command",
73
+ 3: "status",
74
+ 4: "input",
75
+ 5: "image",
76
+ 6: "touch",
77
+ 7: "GPS",
78
+ 8: "param",
79
+ 10: "file",
80
+ 11: "button",
81
+ 12: "CBOR",
82
+ 0xFFFFFFFF: "bootloader",
83
+ }
84
+
85
+ DEVICE_TO_SERVER = frozenset({1, 3, 6, 7, 8, 10, 11, 12})
86
+ """Types the gateway has a handler for (plus 1, handled inline)."""
87
+
88
+ SERVER_TO_DEVICE = frozenset({1, 2, 5, 8, 10})
89
+ """Types the server originates. 2 and 5 are server-only."""
90
+
91
+ @classmethod
92
+ def name(cls, value: int) -> str:
93
+ return cls.NAMES.get(value, f"unknown({value})")
94
+
95
+
96
+ class ControlFlags:
97
+ """``packet.ControlFlags`` -- the bits the gateway actually tests."""
98
+
99
+ ACK = 0x00000001
100
+ """``packet.(*Control).Ack`` is literally ``return flags & 1``."""
101
+
102
+ NACK_CHARGING = 0x02000000
103
+ """Bit 25. ``pv3.go:498`` ``BTL $0x19, flags`` -> ``vio.ErrNackCharging``."""
104
+
105
+ NACK = 0x00000000
106
+ """``flags == 0`` -> ``vio.ErrNack`` (``pv3.go:500``)."""
107
+
108
+
109
+ class ParamControl:
110
+ """``packet.ParamControl`` (uint8), ``param.go:114-124``."""
111
+
112
+ READ = 0
113
+ WRITE = 1
114
+ READ_ERROR = 2
115
+ WRITE_ERROR = 3
116
+
117
+ NAMES: dict[int, str] = {0: "read", 1: "write", 2: "read error", 3: "write error"}
118
+
119
+
120
+ class CommandType:
121
+ """``packet.CommandType`` (int32 -- the negative values are real).
122
+
123
+ ``packet.CommandType.String``, ``packet/command.go:47-95``, and the
124
+ identical v1 ``proto.CommandID.String``, ``proto/command.go:43-92``.
125
+
126
+ .. note::
127
+ ``0`` is **echo** and ``1`` is **reboot**, both in v1 and in v2. An
128
+ earlier revision of this module had the two swapped, from a misread of
129
+ the v2 ``String`` chain; re-reading both jump chains byte by byte (they
130
+ reference the *same* two rodata strings, in the same order) and
131
+ disassembling the vendor's only reboot emitter --
132
+ ``networkmanager main.(*Panda).Reboot``, which writes
133
+ ``movabs $0x400000001`` into the command struct, i.e. ``Command = 1``
134
+ with a 4-byte payload -- settles it. The mistake mattered: with the old
135
+ values, :meth:`~pyvisionect.session.DeviceConnection.reboot` would have
136
+ sent ``echo`` and an "echo" would have rebooted the sign.
137
+ """
138
+
139
+ ECHO = 0
140
+ REBOOT = 1
141
+ CONFIGURATION = 2
142
+ AT_COMMAND = 3
143
+ SLEEP = 4
144
+ LOGS = 5
145
+ SET_VCOM = 6
146
+ SET_HEARTBEAT = 7
147
+ SET_NETWORK_RETRIES = 8
148
+ LED_WINDOW = 9
149
+ LDRLED = 10
150
+ STATUS_REQUEST = 11
151
+ SYSTEM = 12
152
+ BATTERY = 13
153
+ TOUCH_UPDATE = 14
154
+ SET_GPS = 16
155
+ FRONT_LIGHT = 17
156
+ SYNC_DISPLAY = 18
157
+ FRONT_LIGHT_EXTENSION = 22
158
+ REFRESH = -1
159
+ CLEAR_SCREEN = -2
160
+ KEYBOARD = -3
161
+ BEEP = -4
162
+
163
+ DISPLAY_ID = 15
164
+ """Not in either ``String`` chain (both print ``unknown`` for 15), but the
165
+ engine really does emit it: ``stdcmd.DisplayID.Done`` writes ``15`` with a
166
+ uint32 panel-type id in 1..10. Do not send this; the wrong value selects
167
+ the wrong waveform."""
168
+
169
+ NAMES: dict[int, str] = {
170
+ 0: "echo",
171
+ 1: "reboot",
172
+ 2: "configuration",
173
+ 3: "AT command",
174
+ 4: "sleep",
175
+ 5: "logs",
176
+ 6: "set Vcom",
177
+ 7: "set heartbeat",
178
+ 8: "set network retries",
179
+ 9: "LED window",
180
+ 10: "LDRLED",
181
+ 11: "status request",
182
+ 12: "system",
183
+ 13: "battery",
184
+ 14: "touch update",
185
+ 16: "set gps",
186
+ 17: "front light",
187
+ 18: "sync display",
188
+ 22: "front light extension",
189
+ -1: "refresh",
190
+ -2: "clear screen",
191
+ -3: "keyboard",
192
+ -4: "beep",
193
+ }
194
+
195
+
196
+ class FileOperation:
197
+ """``packet.FileOperation`` (uint32), ``file.go:98-114``."""
198
+
199
+ OPEN = 0
200
+ CLOSE = 1
201
+ READ = 2
202
+ WRITE = 3
203
+ ERASE = 4
204
+ WRITE_DESCRIPTOR = 5
205
+ EVENT = 6
206
+
207
+ NAMES: dict[int, str] = {
208
+ 0: "open",
209
+ 1: "close",
210
+ 2: "read",
211
+ 3: "write",
212
+ 4: "erase",
213
+ 5: "write descriptor",
214
+ 6: "event",
215
+ }
216
+
217
+
218
+ class FileMode:
219
+ """``packet.FileMode`` (uint32), ``file.go:127-134``."""
220
+
221
+ NONE = 0
222
+ WRITE = 1
223
+ READ = 2
224
+
225
+ NAMES: dict[int, str] = {0: "none", 1: "write", 2: "read"}
226
+
227
+
228
+ class EncodingType:
229
+ """``packet.EncodingType`` (uint16), ``image.go:197-204``.
230
+
231
+ Only 1 and 4 exist. 16 greys are the uniform ramp ``n * 17``.
232
+ """
233
+
234
+ UNDEFINED = 0
235
+ ONE_BIT = 1
236
+ FOUR_BIT = 4
237
+
238
+ NAMES: dict[int, str] = {0: "undefined", 1: "1 bit", 4: "4 bit"}
239
+
240
+ ALIGNMENT: dict[int, int] = {1: 16, 4: 4}
241
+ """Horizontal alignment quantum in pixels, per encoding."""
242
+
243
+
244
+ class ImageType:
245
+ """``packet.ImageType`` (uint16), ``image.go:217-224``."""
246
+
247
+ UNKNOWN = 0
248
+ GRAY = 1
249
+
250
+ NAMES: dict[int, str] = {0: "unknown", 1: "gray"}
251
+
252
+
253
+ # ------------------------------------------------------------- status enums
254
+
255
+ CONNECT_REASON: dict[int, str] = {
256
+ 0: "unknown",
257
+ 1: "reboot",
258
+ 2: "wakeup",
259
+ 3: "heartbeat",
260
+ 4: "logs full",
261
+ 5: "connection error",
262
+ 6: "protocol error",
263
+ 7: "command line",
264
+ 8: "by server request",
265
+ 9: "display driver failed",
266
+ 10: "connection driver error",
267
+ 11: "server changes",
268
+ }
269
+ """Status tag 0. ``status.(*ConnectReason).String.jump5`` @ ``0x1adb940``.
270
+
271
+ Note: the captured first-packet-after-connect carries 5, steady-state heartbeats
272
+ carry 3. **[live]** ``2`` is what follows an ``app_wakeup`` out of deep sleep,
273
+ and ``8`` is what the device sends in answer to a ``status request`` command
274
+ (``CommandType 11``) -- both confirmed on hardware 2026-10-05.
275
+ """
276
+
277
+ ERROR_CODE: dict[int, str] = {
278
+ 0: "no error",
279
+ 1: "none",
280
+ 2: "command pending",
281
+ 3: "image received",
282
+ 4: "wakeup",
283
+ 5: "connectivity error",
284
+ 6: "pv2 error",
285
+ 7: "heartbeat",
286
+ 8: "connectivity changed",
287
+ 9: "image transfer pending",
288
+ 10: "touch pending",
289
+ 11: "gps pending",
290
+ 12: "status send",
291
+ 13: "deep sleep request",
292
+ 14: "connectivity start",
293
+ 15: "internal image update",
294
+ 16: "gps control",
295
+ 17: "connectivity driver error",
296
+ 18: "button pending",
297
+ 19: "reboot",
298
+ 20: "local image",
299
+ 21: "proximity",
300
+ 22: "status acked",
301
+ 23: "file transfer pending",
302
+ 24: "file transfer done",
303
+ 25: "server change",
304
+ }
305
+ """Status tag 1. ``(*ErrorCode).String.jump5`` @ ``0x1aea4c0``, 26 entries.
306
+
307
+ **This is the reason the packet was sent, not a fault.** 13 ("deep sleep
308
+ request") is the device asking to sleep, not an error condition.
309
+ """
310
+
311
+ CONNECTIVITY_USED: dict[int, str] = {
312
+ 0: "not selected",
313
+ 1: "redpine rs9110",
314
+ 2: "simcom sim5320",
315
+ 3: "wiznet w5500",
316
+ 4: "redpine rs9113",
317
+ 5: "atmel winc1500",
318
+ 6: "ti CC3100",
319
+ 7: "stm 32F7ETH",
320
+ 8: "simcom SIM7500",
321
+ 9: "redpine RS9116",
322
+ 10: "ti CC3135",
323
+ }
324
+ """Status tag 6. The live 32" sign reports 6."""
325
+
326
+ CHARGING_STATUS: dict[int, str] = {
327
+ 0: "pre charge",
328
+ 1: "fast charge",
329
+ 2: "done",
330
+ 3: "disabled",
331
+ }
332
+ """Status tag 11."""
333
+
334
+ TOUCH_TYPE: dict[int, str] = {0: "none", 1: "CB060E", 2: "EKTF2227"}
335
+ """Status tag 29."""
336
+
337
+ DCM_STATE: dict[int, str] = {0: "off", 1: "on"}
338
+ """Status tag 88."""
339
+
340
+ JS_APP_TYPE: dict[int, str] = {0: "none", 1: "TC", 2: "AC"}
341
+ """Status tag 86."""
342
+
343
+ HARDWARE_FAMILY: dict[int, str] = {
344
+ 1: "V-Tablet",
345
+ 3: "DS",
346
+ 4: "Quad",
347
+ 5: "V-Tablet 2",
348
+ }
349
+ """The ``Family`` byte inside status tag 2 (``HardwareID``).
350
+
351
+ 0, 2 and >= 6 render ``n/a``; value 2 genuinely has no case in the binary.
352
+ """
353
+
354
+ QSPI_FLASH_ID: dict[int, str] = {
355
+ 0x9D7020: "IS25WP512MG",
356
+ 0x9D701A: "IS25WP512M",
357
+ 0x9D7019: "IS25WP256D",
358
+ }
359
+ """Status tag 103: raw JEDEC RDID words (0x9D = ISSI)."""
360
+
361
+ RENDERER: dict[int, str] = {
362
+ 0: "unknown",
363
+ 1: "HTTP",
364
+ 2: "HTML",
365
+ 3: "ACRender2",
366
+ 4: "PNG",
367
+ }
368
+ """Server-side only (cbor key 5000000004); never on the wire."""
369
+
370
+ PV2_FEATURE_BITS: tuple[str, ...] = (
371
+ "RemoteBootloaderUpgrade", # bit 0 0x001
372
+ "TouchDisabled", # bit 1 0x002
373
+ "WPA2EnterpriseDisabled", # bit 2 0x004
374
+ "FileSystem", # bit 3 0x008
375
+ "DisplayScan42", # bit 4 0x010
376
+ "NoFading", # bit 5 0x020
377
+ "FastBoot", # bit 6 0x040
378
+ "JSPatchUpdate", # bit 7 0x080
379
+ "DoubleBuffer", # bit 8 0x100
380
+ "WiFiOTA", # bit 9 0x200
381
+ )
382
+ """Status tag 43, a **10**-bit mask.
383
+
384
+ ``status.(*Features).UnmarshalUint32`` is literally ten ``BTL $i, BX`` pairs, and
385
+ the struct field order equals the cbor keyasint order, so bit *i* is field *i*.
386
+
387
+ The vendor's *legacy* parser ``proto.ParsePV2Features1`` loops
388
+ ``for mask := 1; mask <= 0x100; mask <<= 1`` and therefore silently drops bit 9
389
+ (``WiFiOTA``, 512). ``admin`` and ``engine`` use that parser and see the live
390
+ sign's ``585`` as if it were ``73``. **We do not replicate that bug.**
391
+ """
392
+
393
+ SCPU_SENSOR_BITS: tuple[str, ...] = (
394
+ "SCPUTemperature",
395
+ "ExternalTemperature",
396
+ "Humidity",
397
+ "Pressure",
398
+ "SCPUVoltage",
399
+ "ExternalVoltage",
400
+ "ExternalLDRVoltage",
401
+ "ExternalUserSensorVoltage",
402
+ )
403
+ """Status tag 44, same construction with 8 bits."""