Redis API Reference
All LibreScoot services communicate through Redis on the MDB. Below are the state hashes, command queues, and pub/sub channels.
Redis runs on the MDB at
192.168.7.1:6379. The DBC connects over USB Ethernet. From a connected machine:
redis-cli -h 192.168.7.1 # or via SSH tunnel: ssh -L 6379:localhost:6379 root@<mdb-ip>
Go services use the redis-ipc library which wraps go-redis with helpers for hash publishing, queue processing, and pub/sub. Read its README for the patterns used across all services.
State Hashes
State is stored in Redis hashes. Services update fields with HSET and publish change notifications on channels of the same name.
vehicle
redis-cli -h 192.168.7.1 HGETALL vehicle
| Field | Values | Description |
|---|---|---|
state | stand-by / ready-to-drive / parked / booting / shutting-down / hibernating / updating | Vehicle operating state |
handlebar:position | on-place / off-place | Handlebar position sensor |
handlebar:lock-sensor | locked / unlocked | Handlebar lock state |
seatbox:lock | open / closed | Seatbox lock state |
seatbox:button | on / off | Seat open button |
kickstand | up / down | Side stand position |
brake:left / brake:right | on / off | Brake lever states |
blinker:switch | left / right / both / off | Blinker switch position |
blinker:state | on / off | Blinker currently active |
main-power | on / off | Main power state |
horn:button | on / off | Horn button |
battery:0 / battery:1
redis-cli -h 192.168.7.1 HGETALL battery:0
| Field | Type | Description |
|---|---|---|
present | true / false | Battery presence |
state | string | Battery state |
charge | integer (%) | Charge level |
voltage | integer (mV) | Battery voltage |
current | integer (mA) | Battery current |
temperature:0–temperature:3 | integer (°C) | Temperature sensors |
state-of-health | integer (%) | Battery health |
cycle-count | integer | Charge cycles |
serial-number | string | Battery serial |
fw-version | string | BMS firmware version |
engine-ecu
redis-cli -h 192.168.7.1 HGETALL engine-ecu
| Field | Type | Description |
|---|---|---|
speed | integer (km/h) | Vehicle speed |
rpm | integer | Motor RPM |
odometer | integer (m) | Total distance |
motor:voltage | integer (mV) | Motor voltage |
motor:current | integer (mA) | Motor current |
temperature | integer (°C) | ECU temperature |
throttle | on / off | Throttle active |
kers | on / off | Regenerative braking active |
kers-reason-off | string | Why KERS is off (none / cold / hot) |
gear | integer | Gear position |
fw-version | hex string | ECU firmware version |
internet
| Field | Description |
|---|---|
status | Connection status (connected / disconnected) |
access-tech | Access technology (e.g. LTE) |
signal-quality | Signal strength 0–100 |
ip-address | Current IP address |
modem-state | Modem power state |
gps
| Field | Description |
|---|---|
state | off / searching / fix-established / error |
latitude / longitude | Current position (6 decimal places) |
altitude | Altitude in meters |
speed | GPS speed |
course | Heading in degrees |
timestamp | GPS timestamp (ISO format) |
alarm
| Field | Values |
|---|---|
status | disabled / disarmed / armed / level-1-triggered / level-2-triggered |
settings
Persistent configuration managed by settings-service. All fields are readable/writable via lsc settings get/set. Notable keys:
| Key | Description |
|---|---|
alarm.enabled | true/false, alarm system on/off |
alarm.honk | true/false, horn during alarm |
alarm.duration | Alarm duration in seconds |
updates.mdb.channel | OTA channel: testing / nightly / stable |
updates.mdb.method | full or delta |
dashboard.valhalla-url | Routing engine endpoint |
dashboard.map.type | online / offline |
scooter.auto-standby-seconds | Auto-lock timeout (0 = disabled) |
hibernation-timer | Hibernation timeout in seconds (0 = disabled) |
ota
| Field | Description |
|---|---|
status:mdb / status:dbc | idle / downloading / installing / rebooting / error |
download-progress:mdb | Download progress 0–100 |
update-version:mdb | Target version string |
error-message:mdb | Error description if status is error |
version:mdb / version:dbc
Written by version-service from /etc/os-release. Contains fields like version_id, build_id, id.
Command Queues
Services accept commands via Redis lists. Send with LPUSH; services consume with BRPOP.
| Queue | Commands |
|---|---|
scooter:state | lock, unlock, lock-hibernate |
scooter:seatbox | open |
scooter:power | run, suspend, hibernate, hibernate-manual, reboot |
scooter:blinker | left, right, both, off |
scooter:horn | on, off |
scooter:alarm | enable, disable, start:<seconds>, stop |
scooter:modem | enable, disable, gps:enable, gps:disable |
scooter:update | check-now |
scooter:bluetooth | advertising-start-with-whitelisting, advertising-restart-no-whitelisting, advertising-stop, delete-all-bonds |
Example:
redis-cli -h 192.168.7.1 LPUSH scooter:state unlock redis-cli -h 192.168.7.1 LPUSH scooter:alarm start:30
Pub/Sub
When a service updates a hash field, it publishes the changed field name to a channel with the same name as the hash. Consumers subscribe and re-read only the changed field.
# Subscribe to vehicle state changes redis-cli -h 192.168.7.1 SUBSCRIBE vehicle # Subscribe to battery updates redis-cli -h 192.168.7.1 SUBSCRIBE battery:0 battery:1
The published message payload is the field name that changed (e.g. "state", "charge"). Recipients call HGET <hash> <field> to get the new value.
This pattern is implemented in the redis-ipc library.