Add device lock support and demo mode
Device lock (hardware lock of the DSP, independent of the app lock): - detect a locked DSP from the 0x2C answer during connect and wait for the code - unlock with 0x2D, optionally remember the code and unlock automatically - set a new code (0x2F) from the device settings - simulator: --lock CODE Demo mode: - switch in the settings starts a simulated DSP 204/408 inside the server - real DSPs are disconnected and greyed out meanwhile and resume afterwards - demo devices are never saved or exported; sim.py ships with the Pi image and EXEs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fe13f261f7
commit
61400df667
13 files changed
+426
-38
No files matched your search
+11
-1
@@ -2,6 +2,7 @@
|
||||
|
||||
import copy
|
||||
import math
|
||||
import re
|
||||
import struct
|
||||
from dataclasses import dataclass
|
||||
|
||||
@@ -10,6 +11,7 @@ PORT = 9761
|
||||
# Read / system commands
|
||||
CMD_ACK = 0x01
|
||||
CMD_HANDSHAKE = 0x10
|
||||
CMD_LOGOUT = 0x11 # sent after setting a lock code
|
||||
CMD_STATUS = 0x12
|
||||
CMD_DEVICE_INFO = 0x13
|
||||
CMD_INIT_14 = 0x14
|
||||
@@ -20,7 +22,9 @@ CMD_CONFIG_CHUNK = 0x24
|
||||
CMD_PRESET_STORE_NAME = 0x26
|
||||
CMD_CONFIG_REQUEST = 0x27
|
||||
CMD_PRESET_NAME = 0x29
|
||||
CMD_PRESET_COUNT = 0x2C
|
||||
CMD_PRESET_COUNT = 0x2C # answer: [time lock][4 bytes time lock data][device lock] (see device_locked)
|
||||
CMD_UNLOCK = 0x2D # [0][code 4] -> answer [0][1 = unlocked, 0 = wrong code]
|
||||
CMD_SET_LOCK_CODE = 0x2F # [code 4]
|
||||
CMD_METER = 0x40
|
||||
|
||||
# Parameter commands
|
||||
@@ -41,6 +45,12 @@ CMD_GEQ = 0x48
|
||||
CMD_LINK = 0x3B # [ch][u16 link mask], see link_masks()
|
||||
|
||||
CHUNK_SIZE = 50
|
||||
LOCK_CODE = re.compile(r"[A-Z0-9]{4}") # device lock code: 4 characters, digits and upper-case letters
|
||||
|
||||
|
||||
def device_locked(count_payload: bytes) -> bool:
|
||||
"""True if the answer to CMD_PRESET_COUNT says the DSP waits for its lock code."""
|
||||
return len(count_payload) > 5 and count_payload[5] != 0
|
||||
|
||||
|
||||
def checksum(data: bytes) -> int:
|
||||
|
||||
Reference in new issue
Block a user